From ab5f9259a4e67d3fe0e4832bd407a9e596e2d884 Mon Sep 17 00:00:00 2001 From: Patrick Stotko Date: Sat, 5 May 2018 18:03:13 +0200 Subject: [PATCH] Use target-based include_directories to enable modern CMake usage (#583) --- CMakeLists.txt | 15 ++++++++++++--- test/CMakeLists.txt | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d2d8810..715c846 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -116,9 +116,10 @@ if(VERBOSE) message(STATUS "contrib_private_headers: ${contrib_private_headers}") endif() -include_directories(${YAML_CPP_SOURCE_DIR}/src) -include_directories(${YAML_CPP_SOURCE_DIR}/include) - +if (CMAKE_VERSION VERSION_LESS 2.8.12) + include_directories(${YAML_CPP_SOURCE_DIR}/src) + include_directories(${YAML_CPP_SOURCE_DIR}/include) +endif() ### @@ -275,6 +276,14 @@ set(_INSTALL_DESTINATIONS ### Library ### add_library(yaml-cpp ${library_sources}) + +if (NOT CMAKE_VERSION VERSION_LESS 2.8.12) + target_include_directories(yaml-cpp + PUBLIC $ + $ + PRIVATE $) +endif() + set_target_properties(yaml-cpp PROPERTIES COMPILE_FLAGS "${yaml_c_flags} ${yaml_cxx_flags}" ) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3633da5..ad61a3c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -30,6 +30,7 @@ file(GLOB test_new_api_sources new-api/[a-z]*.cpp) list(APPEND test_sources ${test_new_api_sources}) add_sources(${test_sources} ${test_headers}) +include_directories(${YAML_CPP_SOURCE_DIR}/src) include_directories(${YAML_CPP_SOURCE_DIR}/test) add_executable(run-tests