Revision: 77753
          http://sourceforge.net/p/brlcad/code/77753
Author:   starseeker
Date:     2020-11-20 01:22:17 +0000 (Fri, 20 Nov 2020)
Log Message:
-----------
Try an approach suggested by Sean, using the install_name_tool to add the rpath 
when the 3rd party build does not.

Modified Paths:
--------------
    brlcad/branches/extbuild/src/other/ext/CMake/ExternalProject_Target.cmake
    brlcad/branches/extbuild/src/other/ext/tcl.cmake

Removed Paths:
-------------
    brlcad/branches/extbuild/src/other/ext/CMake/tcl_configure.patch

Modified: 
brlcad/branches/extbuild/src/other/ext/CMake/ExternalProject_Target.cmake
===================================================================
--- brlcad/branches/extbuild/src/other/ext/CMake/ExternalProject_Target.cmake   
2020-11-19 17:57:40 UTC (rev 77752)
+++ brlcad/branches/extbuild/src/other/ext/CMake/ExternalProject_Target.cmake   
2020-11-20 01:22:17 UTC (rev 77753)
@@ -24,12 +24,32 @@
 # cmake -E copy follows symlinks to get the final file, which is not what we
 # want in this situation.  To avoid this, we create a copy script which uses
 # file(COPY) and run that script with cmake -P
