From ab349ee88b25b55e91a52657aab978d7288969fd Mon Sep 17 00:00:00 2001 From: Tessil Date: Sat, 26 Jan 2019 13:22:23 +0100 Subject: [PATCH] Rename CMake project name from tsl_robin_map to tsl-robin-map for coherence with the convention used by most package managers. --- CMakeLists.txt | 60 ++++++++++++++---------------- README.md | 2 +- cmake/tsl-robin-mapConfig.cmake.in | 9 +++++ cmake/tsl_robin_mapConfig.cmake.in | 9 ----- tests/CMakeLists.txt | 6 ++- 5 files changed, 42 insertions(+), 44 deletions(-) create mode 100644 cmake/tsl-robin-mapConfig.cmake.in delete mode 100644 cmake/tsl_robin_mapConfig.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index ded5499..a5d685c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 "$" - "$") + "$") 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 "$") if(MSVC) target_sources(robin_map INTERFACE "$" - "$") -endif() - -# Only compatible with CMake version >= 3.8 -if(${CMAKE_VERSION} VERSION_GREATER "3.7") - target_compile_features(robin_map INTERFACE cxx_std_11) + "$") 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() diff --git a/README.md b/README.md index 6d8ec8a..c423163 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/cmake/tsl-robin-mapConfig.cmake.in b/cmake/tsl-robin-mapConfig.cmake.in new file mode 100644 index 0000000..d2ce233 --- /dev/null +++ b/cmake/tsl-robin-mapConfig.cmake.in @@ -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() diff --git a/cmake/tsl_robin_mapConfig.cmake.in b/cmake/tsl_robin_mapConfig.cmake.in deleted file mode 100644 index 64899d4..0000000 --- a/cmake/tsl_robin_mapConfig.cmake.in +++ /dev/null @@ -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() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8955703..3accb0e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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)