Implemented dependency collection via CPM.cmake

This commit is contained in:
spectranator
2025-04-12 04:09:50 +02:00
parent 7c17d72b1a
commit 977ed0063a
6 changed files with 1419 additions and 35 deletions

View File

@@ -15,17 +15,21 @@ set(BUILD_SHARED_LIBS OFF)
set_directory_properties(PROPERTIES EXCLUDE_FROM_ALL ON)
# SPIRV Headers
find_package(SPIRV-Headers)
if (NOT TARGET SPIRV-Headers::SPIRV-Headers)
add_subdirectory(SPIRV-Headers)
find_package(SPIRV-Headers)
if (NOT TARGET SPIRV-Headers::SPIRV-Headers)
add_subdirectory(SPIRV-Headers)
endif()
endif()
# fmt (also used by Dynarmic, so needs to be added first)
find_package(fmt)
if (NOT TARGET fmt::fmt)
# fmtlib formatting library
set(FMT_INSTALL ON)
add_subdirectory(fmt)
find_package(fmt)
if (NOT TARGET fmt::fmt)
# fmtlib formatting library
set(FMT_INSTALL ON)
add_subdirectory(fmt)
endif()
endif()
# Xbyak (also used by Dynarmic, so needs to be added first)
@@ -197,8 +201,10 @@ if (NOT TARGET LLVM::Demangle)
add_library(LLVM::Demangle ALIAS demangle)
endif()
add_library(stb stb/stb_dxt.cpp)
target_include_directories(stb PUBLIC ./stb)
if (NOT TARGET stb)
add_library(stb stb/stb_dxt.cpp)
target_include_directories(stb PUBLIC ./stb)
endif()
if (NOT TARGET stb::headers)
add_library(stb::headers ALIAS stb)

View File

@@ -185,7 +185,13 @@ endif()
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
install(TARGETS dynarmic EXPORT dynarmicTargets)
# Hack to get CPM.cmake working with this (should be fine though)
set(BOOST_TARGET )
if (TARGET boost_headers)
set(BOOST_TARGET boost_headers)
endif()
install(TARGETS dynarmic ${BOOST_TARGET} EXPORT dynarmicTargets)
install(EXPORT dynarmicTargets
NAMESPACE dynarmic::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/dynarmic"

View File

@@ -503,11 +503,22 @@ set_target_properties(dynarmic PROPERTIES
target_compile_options(dynarmic PRIVATE ${DYNARMIC_CXX_FLAGS})
target_link_libraries(dynarmic
PRIVATE
Boost::boost
fmt::fmt
merry::mcl
tsl::robin_map
)
if (TARGET boost_headers)
target_link_libraries(dynarmic
PRIVATE
boost_headers
)
else()
target_link_libraries(dynarmic
PRIVATE
Boost::boost
)
endif()
if (DYNARMIC_USE_LLVM)
target_include_directories(dynarmic PRIVATE ${LLVM_INCLUDE_DIRS})
target_compile_definitions(dynarmic PRIVATE DYNARMIC_USE_LLVM=1 ${LLVM_DEFINITIONS})