diff --git a/misc/CMake/BRLCAD_ExternalDeps.cmake b/misc/CMake/BRLCAD_ExternalDeps.cmake index 31fb6fad35..b00cf6131c 100644 --- a/misc/CMake/BRLCAD_ExternalDeps.cmake +++ b/misc/CMake/BRLCAD_ExternalDeps.cmake @@ -115,17 +115,20 @@ endif () # If we have a bext_output in the build directory, we need to clear it DISTCLEAN("${CMAKE_BINARY_DIR}/bext_output") -# If we got to ${BRLCAD_EXT_DIR}/install through a symlink, we need to expand it so -# we can spot the path that would have been used in ${BRLCAD_EXT_DIR}/install files +# If we got to ${BRLCAD_EXT_DIR}/install through a symlink, we need to +# expand it so we can spot the path that would have been used in +# ${BRLCAD_EXT_DIR}/install files # # TODO - once we can require CMake 3.21 minimum, add EXPAND_TILDE to # the arguments list + file(REAL_PATH "${BRLCAD_EXT_INSTALL_DIR}" BRLCAD_EXT_DIR_REAL) -# See if we have plief available for rpath manipulation. If it is available, -# we will be using it to manage the RPATH settings for third party exe/lib -# files. If not, see if patchelf is available instead. +# See if we have plief available for rpath manipulation. If it is +# available, we will be using it to manage the RPATH settings for +# third party exe/lib files. If not, see if patchelf is available +# instead. find_program(P_RPATH_EXECUTABLE NAMES plief HINTS ${BRLCAD_EXT_NOINSTALL_DIR}/${BIN_DIR}) if (NOT P_RPATH_EXECUTABLE) find_program(P_RPATH_EXECUTABLE NAMES patchelf HINTS ${BRLCAD_EXT_NOINSTALL_DIR}/${BIN_DIR}) @@ -135,16 +138,16 @@ endif (NOT P_RPATH_EXECUTABLE) find_program(STRCLEAR_EXECUTABLE strclear HINTS ${BRLCAD_EXT_NOINSTALL_DIR}/${BIN_DIR}) -# For repeat configure passes, we need to check any existing files copied -# against the ${BRLCAD_EXT_DIR}/install dir's contents, to detect if the latter has changed -# and we need to redo the process. +# For repeat configure passes, we need to check any existing files +# copied against the ${BRLCAD_EXT_DIR}/install dir's contents, to +# detect if the latter has changed and we need to redo the process. set(TP_INVENTORY "${CMAKE_BINARY_DIR}/CMakeFiles/thirdparty.txt") set(TP_INVENTORY_BINARIES "${CMAKE_BINARY_DIR}/CMakeFiles/thirdparty_binaries.txt") -# These patterns are used to identify sets of files where we are assuming we -# don't need to do post-processing to correct file paths from the external -# install. +# These patterns are used to identify sets of files where we are +# assuming we don't need to do post-processing to correct file paths +# from the external install. set(NOPROCESS_PATTERNS ".*/encodings/.*" ".*/include/.*" @@ -152,10 +155,11 @@ set(NOPROCESS_PATTERNS ".*/msgs/.*" ) -# These patterns are to be excluded from ${BRLCAD_EXT_DIR}/install bundling - i.e., even if -# present in the specified ${BRLCAD_EXT_DIR}/install directory, BRL-CAD will not incorporate -# them. Generally speaking this is used to avoid files needed for external -# building but counterproductive in the BRL-CAD install. +# These patterns are to be excluded from ${BRLCAD_EXT_DIR}/install +# bundling - i.e., even if present in the specified +# ${BRLCAD_EXT_DIR}/install directory, BRL-CAD will not incorporate +# them. Generally speaking this is used to avoid files needed for +# external building but counterproductive in the BRL-CAD install. set(EXCLUDED_PATTERNS ${LIB_DIR}/itcl4.2.3/itclConfig.sh ${LIB_DIR}/tclConfig.sh @@ -169,8 +173,9 @@ set(EXCLUDED_PATTERNS ##################################################################### -# In multiconfig we need to scrub excluded files out of multiple ${BRLCAD_EXT_DIR}/install -# copies, so wrap logic to do so into a function. +# In multiconfig we need to scrub excluded files out of multiple +# ${BRLCAD_EXT_DIR}/install copies, so wrap logic to do so into a +# function. function(STRIP_EXCLUDED RDIR EXPATTERNS) foreach (ep ${${EXPATTERNS}}) file(GLOB_RECURSE MATCHING_FILES LIST_DIRECTORIES false RELATIVE "${RDIR}" "${RDIR}/${ep}") @@ -185,8 +190,8 @@ endfunction(STRIP_EXCLUDED) -# See if a file matches a pattern to skip its processing -# Sets the variable held in SVAR in the parent scope +# See if a file matches a pattern to skip its processing. +# Sets the variable held in SVAR in the parent scope. function(SKIP_PROCESSING tf SVAR) if (IS_SYMLINK ${tf}) set(${SVAR} 1 PARENT_SCOPE) @@ -202,8 +207,8 @@ function(SKIP_PROCESSING tf SVAR) endfunction(SKIP_PROCESSING) -# Since the checking process can be long, we want some sort -# of feedback indicating we're progressing +# Since the checking process can be long, we want some sort of +# feedback indicating we're progressing. function(BFILE_TYPE_MSG ALL_CNT ALL_PROCESSED BINARY_LIST) list(LENGTH ${BINARY_LIST} BCNT) if (BCNT) @@ -237,16 +242,17 @@ function(TFILE_TYPE_MSG ALL_CNT ALL_PROCESSED TEXT_LIST) endif (TCNT) endfunction(TFILE_TYPE_MSG) -# For processing purposes, there are three categories of ${BRLCAD_EXT_DIR}/install file: +# For processing purposes, there are three categories of +# ${BRLCAD_EXT_DIR}/install file: # -# 1. exe or shared library files needing RPATH adjustment (which also need -# to be installed with executable permissions) +# 1. exe or shared library files needing RPATH adjustment (which also +# need to be installed with executable permissions) # 2. binary files which are NOT executable files (images, etc.) # 3. text files # -# If we don't want to hard-code information about specific files we expect -# to find in ${BRLCAD_EXT_DIR}/install, we need a way to detect "on the fly" what we are -# dealing with. +# If we don't want to hard-code information about specific files we +# expect to find in ${BRLCAD_EXT_DIR}/install, we need a way to detect +# "on the fly" what we are dealing with. function(FILE_TYPE fname ALL_CNT BINARY_LIST TEXT_LIST NOEXEC_LIST) if (IS_SYMLINK ${CMAKE_BINARY_DIR}/${fname}) return() @@ -310,17 +316,19 @@ function(FILE_TYPE fname ALL_CNT BINARY_LIST TEXT_LIST NOEXEC_LIST) endfunction(FILE_TYPE) - -# Copy everything in ${BRLCAD_EXT_DIR}/install into the build directory +# Copy everything in ${BRLCAD_EXT_DIR}/install into the build +# directory function(INITIALIZE_TP_FILES) - # Rather than complicate matters trying to pick and choose what to move, just - # stage everything. Depending on what the dependencies write into their - # install directories we may have to be more selective about this in the - # future, but for now let's try simplicity - the less we can couple this - # logic to the specific contents of ${BRLCAD_EXT_DIR}/install, the better. + # Rather than complicate matters trying to pick and choose what to + # move, just stage everything. Depending on what the dependencies + # write into their install directories we may have to be more + # selective about this in the future, but for now let's try + # simplicity - the less we can couple this logic to the specific + # contents of ${BRLCAD_EXT_DIR}/install, the better. # - # Unfortuately, as implemented this is currently quite slow, but cmake's - # -E copy_directory command follows symlinks rather than duplicating them: + # Unfortuately, as implemented this is currently quite slow, but + # cmake's -E copy_directory command follows symlinks rather than + # duplicating them: # https://cmake.org/cmake/help/latest/manual/cmake.1.html if ("${BRLCAD_EXT_DIR}/install" STREQUAL "${BRLCAD_EXT_INSTALL_DIR}") set(EXT_DIR_STR "${BRLCAD_EXT_INSTALL_DIR}") @@ -330,22 +338,24 @@ function(INITIALIZE_TP_FILES) message("Staging third party files from ${EXT_DIR_STR} in build directory...") file(GLOB SDIRS LIST_DIRECTORIES true RELATIVE "${BRLCAD_EXT_INSTALL_DIR}" "${BRLCAD_EXT_INSTALL_DIR}/*") foreach(sd ${SDIRS}) - # Bundled up the sub-directory's contents so that the archive will expand with - # paths relative to the ${BRLCAD_EXT_DIR}/install root + # Bundled up the sub-directory's contents so that the archive will + # expand with paths relative to the ${BRLCAD_EXT_DIR}/install root message("Packing ${sd} subdirectory...") execute_process(COMMAND ${CMAKE_COMMAND} -E tar cf ${CMAKE_BINARY_DIR}/${sd}.tar "${BRLCAD_EXT_INSTALL_DIR}/${sd}" WORKING_DIRECTORY "${BRLCAD_EXT_INSTALL_DIR}") message("Packing ${sd} subdirectory... done.") - # Make sure the build directory has the target directory to write to + # Make sure build directory has the target directory to write to file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${sd}) - # Whether we're single or multi config, do a top level decompression to give - # the install targets a uniform source for all configurations. + # Whether we're single or multi config, do a top level + # decompression to give the install targets a uniform source for + # all configurations. message("Expanding ${sd}.tar in build directory...") if ("${CMAKE_VERSION}" VERSION_LESS "3.24") execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf ${CMAKE_BINARY_DIR}/${sd}.tar WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") else ("${CMAKE_VERSION}" VERSION_LESS "3.24") - # If we have it, use --touch instead of the (very slow) per file -E touch update + # If we have it, use --touch instead of the (very slow) per file + # -E touch update # https://cmake.org/cmake/help/latest/manual/cmake.1.html#cmdoption-cmake-E_tar-touch execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf ${CMAKE_BINARY_DIR}/${sd}.tar --touch WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") endif ("${CMAKE_VERSION}" VERSION_LESS "3.24") @@ -355,17 +365,18 @@ function(INITIALIZE_TP_FILES) execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/${sd}.tar) endforeach(sd ${SDIRS}) - # The above copy is indiscriminate, so we follow behind it and strip out the - # files we don't wish to include + # The above copy is indiscriminate, so we follow behind it and strip + # out the files we don't wish to include message("Removing files indicated by exclude patterns...") STRIP_EXCLUDED("${CMAKE_BINARY_DIR}" EXCLUDED_PATTERNS) message("Removing files indicated by exclude patterns... done.") - # In older CMake, unpacking the files didn't come with the option to update - # their timestamps - see https://cmake.org/cmake/help/latest/manual/cmake.1.html#cmdoption-cmake-E_tar-touch - # If we want to be able to check if ${BRLCAD_EXT_DIR}/install has changed, we need to make - # sure the build dir copies are newer than the ${BRLCAD_EXT_DIR}/install copies for - # IS_NEWER_THAN testing. + # In older CMake, unpacking the files didn't come with the option to + # update their timestamps - see + # https://cmake.org/cmake/help/latest/manual/cmake.1.html#cmdoption-cmake-E_tar-touch + # If we want to be able to check if ${BRLCAD_EXT_DIR}/install has + # changed, we need to make sure the build dir copies are newer than + # the ${BRLCAD_EXT_DIR}/install copies for IS_NEWER_THAN testing. if ("${CMAKE_VERSION}" VERSION_LESS "3.24") message("Updating copied file timestamps...") foreach(tf ${TP_FILES}) @@ -376,27 +387,31 @@ function(INITIALIZE_TP_FILES) message("Staging third party files from ${EXT_DIR_STR} in build directory... done.") - # NOTE - we may need to find and redo symlinks, if we get any that are full - # paths - we expect .so and .so.* style symlinks on some platforms, and there - # may be others. If those paths are absolute in BRLCAD_EXT_INSTALL_DIR they will be - # wrong when copied into the BRL-CAD build - they will work on the build - # machine since full path links will resolve, but will fail when installed on - # another machine. A quick tests suggests we don't have any like that right + # NOTE - we may need to find and redo symlinks, if we get any that + # are full paths - we expect .so and .so.* style symlinks on some + # platforms, and there may be others. If those paths are absolute + # in BRLCAD_EXT_INSTALL_DIR they will be wrong when copied into the + # BRL-CAD build - they will work on the build machine since full + # path links will resolve, but will fail when installed on another + # machine. A quick tests suggests we don't have any like that right # now, but it's not clear we can count on that... endfunction(INITIALIZE_TP_FILES) -# If we have a pre-existing list of files, we need to determine the status of the -# current directories vs the list. Sets three lists at the parent scope: -# TP_NEW - files in ${BRLCAD_EXT_DIR}/install that are new since the previous list was generated -# TP_STALE - files in the old list that are no longer in ${BRLCAD_EXT_DIR}/install -# TP_CHANGED - files present in both lists but newer in ${BRLCAD_EXT_DIR}/install +# If we have a pre-existing list of files, we need to determine the +# status of the current directories vs the list. Sets three lists at +# the parent scope: TP_NEW - files in ${BRLCAD_EXT_DIR}/install that +# are new since the previous list was generated TP_STALE - files in +# the old list that are no longer in ${BRLCAD_EXT_DIR}/install +# TP_CHANGED - files present in both lists but newer in +# ${BRLCAD_EXT_DIR}/install # -# Note that TP_NEW will be empty if there is no previous state. The main logic -# uses a different variable - TP_INIT - to notify the appropriate processing steps -# that there are files to work on, since we don't want to do the copying step -# with configure_file when the initialize routines have already done the work. +# Note that TP_NEW will be empty if there is no previous state. The +# main logic uses a different variable - TP_INIT - to notify the +# appropriate processing steps that there are files to work on, since +# we don't want to do the copying step with configure_file when the +# initialize routines have already done the work. function(TP_COMPARE_STATE TP_NEW_LIST TP_PREV_LIST) # See if any new files have appeared compared to the previous state @@ -409,7 +424,7 @@ function(TP_COMPARE_STATE TP_NEW_LIST TP_PREV_LIST) set(LTP_NEW) endif (LTP_PREVIOUS) - # See if any files previously copied into the build dir have been removed + # See if any files previously copied into build dir were removed set(LTP_STALE ${LTP_PREVIOUS}) if (${TP_NEW_LIST}) list(REMOVE_ITEM LTP_STALE ${${TP_NEW_LIST}}) @@ -434,11 +449,10 @@ function(TP_COMPARE_STATE TP_NEW_LIST TP_PREV_LIST) endfunction(TP_COMPARE_STATE) - # The relative RPATH is specific to the location and platform function(find_relative_rpath fp rp) - # We don't want the filename to count, so offset our directory - # count down by 1 + # We don't want the filename to count, so offset our directory count + # down by 1 set(dcnt -1) set(fp_cpy ${fp}) while (NOT "${fp_cpy}" STREQUAL "") @@ -462,11 +476,11 @@ endfunction(find_relative_rpath) -# Apply the RPATH settings to be used in the build directory. This is a bit -# different from what is done for the final install - the goal here is not -# to produce relocatable files, but just have things work in place in the build -# locations. Parameterized to allow processing of both single and multiconfig -# builds. +# Apply the RPATH settings to be used in the build directory. This is +# a bit different from what is done for the final install - the goal +# here is not to produce relocatable files, but just have things work +# in place in the build locations. Parameterized to allow processing +# of both single and multiconfig builds. function(RPATH_BUILD_DIR_PROCESS ROOT_DIR lf) if (P_RPATH_EXECUTABLE) execute_process(COMMAND ${P_RPATH_EXECUTABLE} --set-rpath "${ROOT_DIR}/${LIB_DIR}" ${lf} WORKING_DIRECTORY ${ROOT_DIR}) @@ -474,10 +488,12 @@ function(RPATH_BUILD_DIR_PROCESS ROOT_DIR lf) execute_process(COMMAND install_name_tool -delete_rpath "${BRLCAD_EXT_DIR}/${BRLCAD_EXT_DIR}/install/${LIB_DIR}" ${lf} WORKING_DIRECTORY ${ROOT_DIR} OUTPUT_VARIABLE OOUT RESULT_VARIABLE ORESULT ERROR_VARIABLE OERROR) execute_process(COMMAND install_name_tool -add_rpath "${ROOT_DIR}/${LIB_DIR}" ${lf} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) endif (P_RPATH_EXECUTABLE) - # RPATH updates are complete - now clear out any other stale paths in the file + # RPATH updates are complete - now clear out any other stale paths + # in the file execute_process(COMMAND ${STRCLEAR_EXECUTABLE} -v -b -c ${ROOT_DIR}/${lf} "${BRLCAD_EXT_DIR_REAL}/${LIB_DIR}" "${BRLCAD_EXT_DIR_REAL}/${BIN_DIR}" "${BRLCAD_EXT_DIR_REAL}/${INCLUDE_DIR}" "${BRLCAD_EXT_DIR_REAL}/") - # Modern Apple security features (particularly on ARM64) complicate our manipulation of these - # files in this fashion. For more info, see: + # Modern Apple security features (particularly on ARM64) complicate + # our manipulation of these files in this fashion. For more info, + # see: # https://developer.apple.com/documentation/security/updating_mac_software # https://developer.apple.com/documentation/xcode/embedding-nonstandard-code-structures-in-a-bundle # https://stackoverflow.com/questions/71744856/install-name-tool-errors-on-arm64 @@ -490,9 +506,9 @@ endfunction(RPATH_BUILD_DIR_PROCESS) ##################################################################### -# Start of processing for BRLCAD_EXT_INSTALL_DIR contents -# We need to keep the build directory copies of ${BRLCAD_EXT_DIR}/install files in -# sync with the BRLCAD_EXT_DIR originals, if they change. +# Start of processing for BRLCAD_EXT_INSTALL_DIR contents We need to +# keep the build directory copies of ${BRLCAD_EXT_DIR}/install files +# in sync with the BRLCAD_EXT_DIR originals, if they change. ##################################################################### if (NOT BRLCAD_DISABLE_RELOCATION) @@ -506,18 +522,19 @@ if (NOT BRLCAD_DISABLE_RELOCATION) # For the very first pass w bulk copy the contents of the - # BRLCAD_EXT_INSTALL_DIR tree into our own directory. For some of the - # external dependencies (like Tcl) library elements must be in sane relative - # locations to binaries being executed, and leaving them in - # BRLCAD_EXT_INSTALL_DIR won't work. On Windows, the dlls for all the - # dependencies will need to be located correctly relative to the bin build - # directory. + # BRLCAD_EXT_INSTALL_DIR tree into our own directory. For some of + # the external dependencies (like Tcl) library elements must be in + # sane relative locations to binaries being executed, and leaving + # them in BRLCAD_EXT_INSTALL_DIR won't work. On Windows, the dlls + # for all the dependencies will need to be located correctly + # relative to the bin build directory. set(TP_INIT) if (NOT EXISTS "${TP_INVENTORY}") INITIALIZE_TP_FILES() - # Special variable for when we need to know about first time initialization + # Special variable for when we need to know about first time + # initialization set(TP_INIT "${TP_FILES}") # With a clean copy, there aren't any previous files to check @@ -525,8 +542,8 @@ if (NOT BRLCAD_DISABLE_RELOCATION) else (NOT EXISTS "${TP_INVENTORY}") - # If we are repeating a configure process, we need to see what (if anything) - # has changed. Read in the previous list. + # If we are repeating a configure process, we need to see what (if + # anything) has changed. Read in the previous list. file(READ "${TP_INVENTORY}" TP_P) string(REPLACE "\n" ";" TP_PREVIOUS "${TP_P}") @@ -540,30 +557,34 @@ if (NOT BRLCAD_DISABLE_RELOCATION) list(SORT TP_FILES) list(SORT TP_PREVIOUS) - # See what the delta looks like between the previous ${BRLCAD_EXT_DIR}/install state (if any) - # and the current + # See what the delta looks like between the previous + # ${BRLCAD_EXT_DIR}/install state (if any) and the current message("Comparing previous and current states...") TP_COMPARE_STATE(TP_FILES TP_PREVIOUS) message("Comparing previous and current states... done.") - # If we do have changes in a repeat configure process, we're going to have to - # redo the find_package tests. However, we don't want to repeat them if we - # don't have to, so key the reset process on what we find. + # If we do have changes in a repeat configure process, we're going + # to have to redo the find_package tests. However, we don't want to + # repeat them if we don't have to, so key the reset process on what + # we find. set(RESET_TP FALSE CACHE BOOL "resetting flag") if (BRLCAD_TP_FULL_RESET) if (TP_NEW OR TP_CHANGED OR TP_STALE) - # If the user has requested it, if anything has changed we do a full flush - # and re-copy of the ${BRLCAD_EXT_DIR}/install contents. This is useful if one is changing - # the ${BRLCAD_EXT_DIR}/install directory to a completely different directory rather than - # incrementally updating the same directory. In the former case, timestamps - # aren't a reliable indicator of what to update in the build tree. + # If the user has requested it, if anything has changed we do a + # full flush and re-copy of the ${BRLCAD_EXT_DIR}/install + # contents. This is useful if one is changing the + # ${BRLCAD_EXT_DIR}/install directory to a completely different + # directory rather than incrementally updating the same + # directory. In the former case, timestamps aren't a reliable + # indicator of what to update in the build tree. # - # The tradeoff is a full re-initialization is usually slower, since it is - # doing more work. On platforms where configure is slow, this can be - # significant. Hence the user setting to control behavior. + # The tradeoff is a full re-initialization is usually slower, + # since it is doing more work. On platforms where configure is + # slow, this can be significant. Hence the user setting to + # control behavior. # Clear old files foreach (ef ${TP_PREVIOUS}) @@ -590,12 +611,14 @@ if (NOT BRLCAD_DISABLE_RELOCATION) message("Removing stale 3rd party files in build directory... done.") endif (TP_STALE) - # Stage new files - we don't have the bulk tar mechanism going after the first - # configure pass, so we have to do the copies needed explicitly. TP_COMPARE_STATE - # shouldn't populate TP_NEW unless we have a previous state to compare to. + # Stage new files - we don't have the bulk tar mechanism going + # after the first configure pass, so we have to do the copies + # needed explicitly. TP_COMPARE_STATE shouldn't populate TP_NEW + # unless we have a previous state to compare to. # - # configure_file follows symlinks rather than copying them, so we can't use - # that for this application and have to fall back on file(COPY): + # configure_file follows symlinks rather than copying them, so we + # can't use that for this application and have to fall back on + # file(COPY): # https://gitlab.kitware.com/cmake/cmake/-/issues/14609 if (TP_NEW) message("Staging new 3rd party files from ${BRLCAD_EXT_DIR}/install...") @@ -630,14 +653,16 @@ if (NOT BRLCAD_DISABLE_RELOCATION) endif (BRLCAD_TP_FULL_RESET) - # We'll either have TP_INIT (on the first pass) or (possibly) one or both of the - # others. Regardless, the processing from here on out is the same. + # We'll either have TP_INIT (on the first pass) or (possibly) one or + # both of the others. Regardless, the processing from here on out + # is the same. set(TP_PROCESS ${TP_CHANGED} ${TP_NEW} ${TP_INIT}) - # We're only going to characterize new files, but even on repeat configures - # we need to know about ALL binary files, old and new, for defining the - # install rules. Read the cached list, if any, and scrub out any entries - # that are in one of the processing or clean-up lists + # We're only going to characterize new files, but even on repeat + # configures we need to know about ALL binary files, old and new, + # for defining the install rules. Read the cached list, if any, and + # scrub out any entries that are in one of the processing or + # clean-up lists set(BINARY_FILES) set(TEXT_FILES) set(NOEXEC_FILES) @@ -656,9 +681,9 @@ if (NOT BRLCAD_DISABLE_RELOCATION) endif (EXISTS ${TP_INVENTORY_BINARIES}) # Use various tools to sort out which files are exec/lib files, - # targeting only the files we've determined need processing (for - # an initialization this is everything, but for subsequent passes - # there is likely to be much less work to do.) + # targeting only the files we've determined need processing (for an + # initialization this is everything, but for subsequent passes there + # is likely to be much less work to do.) message("Characterizing new or changed bundled third party files...") set(NBINARY_FILES) set(NTEXT_FILES) @@ -669,8 +694,8 @@ if (NOT BRLCAD_DISABLE_RELOCATION) endforeach(lf ${TP_PROCESS}) message("Characterizing new or changed bundled third party files... done.") - # Combine the previous lists and the new determinations, writing - # the final lists back out to files + # Combine the previous lists and the new determinations, writing the + # final lists back out to files set(ALL_BINARY_FILES ${BINARY_FILES} ${NBINARY_FILES}) string(REPLACE ";" "\n" TP_B "${ALL_BINARY_FILES}") file(WRITE "${TP_INVENTORY_BINARIES}" "${TP_B}") @@ -712,18 +737,19 @@ if (NOT BRLCAD_DISABLE_RELOCATION) message("Replacing paths in new 3rd party text files... done.") endif (NTEXT_FILES) - # Tell the build cleanup about all the copied-in files - otherwise it won't - # the distcheck cleaning logic won't know to scrub them. + # Tell the build cleanup about all the copied-in files - otherwise + # it won't the distcheck cleaning logic won't know to scrub them. DISTCLEAN("${TP_FILES}") - # Everything until now has been setting the stage in the build directory. Now - # we set up the install rules. It is for these stages that we need complete - # knowledge of the third party files, since configure re-defines all of these - # rules on every pass. + # Everything until now has been setting the stage in the build + # directory. Now we set up the install rules. It is for these + # stages that we need complete knowledge of the third party files, + # since configure re-defines all of these rules on every pass. foreach(tf ${TP_FILES}) - # Rather than doing the PROGRAMS install for all binary files, we target just - # those in the bin directory - those are the ones we would expect to want - # CMake's *_EXECUTE permissions during install. + # Rather than doing the PROGRAMS install for all binary files, we + # target just those in the bin directory - those are the ones we + # would expect to want CMake's *_EXECUTE permissions during + # install. get_filename_component(dir "${tf}" DIRECTORY) if (NOT dir) message("Error - unexpected toplevel ext file: ${tf} ") @@ -734,8 +760,8 @@ if (NOT BRLCAD_DISABLE_RELOCATION) install(PROGRAMS "${CMAKE_BINARY_DIR}/${tf}" DESTINATION "${dir}") continue() endif ("${tf}" IN_LIST ALL_BINARY_FILES) - # BIN_DIR may contain scripts that aren't explicitly binary files - - # catch those based on path + # BIN_DIR may contain scripts that aren't explicitly binary files + # - catch those based on path if (${dir} MATCHES "${BIN_DIR}$") install(PROGRAMS "${CMAKE_BINARY_DIR}/${tf}" DESTINATION "${dir}") else (${dir} MATCHES "${BIN_DIR}$") @@ -743,12 +769,13 @@ if (NOT BRLCAD_DISABLE_RELOCATION) endif (${dir} MATCHES "${BIN_DIR}$") endforeach(tf ${TP_FILES}) - # When installing, need to fix the RPATH on binary files again, similarly to - # what we did when staging in the build directory. Again we don't process - # symlinks since following them will just result in re-processing the same - # file's RPATH multiple times. This time, in contrast to the build directory - # setup, our goal is to define an RPATH that will allow the binary files to - # work when the install directory is relocated. + # When installing, need to fix the RPATH on binary files again, + # similarly to what we did when staging in the build directory. + # Again we don't process symlinks since following them will just + # result in re-processing the same file's RPATH multiple times. + # This time, in contrast to the build directory setup, our goal is + # to define an RPATH that will allow the binary files to work when + # the install directory is relocated. foreach(bf ${ALL_BINARY_FILES}) if (IS_SYMLINK ${bf}) continue() @@ -762,18 +789,21 @@ if (NOT BRLCAD_DISABLE_RELOCATION) install(CODE "execute_process(COMMAND install_name_tool -delete_rpath \"${CMAKE_BINARY_DIR}/${LIB_DIR}\" \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${bf}\" OUTPUT_VARIABLE OOUT RESULT_VARIABLE ORESULT ERROR_VARIABLE OERROR)") install(CODE "execute_process(COMMAND install_name_tool -add_rpath \"${REL_RPATH}\" \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${bf}\")") endif (P_RPATH_EXECUTABLE) - # Overwrite any stale paths in the binary files with null chars, to make sure - # they're not interfering with the behavior of the final executables. This - # is a little fraught in that there's no guarantee these changes aren't going - # to break something, but given that reliance on invalid full paths was going - # to break something in any case eventually doing this will let us find out - # about it sooner. If the path is just a stale, unused leftover this should - # have no impact on functionality, and otherwise this offers a way to avoid - # "accidental success" where the program is using a build dir file to - # successfully run when we don't want it to see them. + # Overwrite any stale paths in the binary files with null chars, + # to make sure they're not interfering with the behavior of the + # final executables. This is a little fraught in that there's no + # guarantee these changes aren't going to break something, but + # given that reliance on invalid full paths was going to break + # something in any case eventually doing this will let us find out + # about it sooner. If the path is just a stale, unused leftover + # this should have no impact on functionality, and otherwise this + # offers a way to avoid "accidental success" where the program is + # using a build dir file to successfully run when we don't want it + # to see them. install(CODE "execute_process(COMMAND ${STRCLEAR_EXECUTABLE} -v -b -c \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${bf}\" \"${CMAKE_BINARY_DIR}/${LIB_DIR}\")") if (APPLE) - # As with the configure time processing, use codesign at install time to appease OSX: + # As with the configure time processing, use codesign at install + # time to appease OSX: # https://developer.apple.com/documentation/security/updating_mac_software # https://developer.apple.com/documentation/xcode/embedding-nonstandard-code-structures-in-a-bundle # https://stackoverflow.com/questions/71744856/install-name-tool-errors-on-arm64 @@ -781,19 +811,22 @@ if (NOT BRLCAD_DISABLE_RELOCATION) endif (APPLE) endforeach(bf ${ALL_BINARY_FILES}) - # Because ${BRLCAD_EXT_DIR}/install is handled at configure time (and indeed MUST be handled at - # configure time so find_package results will be correct) we make the CMake - # process depend on the ${BRLCAD_EXT_DIR}/install files + # Because ${BRLCAD_EXT_DIR}/install is handled at configure time + # (and indeed MUST be handled at configure time so find_package + # results will be correct) we make the CMake process depend on the + # ${BRLCAD_EXT_DIR}/install files foreach (ef ${TP_FILES}) set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${BRLCAD_EXT_INSTALL_DIR}/${ef}) endforeach (ef ${TP_FILES}) - # Add a extnoinstall touched file to also trigger CMake as above, to help - # ensure a reconfigure whenever the brlcad_externals repository is built. - # There should be a build-stamp file there that should be updated after each - # build run in brlcad_externals, regardless of what happens with other files. + # Add a extnoinstall touched file to also trigger CMake as above, to + # help ensure a reconfigure whenever the brlcad_externals repository + # is built. There should be a build-stamp file there that should be + # updated after each build run in brlcad_externals, regardless of + # what happens with other files. file(GLOB_RECURSE TP_NOINST_FILES LIST_DIRECTORIES false RELATIVE "${BRLCAD_EXT_NOINSTALL_DIR}" "${BRLCAD_EXT_NOINSTALL_DIR}/*") - # For consistency, ignore files that would fall into the STRIP_EXCLUDED set + # For consistency, ignore files that would fall into the + # STRIP_EXCLUDED set foreach(ep ${EXCLUDED_PATTERNS}) list(FILTER TP_NOINST_FILES EXCLUDE REGEX ${ep}) endforeach(ep ${EXCLUDED_PATTERNS}) @@ -804,14 +837,14 @@ if (NOT BRLCAD_DISABLE_RELOCATION) endif (NOT BRLCAD_DISABLE_RELOCATION) ##################################################################### -# We want find_package calls that re-run every time configure is -# run, which means we need to unset cache variables. Most of the -# packages use the BRLCAD_Find_Package wrapper for this, but in a -# few cases it's more complicated. +# We want find_package calls that re-run every time configure is run, +# which means we need to unset cache variables. Most of the packages +# use the BRLCAD_Find_Package wrapper for this, but in a few cases +# it's more complicated. ##################################################################### -# Not all packages will define all of these, but it shouldn't matter - an unset -# of an unused variable shouldn't be harmful +# Not all packages will define all of these, but it shouldn't matter - +# an unset of an unused variable shouldn't be harmful function(find_package_reset pname trigger_var) if (NOT ${trigger_var}) return() @@ -833,9 +866,10 @@ endfunction(find_package_reset pname trigger_var) # zlib compression/decompression library # https://zlib.net # -# Note - our copy is modified from Vanilla upstream to support specifying a -# custom prefix - until a similar feature is available in upstream zlib, we -# need this to reliably avoid conflicts between bundled and system zlib. +# Note - our copy is modified from Vanilla upstream to support +# specifying a custom prefix - until a similar feature is available in +# upstream zlib, we need this to reliably avoid conflicts between +# bundled and system zlib. macro(find_package_zlib) cmake_parse_arguments(F "REQUIRED" "" "" ${ARGN}) @@ -913,8 +947,8 @@ macro(find_package_opencv) endmacro(find_package_opencv) -# TCL - scripting language. For Tcl/Tk builds we want -# static lib building on so we get the stub libraries. +# TCL - scripting language. For Tcl/Tk builds we want static lib +# building on so we get the stub libraries. macro(find_package_tcl) cmake_parse_arguments(F "REQUIRED" "" "" ${ARGN}) @@ -983,16 +1017,16 @@ macro(find_package_qt) find_package(Qt6 COMPONENTS ${QtComponents}) endif (NOT Qt6Widgets_FOUND) if (NOT Qt6Widgets_FOUND) - # We didn't find 6, try 5. For non-standard install locations, you may - # need to set the following CMake variables: + # We didn't find 6, try 5. For non-standard install locations, + # you may need to set the following CMake variables: # # Qt5_DIR=/lib/cmake/Qt5 # QT_QMAKE_EXECUTABLE=/bin/qmake # AUTORCC_EXECUTABLE=/bin/rcc list(REMOVE_ITEM QtComponents OpenGLWidgets) if (F_REQUIRED) - # This is our last attempt - if we're requiring Qt and this fails, - # it's fatal + # This is our last attempt - if we're requiring Qt and this + # fails, it's fatal find_package(Qt5 COMPONENTS ${QtComponents} REQUIRED) else() find_package(Qt5 COMPONENTS ${QtComponents})