[brlcad-commits] SF.net SVN: brlcad:[49866] brlcad/trunk
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <sta...@us...> - 2012-04-01 18:54:39
|
Revision: 49866 http://brlcad.svn.sourceforge.net/brlcad/?rev=49866&view=rev Author: starseeker Date: 2012-04-01 18:54:32 +0000 (Sun, 01 Apr 2012) Log Message: ----------- Paths that trigger CMake's regex rules break the CMake logic - shouldn't be using regex based comparisons for such paths anyway, so fix some comparisons and add a subpath checker that doesn't need regex. Reported on the email list by Aur?\195?\169lien Marion Modified Paths: -------------- brlcad/trunk/CMakeLists.txt brlcad/trunk/misc/CMake/BRLCAD_CMakeFiles.cmake brlcad/trunk/misc/CMake/BRLCAD_Targets.cmake brlcad/trunk/misc/CMake/BRLCAD_Util.cmake brlcad/trunk/misc/CMake/ThirdParty.cmake Modified: brlcad/trunk/CMakeLists.txt =================================================================== --- brlcad/trunk/CMakeLists.txt 2012-04-01 05:28:01 UTC (rev 49865) +++ brlcad/trunk/CMakeLists.txt 2012-04-01 18:54:32 UTC (rev 49866) @@ -403,9 +403,9 @@ GET_FILENAME_COMPONENT(ITEM_ABS ${file} ABSOLUTE) set(TEST_BUILD_PATH "${CMAKE_BINARY_DIR}/") set(TEST_SOURCE_PATH "${CMAKE_SOURCE_DIR}/") - string(REGEX REPLACE "^${TEST_BUILD_PATH}" "" BUILD_DIR_TRIMMED "${ITEM_ABS}") + string(REPLACE "${TEST_BUILD_PATH}" "" BUILD_DIR_TRIMMED "${ITEM_ABS}") if(${ITEM_ABS} STREQUAL ${BUILD_DIR_TRIMMED}) - string(REGEX REPLACE "^${TEST_SOURCE_PATH}" "" SOURCE_DIR_TRIMMED "${ITEM_ABS}") + string(REPLACE "${TEST_SOURCE_PATH}" "" SOURCE_DIR_TRIMMED "${ITEM_ABS}") if(NOT ${ITEM_ABS} STREQUAL ${SOURCE_DIR_TRIMMED}) file(APPEND ${CMAKE_BINARY_DIR}/cmakefiles.cmake "${ITEM_ABS}\n") endif(NOT ${ITEM_ABS} STREQUAL ${SOURCE_DIR_TRIMMED}) @@ -435,7 +435,7 @@ if(NOT BRLCAD_IS_SUBBUILD) function(message) _message(${ARGN}) - string(REGEX REPLACE ";" ": " msg "${ARGV}") + string(REPLACE ";" ": " msg "${ARGV}") file(APPEND ${BRLCAD_BINARY_DIR}/CMakeFiles/CMakeOutput.log "${msg}\n") endfunction(message) endif(NOT BRLCAD_IS_SUBBUILD) @@ -1948,7 +1948,7 @@ if(NOT ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) set(TEST_BUILD_PATH "${CMAKE_BINARY_DIR}/") set(TEST_SOURCE_PATH "${CMAKE_SOURCE_DIR}/") - string(REGEX REPLACE "${TEST_SOURCE_PATH}" "" CMAKE_BUILD_DIR_TRIMMED "${TEST_BUILD_PATH}") + string(REPLACE "${TEST_SOURCE_PATH}" "" CMAKE_BUILD_DIR_TRIMMED "${TEST_BUILD_PATH}") if(NOT ${TEST_BUILD_PATH} STREQUAL ${CMAKE_BUILD_DIR_TRIMMED}) set(CPACK_IGNORE_BUILD_PATH "${CMAKE_BUILD_DIR_TRIMMED}") endif(NOT ${TEST_BUILD_PATH} STREQUAL ${CMAKE_BUILD_DIR_TRIMMED}) @@ -2130,18 +2130,26 @@ get_property(CMAKE_DISTCLEAN_TARGET_LIST GLOBAL PROPERTY CMAKE_DISTCLEAN_TARGET_LIST) list(REMOVE_DUPLICATES CMAKE_DISTCLEAN_TARGET_LIST) configure_file(${BRLCAD_CMAKE_DIR}/distclean.cmake.in ${BRLCAD_BINARY_DIR}/distclean.cmake @ONLY) -if("${CMAKE_GENERATOR}" MATCHES "Make" AND ("${cmake_generator}" MATCHES "Make" OR NOT cmake_generator)) +if("${CMAKE_GENERATOR}" MATCHES "Make") add_custom_target(distclean COMMAND ${CMAKE_COMMAND} -E echo "Running make clean..." COMMAND ${CMAKE_COMMAND} -E chdir ${BRLCAD_BINARY_DIR} $(MAKE) clean COMMAND ${CMAKE_COMMAND} -E echo "Running make clean... done." COMMAND ${CMAKE_COMMAND} -P ${BRLCAD_BINARY_DIR}/distclean.cmake ) -else("${CMAKE_GENERATOR}" MATCHES "Make" AND ("${cmake_generator}" MATCHES "Make" OR NOT cmake_generator)) +elseif("${CMAKE_GENERATOR}" MATCHES "Ninja") + message("gothere") add_custom_target(distclean + COMMAND ${CMAKE_COMMAND} -E echo "Running make clean..." + COMMAND ${CMAKE_COMMAND} -E chdir ${BRLCAD_BINARY_DIR} ninja -t clean + COMMAND ${CMAKE_COMMAND} -E echo "Running make clean... done." COMMAND ${CMAKE_COMMAND} -P ${BRLCAD_BINARY_DIR}/distclean.cmake ) -endif("${CMAKE_GENERATOR}" MATCHES "Make" AND ("${cmake_generator}" MATCHES "Make" OR NOT cmake_generator)) +else("${CMAKE_GENERATOR}" MATCHES "Make") + add_custom_target(distclean + COMMAND ${CMAKE_COMMAND} -E echo "Not implemented for generator ${CMAKE_GENERATOR}" + ) +endif("${CMAKE_GENERATOR}" MATCHES "Make") #Done with all really time-consuming steps - do the configure time delta if(NOT BRLCAD_IS_SUBBUILD) Modified: brlcad/trunk/misc/CMake/BRLCAD_CMakeFiles.cmake =================================================================== --- brlcad/trunk/misc/CMake/BRLCAD_CMakeFiles.cmake 2012-04-01 05:28:01 UTC (rev 49865) +++ brlcad/trunk/misc/CMake/BRLCAD_CMakeFiles.cmake 2012-04-01 18:54:32 UTC (rev 49866) @@ -33,6 +33,7 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # + # Define a macro for building lists of files. Distcheck needs to know what files are "supposed" to be present in order to make # sure the source tree is clean prior to building a distribution tarball, hence this macro stores its results in files and not # variables It's a no-op in a SUBBUILD. @@ -66,16 +67,17 @@ # the third party build systems at some point in the future, we may have to exclude src/other # paths from this check. if(NOT "${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}") - if(NOT "${ITEM_PATH}" MATCHES "${CMAKE_BINARY_DIR}") + IS_SUBPATH("${CMAKE_BINARY_DIR}" "${ITEM_PATH}" SUBPATH_TEST) + if("${SUBPATH_TEST}" STREQUAL "0") if("${ITEM_PATH}" MATCHES "${CMAKE_SOURCE_DIR}") message(FATAL_ERROR "${ITEM} is listed in ${CMAKE_CURRENT_SOURCE_DIR} using its absolute path. Please specify the location of this file using a relative path.") endif("${ITEM_PATH}" MATCHES "${CMAKE_SOURCE_DIR}") - endif(NOT "${ITEM_PATH}" MATCHES "${CMAKE_BINARY_DIR}") + endif("${SUBPATH_TEST}" STREQUAL "0") endif(NOT "${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}") # Ignore files specified using full paths, since they should be generated files and are not part # of the source code repository. get_filename_component(ITEM_ABS_PATH ${ITEM_PATH} ABSOLUTE) - if(NOT ${ITEM_PATH} MATCHES "^${ITEM_ABS_PATH}$") + if(NOT "${ITEM_PATH}" STREQUAL "${ITEM_ABS_PATH}") if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${ITEM}) message(FATAL_ERROR "Attempting to ignore non-existent file ${ITEM}, in directory ${CMAKE_CURRENT_SOURCE_DIR}") endif(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${ITEM}) @@ -99,7 +101,7 @@ endif(NOT ${ITEM_NAME} MATCHES "\\.\\.") endif(NOT ITEM_PATH STREQUAL "") endwhile(NOT ITEM_PATH STREQUAL "") - endif(NOT ${ITEM_PATH} MATCHES "^${ITEM_ABS_PATH}$") + endif(NOT "${ITEM_PATH}" STREQUAL "${ITEM_ABS_PATH}") else(NOT ITEM_PATH STREQUAL "") # The easy case - no path specified, so assume the current source directory. if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${ITEM}) Modified: brlcad/trunk/misc/CMake/BRLCAD_Targets.cmake =================================================================== --- brlcad/trunk/misc/CMake/BRLCAD_Targets.cmake 2012-04-01 05:28:01 UTC (rev 49865) +++ brlcad/trunk/misc/CMake/BRLCAD_Targets.cmake 2012-04-01 18:54:32 UTC (rev 49866) @@ -272,18 +272,18 @@ # paths in BRL-CAD build dir foreach(inc_path ${${DIR_LIST}}) - if(${inc_path} MATCHES "^${BRLCAD_BINARY_DIR}") + if("${inc_path}" STREQUAL "${BRLCAD_BINARY_DIR}") set(NEW_DIR_LIST ${NEW_DIR_LIST} ${inc_path}) list(REMOVE_ITEM ${DIR_LIST} ${inc_path}) - endif(${inc_path} MATCHES "^${BRLCAD_BINARY_DIR}") + endif("${inc_path}" STREQUAL "${BRLCAD_BINARY_DIR}") endforeach(inc_path ${${DIR_LIST}}) # paths in BRL-CAD source dir foreach(inc_path ${${DIR_LIST}}) - if(${inc_path} MATCHES "^${BRLCAD_SOURCE_DIR}") + if("${inc_path}" STREQUAL "${BRLCAD_SOURCE_DIR}") set(NEW_DIR_LIST ${NEW_DIR_LIST} ${inc_path}) list(REMOVE_ITEM ${DIR_LIST} ${inc_path}) - endif(${inc_path} MATCHES "^${BRLCAD_SOURCE_DIR}") + endif("${inc_path}" STREQUAL "${BRLCAD_SOURCE_DIR}") endforeach(inc_path ${${DIR_LIST}}) # add anything that might be left Modified: brlcad/trunk/misc/CMake/BRLCAD_Util.cmake =================================================================== --- brlcad/trunk/misc/CMake/BRLCAD_Util.cmake 2012-04-01 05:28:01 UTC (rev 49865) +++ brlcad/trunk/misc/CMake/BRLCAD_Util.cmake 2012-04-01 18:54:32 UTC (rev 49866) @@ -82,7 +82,7 @@ # macro logic need only deal with a variable holding a list, whatever the # original form of the input. macro(NORMALIZE_FILE_LIST inlist targetvar) - set(havevarname 0) + set(havevarname 0) foreach(maybefilename ${inlist}) if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${maybefilename}) set(havevarname 1) @@ -172,8 +172,56 @@ endmacro(BRLCAD_GET_DIR_LIST_CONTENTS) +#----------------------------------------------------------------------------- +# We need a way to tell whether one path is a subpath of another path without +# relying on regular expressions, since file paths may have characters in them +# that will trigger regex matching behavior when we don't want it. (To test, +# for example, use a build directory name of build++) +# +# The routine below does the check without using regex matching. +macro(IS_SUBPATH in_candidate_subpath in_full_path result_var) + # Convert paths to lists of directories - regex based + # matching won't work reliably, so instead look at each + # element compared to its corresponding element in the + # other path using string comparison. + # get the CMake form of the path so we have something consistent + # to work on + file(TO_CMAKE_PATH "${in_full_path}" full_path) + file(TO_CMAKE_PATH "${in_candidate_subpath}" candidate_subpath) + # check the string lengths - if the "subpath" is longer + # than the full path, there's not point in going further + string(LENGTH "${full_path}" FULL_LENGTH) + string(LENGTH "${candidate_subpath}" SUB_LENGTH) + if("${SUB_LENGTH}" GREATER "${FULL_LENGTH}") + set(${result_var} 0) + else("${SUB_LENGTH}" GREATER "${FULL_LENGTH}") + # OK, maybe it's a subpath - time to actually check + string(REPLACE "/" ";" full_path_list "${full_path}") + string(REPLACE "/" ";" candidate_subpath_list "${candidate_subpath}") + set(found_difference 0) + while(NOT found_difference AND candidate_subpath_list) + list(GET full_path_list 0 full_path_element) + list(GET candidate_subpath_list 0 subpath_element) + if("${full_path_element}" STREQUAL "${subpath_element}") + list(REMOVE_AT full_path_list 0) + list(REMOVE_AT candidate_subpath_list 0) + else("${full_path_element}" STREQUAL "${subpath_element}") + set(found_difference 1) + endif("${full_path_element}" STREQUAL "${subpath_element}") + endwhile(NOT found_difference AND candidate_subpath_list) + # Now we know - report the result + if(NOT found_difference) + set(${result_var} 1) + else(NOT found_difference) + set(${result_var} 0) + endif(NOT found_difference) + endif("${SUB_LENGTH}" GREATER "${FULL_LENGTH}") +endmacro(IS_SUBPATH) + + + # Local Variables: # tab-width: 8 # mode: cmake Modified: brlcad/trunk/misc/CMake/ThirdParty.cmake =================================================================== --- brlcad/trunk/misc/CMake/ThirdParty.cmake 2012-04-01 05:28:01 UTC (rev 49865) +++ brlcad/trunk/misc/CMake/ThirdParty.cmake 2012-04-01 18:54:32 UTC (rev 49866) @@ -280,9 +280,10 @@ # or cached value will be replaced with the local path. A feature based disablement # of the tool also applies to the cached version. if(${upper}_EXECUTABLE) - if(NOT "${${upper}_EXECUTABLE}" MATCHES ${CMAKE_BINARY_DIR}) + IS_SUBPATH("${CMAKE_BINARY_DIR}" "${${upper}_EXECUTABLE}" SUBBUILD_TEST) + if("${SUBBUILD_TEST}" STREQUAL "0") get_filename_component(FULL_PATH_EXEC ${${upper}_EXECUTABLE} ABSOLUTE) - IF ("${FULL_PATH_EXEC}" STREQUAL "${${upper}_EXECUTABLE}") + if("${FULL_PATH_EXEC}" STREQUAL "${${upper}_EXECUTABLE}") if(EXISTS ${FULL_PATH_EXEC}) set(EXEC_CACHED ${${upper}_EXECUTABLE}) else(EXISTS ${FULL_PATH_EXEC}) @@ -290,8 +291,8 @@ # and made a mistake doing so - warn that this might be the case. message(WARNING "File path ${${upper}_EXECUTABLE} specified for ${upper}_EXECUTABLE does not exist - this path will not override ${lower} executable search results.") endif(EXISTS ${FULL_PATH_EXEC}) - ENDIF ("${FULL_PATH_EXEC}" STREQUAL "${${upper}_EXECUTABLE}") - endif(NOT "${${upper}_EXECUTABLE}" MATCHES ${CMAKE_BINARY_DIR}) + endif("${FULL_PATH_EXEC}" STREQUAL "${${upper}_EXECUTABLE}") + endif("${SUBBUILD_TEST}" STREQUAL "0") endif(${upper}_EXECUTABLE) # Initialize some variables This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |