mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-20 04:24:36 +08:00
Tests: Enable coverage of special chars in include dirs for Makefiles
Issue: #20555
This commit is contained in:
@@ -3477,6 +3477,8 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH
|
|||||||
--build-two-config
|
--build-two-config
|
||||||
${build_generator_args}
|
${build_generator_args}
|
||||||
--build-project IncludeDirectories
|
--build-project IncludeDirectories
|
||||||
|
--build-options
|
||||||
|
-DMAKE_SUPPORTS_SPACES=${MAKE_SUPPORTS_SPACES}
|
||||||
--test-command IncludeDirectories)
|
--test-command IncludeDirectories)
|
||||||
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/IncludeDirectories")
|
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/IncludeDirectories")
|
||||||
|
|
||||||
|
@@ -66,21 +66,36 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Test escaping of special characters in include directory paths.
|
# Test escaping of special characters in include directory paths.
|
||||||
# FIXME: Implement full support in Makefile generators
|
set(special_chars "~@%&{}()!'")
|
||||||
if(NOT CMAKE_GENERATOR MATCHES "Make")
|
if(NOT CMAKE_GENERATOR STREQUAL "Watcom WMake")
|
||||||
set(special_chars "~@#$%^&=[]{}()!'")
|
# Watcom seems to have no way to encode these characters.
|
||||||
if(NOT CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
string(APPEND special_chars "#=[]")
|
||||||
string(APPEND special_chars ",")
|
endif()
|
||||||
endif()
|
if(NOT (MINGW AND CMAKE_GENERATOR MATCHES "(Unix|MSYS) Makefiles"))
|
||||||
if(NOT WIN32 AND NOT CYGWIN)
|
# FIXME: Dependencies work but command-line generation does not handle '$'.
|
||||||
string(APPEND special_chars "*?<>")
|
string(APPEND special_chars "$")
|
||||||
endif()
|
endif()
|
||||||
set(special_dir "${CMAKE_CURRENT_BINARY_DIR}/special-${special_chars}-include")
|
if(NOT CMAKE_GENERATOR MATCHES "(Borland|NMake) Makefiles")
|
||||||
file(WRITE "${special_dir}/SpecialDir.h" "#define SPECIAL_DIR_H\n")
|
# 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")
|
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")
|
file(WRITE "${special_space_dir}/SpecialSpaceDir.h" "#define SPECIAL_SPACE_DIR_H\n")
|
||||||
target_include_directories(IncludeDirectories PRIVATE "${special_dir}" "${special_space_dir}")
|
target_include_directories(IncludeDirectories PRIVATE "${special_space_dir}")
|
||||||
target_compile_definitions(IncludeDirectories PRIVATE INCLUDE_SPECIAL_DIR)
|
target_compile_definitions(IncludeDirectories PRIVATE INCLUDE_SPECIAL_SPACE_DIR)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(ordertest ordertest.cpp)
|
add_library(ordertest ordertest.cpp)
|
||||||
|
@@ -8,6 +8,9 @@
|
|||||||
# ifndef SPECIAL_DIR_H
|
# ifndef SPECIAL_DIR_H
|
||||||
# error "SPECIAL_DIR_H not defined"
|
# error "SPECIAL_DIR_H not defined"
|
||||||
# endif
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef INCLUDE_SPECIAL_SPACE_DIR
|
||||||
# include "SpecialSpaceDir.h"
|
# include "SpecialSpaceDir.h"
|
||||||
# ifndef SPECIAL_SPACE_DIR_H
|
# ifndef SPECIAL_SPACE_DIR_H
|
||||||
# error "SPECIAL_SPACE_DIR_H not defined"
|
# error "SPECIAL_SPACE_DIR_H not defined"
|
||||||
|
Reference in New Issue
Block a user