Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CMake install prefix when not set at configure time #197

Merged
merged 1 commit into from
Nov 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,13 @@ if (NOT SNITCH_HEADER_ONLY)
target_include_directories(${SNITCH_TARGET_NAME} PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>)
$<INSTALL_INTERFACE:include>)

configure_snitch_exports(${SNITCH_TARGET_NAME})

install(
FILES ${SNITCH_INCLUDES}
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/snitch)
DESTINATION include/snitch)
else()
# Build as a header-only library.
set(SNITCH_TARGET_NAME snitch-header-only)
Expand All @@ -175,15 +175,15 @@ else()
add_dependencies(${SNITCH_TARGET_NAME} snitch-header-only-impl)
target_sources(${SNITCH_TARGET_NAME} INTERFACE
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/snitch/snitch_all.hpp>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/snitch/snitch_all.hpp>)
$<INSTALL_INTERFACE:include/snitch/snitch_all.hpp>)
target_compile_features(${SNITCH_TARGET_NAME} INTERFACE cxx_std_20)
target_include_directories(${SNITCH_TARGET_NAME} INTERFACE
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>)
$<INSTALL_INTERFACE:include>)

install(
FILES ${PROJECT_BINARY_DIR}/snitch/snitch_all.hpp
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/snitch)
DESTINATION include/snitch)
endif()

# Common properties
Expand All @@ -194,21 +194,21 @@ set_target_properties(${SNITCH_TARGET_NAME} PROPERTIES EXPORT_NAME snitch::${SNI
install(TARGETS ${SNITCH_TARGET_NAME} EXPORT ${SNITCH_TARGET_NAME}-targets)

install(EXPORT ${SNITCH_TARGET_NAME}-targets
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cmake/snitch COMPONENT Development)
DESTINATION lib/cmake/snitch COMPONENT Development)

export(EXPORT ${SNITCH_TARGET_NAME}-targets)

include(CMakePackageConfigHelpers)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/snitch-config.cmake.in"
"${PROJECT_BINARY_DIR}/snitch-config.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
INSTALL_DESTINATION lib
NO_CHECK_REQUIRED_COMPONENTS_MACRO
NO_SET_AND_CHECK_MACRO)

install(FILES
"${PROJECT_BINARY_DIR}/snitch-config.cmake"
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cmake/snitch COMPONENT Development)
DESTINATION lib/cmake/snitch COMPONENT Development)

# Setup tests
if (SNITCH_DO_TEST)
Expand Down Expand Up @@ -244,7 +244,7 @@ if (SNITCH_DO_TEST)
add_dependencies(snitch-testlib snitch-header-only-impl)
target_sources(snitch-testlib INTERFACE
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/snitch/snitch_all.hpp>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/snitch/snitch_all.hpp>)
$<INSTALL_INTERFACE:include/snitch/snitch_all.hpp>)

target_compile_features(snitch-testlib INTERFACE cxx_std_20)
target_include_directories(snitch-testlib INTERFACE ${PROJECT_BINARY_DIR})
Expand Down