diff options
author | Brad King <brad.king@kitware.com> | 2020-04-10 19:15:27 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-04-15 12:34:51 (GMT) |
commit | a4173ef1658078d4dde186489e136c805b370410 (patch) | |
tree | 5767435faf9007606508964e6b9ad38caddcc0b5 /Tests/IncludeDirectories | |
parent | d74e651b7834937a6761b880d4e713683f5a44e3 (diff) | |
download | CMake-a4173ef1658078d4dde186489e136c805b370410.zip CMake-a4173ef1658078d4dde186489e136c805b370410.tar.gz CMake-a4173ef1658078d4dde186489e136c805b370410.tar.bz2 |
Tests: Enable coverage of special chars in include dirs for Makefiles
Issue: #20555
Diffstat (limited to 'Tests/IncludeDirectories')
-rw-r--r-- | Tests/IncludeDirectories/CMakeLists.txt | 41 | ||||
-rw-r--r-- | Tests/IncludeDirectories/main.cpp | 3 |
2 files changed, 31 insertions, 13 deletions
diff --git a/Tests/IncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/CMakeLists.txt index 838a236..eb08676 100644 --- a/Tests/IncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/CMakeLists.txt @@ -66,21 +66,36 @@ else() endif() # Test escaping of special characters in include directory paths. -# FIXME: Implement full support in Makefile generators -if(NOT CMAKE_GENERATOR MATCHES "Make") - set(special_chars "~@#$%^&=[]{}()!'") - if(NOT CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008") - string(APPEND special_chars ",") - endif() - if(NOT WIN32 AND NOT CYGWIN) - string(APPEND special_chars "*?<>") - endif() - set(special_dir "${CMAKE_CURRENT_BINARY_DIR}/special-${special_chars}-include") - file(WRITE "${special_dir}/SpecialDir.h" "#define SPECIAL_DIR_H\n") +set(special_chars "~@%&{}()!'") +if(NOT CMAKE_GENERATOR STREQUAL "Watcom WMake") + # Watcom seems to have no way to encode these characters. + string(APPEND special_chars "#=[]") +endif() +if(NOT (MINGW AND CMAKE_GENERATOR MATCHES "(Unix|MSYS) Makefiles")) + # FIXME: Dependencies work but command-line generation does not handle '$'. + string(APPEND special_chars "$") +endif() +if(NOT CMAKE_GENERATOR MATCHES "(Borland|NMake) Makefiles") + # NMake and Borland seem to have no way to encode a single '^'. + string(APPEND special_chars "^") +endif() +if(NOT CMAKE_GENERATOR MATCHES "Visual Studio 9 2008|Watcom WMake") + # The vcproj format separates values with ','. + string(APPEND special_chars ",") +endif() +if(NOT WIN32 AND NOT CYGWIN) + string(APPEND special_chars "*?<>") +endif() +set(special_dir "${CMAKE_CURRENT_BINARY_DIR}/special-${special_chars}-include") +file(WRITE "${special_dir}/SpecialDir.h" "#define SPECIAL_DIR_H\n") +target_include_directories(IncludeDirectories PRIVATE "${special_dir}") +target_compile_definitions(IncludeDirectories PRIVATE INCLUDE_SPECIAL_DIR) + +if(MAKE_SUPPORTS_SPACES) set(special_space_dir "${CMAKE_CURRENT_BINARY_DIR}/special-space ${special_chars}-include") file(WRITE "${special_space_dir}/SpecialSpaceDir.h" "#define SPECIAL_SPACE_DIR_H\n") - target_include_directories(IncludeDirectories PRIVATE "${special_dir}" "${special_space_dir}") - target_compile_definitions(IncludeDirectories PRIVATE INCLUDE_SPECIAL_DIR) + target_include_directories(IncludeDirectories PRIVATE "${special_space_dir}") + target_compile_definitions(IncludeDirectories PRIVATE INCLUDE_SPECIAL_SPACE_DIR) endif() add_library(ordertest ordertest.cpp) diff --git a/Tests/IncludeDirectories/main.cpp b/Tests/IncludeDirectories/main.cpp index 7368ee9..6dc88e2 100644 --- a/Tests/IncludeDirectories/main.cpp +++ b/Tests/IncludeDirectories/main.cpp @@ -8,6 +8,9 @@ # ifndef SPECIAL_DIR_H # error "SPECIAL_DIR_H not defined" # endif +#endif + +#ifdef INCLUDE_SPECIAL_SPACE_DIR # include "SpecialSpaceDir.h" # ifndef SPECIAL_SPACE_DIR_H # error "SPECIAL_SPACE_DIR_H not defined" |