Revision: 77904
          http://sourceforge.net/p/brlcad/code/77904
Author:   starseeker
Date:     2020-12-03 17:20:47 +0000 (Thu, 03 Dec 2020)
Log Message:
-----------
Document why we are setting the object dependencies.

Modified Paths:
--------------
    brlcad/trunk/misc/CMake/BRLCAD_Install_Prefix.cmake
    brlcad/trunk/misc/CMake/BRLCAD_Targets.cmake

Modified: brlcad/trunk/misc/CMake/BRLCAD_Install_Prefix.cmake
===================================================================
--- brlcad/trunk/misc/CMake/BRLCAD_Install_Prefix.cmake 2020-12-03 17:19:33 UTC 
(rev 77903)
+++ brlcad/trunk/misc/CMake/BRLCAD_Install_Prefix.cmake 2020-12-03 17:20:47 UTC 
(rev 77904)
@@ -33,6 +33,10 @@
 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
 ###
+# If we need it, use a standard string to stand in for build types.  This
+# allows for easier replacing later in the logic
+set(BUILD_TYPE_KEY "----BUILD_TYPE----")
+
 #---------------------------------------------------------------------
 # The location in which to install BRL-CAD.  Only do this if
 # CMAKE_INSTALL_PREFIX hasn't been set already, to try and allow
@@ -57,7 +61,7 @@
        set(CMAKE_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(CMAKE_INSTALL_PREFIX 
"/usr/brlcad/${BUILD_TYPE_KEY}-${BRLCAD_VERSION}")
     endif(MSVC)
   endif(NOT CMAKE_CONFIGURATION_TYPES)
   set(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH "BRL-CAD install 
prefix" FORCE)
@@ -65,9 +69,6 @@
 endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR NOT CMAKE_INSTALL_PREFIX)
 set(BRLCAD_PREFIX "${CMAKE_INSTALL_PREFIX}" CACHE STRING "BRL-CAD install 
prefix")
 mark_as_advanced(BRLCAD_PREFIX)
-if (DEFINED CMAKE_INSTALL_PREFIX AND NOT DEFINED CMAKE_INSTALL_PREFIX)
-  set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
-endif (DEFINED CMAKE_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
@@ -83,6 +84,7 @@
 #------------------------------------------------------------------------------
 # If CMAKE_INSTALL_PREFIX is "/usr", be VERY noisy about it - a make install in
 # this location is dangerous/destructive on some systems.
+find_program(SLEEP_EXEC sleep)
 if("${CMAKE_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)
@@ -139,20 +141,40 @@
 # 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(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)
-    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)
+# CMAKE_IGNORE_PATH needs a list of explicit directories, not a
+# list of prefixes - in other words, it ignores EXACTLY the specified
+# path and not any subdirectories under that path.  See:
+# https://cmake.org/cmake/help/latest/variable/CMAKE_IGNORE_PATH.html
+# This means we can't just add the install path to the ignore variables
+# and have find_package skip items in the bin and lib subdirs - we need
+# to list them explicitly for exclusion.
 
-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)
-    set(CMAKE_SYSTEM_IGNORE_PATH "${PATH_NORMALIZED}")
-  endif(NOT "${BRLCAD_PREFIX}" STREQUAL "/usr" AND NOT "${BRLCAD_PREFIX}" 
STREQUAL "/usr/local")
-endif(BRLCAD_PREFIX)
-mark_as_advanced(CMAKE_SYSTEM_IGNORE_PATH)
+if(NOT "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr" AND NOT 
"${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr/local")
+  # Make sure we are working with the fully normalized path
+  get_filename_component(PATH_NORMALIZED "${CMAKE_INSTALL_PREFIX}" ABSOLUTE)
+  set(IGNORE_SUBDIRS ${BIN_DIR} ${LIB_DIR})
+  if (CMAKE_CONFIGURATION_TYPES)
+    # If we're doing multi-config, ignore all the possible output locations
+    foreach(cfg ${CMAKE_CONFIGURATION_TYPES})
+      if ("${cfg}" STREQUAL "Release")
+       string(REPLACE "${BUILD_TYPE_KEY}" "rel" "${CMAKE_INSTALL_PREFIX}" 
TYPEPATH)
+      elseif ("${cfg}" STREQUAL "Debug")
+       string(REPLACE "${BUILD_TYPE_KEY}" "dev" "${CMAKE_INSTALL_PREFIX}" 
TYPEPATH)
+      else ("${cfg}" STREQUAL "Release")
+       string(REPLACE "${BUILD_TYPE_KEY}" "${cfg}" "${CMAKE_INSTALL_PREFIX}" 
TYPEPATH)
+      endif ("${cfg}" STREQUAL "Release")
+      foreach(sd ${IGNORE_SUBDIRS})
+       set(CMAKE_SYSTEM_IGNORE_PATH 
"${CMAKE_SYSTEM_IGNORE_PATH};${TYPEPATH}/${sd}")
+       set(CMAKE_IGNORE_PATH "${CMAKE_SYSTEM_IGNORE_PATH};${TYPEPATH}/${sd}")
+      endforeach(sd ${IGNORE_SUBDIRS})
+    endforeach(cfg ${CMAKE_CONFIGURATION_TYPES})
+  else (CMAKE_CONFIGURATION_TYPES)
+    foreach(sd ${IGNORE_SUBDIRS})
+      set(CMAKE_SYSTEM_IGNORE_PATH 
"${CMAKE_SYSTEM_IGNORE_PATH};${PATH_NORMALIZED}/${sd}")
+      set(CMAKE_IGNORE_PATH 
"${CMAKE_SYSTEM_IGNORE_PATH};${PATH_NORMALIZED}/${sd}")
+    endforeach(sd ${IGNORE_SUBDIRS})
+  endif (CMAKE_CONFIGURATION_TYPES)
+endif(NOT "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr" AND NOT 
"${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr/local")
 
 #------------------------------------------------------------------------------
 # Now that we know the install prefix, generate the binary for calculating

Modified: brlcad/trunk/misc/CMake/BRLCAD_Targets.cmake
===================================================================
--- brlcad/trunk/misc/CMake/BRLCAD_Targets.cmake        2020-12-03 17:19:33 UTC 
(rev 77903)
+++ brlcad/trunk/misc/CMake/BRLCAD_Targets.cmake        2020-12-03 17:20:47 UTC 
(rev 77904)
@@ -451,6 +451,20 @@
       set_property(TARGET ${libname}-obj APPEND PROPERTY COMPILE_DEFINITIONS 
"${UPPER_CORE}_DLL_EXPORTS")
     endif(HIDE_INTERNAL_SYMBOLS)
 
+    # If the library depends on other targets in this build, not just system
+    # libraries, make sure the object targets depends them as well.  In
+    # principle this isn't always required - object compilation may be
+    # independent of the dependencies needed at link time - but if compilation
+    # DOES depends on those targets having first performed some action (like
+    # staging a header in an expected location) NOT setting this dependency
+    # explicitly will eventually cause build failures.
+    #
+    # Without setting the OBJECT dependencies, success in the above case would
+    # depend on whether or not the high level build ordering happened to run
+    # the required targets before performing this step.  That failure mode is
+    # semi-random and intermittent (top level build ordering without explicit
+    # dependencies varies depending on -j flag values) making it hard to debug.
+    # Ask me how I know.
     if(NOT "${libslist}" STREQUAL "" AND NOT "${libslist}" STREQUAL "NONE")
       foreach(ll ${libslist})
        if (TARGET ${ll})

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