Skip to content

Commit 054ec5a

Browse files
committed
Add a CMake TSL_ROBIN_MAP_ENABLE_INSTALL option to explicitly enable/disable the install target
1 parent 612c2be commit 054ec5a

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

CMakeLists.txt

+10-9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ project(tsl-robin-map VERSION 1.3.0 LANGUAGES CXX)
55
include(GNUInstallDirs)
66

77

8+
set(IS_MAIN_PROJECT FALSE)
9+
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
10+
set(IS_MAIN_PROJECT TRUE)
11+
endif()
12+
13+
# Enable the install target if the project is used main project (disable by default if subproject)
14+
option(TSL_ROBIN_MAP_ENABLE_INSTALL "Enable install target" ${IS_MAIN_PROJECT})
15+
16+
817
add_library(robin_map INTERFACE)
918
# Use tsl::robin_map as target, more consistent with other libraries conventions (Boost, Qt, ...)
1019
add_library(tsl::robin_map ALIAS robin_map)
@@ -25,16 +34,8 @@ if(MSVC)
2534
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_DATAROOTDIR}/tsl-robin-map.natvis>")
2635
endif()
2736

28-
29-
30-
31-
set(IS_SUBPROJECT TRUE)
32-
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
33-
set(IS_SUBPROJECT FALSE)
34-
endif()
35-
3637
# Installation
37-
if(NOT IS_SUBPROJECT)
38+
if(TSL_ROBIN_MAP_ENABLE_INSTALL)
3839
include(CMakePackageConfigHelpers)
3940

4041
## Install include directory and potential natvis file

0 commit comments

Comments
 (0)