From b3a92ab54dadd26a0c2a87d2677b80249d2e1a5a Mon Sep 17 00:00:00 2001 From: Alexandre Bouvier Date: Mon, 27 Feb 2023 09:16:10 +0100 Subject: [PATCH] cmake: fix static standalone build --- CMakeLists.txt | 1 + CMakeModules/dynarmicConfig.cmake.in | 37 +++++++++++++--------------- externals/CMakeLists.txt | 13 +++++----- src/dynarmic/CMakeLists.txt | 5 +--- 4 files changed, 26 insertions(+), 30 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e549801..07f32119 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,6 +141,7 @@ endif() if (DYNARMIC_USE_LLVM) find_package(LLVM REQUIRED CONFIG) + separate_arguments(LLVM_DEFINITIONS) endif() if (DYNARMIC_TESTS) diff --git a/CMakeModules/dynarmicConfig.cmake.in b/CMakeModules/dynarmicConfig.cmake.in index ced1210b..fdd7017e 100644 --- a/CMakeModules/dynarmicConfig.cmake.in +++ b/CMakeModules/dynarmicConfig.cmake.in @@ -2,31 +2,28 @@ include(CMakeFindDependencyMacro) -set(ARCHITECTURE @ARCHITECTURE@) +set(ARCHITECTURE "@ARCHITECTURE@") -find_dependency(Boost 1.57 REQUIRED) -if (NOT @CMAKE_DISABLE_FIND_PACKAGE_fmt@) - find_dependency(fmt 9 QUIET) -endif() -if (NOT @CMAKE_DISABLE_FIND_PACKAGE_mcl@) - find_dependency(mcl 0.1.12 EXACT QUIET) -endif() -if (NOT @CMAKE_DISABLE_FIND_PACKAGE_tsl-robin-map@) - find_dependency(tsl-robin-map QUIET) -endif() +if (NOT @BUILD_SHARED_LIBS@) + find_dependency(Boost 1.57) + find_dependency(fmt 9) + find_dependency(mcl 0.1.12 EXACT) + find_dependency(tsl-robin-map) -if ("x86_64" IN_LIST ARCHITECTURE) - if (NOT @CMAKE_DISABLE_FIND_PACKAGE_xbyak@) - find_dependency(xbyak 6 QUIET) + if ("arm64" IN_LIST ARCHITECTURE) + find_dependency(oaknut) endif() - if (NOT @CMAKE_DISABLE_FIND_PACKAGE_Zydis@) - find_dependency(Zydis 4 QUIET) - endif() -endif() -if (@DYNARMIC_USE_LLVM@) - find_dependency(LLVM REQUIRED CONFIG) + if ("x86_64" IN_LIST ARCHITECTURE) + find_dependency(xbyak 6) + find_dependency(Zydis 4) + endif() + + if (@DYNARMIC_USE_LLVM@) + find_dependency(LLVM CONFIG) + endif() endif() include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") + check_required_components(@PROJECT_NAME@) diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index c42cb6eb..ab3d24e6 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -2,6 +2,7 @@ if (BUILD_SHARED_LIBS) set(BUILD_SHARED_LIBS OFF) set(CMAKE_POSITION_INDEPENDENT_CODE ON) + set_property(DIRECTORY PROPERTY EXCLUDE_FROM_ALL ON) endif() # Allow options shadowing with normal variables when subproject use old cmake policy @@ -27,35 +28,35 @@ endif() if (NOT TARGET fmt::fmt) # fmtlib formatting library set(FMT_INSTALL ON) - add_subdirectory(fmt EXCLUDE_FROM_ALL) + add_subdirectory(fmt) endif() # mcl if (NOT TARGET merry::mcl) set(MCL_INSTALL ON) - add_subdirectory(mcl EXCLUDE_FROM_ALL) + add_subdirectory(mcl) endif() # oaknut if (NOT TARGET merry::oaknut) if ("arm64" IN_LIST ARCHITECTURE) - add_subdirectory(oaknut EXCLUDE_FROM_ALL) + add_subdirectory(oaknut) endif() endif() # robin-map if (NOT TARGET tsl::robin_map) - add_subdirectory(robin-map EXCLUDE_FROM_ALL) + add_subdirectory(robin-map) endif() # xbyak if (NOT TARGET xbyak::xbyak) if ("x86_64" IN_LIST ARCHITECTURE) - add_subdirectory(xbyak EXCLUDE_FROM_ALL) + add_subdirectory(xbyak) endif() endif() @@ -68,7 +69,7 @@ if (NOT TARGET Zydis::Zydis) set(ZYDIS_BUILD_DOXYGEN OFF) set(ZYAN_ZYCORE_PATH "${CMAKE_CURRENT_LIST_DIR}/zycore" CACHE PATH "") set(CMAKE_DISABLE_FIND_PACKAGE_Doxygen ON) - add_subdirectory(zydis EXCLUDE_FROM_ALL) + add_subdirectory(zydis) add_library(Zydis::Zydis ALIAS Zydis) endif() endif() diff --git a/src/dynarmic/CMakeLists.txt b/src/dynarmic/CMakeLists.txt index 36a12cc0..3f2f60ed 100644 --- a/src/dynarmic/CMakeLists.txt +++ b/src/dynarmic/CMakeLists.txt @@ -468,10 +468,7 @@ target_link_libraries(dynarmic if (DYNARMIC_USE_LLVM) target_include_directories(dynarmic PRIVATE ${LLVM_INCLUDE_DIRS}) target_compile_definitions(dynarmic PRIVATE DYNARMIC_USE_LLVM=1 ${LLVM_DEFINITIONS}) - if (BUILD_SHARED_LIBS) - set(USE_SHARED "USE_SHARED") - endif() - llvm_config(dynarmic ${USE_SHARED} armdesc armdisassembler aarch64desc aarch64disassembler x86desc x86disassembler) + llvm_config(dynarmic USE_SHARED armdesc armdisassembler aarch64desc aarch64disassembler x86desc x86disassembler) endif() if (DYNARMIC_ENABLE_CPU_FEATURE_DETECTION) target_compile_definitions(dynarmic PRIVATE DYNARMIC_ENABLE_CPU_FEATURE_DETECTION=1)