From 45c8e4b181b0f638576f2cedcaf911fbab7cab82 Mon Sep 17 00:00:00 2001 From: Matthew Woehlke Date: Wed, 13 Mar 2013 17:29:14 -0400 Subject: [PATCH] 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. --- Modules/UseJava.cmake | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index 1b823a8e9b..75735766cc 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})