From 48ce0b366ab5c0c4c79981e64ecc25567233ff72 Mon Sep 17 00:00:00 2001 From: synacker Date: Sun, 29 Sep 2024 20:58:47 +0300 Subject: [PATCH] Fixed dependency pack --- src/Daggy/CMakeLists.txt | 1 + src/DaggyCore/CMakeLists.txt | 2 +- src/DaggyCore/tests/local/CMakeLists.txt | 2 - src/cmake/compiler.cmake | 9 ++- src/cmake/package_deps.cmake | 72 +++++------------------- src/cmake/rpath_bin.cmake | 4 +- src/cmake/rpath_lib.cmake | 4 +- 7 files changed, 27 insertions(+), 67 deletions(-) diff --git a/src/Daggy/CMakeLists.txt b/src/Daggy/CMakeLists.txt index 4f81a0bf..c5087487 100644 --- a/src/Daggy/CMakeLists.txt +++ b/src/Daggy/CMakeLists.txt @@ -50,3 +50,4 @@ target_link_libraries(${TARGET} PRIVATE ${LINK_LIBRARIES}) target_precompile_headers(${TARGET} PRIVATE Precompiled.hpp) install(TARGETS ${TARGET} RUNTIME) +include(package_deps) diff --git a/src/DaggyCore/CMakeLists.txt b/src/DaggyCore/CMakeLists.txt index bd02ae24..24110238 100644 --- a/src/DaggyCore/CMakeLists.txt +++ b/src/DaggyCore/CMakeLists.txt @@ -2,7 +2,6 @@ set(TARGET DaggyCore) find_package(Qt6 COMPONENTS Core Network REQUIRED) add_library(${TARGET}) - include(rpath_lib) set_target_properties(${TARGET} PROPERTIES AUTOMOC ON) @@ -115,3 +114,4 @@ else() endif() install(TARGETS ${TARGET} FILE_SET HEADERS) +include(package_deps) diff --git a/src/DaggyCore/tests/local/CMakeLists.txt b/src/DaggyCore/tests/local/CMakeLists.txt index 3863e34b..6a744aca 100644 --- a/src/DaggyCore/tests/local/CMakeLists.txt +++ b/src/DaggyCore/tests/local/CMakeLists.txt @@ -12,8 +12,6 @@ set(SOURCES main.cpp ) - - qt6_add_executable(${TARGET} ${SOURCES}) include(rpath_bin) add_test(NAME ${TARGET} COMMAND ${TARGET} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}) diff --git a/src/cmake/compiler.cmake b/src/cmake/compiler.cmake index f6b4f2d5..ef6a1ab3 100644 --- a/src/cmake/compiler.cmake +++ b/src/cmake/compiler.cmake @@ -17,8 +17,12 @@ else() set(POSITION_INDEPENDENT_CODE OFF) endif() -make_directory(${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) -make_directory(${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) + + +make_directory(${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) +make_directory(${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) @@ -40,4 +44,3 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) - diff --git a/src/cmake/package_deps.cmake b/src/cmake/package_deps.cmake index b4e790da..2022cd7e 100644 --- a/src/cmake/package_deps.cmake +++ b/src/cmake/package_deps.cmake @@ -1,59 +1,17 @@ -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) -if(UNIX AND NOT APPLE) - install(DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/daggy/ - DESTINATION ${CMAKE_INSTALL_LIBDIR}/daggy/ - FILES_MATCHING - PATTERN libQt6Network.so* - PATTERN libQt6Core.so* - PATTERN libssh2.so* - PATTERN libyaml-cpp.so* - PATTERN libcrypto*.so* - ) -elseif(APPLE) - install(DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/daggy/ - DESTINATION ${CMAKE_INSTALL_LIBDIR}/daggy/ - FILES_MATCHING - PATTERN libQt6Network*dylib - PATTERN libQt6Core*dylib - PATTERN libssh2*dylib - PATTERN libyaml-cpp*dylib - PATTERN libcrypto*dylib - ) -else() - install(TARGETS DaggyCore - DESTINATION ${CMAKE_INSTALL_BINDIR} - RUNTIME_DEPENDENCY_SET daggy_core_deps - ) +if (PACKAGE_DEPS) + install(TARGETS ${TARGET} + RUNTIME_DEPENDENCY_SET ${TARGET}_deps + ) - install(RUNTIME_DEPENDENCY_SET daggy_core_deps - PRE_EXCLUDE_REGEXES - [[api-ms-win-.*]] - [[ext-ms-.*]] - [[kernel32\.dll]] - POST_EXCLUDE_REGEXES - [[.*(\\|/)system32(\\|/).*\.dll]] - DIRECTORIES ${CONAN_RUNTIME_LIB_DIRS} ${CONAN_LIB_DIRS} - ) - - if (CONSOLE) - install(TARGETS daggy - DESTINATION ${CMAKE_INSTALL_BINDIR} - RUNTIME_DEPENDENCY_SET daggy_deps - ) - - install(RUNTIME_DEPENDENCY_SET daggy_deps - PRE_EXCLUDE_REGEXES - [[api-ms-win-.*]] - [[ext-ms-.*]] - [[kernel32\.dll]] - POST_EXCLUDE_REGEXES - [[.*(\\|/)system32(\\|/).*\.dll]] - DIRECTORIES ${CONAN_RUNTIME_LIB_DIRS} ${CONAN_LIB_DIRS} - ) - - install(FILES - ${CMAKE_CURRENT_LIST_DIR}/daggyenv.bat - DESTINATION ${CMAKE_INSTALL_BINDIR}) - endif() + install(RUNTIME_DEPENDENCY_SET ${TARGET}_deps + PRE_EXCLUDE_REGEXES + [=[api-ms-]=] + [=[ext-ms-]=] + [[kernel32\.dll]] + [[libc\.so\..*]] [[libgcc_s\.so\..*]] [[libm\.so\..*]] [[libstdc\+\+\.so\..*]] + POST_EXCLUDE_REGEXES + [=[.*system32\/.*\.dll]=] + [=[^\/(lib|usr\/lib|usr\/local\/lib\/lib64)]=] + DIRECTORIES ${CONAN_RUNTIME_LIB_DIRS} ${CONAN_LIB_DIRS} + ) endif() diff --git a/src/cmake/rpath_bin.cmake b/src/cmake/rpath_bin.cmake index 598c2dde..8e5f1e55 100644 --- a/src/cmake/rpath_bin.cmake +++ b/src/cmake/rpath_bin.cmake @@ -1,7 +1,7 @@ if(CONAN_BUILD) if(APPLE) - set_target_properties(${TARGET} PROPERTIES INSTALL_RPATH "@executable_path/../${CMAKE_INSTALL_LIBDIR};@executable_path/../${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}") + set_target_properties(${TARGET} PROPERTIES INSTALL_RPATH "@executable_path/../${CMAKE_INSTALL_LIBDIR}") elseif(UNIX) - set_target_properties(${TARGET} PROPERTIES INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}:$ORIGIN/../${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}") + set_target_properties(${TARGET} PROPERTIES INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}") endif() endif() diff --git a/src/cmake/rpath_lib.cmake b/src/cmake/rpath_lib.cmake index 0a04943e..97a1b082 100644 --- a/src/cmake/rpath_lib.cmake +++ b/src/cmake/rpath_lib.cmake @@ -1,7 +1,7 @@ if(CONAN_BUILD) if(APPLE) - set_target_properties(${TARGET} PROPERTIES INSTALL_RPATH "@loader_path/${PROJECT_NAME}") + set_target_properties(${TARGET} PROPERTIES INSTALL_RPATH "@loader_path") elseif(UNIX) - set_target_properties(${TARGET} PROPERTIES INSTALL_RPATH "$ORIGIN/${PROJECT_NAME}") + set_target_properties(${TARGET} PROPERTIES INSTALL_RPATH "$ORIGIN") endif() endif()