-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add installation rules in the CMake of the project (#22)
- Loading branch information
1 parent
789292a
commit 8a3be75
Showing
3 changed files
with
78 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,79 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
|
||
project(tsl_ordered_map) | ||
project(tsl_ordered_map VERSION 0.7.0) | ||
|
||
add_library(tsl_ordered_map INTERFACE) | ||
add_library(ordered_map INTERFACE) | ||
# Use tsl::ordered_map as target, more consistent with other libraries conventions (Boost, Qt, ...) | ||
add_library(tsl::ordered_map ALIAS tsl_ordered_map) | ||
add_library(tsl::ordered_map ALIAS ordered_map) | ||
|
||
target_include_directories(tsl_ordered_map INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include") | ||
target_sources(tsl_ordered_map INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include/tsl/ordered_hash.h" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/include/tsl/ordered_map.h" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/include/tsl/ordered_set.h") | ||
target_include_directories(ordered_map INTERFACE | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:include>) | ||
|
||
target_sources(ordered_map INTERFACE | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/tsl/ordered_hash.h | ||
${CMAKE_CURRENT_SOURCE_DIR}/include/tsl/ordered_map.h | ||
${CMAKE_CURRENT_SOURCE_DIR}/include/tsl/ordered_set.h>) | ||
|
||
if(MSVC) | ||
target_sources(tsl_ordered_map INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/tsl_ordered_map.natvis") | ||
target_sources(ordered_map INTERFACE | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/tsl_ordered_map.natvis> | ||
$<INSTALL_INTERFACE:tsl_ordered_map.natvis>) | ||
endif() | ||
|
||
if(${CMAKE_VERSION} VERSION_GREATER "3.7") | ||
# Only available since version 3.8 | ||
target_compile_features(tsl_ordered_map INTERFACE cxx_std_11) | ||
target_compile_features(ordered_map INTERFACE cxx_std_11) | ||
endif() | ||
|
||
|
||
|
||
|
||
# Installation | ||
include(CMakePackageConfigHelpers) | ||
include(GNUInstallDirs) | ||
|
||
## Install include directory and potential natvis file | ||
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/tsl | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
|
||
if(MSVC) | ||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/tsl_ordered_map.natvis | ||
DESTINATION ".") | ||
endif() | ||
|
||
|
||
|
||
## Create and install tsl_ordered_mapConfig.cmake | ||
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake.in | ||
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake | ||
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) | ||
|
||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) | ||
|
||
|
||
|
||
## Create and install tsl_ordered_mapTargets.cmake | ||
install(TARGETS ordered_map | ||
EXPORT ${PROJECT_NAME}Targets) | ||
|
||
install(EXPORT ${PROJECT_NAME}Targets | ||
NAMESPACE tsl:: | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) | ||
|
||
|
||
|
||
## Create and install tsl_ordered_mapConfigVersion.cmake | ||
# ordered_map is header-only and does not depend on the architecture. | ||
# Remove CMAKE_SIZEOF_VOID_P from tsl_ordered_mapConfigVersion.cmake so that an | ||
# tsl_ordered_mapConfig.cmake generated for a 64 bit target can be used for 32 bit | ||
# targets and vice versa. | ||
set(TSL_ORDERED_MAP_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P}) | ||
unset(CMAKE_SIZEOF_VOID_P) | ||
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake | ||
COMPATIBILITY SameMajorVersion) | ||
set(CMAKE_SIZEOF_VOID_P ${TSL_ORDERED_MAP_CMAKE_SIZEOF_VOID_P}) | ||
|
||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# This module sets the following variables: | ||
# * tsl_ordered_map_FOUND - true if tsl_ordered_map found on the system | ||
# * tsl_ordered_map_INCLUDE_DIRS - the directory containing tsl_ordered_map headers | ||
@PACKAGE_INIT@ | ||
|
||
if(NOT TARGET tsl::ordered_map) | ||
include("${CMAKE_CURRENT_LIST_DIR}/tsl_ordered_mapTargets.cmake") | ||
get_target_property(tsl_ordered_map_INCLUDE_DIRS tsl::ordered_map INTERFACE_INCLUDE_DIRECTORIES) | ||
endif() |