Revision: 76176
          http://sourceforge.net/p/brlcad/code/76176
Author:   starseeker
Date:     2020-06-22 15:22:10 +0000 (Mon, 22 Jun 2020)
Log Message:
-----------
One of the things an eventual superbuild migration will require is a separation 
between CMAKE_INSTALL_PREFIX and the ultimate BRLCAD_INSTALL_PREFIX (the latter 
being the superbuild's ultimate installation destination, as opposed to the 
local paths used to install the intermediate subbuilds.)  BRL-CAD itself would 
be build as a subbuild in this scenario, so it would have to target an install 
step to a local CMAKE_INSTALL_PREFIX but still have a different installed 
location 'baked in' to the code itself via the configure headers and rpaths, 
which is something we haven't previously done.

Modified Paths:
--------------
    brlcad/trunk/CMakeLists.txt
    brlcad/trunk/misc/CMake/RPath_Setup.cmake

Modified: brlcad/trunk/CMakeLists.txt
===================================================================
--- brlcad/trunk/CMakeLists.txt 2020-06-22 14:24:45 UTC (rev 76175)
+++ brlcad/trunk/CMakeLists.txt 2020-06-22 15:22:10 UTC (rev 76176)
@@ -154,6 +154,27 @@
 set(CONFIG_DELTA_START "${CMAKE_BINARY_DIR}/CMakeTmp/CONFIG_DELTA_START")
 execute_process(COMMAND "${CMAKE_BINARY_DIR}/CMakeTmp/sstamp${EXE_EXT}" 
"${CONFIG_DELTA_START}")
 
+#------------------------------------------------------------------------------
+# The SuperBuild (https://blog.kitware.com/cmake-superbuilds-git-submodules/)
+# pattern requires a differentiation between the CMake installation prefix used
+# for the build and the specification of the ultimate installation location
+# used for the superbuild's install.  Any hard-coded knowledge of the final
+# path backed into BRL-CAD must use the superbuild's final destination, not the
+# intermediate build-directory installation used by the superbuild.
+#
+# For the moment we are not using superbuild, but we will ultimately need to
+# move to that approach to manage increasingly complex dependencies.  To allow
+# the code to work seamlessly with both variables, make them match unless both
+# are explicitly set in advance.
+if (DEFINED BRLCAD_INSTALL_PREFIX)
+  if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR NOT DEFINED 
CMAKE_INSTALL_PREFIX)
+    set(CMAKE_INSTALL_PREFIX "${BRLCAD_INSTALL_PREFIX}")
+  endif (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR NOT DEFINED 
CMAKE_INSTALL_PREFIX)
+endif (DEFINED BRLCAD_INSTALL_PREFIX)
+if (DEFINED CMAKE_INSTALL_PREFIX AND NOT DEFINED BRLCAD_INSTALL_PREFIX)
+  set(BRLCAD_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
+endif (DEFINED CMAKE_INSTALL_PREFIX AND NOT DEFINED BRLCAD_INSTALL_PREFIX)
+
 #---------------------------------------------------------------------
 # Allow the BRLCAD_ROOT environment variable to set during build, but be noisy
 # about it unless we're specifically told this is intentional.  Having this
@@ -167,15 +188,15 @@
   endif(SLEEP_EXEC)
 endif(NOT "$ENV{BRLCAD_ROOT}" STREQUAL "" AND NOT BRLCAD_ROOT_OVERRIDE)
 
-# If CMAKE_INSTALL_PREFIX is "/usr", be VERY noisy about it - a make install in
+# If BRLCAD_INSTALL_PREFIX is "/usr", be VERY noisy about it - a make install 
in
 # this location is dangerous/destructive on some systems.
-if("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr" AND NOT 
BRLCAD_ALLOW_INSTALL_TO_USR)
+if("${BRLCAD_INSTALL_PREFIX}" STREQUAL "/usr" AND NOT 
BRLCAD_ALLOW_INSTALL_TO_USR)
   message(WARNING "}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}\nIt is 
STRONGLY recommended that you DO NOT install BRL-CAD into /usr as BRL-CAD 
provides several libraries that may conflict with other libraries (e.g. librt, 
libbu, libbn) on certain system configurations.\nSince our libraries predate 
all those that we're known to conflict with and are at the very core of our 
geometry services and project heritage, we have no plans to change the names of 
our libraries at this time.\nINSTALLING INTO /usr CAN MAKE A SYSTEM COMPLETELY 
UNUSABLE.  If you choose to continue installing into /usr, you do so entirely 
at your own risk.  You have been 
warned.\n}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}")
   if(SLEEP_EXEC)
     execute_process(COMMAND ${SLEEP_EXEC} 15)
   endif(SLEEP_EXEC)
   message(FATAL_ERROR "If you wish to proceed using /usr as your prefix, 
define BRLCAD_ALLOW_INSTALL_TO_USR=1 for CMake")
-endif("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr" AND NOT 
BRLCAD_ALLOW_INSTALL_TO_USR)
+endif("${BRLCAD_INSTALL_PREFIX}" STREQUAL "/usr" AND NOT 
BRLCAD_ALLOW_INSTALL_TO_USR)
 
 #---------------------------------------------------------------------
 # Define relative install locations and output directories.  Don't set
@@ -237,6 +258,13 @@
 # To ensure the previous (and internally set) CMAKE_INSTALL_PREFIX value
 # is available, BRLCAD_PREFIX is used to store the value in the cache.)
 
+if(BRLCAD_INSTALL_PREFIX)
+  if(NOT "${BRLCAD_INSTALL_PREFIX}" STREQUAL "/usr" AND NOT 
"${BRLCAD_INSTALL_PREFIX}" STREQUAL "/usr/local")
+    get_filename_component(PATH_NORMALIZED 
"${BRLCAD_INSTALL_PREFIX}/${LIB_DIR}" ABSOLUTE)
+    set(CMAKE_SYSTEM_IGNORE_PATH "${PATH_NORMALIZED}")
+  endif(NOT "${BRLCAD_INSTALL_PREFIX}" STREQUAL "/usr" AND NOT 
"${BRLCAD_INSTALL_PREFIX}" STREQUAL "/usr/local")
+endif(BRLCAD_INSTALL_PREFIX)
+
 if(CMAKE_INSTALL_PREFIX)
   if(NOT "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr" AND NOT 
"${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr/local")
     get_filename_component(PATH_NORMALIZED 
"${CMAKE_INSTALL_PREFIX}/${LIB_DIR}" ABSOLUTE)
@@ -243,6 +271,7 @@
     set(CMAKE_SYSTEM_IGNORE_PATH "${PATH_NORMALIZED}")
   endif(NOT "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr" AND NOT 
"${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr/local")
 endif(CMAKE_INSTALL_PREFIX)
+
 if(BRLCAD_PREFIX)
   if(NOT "${BRLCAD_PREFIX}" STREQUAL "/usr" AND NOT "${BRLCAD_PREFIX}" 
STREQUAL "/usr/local")
     get_filename_component(PATH_NORMALIZED "${BRLCAD_PREFIX}/${LIB_DIR}" 
ABSOLUTE)
@@ -790,19 +819,19 @@
 # ExternalProject_Add approach first as well - that way unmodified install
 # commands in 3rd party CMake files will be moot.
 #
-# if (NOT CMAKE_INSTALL_PREFIX)
-# set(CMAKE_INSTALL_PREFIX "/usr/brlcad/")
+# if (NOT BRLCAD_INSTALL_PREFIX)
+# set(BRLCAD_INSTALL_PREFIX "/usr/brlcad/")
 #    if (NOT MSVC)
 #       set(gen_exp 
$<IF:$<CONFIG:Debug>,dev-${BRLCAD_VERSION}/,$<IF:$<CONFIG:Release>,rel-${BRLCAD_VERSION}/${BRLCAD_VERSION},>>)
 #    else (NOT MSVC)
 #       set(gen_exp)
 #        if(CMAKE_CL_64)
