Skip to content

Commit

Permalink
Only add the CMake installation rules for version of CMake >= 3.3. No…
Browse files Browse the repository at this point in the history
…t compatible with earlier versions.
  • Loading branch information
Tessil committed Oct 20, 2018
1 parent 8a3be75 commit 6a09674
Showing 1 changed file with 41 additions and 39 deletions.
80 changes: 41 additions & 39 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.1)

project(tsl_ordered_map VERSION 0.7.0)
project(tsl_ordered_map VERSION 0.7.1)

add_library(ordered_map INTERFACE)
# Use tsl::ordered_map as target, more consistent with other libraries conventions (Boost, Qt, ...)
Expand All @@ -21,59 +21,61 @@ if(MSVC)
$<INSTALL_INTERFACE:tsl_ordered_map.natvis>)
endif()

# Only compatible with CMake version >= 3.8
if(${CMAKE_VERSION} VERSION_GREATER "3.7")
# Only available since version 3.8
target_compile_features(ordered_map INTERFACE cxx_std_11)
endif()




# Installation
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
# Installation (only compatible with CMake version >= 3.3)
if(${CMAKE_VERSION} VERSION_GREATER "3.2")
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)

## Install include directory and potential natvis file
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/tsl
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
## 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()
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})
## 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})
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_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})
## 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})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
endif()

0 comments on commit 6a09674

Please sign in to comment.