Skip to content

Commit 3872f37

Browse files
authored
Merge pull request #141 from zhao-shihan/master
Add CMake options INDICATORS_INSTALL and INDICATORS_PACKAGE
2 parents a746832 + 824ca21 commit 3872f37

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
cmake_minimum_required(VERSION 3.8)
22

3-
if(DEFINED PROJECT_NAME)
4-
set(INDICATORS_SUBPROJECT ON)
3+
if(NOT DEFINED PROJECT_NAME)
4+
set(INDICATORS_IS_TOP_LEVEL ON)
5+
else()
6+
set(INDICATORS_IS_TOP_LEVEL OFF)
57
endif()
68

79
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.12")
@@ -20,6 +22,8 @@ if(EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
2022
conan_basic_setup()
2123
endif()
2224

25+
option(INDICATORS_INSTALL "Include an install target" ${INDICATORS_IS_TOP_LEVEL})
26+
option(INDICATORS_PACKAGE "Include package targets" ${INDICATORS_IS_TOP_LEVEL})
2327
option(INDICATORS_BUILD_TESTS "Build indicators tests + enable CTest")
2428
option(INDICATORS_SAMPLES "Build indicators samples")
2529
option(INDICATORS_DEMO "Build indicators demo" OFF)
@@ -46,7 +50,7 @@ if(INDICATORS_SAMPLES)
4650
add_subdirectory(samples)
4751
endif()
4852

49-
if(NOT INDICATORS_SUBPROJECT)
53+
if(INDICATORS_INSTALL)
5054
configure_package_config_file(indicatorsConfig.cmake.in
5155
${CMAKE_CURRENT_BINARY_DIR}/indicatorsConfig.cmake
5256
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/indicators)
@@ -71,7 +75,9 @@ if(NOT INDICATORS_SUBPROJECT)
7175
PATTERN "*.hpp")
7276
install(FILES LICENSE LICENSE.termcolor
7377
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/licenses/indicators)
78+
endif()
7479

80+
if(INDICATORS_PACKAGE)
7581
if(EXISTS "${PROJECT_SOURCE_DIR}/.gitignore")
7682
# Simple glob to regex conversion (.gitignore => CPACK_SOURCE_IGNORE_FILES)
7783
file(READ ".gitignore" DOT_GITIGNORE)

0 commit comments

Comments
 (0)