Revision: 77621
http://sourceforge.net/p/brlcad/code/77621
Author: starseeker
Date: 2020-10-23 22:03:26 +0000 (Fri, 23 Oct 2020)
Log Message:
-----------
Clean up and simplify the multiconfig path fixing code.
Modified Paths:
--------------
brlcad/branches/extbuild/misc/CMake/multiconfig_path_read.cmake.in
Modified: brlcad/branches/extbuild/misc/CMake/multiconfig_path_read.cmake.in
===================================================================
--- brlcad/branches/extbuild/misc/CMake/multiconfig_path_read.cmake.in
2020-10-23 22:02:52 UTC (rev 77620)
+++ brlcad/branches/extbuild/misc/CMake/multiconfig_path_read.cmake.in
2020-10-23 22:03:26 UTC (rev 77621)
@@ -52,68 +52,37 @@
set(BUILD_TYPE_NEW "${BUILD_TYPE}")
endif(NOT BUILD_TYPE_NEW)
-# The installation directory is compiled in, so to that extent at least a
build time configuration
-# change that results in a different installation path requires a re-compile.
Write to a temp file
-# to allow the build target to avoid changing the PATH file unless there is an
actual path change -
-# this minimizes recompilation based on PATH to actual installation path
changes, rather than
-# just configuration changes - if CMAKE_INSTALL_PREFIX is not defined based on
the build configuration,
-# PATH is constant.
-string(REPLACE "----BUILD_TYPE----" "${BUILD_TYPE_NEW}"
CMAKE_INSTALL_PREFIX_CFG "@CMAKE_INSTALL_PREFIX_CFG@")
-
# We have no way to tell the build tool at build time what string we want
# it to use for the installation path - it only knows its build configuration
# type. Hence, we update the cmake_install.cmake files to let them know
-# directly. Only do this if we need to - i.e. we're using a string other
-# than the build type string itself in the install path.
-#
-# In the event of multiple configuration switches we need to avoid matching
failures
-# due to previous substitutions, so the first time we do this stash the
original
-# contents in cmake_install.cmake.orig file.
-string(REPLACE "----BUILD_TYPE----" "\${BUILD_TYPE}"
CMAKE_INSTALL_PREFIX_CFG_ORIG "@CMAKE_INSTALL_PREFIX_CFG@")
-if(NOT "${BUILD_TYPE_NEW}" STREQUAL "${BUILD_TYPE}")
- file(GLOB_RECURSE ALL_CMAKE_INSTALL_FILES "cmake_install.cmake")
- foreach(cmake_install_file ${ALL_CMAKE_INSTALL_FILES})
- message("cmake_install_file: ${cmake_install_file}")
- if(EXISTS "${cmake_install_file}.orig")
- file(STRINGS "${cmake_install_file}.orig" OLD_INSTALL_CONTENTS)
- else(EXISTS "${cmake_install_file}.orig")
- file(READ "${cmake_install_file}" ORIG_INSTALL_CONTENTS)
- file(WRITE "${cmake_install_file}.orig" "\n${ORIG_INSTALL_CONTENTS}")
- file(STRINGS "${cmake_install_file}.orig" OLD_INSTALL_CONTENTS)
- endif(EXISTS "${cmake_install_file}.orig")
- file(REMOVE "${cmake_install_file}")
- foreach(line ${OLD_INSTALL_CONTENTS})
- set(nline "${line}")
- if (NOT "${nline}" MATCHES ".cmake_install.*"
- )
- if ("${nline}" MATCHES ".*${CMAKE_INSTALL_PREFIX_CFG_ORIG}.*")
- message("nline1_pre: ${nline}")
- string(REPLACE "${CMAKE_INSTALL_PREFIX_CFG_ORIG}"
"${CMAKE_INSTALL_PREFIX_CFG}" nline "${nline}")
- message("nline1_post: ${nline}")
- endif ("${nline}" MATCHES ".*${CMAKE_INSTALL_PREFIX_CFG_ORIG}.*")
- if ("${nline}" MATCHES ".*CONFIG.*")
- message("nline2_pre: ${nline}")
- string(REPLACE "$<CONFIG>/" "${BUILD_TYPE}/" nline "${nline}")
- string(REPLACE "$<CONFIG>" "${BUILD_TYPE}" nline "${nline}")
- message("nline2_post: ${nline}")
- endif ("${nline}" MATCHES ".*CONFIG.*")
- if ("${nline}" MATCHES ".*CONFIGURATION.*")
- message("nline3_pre: ${nline}")
- string(REPLACE "\${CONFIGURATION}/" "${BUILD_TYPE}/" nline "${nline}")
- string(REPLACE "\${CONFIGURATION}" "${BUILD_TYPE}" nline "${nline}")
- message("nline3_post: ${nline}")
- endif ("${nline}" MATCHES ".*CONFIGURATION.*")
- if ("${nline}" MATCHES ".*----BUILD_TYPE----.*")
- message("nline4_pre: ${nline}")
- string(REPLACE "----BUILD_TYPE----" "${BUILD_TYPE_NEW}" nline
"${nline}")
- message("nline4_post: ${nline}")
- endif ("${nline}" MATCHES ".*----BUILD_TYPE----.*")
- endif ()
- file(APPEND "${cmake_install_file}" "${nline}\n")
- endforeach(line ${OLD_INSTALL_CONTENTS})
- endforeach(cmake_install_file ${ALL_CMAKE_INSTALL_FILES})
-endif(NOT "${BUILD_TYPE_NEW}" STREQUAL "${BUILD_TYPE}")
+# directly.
+file(GLOB_RECURSE ALL_CMAKE_INSTALL_FILES "cmake_install.cmake")
+foreach(cmake_install_file ${ALL_CMAKE_INSTALL_FILES})
+
+ # We need to work with the original state of the cmake_install.cmake file
+ # for consistency, so stash a copy if we haven't already done so.
+ if(EXISTS "${cmake_install_file}.orig")
+ file(READ "${cmake_install_file}.orig" OLD_INSTALL_CONTENTS)
+ else(EXISTS "${cmake_install_file}.orig")
+ file(READ "${cmake_install_file}" OLD_INSTALL_CONTENTS)
+ file(WRITE "${cmake_install_file}.orig" "\n${OLD_INSTALL_CONTENTS}")
+ endif(EXISTS "${cmake_install_file}.orig")
+
+ # Remove the obsolete previous state
+ file(REMOVE "${cmake_install_file}")
+
+ # Replace the original cmake_install contents with config specific info
+ set(INSTALL_CONTENTS "${OLD_INSTALL_CONTENTS}")
+ string(REPLACE "$<CONFIG>/" "${BUILD_TYPE}/" INSTALL_CONTENTS
"${INSTALL_CONTENTS}")
+ string(REPLACE "$<CONFIG>" "${BUILD_TYPE}" INSTALL_CONTENTS
"${INSTALL_CONTENTS}")
+ string(REPLACE "\${CONFIGURATION}/" "${BUILD_TYPE}/" INSTALL_CONTENTS
"${INSTALL_CONTENTS}")
+ string(REPLACE "\${CONFIGURATION}" "${BUILD_TYPE}" INSTALL_CONTENTS
"${INSTALL_CONTENTS}")
+ string(REPLACE "----BUILD_TYPE----" "${BUILD_TYPE_NEW}" INSTALL_CONTENTS
"${INSTALL_CONTENTS}")
+ file(WRITE "${cmake_install_file}" "${INSTALL_CONTENTS}\n")
+
+endforeach(cmake_install_file ${ALL_CMAKE_INSTALL_FILES})
+
# Local Variables:
# tab-width: 8
# mode: cmake
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits