Skip to content

Commit

Permalink
Use target-based include_directories to enable modern CMake usage (#583)
Browse files Browse the repository at this point in the history
  • Loading branch information
stotko authored and jbeder committed May 5, 2018
1 parent 124ae47 commit ab5f925
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
15 changes: 12 additions & 3 deletions CMakeLists.txt
Expand Up @@ -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()


###
Expand Down Expand Up @@ -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 $<BUILD_INTERFACE:${YAML_CPP_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${INCLUDE_INSTALL_ROOT_DIR}>
PRIVATE $<BUILD_INTERFACE:${YAML_CPP_SOURCE_DIR}/src>)
endif()

set_target_properties(yaml-cpp PROPERTIES
COMPILE_FLAGS "${yaml_c_flags} ${yaml_cxx_flags}"
)
Expand Down
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Expand Up @@ -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
Expand Down

0 comments on commit ab5f925

Please sign in to comment.