2011-06-02 18:28:10 +04:00
|
|
|
cmake_minimum_required (VERSION 2.6)
|
|
|
|
project(IncludeDirectories)
|
|
|
|
|
2013-07-02 16:30:10 +04:00
|
|
|
if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.4)
|
|
|
|
OR CMAKE_C_COMPILER_ID STREQUAL Clang)
|
|
|
|
AND (CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR STREQUAL "Ninja"))
|
|
|
|
include(CheckCXXCompilerFlag)
|
|
|
|
check_cxx_compiler_flag(-Wunused-variable run_sys_includes_test)
|
|
|
|
if(run_sys_includes_test)
|
|
|
|
# The Bullseye wrapper appears to break the -isystem effect.
|
|
|
|
execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE out ERROR_VARIABLE out)
|
|
|
|
if("x${out}" MATCHES "Bullseye")
|
|
|
|
set(run_sys_includes_test 0)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
if (run_sys_includes_test)
|
|
|
|
add_subdirectory(SystemIncludeDirectories)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2011-06-03 21:45:31 +04:00
|
|
|
file(WRITE ${CMAKE_BINARY_DIR}/Flags/Flags.h
|
|
|
|
"//Flags.h
|
|
|
|
")
|
|
|
|
file(WRITE ${CMAKE_BINARY_DIR}/IncDir/IncDir.h
|
|
|
|
"//IncDir.h
|
|
|
|
")
|
|
|
|
file(WRITE ${CMAKE_BINARY_DIR}/SrcProp/SrcProp.h
|
|
|
|
"//SrcProp.h
|
|
|
|
")
|
|
|
|
file(WRITE ${CMAKE_BINARY_DIR}/TarProp/TarProp.h
|
|
|
|
"//TarProp.h
|
|
|
|
")
|
|
|
|
|
2011-06-04 00:16:50 +04:00
|
|
|
# default to testing with full path
|
|
|
|
# some compilers can not handle the escape for directories
|
|
|
|
# with spaces in them.
|
|
|
|
set(USE_FULLPATH TRUE)
|
|
|
|
if(WATCOM OR MSVC60)
|
|
|
|
set(USE_FULLPATH FALSE)
|
|
|
|
endif()
|
|
|
|
if(USE_FULLPATH)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \"-I${CMAKE_BINARY_DIR}/Flags\"")
|
|
|
|
else()
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -IFlags")
|
|
|
|
endif()
|
|
|
|
|
2011-06-03 21:45:31 +04:00
|
|
|
include_directories(${CMAKE_BINARY_DIR}/IncDir)
|
2011-06-04 00:16:50 +04:00
|
|
|
if(USE_FULLPATH)
|
|
|
|
set_source_files_properties(main.cpp PROPERTIES COMPILE_FLAGS
|
|
|
|
"\"-I${CMAKE_BINARY_DIR}/SrcProp\"")
|
|
|
|
else()
|
|
|
|
set_source_files_properties(main.cpp PROPERTIES COMPILE_FLAGS
|
|
|
|
"-ISrcProp")
|
|
|
|
endif()
|
|
|
|
|
2011-06-02 18:28:10 +04:00
|
|
|
add_executable(IncludeDirectories main.cpp)
|
2011-06-04 00:16:50 +04:00
|
|
|
|
|
|
|
if(USE_FULLPATH)
|
|
|
|
set_target_properties(IncludeDirectories
|
|
|
|
PROPERTIES COMPILE_FLAGS "\"-I${CMAKE_BINARY_DIR}/TarProp\"")
|
|
|
|
else()
|
|
|
|
set_target_properties(IncludeDirectories
|
|
|
|
PROPERTIES COMPILE_FLAGS "-ITarProp")
|
|
|
|
endif()
|
2011-11-05 19:17:49 +04:00
|
|
|
|
|
|
|
add_subdirectory(TargetIncludeDirectories)
|
2013-04-10 20:12:56 +04:00
|
|
|
|
|
|
|
set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES "${CMAKE_BINARY_DIR}")
|
|
|
|
get_property(propContent DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
|
|
|
|
if (NOT propContent STREQUAL "${CMAKE_BINARY_DIR}")
|
|
|
|
message(SEND_ERROR "Setting DIRECTORY property failed.")
|
|
|
|
endif()
|
|
|
|
set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
|
|
|
|
get_property(propContentAfter DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
|
|
|
|
if (NOT propContentAfter STREQUAL "")
|
|
|
|
message(SEND_ERROR "Clearing DIRECTORY property failed.")
|
|
|
|
endif()
|
2013-05-20 14:25:59 +04:00
|
|
|
|
|
|
|
add_library(empty_entry_test SHARED empty.cpp)
|
|
|
|
set_target_properties(empty_entry_test PROPERTIES INCLUDE_DIRECTORIES "")
|
|
|
|
include_directories(/one/two
|
|
|
|
" "
|
|
|
|
" "
|
|
|
|
)
|
|
|
|
get_target_property(incs empty_entry_test INCLUDE_DIRECTORIES)
|
|
|
|
if (NOT incs STREQUAL ";/one/two")
|
|
|
|
message(SEND_ERROR "Empty include_directories entry was not ignored.")
|
|
|
|
endif()
|