2004-09-22 22:42:05 +04:00
|
|
|
PROJECT(hello Java)
|
2004-09-23 01:41:04 +04:00
|
|
|
SET(CMAKE_VERBOSE_MAKEFILE 1)
|
2006-04-22 17:13:07 +04:00
|
|
|
|
|
|
|
IF("${hello_SOURCE_DIR}" STREQUAL "${hello_BINARY_DIR}")
|
2007-06-21 22:06:52 +04:00
|
|
|
MESSAGE("In Source, building Java using ADD_CUSTOM_COMMAND()")
|
2006-04-22 17:13:07 +04:00
|
|
|
SET(OLD_CUSTOM_COMMAND_WAY 1)
|
2007-06-21 22:06:52 +04:00
|
|
|
ELSE("${hello_SOURCE_DIR}" STREQUAL "${hello_BINARY_DIR}")
|
|
|
|
MESSAGE("Out of source, using built-in Java support")
|
|
|
|
SET(OLD_CUSTOM_COMMAND_WAY )
|
2006-04-22 17:13:07 +04:00
|
|
|
ENDIF("${hello_SOURCE_DIR}" STREQUAL "${hello_BINARY_DIR}")
|
2007-06-21 22:06:52 +04:00
|
|
|
|
2004-09-22 22:42:05 +04:00
|
|
|
IF(NOT OLD_CUSTOM_COMMAND_WAY)
|
2007-06-21 22:06:52 +04:00
|
|
|
|
2004-09-25 00:34:59 +04:00
|
|
|
INCLUDE_DIRECTORIES(${hello_SOURCE_DIR}
|
2004-09-24 23:40:40 +04:00
|
|
|
${hello_BINARY_DIR} )
|
2004-09-22 22:42:05 +04:00
|
|
|
ADD_LIBRARY(hello A.java HelloWorld.java)
|
|
|
|
|
2007-06-21 22:06:52 +04:00
|
|
|
ELSE(NOT OLD_CUSTOM_COMMAND_WAY)
|
2004-09-22 22:42:05 +04:00
|
|
|
|
|
|
|
ADD_CUSTOM_COMMAND(
|
|
|
|
OUTPUT ${hello_BINARY_DIR}/A.class
|
|
|
|
MAIN_DEPENDENCY ${hello_SOURCE_DIR}/A.java
|
2006-04-23 19:10:41 +04:00
|
|
|
COMMAND ${CMAKE_Java_COMPILER} ARGS -classpath . -d ${hello_BINARY_DIR} ${hello_SOURCE_DIR}/A.java)
|
2004-09-22 22:42:05 +04:00
|
|
|
ADD_CUSTOM_COMMAND(
|
|
|
|
OUTPUT ${hello_BINARY_DIR}/HelloWorld.class
|
|
|
|
MAIN_DEPENDENCY ${hello_SOURCE_DIR}/HelloWorld.java
|
2006-04-23 19:10:41 +04:00
|
|
|
DEPENDS ${hello_BINARY_DIR}/A.class
|
|
|
|
COMMAND ${CMAKE_Java_COMPILER} ARGS -classpath . -d ${hello_BINARY_DIR} ${hello_SOURCE_DIR}/HelloWorld.java)
|
|
|
|
ADD_CUSTOM_COMMAND(
|
2006-04-23 23:34:34 +04:00
|
|
|
OUTPUT ${hello_BINARY_DIR}/hello.jar
|
2006-04-23 19:10:41 +04:00
|
|
|
DEPENDS ${hello_BINARY_DIR}/A.class ${hello_BINARY_DIR}/HelloWorld.class
|
2004-09-22 22:42:05 +04:00
|
|
|
COMMAND ${CMAKE_COMMAND}
|
|
|
|
ARGS -E chdir ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
${CMAKE_Java_ARCHIVE}
|
2006-04-24 07:24:48 +04:00
|
|
|
-cvf hello.jar *.class)
|
2006-04-23 19:10:41 +04:00
|
|
|
|
2007-06-27 21:22:45 +04:00
|
|
|
ADD_CUSTOM_TARGET(hello_jar ALL
|
2006-04-23 23:34:34 +04:00
|
|
|
DEPENDS ${hello_BINARY_DIR}/hello.jar)
|
2007-06-21 22:06:52 +04:00
|
|
|
|
|
|
|
ENDIF(NOT OLD_CUSTOM_COMMAND_WAY)
|
|
|
|
|