Rename CMake project name from tsl_robin_map to tsl-robin-map for coherence with the convention used by most package managers.

This commit is contained in:
Tessil 2019-01-26 13:22:23 +01:00
parent 6edac20535
commit ab349ee88b
5 changed files with 42 additions and 44 deletions

View File

@ -1,6 +1,8 @@
cmake_minimum_required(VERSION 3.1)
include(GNUInstallDirs)
project(tsl_robin_map VERSION 0.5.0)
project(tsl-robin-map VERSION 0.5.0)
add_library(robin_map INTERFACE)
# Use tsl::robin_map as target, more consistent with other libraries conventions (Boost, Qt, ...)
@ -8,7 +10,7 @@ add_library(tsl::robin_map ALIAS robin_map)
target_include_directories(robin_map INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
list(APPEND headers "${CMAKE_CURRENT_SOURCE_DIR}/include/tsl/robin_growth_policy.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/tsl/robin_hash.h"
@ -19,12 +21,7 @@ target_sources(robin_map INTERFACE "$<BUILD_INTERFACE:${headers}>")
if(MSVC)
target_sources(robin_map INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/tsl-robin-map.natvis>"
"$<INSTALL_INTERFACE:tsl-robin-map.natvis>")
endif()
# Only compatible with CMake version >= 3.8
if(${CMAKE_VERSION} VERSION_GREATER "3.7")
target_compile_features(robin_map INTERFACE cxx_std_11)
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_DATAROOTDIR}/tsl-robin-map.natvis>")
endif()
@ -33,7 +30,6 @@ endif()
# 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"
@ -41,42 +37,42 @@ if(${CMAKE_VERSION} VERSION_GREATER "3.2")
if(MSVC)
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/tsl-robin-map.natvis"
DESTINATION ".")
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}")
endif()
## Create and install tsl_robin_mapConfig.cmake
configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/tsl_robin_mapConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/tsl_robin_mapConfig.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/tsl_robin_map")
## Create and install tsl-robin-mapConfig.cmake
configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/tsl-robin-mapConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/tsl-robin-mapConfig.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/cmake/tsl-robin-map")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/tsl_robin_mapConfig.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/tsl_robin_map")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/tsl-robin-mapConfig.cmake"
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/cmake/tsl-robin-map")
## Create and install tsl_robin_mapTargets.cmake
## Create and install tsl-robin-mapTargets.cmake
install(TARGETS robin_map
EXPORT tsl_robin_mapTargets)
install(EXPORT tsl_robin_mapTargets
EXPORT tsl-robin-mapTargets)
install(EXPORT tsl-robin-mapTargets
NAMESPACE tsl::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/tsl_robin_map")
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/cmake/tsl-robin-map")
## Create and install tsl_robin_mapConfigVersion.cmake
# tsl_robin_map is header-only and does not depend on the architecture.
# Remove CMAKE_SIZEOF_VOID_P from tsl_robin_mapConfigVersion.cmake so that a
# tsl_robin_mapConfig.cmake generated for a 64 bit target can be used for 32 bit
## Create and install tsl-robin-mapConfigVersion.cmake
# tsl-robin-map is header-only and does not depend on the architecture.
# Remove CMAKE_SIZEOF_VOID_P from tsl-robin-mapConfigVersion.cmake so that a
# tsl-robin-mapConfig.cmake generated for a 64 bit target can be used for 32 bit
# targets and vice versa.
set(TSL_ROBIN_MAP_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
set(CMAKE_SIZEOF_VOID_P_BACKUP ${CMAKE_SIZEOF_VOID_P})
unset(CMAKE_SIZEOF_VOID_P)
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/tsl_robin_mapConfigVersion.cmake"
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/tsl-robin-mapConfigVersion.cmake"
COMPATIBILITY SameMajorVersion)
set(CMAKE_SIZEOF_VOID_P ${TSL_ROBIN_MAP_CMAKE_SIZEOF_VOID_P})
set(CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P_BACKUP})
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/tsl_robin_mapConfigVersion.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/tsl_robin_map")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/tsl-robin-mapConfigVersion.cmake"
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/cmake/tsl-robin-map")
endif()

View File

@ -86,7 +86,7 @@ add_subdirectory(third-party/robin-map)
target_link_libraries(your_target PRIVATE tsl::robin_map)
```
If the project has been installed through `make install`, you can also use `find_package(tsl_robin_map REQUIRED)` instead of `add_subdirectory`.
If the project has been installed through `make install`, you can also use `find_package(tsl-robin-map REQUIRED)` instead of `add_subdirectory`.
The code should work with any C++11 standard-compliant compiler and has been tested with GCC 4.8.4, Clang 3.5.0 and Visual Studio 2015.

View File

@ -0,0 +1,9 @@
# This module sets the following variables:
# * tsl-robin-map_FOUND - true if tsl-robin-map found on the system
# * tsl-robin-map_INCLUDE_DIRS - the directory containing tsl-robin-map headers
@PACKAGE_INIT@
if(NOT TARGET tsl::robin_map)
include("${CMAKE_CURRENT_LIST_DIR}/tsl-robin-mapTargets.cmake")
get_target_property(tsl-robin-map_INCLUDE_DIRS tsl::robin_map INTERFACE_INCLUDE_DIRECTORIES)
endif()

View File

@ -1,9 +0,0 @@
# This module sets the following variables:
# * tsl_robin_map_FOUND - true if tsl_robin_map found on the system
# * tsl_robin_map_INCLUDE_DIRS - the directory containing tsl_robin_map headers
@PACKAGE_INIT@
if(NOT TARGET tsl::robin_map)
include("${CMAKE_CURRENT_LIST_DIR}/tsl_robin_mapTargets.cmake")
get_target_property(tsl_robin_map_INCLUDE_DIRS tsl::robin_map INTERFACE_INCLUDE_DIRECTORIES)
endif()

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.8)
project(tsl_robin_map_tests)
@ -6,7 +6,9 @@ add_executable(tsl_robin_map_tests "main.cpp"
"custom_allocator_tests.cpp"
"policy_tests.cpp"
"robin_map_tests.cpp"
"robin_set_tests.cpp")
"robin_set_tests.cpp")
target_compile_features(tsl_robin_map_tests PRIVATE cxx_std_11)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
target_compile_options(tsl_robin_map_tests PRIVATE -Werror -Wall -Wextra -Wold-style-cast -DTSL_DEBUG -UNDEBUG)