diff options
author | Asit Dhal <dhal.asitk@gmail.com> | 2020-12-19 12:44:35 (GMT) |
---|---|---|
committer | Asit Dhal <dhal.asitk@gmail.com> | 2020-12-19 13:51:39 (GMT) |
commit | b68699b71799762812fd58a6f257bc7cc9820761 (patch) | |
tree | 6692ccde6094d379de31bc0f531658a8b0461f6c /Tests/RunCMake | |
parent | d231f429f10e920e08607a7371f6f7e7e17aa93b (diff) | |
download | CMake-b68699b71799762812fd58a6f257bc7cc9820761.zip CMake-b68699b71799762812fd58a6f257bc7cc9820761.tar.gz CMake-b68699b71799762812fd58a6f257bc7cc9820761.tar.bz2 |
target_include_directories: Support AFTER option
Fixes: #20134
Diffstat (limited to 'Tests/RunCMake')
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() |