-#          set(CMAKE_INSTALL_PREFIX "C:/Program Files/BRL-CAD 
${BRLCAD_VERSION}")
+#          set(BRLCAD_INSTALL_PREFIX "C:/Program Files/BRL-CAD 
${BRLCAD_VERSION}")
 #        else(CMAKE_CL_64)
-#          set(CMAKE_INSTALL_PREFIX "C:/Program Files (x86)/BRL-CAD 
${BRLCAD_VERSION}")
+#          set(BRLCAD_INSTALL_PREFIX "C:/Program Files (x86)/BRL-CAD 
${BRLCAD_VERSION}")
 #        endif(CMAKE_CL_64)
 #    endif (NOT MSVC)
-# endif (NOT CMAKE_INSTALL_PREFIX)
+# endif (NOT BRLCAD_INSTALL_PREFIX)
 # install(TARGETS mged DESTINATION ${gen_exp}${BIN_DIR})
 #
 # Another (maybe better) option instead of generators might be to use the 
CONFIGURATIONS
@@ -809,40 +838,44 @@
 # option in our macros and the ExternalProject_Add management:
 # https://cmake.org/cmake/help/latest/command/install.html
 #
-if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR NOT CMAKE_INSTALL_PREFIX)
+if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR NOT BRLCAD_INSTALL_PREFIX)
   if(NOT CMAKE_CONFIGURATION_TYPES)
     if("${CMAKE_BUILD_TYPE}" MATCHES "Release")
