Skip to content

Commit

Permalink
🔧 Simplify FixupBundlePostBuild
Browse files Browse the repository at this point in the history
  • Loading branch information
AnotherFoxGuy committed May 2, 2024
1 parent 12858ef commit 098edcb
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 92 deletions.
4 changes: 0 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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")
22 changes: 0 additions & 22 deletions cmake/macros/AddPathsToFixupLibs.cmake

This file was deleted.

49 changes: 11 additions & 38 deletions cmake/macros/PackageLibrariesForDeployment.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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="$<TARGET_FILE:${TARGET_NAME}>"
-DBUNDLE_PLUGIN_DIR="$<TARGET_FILE_DIR:${TARGET_NAME}>/${PLUGIN_PATH}"
-P "${CMAKE_CURRENT_BINARY_DIR}/FixupBundlePostBuild.cmake"
)

if (WIN32)
set(PLUGIN_PATH "plugins")

Expand All @@ -47,27 +31,16 @@ macro(PACKAGE_LIBRARIES_FOR_DEPLOYMENT)
COMMAND "${CMAKE_CURRENT_BINARY_DIR}/windeploy-${TARGET_NAME}.bat" $<$<OR:$<CONFIG:Release>,$<CONFIG:MinSizeRel>,$<CONFIG:RelWithDebInfo>>:--release> \"$<TARGET_FILE:${TARGET_NAME}>\"
)


# TODO: Is this still needed? needs testing
# set(QTAUDIO_PATH "$<TARGET_FILE_DIR:${TARGET_NAME}>/audio")
# set(QTAUDIO_WIN7_PATH "$<TARGET_FILE_DIR:${TARGET_NAME}>/audioWin7/audio")
# set(QTAUDIO_WIN8_PATH "$<TARGET_FILE_DIR:${TARGET_NAME}>/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="$<TARGET_FILE:${TARGET_NAME}>"
-DBUNDLE_PLUGIN_DIR="$<TARGET_FILE_DIR:${TARGET_NAME}>/${PLUGIN_PATH}"
-DLIB_PATHS="${CMAKE_BINARY_DIR}/conanlibs/$<CONFIGURATION>"
-P "${CMAKE_SOURCE_DIR}/cmake/FixupBundlePostBuild.cmake"
)
endmacro()
3 changes: 0 additions & 3 deletions cmake/modules/FindLeapMotion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 0 additions & 1 deletion cmake/modules/FindNSIGHT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand Down
30 changes: 9 additions & 21 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)

0 comments on commit 098edcb

Please sign in to comment.