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

cmake: add "cmake" directory to install #15

Merged
merged 2 commits into from
Aug 9, 2023
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
22 changes: 14 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

cmake_minimum_required( VERSION 3.15 )
# 3.1 target_compile_features
# 3.8 target_compile_features( cxx_std_11 )
# 3.8 target_compile_features( cxx_std_17 )
# 3.14 install( LIBRARY DESTINATION lib ) default
# 3.15 $<$COMPILE_LANG_AND_ID # optional
# 3.15 message DEBUG
Expand Down Expand Up @@ -147,31 +147,37 @@ if (testsweeper_is_project)
endif()

#-------------------------------------------------------------------------------
# Install rules.
# When TestSweeper is used as a sub-project,
# the parent (e.g., BLAS++) may not want to install it.
if (testsweeper_install)
# GNU Filesystem Conventions
include( GNUInstallDirs )
set( INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/testsweeper )
if (WIN32)
set( install_configdir "testsweeper" )
else()
set( install_configdir "${CMAKE_INSTALL_LIBDIR}/cmake/testsweeper" )
endif()

# Install library and add to <package>Targets.cmake
install(
TARGETS testsweeper
EXPORT testsweeperTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} # no default before 3.14
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
)

# Install header files
install(
FILES "testsweeper.hh"
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)

# Install <package>Targets.cmake
install(
EXPORT testsweeperTargets
DESTINATION ${INSTALL_CONFIGDIR}
DESTINATION "${install_configdir}"
)

# Also export <package>Targets.cmake in build directory
Expand All @@ -186,7 +192,7 @@ if (testsweeper_install)
configure_package_config_file(
"testsweeperConfig.cmake.in"
"testsweeperConfig.cmake"
INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
INSTALL_DESTINATION "${install_configdir}"
)
write_basic_package_version_file(
"testsweeperConfigVersion.cmake"
Expand All @@ -196,6 +202,6 @@ if (testsweeper_install)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/testsweeperConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/testsweeperConfigVersion.cmake"
DESTINATION ${INSTALL_CONFIGDIR}
DESTINATION "${install_configdir}"
)
endif()