build(cmake): add install target
This makes dynarmic installable, and also adds a CMake package config file, that allows projects to use `find_package(dynarmic)` to import the library. I know #636 adds the same thing, but while experimenting with the different install options in https://github.com/merryhime/dynarmic/pull/636#discussion_r725656034 I ended up with a working patch, so I'm proposing this as well. This implements solution 2.
This commit is contained in:
parent
cce7e4ee5d
commit
4dcebc1822
4 changed files with 47 additions and 11 deletions
|
@ -171,3 +171,32 @@ add_subdirectory(src/dynarmic)
|
|||
if (DYNARMIC_TESTS)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
#
|
||||
# Install
|
||||
#
|
||||
if (MASTER_PROJECT)
|
||||
include(GNUInstallDirs)
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
install(TARGETS dynarmic EXPORT dynarmicTargets)
|
||||
install(EXPORT dynarmicTargets
|
||||
NAMESPACE dynarmic::
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/dynarmic"
|
||||
)
|
||||
|
||||
configure_package_config_file(CMakeModules/dynarmicConfig.cmake.in
|
||||
dynarmicConfig.cmake
|
||||
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/dynarmic"
|
||||
)
|
||||
write_basic_package_version_file(dynarmicConfigVersion.cmake
|
||||
COMPATIBILITY SameMajorVersion
|
||||
)
|
||||
install(FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/dynarmicConfig.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/dynarmicConfigVersion.cmake"
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/dynarmic"
|
||||
)
|
||||
|
||||
install(DIRECTORY src/dynarmic TYPE INCLUDE FILES_MATCHING PATTERN "*.h")
|
||||
endif()
|
||||
|
|
5
CMakeModules/dynarmicConfig.cmake.in
Normal file
5
CMakeModules/dynarmicConfig.cmake.in
Normal file
|
@ -0,0 +1,5 @@
|
|||
@PACKAGE_INIT@
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
|
||||
|
||||
check_required_components(@PROJECT_NAME@)
|
4
externals/CMakeLists.txt
vendored
4
externals/CMakeLists.txt
vendored
|
@ -24,9 +24,7 @@ target_include_directories(mp INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE
|
|||
# robin-map
|
||||
|
||||
if (NOT TARGET tsl::robin_map)
|
||||
add_library(robin_map INTERFACE)
|
||||
add_library(tsl::robin_map ALIAS robin_map)
|
||||
target_include_directories(robin_map SYSTEM INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/robin-map/include>")
|
||||
add_subdirectory(robin-map)
|
||||
endif()
|
||||
|
||||
# vixl
|
||||
|
|
|
@ -350,7 +350,7 @@ if (ARCHITECTURE STREQUAL "x86_64")
|
|||
endif()
|
||||
elseif (UNIX)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
target_link_libraries(dynarmic PUBLIC rt)
|
||||
target_link_libraries(dynarmic PRIVATE rt)
|
||||
endif()
|
||||
target_sources(dynarmic PRIVATE backend/x64/exception_handler_posix.cpp)
|
||||
else()
|
||||
|
@ -363,20 +363,24 @@ endif()
|
|||
include(CreateDirectoryGroups)
|
||||
create_target_directory_groups(dynarmic)
|
||||
|
||||
target_include_directories(dynarmic PUBLIC ..)
|
||||
target_include_directories(dynarmic PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||
)
|
||||
set_target_properties(dynarmic PROPERTIES
|
||||
VERSION ${dynarmic_VERSION}
|
||||
SOVERSION ${dynarmic_VERSION_MAJOR}
|
||||
)
|
||||
target_compile_options(dynarmic PRIVATE ${DYNARMIC_CXX_FLAGS})
|
||||
# $<BUILD_INTERFACE:> required because of https://gitlab.kitware.com/cmake/cmake/-/issues/15415
|
||||
target_link_libraries(dynarmic
|
||||
PUBLIC
|
||||
boost
|
||||
fmt::fmt
|
||||
mp
|
||||
PRIVATE
|
||||
$<BUILD_INTERFACE:boost>
|
||||
$<BUILD_INTERFACE:fmt::fmt>
|
||||
$<BUILD_INTERFACE:mp>
|
||||
tsl::robin_map
|
||||
xbyak
|
||||
Zydis
|
||||
$<BUILD_INTERFACE:xbyak>
|
||||
$<BUILD_INTERFACE:Zydis>
|
||||
$<$<BOOL:DYNARMIC_USE_LLVM>:${llvm_libs}>
|
||||
)
|
||||
if (DYNARMIC_ENABLE_CPU_FEATURE_DETECTION)
|
||||
|
|
Loading…
Reference in a new issue