Skip to content

Commit 7d06655

Browse files
authored
Allow yaml-cpp to be installed from another project (#1007)
Changes YAML_CPP_INSTALL from a cmake_dependent_option to an option. Fixes #756, #847, and #1011.
1 parent 0e6e98e commit 7d06655

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ endif()
99

1010
project(YAML_CPP VERSION 0.7.0 LANGUAGES CXX)
1111

12+
set(YAML_CPP_MAIN_PROJECT OFF)
13+
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
14+
set(YAML_CPP_MAIN_PROJECT ON)
15+
endif()
16+
1217
include(CMakePackageConfigHelpers)
1318
include(CMakeDependentOption)
1419
include(CheckCXXCompilerFlag)
@@ -17,6 +22,7 @@ include(GNUInstallDirs)
1722
option(YAML_CPP_BUILD_CONTRIB "Enable yaml-cpp contrib in library" ON)
1823
option(YAML_CPP_BUILD_TOOLS "Enable parse tools" ON)
1924
option(YAML_BUILD_SHARED_LIBS "Build yaml-cpp shared library" ${BUILD_SHARED_LIBS})
25+
option(YAML_CPP_INSTALL "Enable generation of yaml-cpp install targets" ${YAML_CPP_MAIN_PROJECT})
2026
option(YAML_CPP_FORMAT_SOURCE "Format source" ON)
2127

2228
if (YAML_CPP_BUILD_TESTS)
@@ -30,9 +36,6 @@ endif()
3036
cmake_dependent_option(YAML_CPP_BUILD_TESTS
3137
"Enable yaml-cpp tests" ON
3238
"BUILD_TESTING;CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF)
33-
cmake_dependent_option(YAML_CPP_INSTALL
34-
"Enable generation of yaml-cpp install targets" ON
35-
"CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF)
3639
cmake_dependent_option(YAML_MSVC_SHARED_RT
3740
"MSVC: Build yaml-cpp with shared runtime libs (/MD)" ON
3841
"CMAKE_SYSTEM_NAME MATCHES Windows" OFF)

0 commit comments

Comments
 (0)