Skip to content

Commit

Permalink
Merge pull request #323 from mathstuf/install-module-rules
Browse files Browse the repository at this point in the history
Install module rules
  • Loading branch information
hanickadot authored Sep 16, 2024
2 parents f3f5588 + 8c94f42 commit 68629cc
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ if(CTRE_MODULE)
add_library(${PROJECT_NAME})

target_sources(${PROJECT_NAME} PUBLIC FILE_SET CXX_MODULES TYPE CXX_MODULES FILES ctre.cppm)
target_sources(${PROJECT_NAME} PUBLIC FILE_SET HEADERS TYPE HEADERS FILES
target_sources(${PROJECT_NAME} PUBLIC FILE_SET HEADERS TYPE HEADERS
BASE_DIRS
"${CMAKE_CURRENT_SOURCE_DIR}/include"
FILES
include/ctll.hpp
include/ctre/functions.hpp
include/ctre/utility.hpp
Expand Down Expand Up @@ -96,8 +99,11 @@ if(CTRE_MODULE)
set(CTRE_CXX_STANDARD 23)
endif()

target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_${CTRE_CXX_STANDARD})

install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-targets
FILE_SET CXX_MODULES DESTINATION "${CMAKE_INSTALL_LIBDIR}/cxx/${PROJECT_NAME}"
FILE_SET HEADERS DESTINATION "include")
else()
message(FATAL_ERROR "unsupported cmake for c++ modules")
endif()
Expand All @@ -116,12 +122,12 @@ else()
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_SCAN_FOR_MODULES 0)

install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-targets)
install(DIRECTORY include/ DESTINATION include
FILES_MATCHING PATTERN *.hpp)
endif()

add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})

if (NOT CTRE_MODULE)

if (NOT EXISTS "${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake.in")
file(WRITE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake.in [[
@PACKAGE_INIT@
Expand All @@ -132,7 +138,7 @@ endif()
configure_package_config_file(
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake.in"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/${PROJECT_NAME}"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO)

Expand All @@ -141,15 +147,13 @@ write_basic_package_version_file(ctre-config-version.cmake
COMPATIBILITY SameMajorVersion)

install(EXPORT ${PROJECT_NAME}-targets
DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/${PROJECT_NAME}"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
NAMESPACE ${PROJECT_NAME}::)
install(
FILES
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
DESTINATION ${CMAKE_INSTALL_DATADIR}/cmake/${PROJECT_NAME})
install(DIRECTORY include/ DESTINATION include
FILES_MATCHING PATTERN *.hpp)
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})

if(CTRE_BUILD_TESTS)
add_subdirectory(tests)
Expand Down Expand Up @@ -184,11 +188,9 @@ set(CPACK_RPM_PACKAGE_NAME "lib${PROJECT_NAME}-devel")
set(PKG_CONFIG_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/packaging/pkgconfig.pc.in" "${PKG_CONFIG_FILE_NAME}" @ONLY)
install(FILES "${PKG_CONFIG_FILE_NAME}"
DESTINATION "${CMAKE_INSTALL_DATADIR}/pkgconfig"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
)

list(APPEND CPACK_SOURCE_IGNORE_FILES /.git/ /build/ .gitignore .DS_Store)

include(CPack)

endif()

0 comments on commit 68629cc

Please sign in to comment.