2013-01-02 02:20:04 +04:00
|
|
|
cmake_minimum_required(VERSION 2.8)
|
|
|
|
|
|
|
|
project(target_include_directories)
|
|
|
|
|
|
|
|
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/privateinclude")
|
|
|
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/privateinclude/privateinclude.h" "#define PRIVATEINCLUDE_DEFINE\n")
|
|
|
|
|
|
|
|
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/publicinclude")
|
|
|
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/publicinclude/publicinclude.h" "#define PUBLICINCLUDE_DEFINE\n")
|
|
|
|
|
|
|
|
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/interfaceinclude")
|
|
|
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/interfaceinclude/interfaceinclude.h" "#define INTERFACEINCLUDE_DEFINE\n")
|
|
|
|
|
|
|
|
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/poison")
|
|
|
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/poison/common.h" "#error Should not be included\n")
|
|
|
|
|
|
|
|
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/cure")
|
|
|
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cure/common.h" "#define CURE_DEFINE\n")
|
|
|
|
|
|
|
|
add_executable(target_include_directories
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/main.cpp"
|
|
|
|
)
|
|
|
|
target_include_directories(target_include_directories
|
|
|
|
PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/privateinclude"
|
|
|
|
PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/publicinclude"
|
|
|
|
INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/interfaceinclude"
|
|
|
|
)
|
|
|
|
|
|
|
|
target_include_directories(target_include_directories
|
|
|
|
PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/poison"
|
|
|
|
)
|
|
|
|
target_include_directories(target_include_directories
|
2013-02-25 18:24:15 +04:00
|
|
|
BEFORE PUBLIC "$<$<STREQUAL:$<TARGET_PROPERTY:target_include_directories,TYPE>,EXECUTABLE>:${CMAKE_CURRENT_BINARY_DIR}/cure>"
|
2013-01-17 01:16:46 +04:00
|
|
|
)
|
|
|
|
|
2013-02-25 18:24:15 +04:00
|
|
|
# Has no effect because the target type is not SHARED_LIBRARY:
|
2013-01-17 01:16:46 +04:00
|
|
|
target_include_directories(target_include_directories
|
2013-02-25 18:24:15 +04:00
|
|
|
BEFORE PUBLIC "$<$<STREQUAL:$<TARGET_PROPERTY:target_include_directories,TYPE>,SHARED_LIBRARY>:${CMAKE_CURRENT_BINARY_DIR}/poison>"
|
2013-01-02 02:20:04 +04:00
|
|
|
)
|
|
|
|
|
|
|
|
add_executable(consumer
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/consumer.cpp"
|
|
|
|
)
|
|
|
|
|
2015-03-04 23:53:15 +03:00
|
|
|
if (CMAKE_GENERATOR MATCHES "Makefiles" OR CMAKE_GENERATOR MATCHES "Ninja")
|
|
|
|
target_sources(consumer PRIVATE
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/consumer.c"
|
|
|
|
)
|
|
|
|
target_include_directories(consumer
|
|
|
|
PRIVATE
|
|
|
|
$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/cxx_only>
|
|
|
|
$<$<COMPILE_LANGUAGE:C>:${CMAKE_CURRENT_SOURCE_DIR}/c_only>
|
|
|
|
)
|
|
|
|
target_compile_definitions(consumer
|
|
|
|
PRIVATE -DTEST_LANG_DEFINES
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2013-01-02 02:20:04 +04:00
|
|
|
target_include_directories(consumer
|
2013-01-31 02:38:04 +04:00
|
|
|
PRIVATE
|
|
|
|
$<TARGET_PROPERTY:target_include_directories,INTERFACE_INCLUDE_DIRECTORIES>
|
2013-11-26 05:38:55 +04:00
|
|
|
relative_dir
|
|
|
|
relative_dir/$<TARGET_PROPERTY:NAME>
|
2013-01-02 02:20:04 +04:00
|
|
|
)
|
2013-07-31 18:02:07 +04:00
|
|
|
|
|
|
|
# Test no items
|
|
|
|
target_include_directories(consumer
|
|
|
|
PRIVATE
|
|
|
|
)
|
|
|
|
target_include_directories(consumer
|
|
|
|
BEFORE PRIVATE
|
|
|
|
)
|
|
|
|
target_include_directories(consumer
|
|
|
|
SYSTEM BEFORE PRIVATE
|
|
|
|
)
|
|
|
|
target_include_directories(consumer
|
|
|
|
SYSTEM PRIVATE
|
|
|
|
)
|
2013-12-26 17:11:23 +04:00
|
|
|
|
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
add_library(imp UNKNOWN IMPORTED)
|
|
|
|
get_target_property(_res imp INCLUDE_DIRECTORIES)
|
|
|
|
if (_res)
|
|
|
|
message(SEND_ERROR "include_directories populated the INCLUDE_DIRECTORIES target property")
|
|
|
|
endif()
|