Skip to content

Commit ab5f925

Browse files
stotkojbeder
authored andcommitted
Use target-based include_directories to enable modern CMake usage (#583)
1 parent 124ae47 commit ab5f925

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

CMakeLists.txt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,10 @@ if(VERBOSE)
116116
message(STATUS "contrib_private_headers: ${contrib_private_headers}")
117117
endif()
118118

119-
include_directories(${YAML_CPP_SOURCE_DIR}/src)
120-
include_directories(${YAML_CPP_SOURCE_DIR}/include)
121-
119+
if (CMAKE_VERSION VERSION_LESS 2.8.12)
120+
include_directories(${YAML_CPP_SOURCE_DIR}/src)
121+
include_directories(${YAML_CPP_SOURCE_DIR}/include)
122+
endif()
122123

123124

124125
###
@@ -275,6 +276,14 @@ set(_INSTALL_DESTINATIONS
275276
### Library
276277
###
277278
add_library(yaml-cpp ${library_sources})
279+
280+
if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
281+
target_include_directories(yaml-cpp
282+
PUBLIC $<BUILD_INTERFACE:${YAML_CPP_SOURCE_DIR}/include>
283+
$<INSTALL_INTERFACE:${INCLUDE_INSTALL_ROOT_DIR}>
284+
PRIVATE $<BUILD_INTERFACE:${YAML_CPP_SOURCE_DIR}/src>)
285+
endif()
286+
278287
set_target_properties(yaml-cpp PROPERTIES
279288
COMPILE_FLAGS "${yaml_c_flags} ${yaml_cxx_flags}"
280289
)

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ file(GLOB test_new_api_sources new-api/[a-z]*.cpp)
3030
list(APPEND test_sources ${test_new_api_sources})
3131
add_sources(${test_sources} ${test_headers})
3232

33+
include_directories(${YAML_CPP_SOURCE_DIR}/src)
3334
include_directories(${YAML_CPP_SOURCE_DIR}/test)
3435

3536
add_executable(run-tests

0 commit comments

Comments
 (0)