<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>nd4j-backend-impls</artifactId>
        <groupId>org.nd4j</groupId>
        <version>0.9.0</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>nd4j-cuda-7.5</artifactId>
    <name>nd4j-cuda</name>

    <properties>
        <cuda.version>7.5</cuda.version>
        <cudnn.version>6.0</cudnn.version>
        <env.LIBND4J_HOME>${basedir}/../../../../libnd4j/</env.LIBND4J_HOME>
    </properties>

    <build>
        <testSourceDirectory>../../nd4j-tests/src/test/java</testSourceDirectory>
        <testResources>
            <testResource>
                <directory>${project.basedir}/../../nd4j-tests/src/test/resources</directory>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.surefire</groupId>
                        <artifactId>surefire-junit47</artifactId>
                        <version>2.19.1</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <environmentVariables>
                        <LD_LIBRARY_PATH>${env.LD_LIBRARY_PATH}:${user.dir}:${env.LIBND4J_HOME}/blasbuild/cuda/blas/</LD_LIBRARY_PATH>
                    </environmentVariables>
                    <testSourceDirectory>../../nd4j-tests/src/test/java</testSourceDirectory>
                    <includes>
                        <include>*.java</include>
                    </includes>
                    <systemPropertyVariables>
                        <org.nd4j.linalg.defaultbackend>org.nd4j.linalg.jcublas.JCublasBackend</org.nd4j.linalg.defaultbackend>
                        <org.nd4j.linalg.tests.backendstorun>org.nd4j.linalg.jcublas.JCublasBackend</org.nd4j.linalg.tests.backendstorun>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <executions>
                    <execution>
                        <id>javacpp.parser</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                        <configuration>
                            <skipMain>${javacpp.parser.skip}</skipMain>
                            <includes>
                                <include>org/nd4j/nativeblas/Nd4jCudaPresets.java</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.bytedeco</groupId>
                <artifactId>javacpp</artifactId>
                <version>${javacpp.version}</version>
                <dependencies>
                    <dependency>
                        <groupId>org.nd4j</groupId>
                        <artifactId>nd4j-native-api</artifactId>
                        <version>${project.version}</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <properties>${javacpp.platform}</properties>
                    <propertyKeysAndValues>
                        <property>
                            <name>platform.root</name>
                            <value>${javacpp.platform.root}</value>
                        </property>
                        <property>
                            <name>platform.compiler</name>
                            <value>${javacpp.platform.compiler}</value>
                        </property>
                    </propertyKeysAndValues>
                    <classPaths>
                        <classPath>${project.build.outputDirectory}</classPath>
                    </classPaths>
                    <includePaths>
                        <includePath>${env.LIBND4J_HOME}/blas</includePath>
                        <includePath>${env.LIBND4J_HOME}/include</includePath>
                        <includePath>${env.LIBND4J_HOME}/include/cnpy</includePath>
                    </includePaths>
                    <linkPaths>
                        <linkPath>${env.LIBND4J_HOME}/blasbuild/cuda-${cuda.version}/blas</linkPath>
                        <linkPath>${env.LIBND4J_HOME}/blasbuild/cuda/blas</linkPath>
                    </linkPaths>
                </configuration>
                <executions>
                    <execution>
                        <id>javacpp.parser</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>build</goal>
                        </goals>
                        <configuration>
                            <skip>${javacpp.parser.skip}</skip>
                            <outputDirectory>${project.build.sourceDirectory}</outputDirectory>
                            <classOrPackageName>org.nd4j.nativeblas.Nd4jCudaPresets</classOrPackageName>
                        </configuration>
                    </execution>
                    <execution>
                        <id>javacpp.compiler</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>build</goal>
                        </goals>
                        <configuration>
                            <skip>${javacpp.compiler.skip}</skip>
                            <classOrPackageName>org.nd4j.nativeblas.Nd4jCuda</classOrPackageName>
                            <copyLibs>true</copyLibs>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>1.4.1</version>
                <executions>
                    <execution>
                        <id>libnd4j-checks</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireProperty>
                                    <property>env.LIBND4J_HOME</property>
                                    <message>You must set the LIBND4J_HOME environment variable!</message>
                                    <regex>.*/.*</regex>
                                    <regexMessage>!!! LIBND4J_HOME must be a valid unix path!</regexMessage>
                                </requireProperty>
                                <requireFilesExist>
                                    <files>
                                        <file>${env.LIBND4J_HOME}/blas/NativeOps.h</file>
                                        <file>${env.LIBND4J_HOME}/blasbuild/cuda/blas</file>
                                    </files>
                                    <message>!!! You have to compile libnd4j with cuda support first!</message>
                                </requireFilesExist>
                            </rules>
                            <fail>true</fail>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>


    <dependencies>
        <dependency>
            <groupId>${dependency.groupId}</groupId>
            <artifactId>${dependency.artifactId}</artifactId>
            <version>${dependency.version}</version>
            <type>${dependency.packaging}</type>
            <classifier>${dependency.classifier}</classifier>
        </dependency>

        <dependency>
            <groupId>org.bytedeco</groupId>
            <artifactId>javacpp</artifactId>
            <version>${javacpp.version}</version>
        </dependency>
        <dependency>
            <groupId>org.bytedeco.javacpp-presets</groupId>
            <artifactId>cuda</artifactId>
            <version>${cuda.version}-${cudnn.version}-${javacpp-presets.version}</version>
        </dependency>
        <dependency>
            <groupId>org.bytedeco.javacpp-presets</groupId>
            <artifactId>cuda</artifactId>
            <version>${cuda.version}-${cudnn.version}-${javacpp-presets.version}</version>
            <classifier>${dependency.platform}</classifier>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.nd4j</groupId>
            <artifactId>nd4j-base64</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.nd4j</groupId>
            <artifactId>nd4j-jackson</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.nd4j</groupId>
            <artifactId>nd4j-api</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.nd4j</groupId>
            <artifactId>nd4j-native-api</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>${logback.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
            <version>${logback.version}</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <profiles>
        <profile>
            <id>msvc</id>
            <activation>
                <os><family>windows</family></os>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.bytedeco</groupId>
                        <artifactId>javacpp</artifactId>
                        <configuration>
                            <properties>${javacpp.platform}</properties>
                            <compilerOptions>
                                <compilerOption>/MT</compilerOption>
                            </compilerOptions>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
