cmake: fix static standalone build

This commit is contained in:
Alexandre Bouvier 2023-02-27 09:16:10 +01:00 committed by merry
parent e92f69aca0
commit b3a92ab54d
4 changed files with 26 additions and 30 deletions

View file

@ -141,6 +141,7 @@ endif()
if (DYNARMIC_USE_LLVM) if (DYNARMIC_USE_LLVM)
find_package(LLVM REQUIRED CONFIG) find_package(LLVM REQUIRED CONFIG)
separate_arguments(LLVM_DEFINITIONS)
endif() endif()
if (DYNARMIC_TESTS) if (DYNARMIC_TESTS)

View file

@ -2,31 +2,28 @@
include(CMakeFindDependencyMacro) include(CMakeFindDependencyMacro)
set(ARCHITECTURE @ARCHITECTURE@) set(ARCHITECTURE "@ARCHITECTURE@")
find_dependency(Boost 1.57 REQUIRED) if (NOT @BUILD_SHARED_LIBS@)
if (NOT @CMAKE_DISABLE_FIND_PACKAGE_fmt@) find_dependency(Boost 1.57)
find_dependency(fmt 9 QUIET) find_dependency(fmt 9)
endif() find_dependency(mcl 0.1.12 EXACT)
if (NOT @CMAKE_DISABLE_FIND_PACKAGE_mcl@) find_dependency(tsl-robin-map)
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 ("x86_64" IN_LIST ARCHITECTURE) if ("arm64" IN_LIST ARCHITECTURE)
if (NOT @CMAKE_DISABLE_FIND_PACKAGE_xbyak@) find_dependency(oaknut)
find_dependency(xbyak 6 QUIET)
endif() endif()
if (NOT @CMAKE_DISABLE_FIND_PACKAGE_Zydis@)
find_dependency(Zydis 4 QUIET)
endif()
endif()
if (@DYNARMIC_USE_LLVM@) if ("x86_64" IN_LIST ARCHITECTURE)
find_dependency(LLVM REQUIRED CONFIG) find_dependency(xbyak 6)
find_dependency(Zydis 4)
endif()
if (@DYNARMIC_USE_LLVM@)
find_dependency(LLVM CONFIG)
endif()
endif() endif()
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
check_required_components(@PROJECT_NAME@) check_required_components(@PROJECT_NAME@)

View file

@ -2,6 +2,7 @@
if (BUILD_SHARED_LIBS) if (BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS OFF) set(BUILD_SHARED_LIBS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set_property(DIRECTORY PROPERTY EXCLUDE_FROM_ALL ON)
endif() endif()
# Allow options shadowing with normal variables when subproject use old cmake policy # Allow options shadowing with normal variables when subproject use old cmake policy
@ -27,35 +28,35 @@ endif()
if (NOT TARGET fmt::fmt) if (NOT TARGET fmt::fmt)
# fmtlib formatting library # fmtlib formatting library
set(FMT_INSTALL ON) set(FMT_INSTALL ON)
add_subdirectory(fmt EXCLUDE_FROM_ALL) add_subdirectory(fmt)
endif() endif()
# mcl # mcl
if (NOT TARGET merry::mcl) if (NOT TARGET merry::mcl)
set(MCL_INSTALL ON) set(MCL_INSTALL ON)
add_subdirectory(mcl EXCLUDE_FROM_ALL) add_subdirectory(mcl)
endif() endif()
# oaknut # oaknut
if (NOT TARGET merry::oaknut) if (NOT TARGET merry::oaknut)
if ("arm64" IN_LIST ARCHITECTURE) if ("arm64" IN_LIST ARCHITECTURE)
add_subdirectory(oaknut EXCLUDE_FROM_ALL) add_subdirectory(oaknut)
endif() endif()
endif() endif()
# robin-map # robin-map
if (NOT TARGET tsl::robin_map) if (NOT TARGET tsl::robin_map)
add_subdirectory(robin-map EXCLUDE_FROM_ALL) add_subdirectory(robin-map)
endif() endif()
# xbyak # xbyak
if (NOT TARGET xbyak::xbyak) if (NOT TARGET xbyak::xbyak)
if ("x86_64" IN_LIST ARCHITECTURE) if ("x86_64" IN_LIST ARCHITECTURE)
add_subdirectory(xbyak EXCLUDE_FROM_ALL) add_subdirectory(xbyak)
endif() endif()
endif() endif()
@ -68,7 +69,7 @@ if (NOT TARGET Zydis::Zydis)
set(ZYDIS_BUILD_DOXYGEN OFF) set(ZYDIS_BUILD_DOXYGEN OFF)
set(ZYAN_ZYCORE_PATH "${CMAKE_CURRENT_LIST_DIR}/zycore" CACHE PATH "") set(ZYAN_ZYCORE_PATH "${CMAKE_CURRENT_LIST_DIR}/zycore" CACHE PATH "")
set(CMAKE_DISABLE_FIND_PACKAGE_Doxygen ON) set(CMAKE_DISABLE_FIND_PACKAGE_Doxygen ON)
add_subdirectory(zydis EXCLUDE_FROM_ALL) add_subdirectory(zydis)
add_library(Zydis::Zydis ALIAS Zydis) add_library(Zydis::Zydis ALIAS Zydis)
endif() endif()
endif() endif()

View file

@ -468,10 +468,7 @@ target_link_libraries(dynarmic
if (DYNARMIC_USE_LLVM) if (DYNARMIC_USE_LLVM)
target_include_directories(dynarmic PRIVATE ${LLVM_INCLUDE_DIRS}) target_include_directories(dynarmic PRIVATE ${LLVM_INCLUDE_DIRS})
target_compile_definitions(dynarmic PRIVATE DYNARMIC_USE_LLVM=1 ${LLVM_DEFINITIONS}) target_compile_definitions(dynarmic PRIVATE DYNARMIC_USE_LLVM=1 ${LLVM_DEFINITIONS})
if (BUILD_SHARED_LIBS) llvm_config(dynarmic USE_SHARED armdesc armdisassembler aarch64desc aarch64disassembler x86desc x86disassembler)
set(USE_SHARED "USE_SHARED")
endif()
llvm_config(dynarmic ${USE_SHARED} armdesc armdisassembler aarch64desc aarch64disassembler x86desc x86disassembler)
endif() endif()
if (DYNARMIC_ENABLE_CPU_FEATURE_DETECTION) if (DYNARMIC_ENABLE_CPU_FEATURE_DETECTION)
target_compile_definitions(dynarmic PRIVATE DYNARMIC_ENABLE_CPU_FEATURE_DETECTION=1) target_compile_definitions(dynarmic PRIVATE DYNARMIC_ENABLE_CPU_FEATURE_DETECTION=1)