Skip to content

Commit

Permalink
Rename CMake project name from tsl_robin_map to tsl-robin-map for coh…
Browse files Browse the repository at this point in the history
…erence with the convention used by most package managers.
  • Loading branch information
Tessil committed Jan 27, 2019
1 parent 6edac20 commit ab349ee
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 44 deletions.
60 changes: 28 additions & 32 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
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, ...)
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"
Expand All @@ -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()


Expand All @@ -33,50 +30,49 @@ 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"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")

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()
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
9 changes: 9 additions & 0 deletions cmake/tsl-robin-mapConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -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()
9 changes: 0 additions & 9 deletions cmake/tsl_robin_mapConfig.cmake.in

This file was deleted.

6 changes: 4 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.8)

project(tsl_robin_map_tests)

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)
Expand Down

0 comments on commit ab349ee

Please sign in to comment.