-      set(CMAKE_INSTALL_PREFIX "/usr/brlcad/rel-${BRLCAD_VERSION}")
+      set(BRLCAD_INSTALL_PREFIX "/usr/brlcad/rel-${BRLCAD_VERSION}")
     else("${CMAKE_BUILD_TYPE}" MATCHES "Release")
-      set(CMAKE_INSTALL_PREFIX "/usr/brlcad/dev-${BRLCAD_VERSION}")
+      set(BRLCAD_INSTALL_PREFIX "/usr/brlcad/dev-${BRLCAD_VERSION}")
     endif("${CMAKE_BUILD_TYPE}" MATCHES "Release")
   else(NOT CMAKE_CONFIGURATION_TYPES)
     if(MSVC)
       if(CMAKE_CL_64)
-       set(CMAKE_INSTALL_PREFIX "C:/Program Files/BRL-CAD ${BRLCAD_VERSION}")
+       set(BRLCAD_INSTALL_PREFIX "C:/Program Files/BRL-CAD ${BRLCAD_VERSION}")
       else(CMAKE_CL_64)
-       set(CMAKE_INSTALL_PREFIX "C:/Program Files (x86)/BRL-CAD 
${BRLCAD_VERSION}")
+       set(BRLCAD_INSTALL_PREFIX "C:/Program Files (x86)/BRL-CAD 
${BRLCAD_VERSION}")
       endif(CMAKE_CL_64)
     else(MSVC)
-      set(CMAKE_INSTALL_PREFIX "/usr/brlcad/dev-${BRLCAD_VERSION}")
+      set(BRLCAD_INSTALL_PREFIX "/usr/brlcad/dev-${BRLCAD_VERSION}")
     endif(MSVC)
   endif(NOT CMAKE_CONFIGURATION_TYPES)
-  set(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH "BRL-CAD install 
prefix" FORCE)
-  set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT 0)
-endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR NOT CMAKE_INSTALL_PREFIX)
-set(BRLCAD_PREFIX "${CMAKE_INSTALL_PREFIX}" CACHE STRING "BRL-CAD install 
prefix")
+  set(BRLCAD_INSTALL_PREFIX ${BRLCAD_INSTALL_PREFIX} CACHE PATH "BRL-CAD 
install prefix" FORCE)
+  set(BRLCAD_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT 0)
+endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR NOT BRLCAD_INSTALL_PREFIX)
+set(BRLCAD_PREFIX "${BRLCAD_INSTALL_PREFIX}" CACHE STRING "BRL-CAD install 
prefix")
 mark_as_advanced(BRLCAD_PREFIX)
+if (DEFINED BRLCAD_INSTALL_PREFIX AND NOT DEFINED CMAKE_INSTALL_PREFIX)
+  set(CMAKE_INSTALL_PREFIX "${BRLCAD_INSTALL_PREFIX}")
+endif (DEFINED BRLCAD_INSTALL_PREFIX AND NOT DEFINED CMAKE_INSTALL_PREFIX)
 
+
 # If we've a Release build with a Debug path or vice versa, warn about
 # it.  A "make install" of a Release build into a dev install
 # directory or vice versa is going to result in an install that
 # doesn't respect BRL-CAD standard naming conventions.
-if("${CMAKE_BUILD_TYPE}" MATCHES "Release" AND "${CMAKE_INSTALL_PREFIX}" 
STREQUAL "/usr/brlcad/dev-${BRLCAD_VERSION}")
-  message(FATAL_ERROR "\nInstallation directory (CMAKE_INSTALL_PREFIX) is set 
to /usr/brlcad/dev-${BRLCAD_VERSION}, but build type is set to Release!\n")
-endif("${CMAKE_BUILD_TYPE}" MATCHES "Release" AND "${CMAKE_INSTALL_PREFIX}" 
STREQUAL "/usr/brlcad/dev-${BRLCAD_VERSION}")
-if("${CMAKE_BUILD_TYPE}" MATCHES "Debug" AND "${CMAKE_INSTALL_PREFIX}" 
STREQUAL "/usr/brlcad/rel-${BRLCAD_VERSION}")
-  message(FATAL_ERROR "\nInstallation directory (CMAKE_INSTALL_PREFIX) is set 
to /usr/brlcad/rel-${BRLCAD_VERSION}, but build type is set to Debug!\n")
-endif("${CMAKE_BUILD_TYPE}" MATCHES "Debug" AND "${CMAKE_INSTALL_PREFIX}" 
STREQUAL "/usr/brlcad/rel-${BRLCAD_VERSION}")
+if("${CMAKE_BUILD_TYPE}" MATCHES "Release" AND "${BRLCAD_INSTALL_PREFIX}" 
STREQUAL "/usr/brlcad/dev-${BRLCAD_VERSION}")
+  message(FATAL_ERROR "\nInstallation directory (BRLCAD_INSTALL_PREFIX) is set 
to /usr/brlcad/dev-${BRLCAD_VERSION}, but build type is set to Release!\n")
+endif("${CMAKE_BUILD_TYPE}" MATCHES "Release" AND "${BRLCAD_INSTALL_PREFIX}" 
STREQUAL "/usr/brlcad/dev-${BRLCAD_VERSION}")
+if("${CMAKE_BUILD_TYPE}" MATCHES "Debug" AND "${BRLCAD_INSTALL_PREFIX}" 
STREQUAL "/usr/brlcad/rel-${BRLCAD_VERSION}")
+  message(FATAL_ERROR "\nInstallation directory (BRLCAD_INSTALL_PREFIX) is set 
to /usr/brlcad/rel-${BRLCAD_VERSION}, but build type is set to Debug!\n")
+endif("${CMAKE_BUILD_TYPE}" MATCHES "Debug" AND "${BRLCAD_INSTALL_PREFIX}" 
STREQUAL "/usr/brlcad/rel-${BRLCAD_VERSION}")
 
 #------------------------------------------------------------------------------
 # Now that we know the install prefix, generate the binary for calculating
@@ -992,8 +1025,10 @@
 CONFIG_H_APPEND(BRLCAD "#define EXECUTABLE_SUFFIX 
\"${CMAKE_EXECUTABLE_SUFFIX}\"\n")
 CONFIG_H_APPEND(BRLCAD "#define SHARED_LIBRARY_SUFFIX 
\"${CMAKE_SHARED_LIBRARY_SUFFIX}\"\n")
 
-# Let bu_dir know what the target install directory is
-CONFIG_H_APPEND(BRLCAD "#define BRLCAD_ROOT \"${CMAKE_INSTALL_PREFIX}\"\n")
+# Let bu_dir know what the target install directory is.  In a superbuild
+# configuration this will be the most import place to be sure that we get the
+# actual superbuild install path, not the local BRL-CAD subbuild install path.
+CONFIG_H_APPEND(BRLCAD "#define BRLCAD_ROOT \"${BRLCAD_INSTALL_PREFIX}\"\n")
 
 # Define the various relative paths for bu_dir (be sure to have included
 # Path_Setup.cmake before this point, as that file defines these variables.)
@@ -3394,6 +3429,8 @@
 endif(NOT BRLCAD_IS_SUBBUILD)
 
 
+# TODO - the below logic will have to be rethought in a superbuild setup...
+
 # To set correct install paths for CMake at build time, rather than CMake
 # time, some rather special logic is necessary - a build target that needs
 # to be run when the current build type changes, and introspective scripting

Modified: brlcad/trunk/misc/CMake/RPath_Setup.cmake
===================================================================
--- brlcad/trunk/misc/CMake/RPath_Setup.cmake   2020-06-22 14:24:45 UTC (rev 
76175)
+++ brlcad/trunk/misc/CMake/RPath_Setup.cmake   2020-06-22 15:22:10 UTC (rev 
76176)
@@ -55,9 +55,9 @@
       # location relative to the loading file's path if the installed version 
is
       # not present.  How to do so is platform specific.
       if(NOT APPLE)
-       set(CMAKE_INSTALL_RPATH 
"${CMAKE_INSTALL_PREFIX}/${LIB_DIR}:\$ORIGIN/../${LIB_DIR}" PARENT_SCOPE)
+       set(CMAKE_INSTALL_RPATH 
"${BRLCAD_INSTALL_PREFIX}/${LIB_DIR}:\$ORIGIN/../${LIB_DIR}" PARENT_SCOPE)
       else(NOT APPLE)
-       set(CMAKE_INSTALL_RPATH 
"${CMAKE_INSTALL_PREFIX}/${LIB_DIR};@loader_path/../${LIB_DIR}" PARENT_SCOPE)
+       set(CMAKE_INSTALL_RPATH 
"${BRLCAD_INSTALL_PREFIX}/${LIB_DIR};@loader_path/../${LIB_DIR}" PARENT_SCOPE)
       endif(NOT APPLE)
 
       # On OSX, we need to set INSTALL_NAME_DIR instead of RPATH for CMake < 
3.0
@@ -64,7 +64,7 @@
       # 
http://www.cmake.org/cmake/help/cmake-2-8-docs.html#variable:CMAKE_INSTALL_NAME_DIR
       # http://www.cmake.org/cmake/help/v3.2/policy/CMP0042.html
       if ("${CMAKE_VERSION}" VERSION_LESS 3.0)
-       set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${LIB_DIR}" 
PARENT_SCOPE)
+       set(CMAKE_INSTALL_NAME_DIR "${BRLCAD_INSTALL_PREFIX}/${LIB_DIR}" 
PARENT_SCOPE)
       endif ("${CMAKE_VERSION}" VERSION_LESS 3.0)
 
       # Add the automatically determined parts of the RPATH which point to

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

Reply via email to