+# We can't always rely on rpath being present from 3rd party OSX builds, but 
we do need
+# it for CMake and there is a Mac tool that can add it for us - as part of the 
copy
+# process, check if if is set and if not, set it.
 file(WRITE "${CMAKE_BINARY_DIR}/CMakeFiles/cp.cmake" "
+if(\"\${FTYPE}\" STREQUAL \"EXEC\" OR \"\${FTYPE}\" STREQUAL \"SHARED\")
+  if(APPLE)
+    set(CMAKE_BUILD_RPATH \"${CMAKE_BUILD_RPATH}\")
+    execute_process(COMMAND otool -l \"\${SRC}\" RESULT_VARIABLE ORET 
OUTPUT_VARIABLE OTOOL_OUT ERROR_VARIABLE OTOOL_OUT)
+    message(\"\${SRC} OTOOL_OUT: \${OTOOL_OUT}\\n\")
+    if (NOT ORET)
+      if (NOT \"\${OTOOL_OUT}\" MATCHES \".*LC_RPATH.*\")
+       execute_process(COMMAND chmod u+w \"\${SRC}\")
+       execute_process(COMMAND install_name_tool -add_rpath 
\"\${CMAKE_BUILD_RPATH}\" \"\${SRC}\")
+       execute_process(COMMAND otool -l \"\${SRC}\" OUTPUT_VARIABLE OTOOL_OUT2)
+       message(\"OTOOL_OUT2: \${OTOOL_OUT2}\")
+      endif ()
+    endif ()
+  endif()
+endif()
 get_filename_component(DNAME \"\${DEST}\" NAME)
 string(REGEX REPLACE \"\${DNAME}$\" \"\" DDIR \"\${DEST}\")
 file(COPY \"\${SRC}\" DESTINATION \"\${DDIR}\")
 ")
 
+execute_process(COMMAND ${CMAKE_COMMAND} -E cat 
"${CMAKE_BINARY_DIR}/CMakeFiles/cp.cmake")
+
 # When staging files in the build directory, we have to be aware of multiple
 # configurations.  This is done post-ExternalProject build, at the parent build
 # time, so it needs to be a custom command. Until add_custom_command outputs
@@ -37,12 +57,12 @@
 # path.  This is key, because it allows the add_custom_command to be aware that
 # it needs to execute the correct copy command for a current configuration at 
build
 # time.
-function(fcfgcpy outvar extproj root ofile dir tfile)
+function(fcfgcpy ftype outvar extproj root ofile dir tfile)
   string(REPLACE "${CMAKE_BINARY_DIR}/" "" rdir "${dir}")
   if (CMAKE_CONFIGURATION_TYPES)
     add_custom_command(
       OUTPUT "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${rdir}/${tfile}"
-      COMMAND ${CMAKE_COMMAND} -DSRC=${root}/${rdir}/${ofile} 
-DDEST=${CMAKE_BINARY_DIR}/$<CONFIG>/${rdir}/${tfile} -P 
"${CMAKE_BINARY_DIR}/CMakeFiles/cp.cmake"
+      COMMAND ${CMAKE_COMMAND} -DFTYPE=${ftype} -DSRC=${root}/${rdir}/${ofile} 
-DDEST=${CMAKE_BINARY_DIR}/$<CONFIG>/${rdir}/${tfile} -P 
"${CMAKE_BINARY_DIR}/CMakeFiles/cp.cmake"
       DEPENDS ${extproj}
       )
     set(TOUT ${TOUT} 
"${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${rdir}/${tfile}")
@@ -49,7 +69,7 @@
   else (CMAKE_CONFIGURATION_TYPES)
     add_custom_command(
       OUTPUT "${CMAKE_BINARY_DIR}/${rdir}/${tfile}"
-      COMMAND ${CMAKE_COMMAND} -DSRC=${root}/${rdir}/${ofile} 
-DDEST=${CMAKE_BINARY_DIR}/${rdir}/${tfile} -P 
"${CMAKE_BINARY_DIR}/CMakeFiles/cp.cmake"
+      COMMAND ${CMAKE_COMMAND} -DFTYPE=${ftype} -DSRC=${root}/${rdir}/${ofile} 
-DDEST=${CMAKE_BINARY_DIR}/${rdir}/${tfile} -P 
"${CMAKE_BINARY_DIR}/CMakeFiles/cp.cmake"
       DEPENDS ${extproj}
       )
     set(TOUT ${TOUT} "${CMAKE_BINARY_DIR}/${rdir}/${tfile}")
@@ -88,7 +108,7 @@
   foreach (bpf ${E_UNPARSED_ARGUMENTS})
 
     unset(TOUT)
-    fcfgcpy(TOUT ${extproj} ${extroot} ${bpf} "${dir}" ${bpf})
+    fcfgcpy(FILE TOUT ${extproj} ${extroot} ${bpf} "${dir}" ${bpf})
     set(ALL_TOUT ${ALL_TOUT} ${TOUT})
 
     if (NOT E_NOINSTALL)
@@ -250,6 +270,9 @@
   # Note - proper quoting for install(CODE) is extremely important for CPack, 
see
   # https://stackoverflow.com/a/48487133
   install(CODE "
+  message(\"OLD_RPATH: ${CMAKE_BUILD_RPATH}\")
+  message(\"NEW_RPATH: ${NEW_RPATH}\")
+  execute_process(COMMAND otool -l \${CMAKE_INSTALL_PREFIX}/${OFILE})
   file(RPATH_CHANGE
     FILE \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${OFILE}\"
     OLD_RPATH \"${CMAKE_BUILD_RPATH}\"
@@ -333,14 +356,15 @@
       set(SHARED_DIR ${LIB_DIR})
     endif (MSVC)
 
-    fcfgcpy(TOUT ${extproj} ${extroot} ${fname} ${SHARED_DIR} ${fname})
+    fcfgcpy(SHARED TOUT ${extproj} ${extroot} ${fname} ${SHARED_DIR} ${fname})
 
     # On Windows, we need both a .dll and a .lib file to use a shared library 
for compilation
     if (MSVC)
       string(REPLACE "${CMAKE_SHARED_LIBRARY_SUFFIX}" ".lib" IMPLIB_FILE 
"${fname}")
-      fcfgcpy(TOUT ${extproj} ${extroot} ${IMPLIB_FILE} ${LIB_DIR} 
${IMPLIB_FILE})
+      fcfgcpy(FILE TOUT ${extproj} ${extroot} ${IMPLIB_FILE} ${LIB_DIR} 
${IMPLIB_FILE})
     endif (MSVC)
 
+
     # Because we're using LINK_TARGET here rather than fname, we need to take 
any relative
     # directories specified in fname and ppend them to SHARED_DIR. (For other 
cases we are
     # just feeding fname directly, so there are no such concerns.  TODO - 
should we just
@@ -366,7 +390,7 @@
 
       # Add install rules for any symlinks the caller has listed
       foreach(slink ${E_SYMLINKS})
-       fcfgcpy(TOUT ${extproj} ${extroot} ${slink} ${SHARED_DIR} ${slink})
+       fcfgcpy(FILE TOUT ${extproj} ${extroot} ${slink} ${SHARED_DIR} ${slink})
        install(FILES "${CMAKE_BINARY_ROOT}/${SHARED_DIR}/${slink}" DESTINATION 
${SHARED_DIR}/${E_SUBDIR})
       endforeach(slink ${E_SYMLINKS})
 
@@ -379,7 +403,7 @@
 
     add_library(${etarg} STATIC IMPORTED GLOBAL)
 
-    fcfgcpy(TOUT ${extproj} ${extroot} ${fname} ${LIB_DIR} ${fname})
+    fcfgcpy(FILE TOUT ${extproj} ${extroot} ${fname} ${LIB_DIR} ${fname})
 
     ET_target_props(${etarg} "${LIB_DIR}" ${fname} STATIC LINK_TARGET_DEBUG 
"${LINK_TARGET_DEBUG}")
     install(FILES "${CMAKE_BINARY_ROOT}/${LIB_DIR}/${fname}" DESTINATION 
${LIB_DIR}/${E_SUBDIR})
@@ -392,7 +416,7 @@
 
       # Add install rules for any symlinks the caller has listed
       foreach(slink ${E_SYMLINKS})
-       fcfgcpy(TOUT ${extproj} ${extroot} ${slink} ${LIB_DIR} ${slink})
+       fcfgcpy(FILE TOUT ${extproj} ${extroot} ${slink} ${LIB_DIR} ${slink})
        install(FILES "${CMAKE_BINARY_ROOT}/${LIB_DIR}/${slink}" DESTINATION 
${LIB_DIR})
       endforeach(slink ${E_SYMLINKS})
 
@@ -405,7 +429,7 @@
 
     add_executable(${etarg} IMPORTED GLOBAL)
 
-    fcfgcpy(TOUT ${extproj} ${extroot} ${fname} ${BIN_DIR} ${fname})
+    fcfgcpy(EXEC TOUT ${extproj} ${extroot} ${fname} ${BIN_DIR} ${fname})
 
     ET_target_props(${etarg} "${BIN_DIR}" ${fname})
 

Deleted: brlcad/branches/extbuild/src/other/ext/CMake/tcl_configure.patch
===================================================================
--- brlcad/branches/extbuild/src/other/ext/CMake/tcl_configure.patch    
2020-11-19 17:57:40 UTC (rev 77752)
+++ brlcad/branches/extbuild/src/other/ext/CMake/tcl_configure.patch    
2020-11-20 01:22:17 UTC (rev 77753)
@@ -1,13 +0,0 @@
-Index: unix/configure
-===================================================================
---- unix/configure     (revision 77749)
-+++ unix/configure     (working copy)
-@@ -7548,6 +7548,8 @@
-           esac
-           ;;
-       Darwin-*)
-+          CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
-+          LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
-           CFLAGS_OPTIMIZE="-Os"
-           SHLIB_CFLAGS="-fno-common"
-           # To avoid discrepancies between what headers configure sees during

Modified: brlcad/branches/extbuild/src/other/ext/tcl.cmake
===================================================================
--- brlcad/branches/extbuild/src/other/ext/tcl.cmake    2020-11-19 17:57:40 UTC 
(rev 77752)
+++ brlcad/branches/extbuild/src/other/ext/tcl.cmake    2020-11-20 01:22:17 UTC 
(rev 77753)
@@ -75,8 +75,7 @@
     ExternalProject_Add(TCL_BLD
       URL "${CMAKE_CURRENT_SOURCE_DIR}/tcl"
       BUILD_ALWAYS ${EXTERNAL_BUILD_UPDATE} ${LOG_OPTS}
-      PATCH_COMMAND patch "${TCL_SRC_DIR}/unix/configure" 
"${CMAKE_CURRENT_SOURCE_DIR}/CMake/tcl_configure.patch"
-      COMMAND rpath_replace ${TCL_PATCH_FILES}
+      PATCH_COMMAND rpath_replace ${TCL_PATCH_FILES}
       COMMAND tcl_replace ${TCL_REWORK_FILES}
       CONFIGURE_COMMAND CPPFLAGS=-I${CMAKE_BINARY_ROOT}/${INCLUDE_DIR} 
LDFLAGS=-L${CMAKE_BINARY_ROOT}/${LIB_DIR} ${TCL_SRC_DIR}/unix/configure 
--prefix=${TCL_INSTDIR}
       BUILD_COMMAND make -j${pcnt}

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