From 098edcbae769f9ebe4cbc87acfbdf4d4d8a62732 Mon Sep 17 00:00:00 2001 From: Edgar Date: Tue, 27 Feb 2024 16:31:52 +0100 Subject: [PATCH] :wrench: Simplify FixupBundlePostBuild --- CMakeLists.txt | 4 -- ...ld.cmake.in => FixupBundlePostBuild.cmake} | 6 +-- cmake/macros/AddPathsToFixupLibs.cmake | 22 --------- .../PackageLibrariesForDeployment.cmake | 49 +++++-------------- cmake/modules/FindLeapMotion.cmake | 3 -- cmake/modules/FindNSIGHT.cmake | 1 - conanfile.py | 30 ++++-------- 7 files changed, 23 insertions(+), 92 deletions(-) rename cmake/{templates/FixupBundlePostBuild.cmake.in => FixupBundlePostBuild.cmake} (73%) delete mode 100644 cmake/macros/AddPathsToFixupLibs.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index dbdd527e51d..2826764f407 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -160,10 +160,6 @@ project(overte) include("cmake/init.cmake") include("cmake/compiler.cmake") -include(${CMAKE_BINARY_DIR}/cmake/ConanBinDirs.cmake) - -add_paths_to_fixup_libs(${CONAN_BIN_DIRS}) - if (NOT DEFINED CLIENT_ONLY) set(CLIENT_ONLY 0) endif() diff --git a/cmake/templates/FixupBundlePostBuild.cmake.in b/cmake/FixupBundlePostBuild.cmake similarity index 73% rename from cmake/templates/FixupBundlePostBuild.cmake.in rename to cmake/FixupBundlePostBuild.cmake index 762945c5cc1..35188cb1ae4 100644 --- a/cmake/templates/FixupBundlePostBuild.cmake.in +++ b/cmake/FixupBundlePostBuild.cmake @@ -1,6 +1,6 @@ # -# FixupBundlePostBuild.cmake.in -# cmake/templates +# FixupBundlePostBuild.cmake +# cmake # # Copyright 2015 High Fidelity, Inc. # Created by Stephen Birarda on February 13, 2014 @@ -20,4 +20,4 @@ else() endif() file(GLOB EXTRA_PLUGINS "${BUNDLE_PLUGIN_DIR}/*.${PLUGIN_EXTENSION}") -fixup_bundle("${BUNDLE_EXECUTABLE}" "${EXTRA_PLUGINS}" "@FIXUP_LIBS@" IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe") +fixup_bundle("${BUNDLE_EXECUTABLE}" "${EXTRA_PLUGINS}" "${LIB_PATHS}" IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe") diff --git a/cmake/macros/AddPathsToFixupLibs.cmake b/cmake/macros/AddPathsToFixupLibs.cmake deleted file mode 100644 index 913fcb7ee75..00000000000 --- a/cmake/macros/AddPathsToFixupLibs.cmake +++ /dev/null @@ -1,22 +0,0 @@ -# -# AddPathsToFixupLibs.cmake -# cmake/macros -# -# Copyright 2015 High Fidelity, Inc. -# Created by Stephen Birarda on February 17, 2014 -# -# Distributed under the Apache License, Version 2.0. -# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -# - -macro(add_paths_to_fixup_libs) - foreach(_PATH ${ARGN}) - set(_TEMP_LIB_PATHS ${FIXUP_LIBS}) - - list(APPEND _TEMP_LIB_PATHS ${_PATH}) - - list(REMOVE_DUPLICATES _TEMP_LIB_PATHS) - - set(FIXUP_LIBS ${_TEMP_LIB_PATHS} CACHE STRING "Paths for external libraries passed to fixup_bundle" FORCE) - endforeach() -endmacro() \ No newline at end of file diff --git a/cmake/macros/PackageLibrariesForDeployment.cmake b/cmake/macros/PackageLibrariesForDeployment.cmake index 74815b242ac..1cc56bb883e 100644 --- a/cmake/macros/PackageLibrariesForDeployment.cmake +++ b/cmake/macros/PackageLibrariesForDeployment.cmake @@ -10,22 +10,6 @@ # macro(PACKAGE_LIBRARIES_FOR_DEPLOYMENT) - configure_file( - ${HF_CMAKE_DIR}/templates/FixupBundlePostBuild.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/FixupBundlePostBuild.cmake - @ONLY - ) - - # add a post-build command to copy the librarys beside the executable - add_custom_command( - TARGET ${TARGET_NAME} - POST_BUILD - COMMAND ${CMAKE_COMMAND} - -DBUNDLE_EXECUTABLE="$" - -DBUNDLE_PLUGIN_DIR="$/${PLUGIN_PATH}" - -P "${CMAKE_CURRENT_BINARY_DIR}/FixupBundlePostBuild.cmake" - ) - if (WIN32) set(PLUGIN_PATH "plugins") @@ -47,27 +31,16 @@ macro(PACKAGE_LIBRARIES_FOR_DEPLOYMENT) COMMAND "${CMAKE_CURRENT_BINARY_DIR}/windeploy-${TARGET_NAME}.bat" $<$,$,$>:--release> \"$\" ) - - # TODO: Is this still needed? needs testing - # set(QTAUDIO_PATH "$/audio") - # set(QTAUDIO_WIN7_PATH "$/audioWin7/audio") - # set(QTAUDIO_WIN8_PATH "$/audioWin8/audio") - - # # copy qtaudio_wasapi.dll and qtaudio_windows.dll in the correct directories for runtime selection - # add_custom_command( - # TARGET ${TARGET_NAME} - # POST_BUILD - # COMMAND ${CMAKE_COMMAND} -E make_directory "${QTAUDIO_WIN7_PATH}" - # COMMAND ${CMAKE_COMMAND} -E make_directory "${QTAUDIO_WIN8_PATH}" - # # copy release DLLs - # COMMAND if exist "${QTAUDIO_PATH}/qtaudio_windows.dll" ( ${CMAKE_COMMAND} -E copy "${QTAUDIO_PATH}/qtaudio_windows.dll" "${QTAUDIO_WIN7_PATH}" ) - # COMMAND if exist "${QTAUDIO_PATH}/qtaudio_windows.dll" ( ${CMAKE_COMMAND} -E copy "${WASAPI_DLL_PATH}/qtaudio_wasapi.dll" "${QTAUDIO_WIN8_PATH}" ) - # # copy debug DLLs - # COMMAND if exist "${QTAUDIO_PATH}/qtaudio_windowsd.dll" ( ${CMAKE_COMMAND} -E copy "${QTAUDIO_PATH}/qtaudio_windowsd.dll" "${QTAUDIO_WIN7_PATH}" ) - # COMMAND if exist "${QTAUDIO_PATH}/qtaudio_windowsd.dll" ( ${CMAKE_COMMAND} -E copy "${WASAPI_DLL_PATH}/qtaudio_wasapid.dll" "${QTAUDIO_WIN8_PATH}" ) - # # remove directory - # COMMAND ${CMAKE_COMMAND} -E remove_directory "${QTAUDIO_PATH}" - # ) - endif () + + # Add a post-build command to copy the libraries beside the executable + add_custom_command( + TARGET ${TARGET_NAME} + POST_BUILD + COMMAND ${CMAKE_COMMAND} + -DBUNDLE_EXECUTABLE="$" + -DBUNDLE_PLUGIN_DIR="$/${PLUGIN_PATH}" + -DLIB_PATHS="${CMAKE_BINARY_DIR}/conanlibs/$" + -P "${CMAKE_SOURCE_DIR}/cmake/FixupBundlePostBuild.cmake" + ) endmacro() diff --git a/cmake/modules/FindLeapMotion.cmake b/cmake/modules/FindLeapMotion.cmake index b5d6fe1b698..35f4ab7305f 100644 --- a/cmake/modules/FindLeapMotion.cmake +++ b/cmake/modules/FindLeapMotion.cmake @@ -45,8 +45,5 @@ endif () include(FindPackageHandleStandardArgs) find_package_handle_standard_args(LeapMotion DEFAULT_MSG ${LEAPMOTION_REQUIREMENTS}) -if (WIN32) - add_paths_to_fixup_libs(${LEAPMOTION_DLL_PATH}) -endif () mark_as_advanced(LEAPMOTION_INCLUDE_DIRS LEAPMOTION_LIBRARIES LEAPMOTION_SEARCH_DIRS) diff --git a/cmake/modules/FindNSIGHT.cmake b/cmake/modules/FindNSIGHT.cmake index 243c337adbc..8e7f18ba83a 100644 --- a/cmake/modules/FindNSIGHT.cmake +++ b/cmake/modules/FindNSIGHT.cmake @@ -45,7 +45,6 @@ if (WIN32) PATHS "C:/Program Files/NVIDIA Corporation/NvToolsExt") - add_paths_to_fixup_libs("C:/Program Files/NVIDIA Corporation/NvToolsExt/bin/${ARCH_DIR}") include(SelectLibraryConfigurations) select_library_configurations(NSIGHT) endif () diff --git a/conanfile.py b/conanfile.py index e34f2888ee9..da0783fd583 100644 --- a/conanfile.py +++ b/conanfile.py @@ -93,28 +93,11 @@ def generate(self): deps.configuration = "RelWithDebInfo" deps.generate() - bindirs = [] for dep in self.dependencies.values(): - bindirs += dep.cpp_info.bindirs - - if self.settings.os == "Linux": - for dep in self.dependencies.values(): - bindirs += dep.cpp_info.libdirs - - bindirs_win = [] - for dir in bindirs: - bindirs_win.append(os.path.join(dir, f"{self.settings.build_type}")) - - conan_data = 'set(CONAN_BIN_DIRS "%s;%s")\n' % ( - ";".join(bindirs).replace("\\", "/"), - ";".join(bindirs_win).replace("\\", "/"), - ) - - save( - self, - os.path.join(self.build_folder, "cmake", "ConanBinDirs.cmake"), - conan_data, - ) + for f in dep.cpp_info.bindirs: + self.cp_libs(f) + for f in dep.cpp_info.libdirs: + self.cp_libs(f) toolspath = """ set(GLSLANG_DIR "%s") @@ -136,3 +119,8 @@ def generate(self): os.path.join(self.build_folder, "cmake", "ConanToolsDirs.cmake"), toolspath, ) + + def cp_libs(self, src): + bindir = os.path.join(self.build_folder, "conanlibs", f"{self.settings.build_type}") + copy(self, "*.dll", src, bindir, False) + copy(self, "*.so*", src, bindir, False) \ No newline at end of file