include_regular_expression: Fix propagation to subdirectories

Refactoring in commit v3.4.0-rc1~321^2 (cmMakefile: Remove special
handling of INCLUDE_REGULAR_EXPRESSION, 2015-04-04) accidentally broke
propagation of the include regex to subdirectories.  Refactoring in
commit v3.5.0-rc1~319^2~1 (cmState: Initialize properties immediately,
2015-10-07) moved maintenance of this value from `cmMakefile` to
`cmStateSnapshot`.

Restore propagation of the `INCLUDE_REGULAR_EXPRESSION` to
subdirectories and add a test to cover it.

Fixes: #17676
This commit is contained in:
Brad King
2018-01-24 08:17:43 -05:00
parent 1345bdf1b6
commit 2d64f9f08d
5 changed files with 15 additions and 0 deletions

View File

@@ -386,6 +386,12 @@ void cmStateSnapshot::InitializeFromParent()
parent->BuildSystemDirectory->CompileOptionsBacktraces,
this->Position->BuildSystemDirectory->CompileOptionsBacktraces,
this->Position->CompileOptionsPosition);
const char* include_regex =
parent->BuildSystemDirectory->Properties.GetPropertyValue(
"INCLUDE_REGULAR_EXPRESSION");
this->Position->BuildSystemDirectory->Properties.SetProperty(
"INCLUDE_REGULAR_EXPRESSION", include_regex);
}
cmState* cmStateSnapshot::GetState() const

View File

@@ -0,0 +1,4 @@
include("${RunCMake_TEST_BINARY_DIR}/IncludeRegexSubdir/CMakeFiles/CMakeDirectoryInformation.cmake" OPTIONAL)
if(NOT CMAKE_C_INCLUDE_REGEX_SCAN STREQUAL "^custom_include_regex$")
set(RunCMake_TEST_FAILED "CMAKE_C_INCLUDE_REGEX_SCAN has unexpected value:\n \"${CMAKE_C_INCLUDE_REGEX_SCAN}\"")
endif()

View File

@@ -0,0 +1,3 @@
enable_language(C)
include_regular_expression("^custom_include_regex$")
add_subdirectory(IncludeRegexSubdir)

View File

@@ -0,0 +1 @@
# We only need this directory to be processed. No targets needed.

View File

@@ -17,3 +17,4 @@ run_TargetMessages(VAR-ON -DCMAKE_TARGET_MESSAGES=ON)
run_TargetMessages(VAR-OFF -DCMAKE_TARGET_MESSAGES=OFF)
run_cmake(CustomCommandDepfile-ERROR)
run_cmake(IncludeRegexSubdir)