summaryrefslogtreecommitdiffstats
path: root/Modules/UseJava.cmake
diff options
context:
space:
mode:
authorMatthew Woehlke <matthew.woehlke@kitware.com>2013-03-13 21:29:14 (GMT)
committerMatthew Woehlke <matthew.woehlke@kitware.com>2013-03-13 21:29:14 (GMT)
commit45c8e4b181b0f638576f2cedcaf911fbab7cab82 (patch)
tree0dea2a7ef1e64f6d43eeb7ebf62ae48a46a67389 /Modules/UseJava.cmake
parenta95968fec95bf5feacb81871b3a2e052c5364345 (diff)
downloadCMake-45c8e4b181b0f638576f2cedcaf911fbab7cab82.zip
CMake-45c8e4b181b0f638576f2cedcaf911fbab7cab82.tar.gz
CMake-45c8e4b181b0f638576f2cedcaf911fbab7cab82.tar.bz2
UseJava.cmake: simplify path logic
Move logic to determine relative path to .java file to after the file extension check, so that it only executes when it is actually used.
Diffstat (limited to 'Modules/UseJava.cmake')
-rw-r--r--Modules/UseJava.cmake22
1 files changed, 11 insertions, 11 deletions
diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake
index 1b823a8..7573576 100644
--- a/Modules/UseJava.cmake
+++ b/Modules/UseJava.cmake
@@ -264,18 +264,18 @@ function(add_jar _TARGET_NAME)
get_filename_component(_JAVA_PATH ${_JAVA_SOURCE_FILE} PATH)
get_filename_component(_JAVA_FULL ${_JAVA_SOURCE_FILE} ABSOLUTE)
- file(RELATIVE_PATH _JAVA_REL_BINARY_PATH ${CMAKE_JAVA_TARGET_OUTPUT_DIR} ${_JAVA_FULL})
- file(RELATIVE_PATH _JAVA_REL_SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${_JAVA_FULL})
- string(LENGTH ${_JAVA_REL_BINARY_PATH} _BIN_LEN)
- string(LENGTH ${_JAVA_REL_SOURCE_PATH} _SRC_LEN)
- if (${_BIN_LEN} LESS ${_SRC_LEN})
- set(_JAVA_REL_PATH ${_JAVA_REL_BINARY_PATH})
- else ()
- set(_JAVA_REL_PATH ${_JAVA_REL_SOURCE_PATH})
- endif ()
- get_filename_component(_JAVA_REL_PATH ${_JAVA_REL_PATH} PATH)
-
if (_JAVA_EXT MATCHES ".java")
+ file(RELATIVE_PATH _JAVA_REL_BINARY_PATH ${CMAKE_JAVA_TARGET_OUTPUT_DIR} ${_JAVA_FULL})
+ file(RELATIVE_PATH _JAVA_REL_SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${_JAVA_FULL})
+ string(LENGTH ${_JAVA_REL_BINARY_PATH} _BIN_LEN)
+ string(LENGTH ${_JAVA_REL_SOURCE_PATH} _SRC_LEN)
+ if (${_BIN_LEN} LESS ${_SRC_LEN})
+ set(_JAVA_REL_PATH ${_JAVA_REL_BINARY_PATH})
+ else ()
+ set(_JAVA_REL_PATH ${_JAVA_REL_SOURCE_PATH})
+ endif ()
+ get_filename_component(_JAVA_REL_PATH ${_JAVA_REL_PATH} PATH)
+
list(APPEND _JAVA_COMPILE_FILES ${_JAVA_SOURCE_FILE})
set(_JAVA_CLASS_FILE "${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${_JAVA_REL_PATH}/${_JAVA_FILE}.class")
set(_JAVA_CLASS_FILES ${_JAVA_CLASS_FILES} ${_JAVA_CLASS_FILE})