BUG: Fix find_* search order with path suffixes
[cmake.git] / Tests / Java / CMakeLists.txt
blobb0dfaa5e6752d28f3ecaee5a7b066345c8b84d6e
1 cmake_minimum_required (VERSION 2.6)
2 PROJECT(hello Java)
3 SET(CMAKE_VERBOSE_MAKEFILE 1)
4   
5 IF("${hello_SOURCE_DIR}" STREQUAL "${hello_BINARY_DIR}")
6   MESSAGE("In Source, building Java using ADD_CUSTOM_COMMAND()")
7   SET(OLD_CUSTOM_COMMAND_WAY 1)
8 ELSE("${hello_SOURCE_DIR}" STREQUAL "${hello_BINARY_DIR}")
9   MESSAGE("Out of source, using built-in Java support")
10   SET(OLD_CUSTOM_COMMAND_WAY )
11 ENDIF("${hello_SOURCE_DIR}" STREQUAL "${hello_BINARY_DIR}")
13 IF(NOT OLD_CUSTOM_COMMAND_WAY)
15   INCLUDE_DIRECTORIES(${hello_SOURCE_DIR}
16     ${hello_BINARY_DIR} )
17   ADD_LIBRARY(hello A.java HelloWorld.java)
19 ELSE(NOT OLD_CUSTOM_COMMAND_WAY)
21   ADD_CUSTOM_COMMAND(
22     OUTPUT ${hello_BINARY_DIR}/A.class
23     MAIN_DEPENDENCY ${hello_SOURCE_DIR}/A.java
24     COMMAND ${CMAKE_Java_COMPILER} ARGS -classpath . -d ${hello_BINARY_DIR} ${hello_SOURCE_DIR}/A.java)
25   ADD_CUSTOM_COMMAND(
26     OUTPUT ${hello_BINARY_DIR}/HelloWorld.class
27     MAIN_DEPENDENCY ${hello_SOURCE_DIR}/HelloWorld.java
28     DEPENDS ${hello_BINARY_DIR}/A.class
29     COMMAND ${CMAKE_Java_COMPILER} ARGS -classpath . -d ${hello_BINARY_DIR} ${hello_SOURCE_DIR}/HelloWorld.java)
30   ADD_CUSTOM_COMMAND(
31     OUTPUT ${hello_BINARY_DIR}/hello.jar
32     DEPENDS ${hello_BINARY_DIR}/A.class ${hello_BINARY_DIR}/HelloWorld.class
33     COMMAND ${CMAKE_COMMAND}
34     ARGS -E chdir ${CMAKE_CURRENT_BINARY_DIR}
35     ${CMAKE_Java_ARCHIVE}
36     -cvf hello.jar *.class)
37   
38   ADD_CUSTOM_TARGET(hello_jar ALL 
39     DEPENDS ${hello_BINARY_DIR}/hello.jar)
41 ENDIF(NOT OLD_CUSTOM_COMMAND_WAY)