diff options
author | Brad King <brad.king@kitware.com> | 2020-12-22 14:13:02 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-12-22 14:13:08 (GMT) |
commit | 72a28635b8a92ecf2bd14c18c6fca0a391391f85 (patch) | |
tree | be9a8b0dff91b018fa0547ce7273c6c561963af9 /Tests | |
parent | 3cf1a8c59ba8ebaeb86c41300cf3f78469a30310 (diff) | |
parent | b68699b71799762812fd58a6f257bc7cc9820761 (diff) | |
download | CMake-72a28635b8a92ecf2bd14c18c6fca0a391391f85.zip CMake-72a28635b8a92ecf2bd14c18c6fca0a391391f85.tar.gz CMake-72a28635b8a92ecf2bd14c18c6fca0a391391f85.tar.bz2 |
Merge topic 'issue-20134'
b68699b717 target_include_directories: Support AFTER option
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5633
Diffstat (limited to 'Tests')
4 files changed, 57 insertions, 0 deletions
diff --git a/Tests/RunCMake/target_include_directories/RunCMakeTest.cmake b/Tests/RunCMake/target_include_directories/RunCMakeTest.cmake index b67c598..48a750d 100644 --- a/Tests/RunCMake/target_include_directories/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_include_directories/RunCMakeTest.cmake @@ -1,3 +1,6 @@ include(RunCMake) run_cmake(empty_keyword_args) +run_cmake(include_before) +run_cmake(include_after) +run_cmake(include_default) diff --git a/Tests/RunCMake/target_include_directories/include_after.cmake b/Tests/RunCMake/target_include_directories/include_after.cmake new file mode 100644 index 0000000..68a08a7 --- /dev/null +++ b/Tests/RunCMake/target_include_directories/include_after.cmake @@ -0,0 +1,18 @@ +enable_language(C) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.c" "int main() { return 0;}") + +set(include_dir "${CMAKE_CURRENT_BINARY_DIR}/dir") +set(after_include_dir "${CMAKE_CURRENT_BINARY_DIR}/dirAfter") +file(MAKE_DIRECTORY "${include_dir}") +file(MAKE_DIRECTORY "${after_include_dir}") + +add_executable(main "${CMAKE_CURRENT_BINARY_DIR}/main.c") +include_directories("${include_dir}") +target_include_directories(main AFTER PRIVATE "${after_include_dir}") + +get_target_property(actual_include_dirs main INCLUDE_DIRECTORIES) +set(desired_include_dirs "${include_dir}" "${after_include_dir}") + +if (NOT "${actual_include_dirs}" MATCHES "${desired_include_dirs}") + message(SEND_ERROR "include after does not work") +endif() diff --git a/Tests/RunCMake/target_include_directories/include_before.cmake b/Tests/RunCMake/target_include_directories/include_before.cmake new file mode 100644 index 0000000..9bebecd --- /dev/null +++ b/Tests/RunCMake/target_include_directories/include_before.cmake @@ -0,0 +1,18 @@ +enable_language(C) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.c" "int main() { return 0;}") + +set(include_dir "${CMAKE_CURRENT_BINARY_DIR}/dir") +set(before_include_dir "${CMAKE_CURRENT_BINARY_DIR}/dirBefore") +file(MAKE_DIRECTORY "${include_dir}") +file(MAKE_DIRECTORY "${before_include_dir}") + +add_executable(main "${CMAKE_CURRENT_BINARY_DIR}/main.c") +include_directories("${include_dir}") +target_include_directories(main BEFORE PRIVATE "${before_include_dir}") + +get_target_property(actual_include_dirs main INCLUDE_DIRECTORIES) +set(desired_include_dirs "${before_include_dir}" "${include_dir}") + +if (NOT "${actual_include_dirs}" MATCHES "${desired_include_dirs}") + message(SEND_ERROR "include before does not work") +endif() diff --git a/Tests/RunCMake/target_include_directories/include_default.cmake b/Tests/RunCMake/target_include_directories/include_default.cmake new file mode 100644 index 0000000..88b2502 --- /dev/null +++ b/Tests/RunCMake/target_include_directories/include_default.cmake @@ -0,0 +1,18 @@ +enable_language(C) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.c" "int main() { return 0;}") + +set(include_dir "${CMAKE_CURRENT_BINARY_DIR}/dir") +set(default_include_dir "${CMAKE_CURRENT_BINARY_DIR}/dirDefault") +file(MAKE_DIRECTORY "${include_dir}") +file(MAKE_DIRECTORY "${default_include_dir}") + +add_executable(main "${CMAKE_CURRENT_BINARY_DIR}/main.c") +include_directories("${include_dir}") +target_include_directories(main AFTER PRIVATE "${default_include_dir}") + +get_target_property(actual_include_dirs main INCLUDE_DIRECTORIES) +set(desired_include_dirs "${include_dir}" "${default_include_dir}") + +if (NOT "${actual_include_dirs}" MATCHES "${desired_include_dirs}") + message(SEND_ERROR "include default does not work") +endif() |