diff options
-rw-r--r-- | Help/command/FIND_XXX.txt | 23 | ||||
-rw-r--r-- | Help/command/block.rst | 31 | ||||
-rw-r--r-- | Help/command/continue.rst | 6 | ||||
-rw-r--r-- | Help/command/return.rst | 81 | ||||
-rw-r--r-- | Help/prop_tgt/MSVC_DEBUG_INFORMATION_FORMAT-VALUES.txt | 5 | ||||
-rw-r--r-- | Help/prop_tgt/MSVC_RUNTIME_LIBRARY-VALUES.txt | 5 | ||||
-rw-r--r-- | Help/variable/CMAKE_TASKING_TOOLSET.rst | 11 | ||||
-rw-r--r-- | Modules/Compiler/Tasking.cmake | 32 | ||||
-rw-r--r-- | Modules/FindOpenSSL.cmake | 2 | ||||
-rw-r--r-- | Source/cmState.cxx | 21 | ||||
-rw-r--r-- | Source/cmStatePrivate.h | 2 | ||||
-rw-r--r-- | Source/cmStateSnapshot.cxx | 10 | ||||
-rw-r--r-- | Tests/RunCMake/block/Scope-POLICIES.cmake | 10 | ||||
-rw-r--r-- | Tests/RunCMake/block/Scope-VARIABLES.cmake | 12 | ||||
-rw-r--r-- | Tests/RunCMake/block/Scope.cmake | 12 | ||||
-rw-r--r-- | Tests/RunCMake/block/Scope/CMakeLists.txt | 2 |
16 files changed, 158 insertions, 107 deletions
diff --git a/Help/command/FIND_XXX.txt b/Help/command/FIND_XXX.txt index 59a4e71..bd55e24 100644 --- a/Help/command/FIND_XXX.txt +++ b/Help/command/FIND_XXX.txt @@ -70,23 +70,28 @@ Options include: ``VALIDATOR`` .. versionadded:: 3.25 - Specify a :command:`function` (a :command:`macro` is not an acceptable - choice) which will be called for each found item. The search ends when - the validation function returns a successful status. - - The validation function expects two arguments: output variable name and item - value. By default, the output variable name already holds a ``TRUE`` value. + Specify a :command:`function` to be called for each candidate item found + (a :command:`macro` cannot be provided, that will result in an error). + Two arguments will be passed to the validator function: the name of a + result variable, and the absolute path to the candidate item. The item + will be accepted and the search will end unless the function sets the + value in the result variable to false in the calling scope. The result + variable will hold a true value when the validator function is entered. .. parsed-literal:: - function (MY_CHECK output_status item) - if (NOT item MATCHES ...) - set(${output_status} FALSE PARENT_SCOPE) + function(my_check validator_result_var item) + if(NOT item MATCHES ...) + set(${validator_result_var} FALSE PARENT_SCOPE) endif() endfunction() |FIND_XXX| (result NAMES ... VALIDATOR my_check) + Note that if a cached result is used, the search is skipped and any + ``VALIDATOR`` is ignored. The cached result is not required to pass the + validation function. + ``DOC`` Specify the documentation string for the ``<VAR>`` cache entry. diff --git a/Help/command/block.rst b/Help/command/block.rst index 9d37deb..dfd60d4 100644 --- a/Help/command/block.rst +++ b/Help/command/block.rst @@ -7,14 +7,14 @@ Evaluate a group of commands with a dedicated variable and/or policy scope. .. code-block:: cmake - block([SCOPE_FOR (POLICIES|VARIABLES)] [PROPAGATE <var-name>...]) + block([SCOPE_FOR [POLICIES] [VARIABLES] ] [PROPAGATE <var-name>...]) <commands> endblock() All commands between ``block()`` and the matching :command:`endblock` are recorded without being invoked. Once the :command:`endblock` is evaluated, the -recorded list of commands is invoked inside the requested scopes, and, finally, -the scopes created by ``block()`` command are removed. +recorded list of commands is invoked inside the requested scopes, then the +scopes created by the ``block()`` command are removed. ``SCOPE_FOR`` Specify which scopes must be created. @@ -33,28 +33,29 @@ the scopes created by ``block()`` command are removed. block(SCOPE_FOR VARIABLES POLICIES) ``PROPAGATE`` - When a variable scope is created by :command:`block` command, this option - set or unset the specified variables in the parent scope. This is equivalent - to :command:`set(PARENT_SCOPE)` or :command:`unset(PARENT_SCOPE)` commands. + When a variable scope is created by the :command:`block` command, this + option sets or unsets the specified variables in the parent scope. This is + equivalent to :command:`set(PARENT_SCOPE)` or :command:`unset(PARENT_SCOPE)` + commands. .. code-block:: cmake - set(VAR1 "INIT1") - set(VAR2 "INIT2") + set(var1 "INIT1") + set(var2 "INIT2") - block(PROPAGATE VAR1 VAR2) - set(VAR1 "VALUE1") - unset(VAR2) + block(PROPAGATE var1 var2) + set(var1 "VALUE1") + unset(var2) endblock() - # here, VAR1 holds value VALUE1 and VAR2 is unset + # Now var1 holds VALUE1, and var2 is unset This option is only allowed when a variable scope is created. An error will be raised in the other cases. -When the ``block`` is local to a :command:`foreach` or :command:`while` -command, the commands :command:`break` and :command:`continue` can be used -inside this block. +When the ``block()`` is inside a :command:`foreach` or :command:`while` +command, the :command:`break` and :command:`continue` commands can be used +inside the block. .. code-block:: cmake diff --git a/Help/command/continue.rst b/Help/command/continue.rst index f62802e..e8012ee 100644 --- a/Help/command/continue.rst +++ b/Help/command/continue.rst @@ -9,8 +9,8 @@ Continue to the top of enclosing foreach or while loop. continue() -The ``continue`` command allows a cmake script to abort the rest of a block -in a :command:`foreach` or :command:`while` loop, and start at the top of -the next iteration. +The ``continue()`` command allows a cmake script to abort the rest of the +current iteration of a :command:`foreach` or :command:`while` loop, and start +at the top of the next iteration. See also the :command:`break` command. diff --git a/Help/command/return.rst b/Help/command/return.rst index 029fd05..3013b52 100644 --- a/Help/command/return.rst +++ b/Help/command/return.rst @@ -7,46 +7,83 @@ Return from a file, directory or function. return([PROPAGATE <var-name>...]) -Returns from a file, directory or function. When this command is -encountered in an included file (via :command:`include` or +When this command is encountered in an included file (via :command:`include` or :command:`find_package`), it causes processing of the current file to stop and control is returned to the including file. If it is encountered in a -file which is not included by another file, e.g. a ``CMakeLists.txt``, +file which is not included by another file, e.g. a ``CMakeLists.txt``, deferred calls scheduled by :command:`cmake_language(DEFER)` are invoked and -control is returned to the parent directory if there is one. If return is -called in a function, control is returned to the caller of the function. +control is returned to the parent directory if there is one. + +If ``return()`` is called in a function, control is returned to the caller +of that function. Note that a :command:`macro`, unlike a :command:`function`, +is expanded in place and therefore cannot handle ``return()``. + +Policy :policy:`CMP0140` controls the behavior regarding the arguments of the +command. All arguments are ignored unless that policy is set to ``NEW``. ``PROPAGATE`` .. versionadded:: 3.25 - This option set or unset the specified variables in the parent directory or + This option sets or unsets the specified variables in the parent directory or function caller scope. This is equivalent to :command:`set(PARENT_SCOPE)` or - :command:`unset(PARENT_SCOPE)` commands. + :command:`unset(PARENT_SCOPE)` commands, except for the way it interacts + with the :command:`block` command, as described below. - The option ``PROPAGATE`` can be very useful in conjunction with the - :command:`block` command because the :command:`return` will cross over - various scopes created by the :command:`block` commands. + The ``PROPAGATE`` option can be very useful in conjunction with the + :command:`block` command. A :command:`return` will propagate the + specified variables through any enclosing block scopes created by the + :command:`block` commands. Inside a function, this ensures the variables + are propagated to the function's caller, regardless of any blocks within + the function. If not inside a function, it ensures the variables are + propagated to the parent file or directory scope. For example: .. code-block:: cmake + :caption: CMakeLists.txt + + cmake_version_required(VERSION 3.25) + project(example) + + set(var1 "top-value") + + block(SCOPE_FOR VARIABLES) + add_subdirectory(subDir) + # var1 has the value "block-nested" + endblock() - function(MULTI_SCOPES RESULT_VARIABLE) + # var1 has the value "top-value" + + .. code-block:: cmake + :caption: subDir/CMakeLists.txt + + function(multi_scopes result_var1 result_var2) block(SCOPE_FOR VARIABLES) - # here set(PARENT_SCOPE) is not usable because it will not set the - # variable in the caller scope but in the parent scope of the block() - set(${RESULT_VARIABLE} "new-value") - return(PROPAGATE ${RESULT_VARIABLE}) + # This would only propagate out of the immediate block, not to + # the caller of the function. + #set(${result_var1} "new-value" PARENT_SCOPE) + #unset(${result_var2} PARENT_SCOPE) + + # This propagates the variables through the enclosing block and + # out to the caller of the function. + set(${result_var1} "new-value") + unset(${result_var2}) + return(PROPAGATE ${result_var1} ${result_var2}) endblock() endfunction() - set(MY_VAR "initial-value") - multi_scopes(MY_VAR) - # here MY_VAR will holds "new-value" + set(var1 "some-value") + set(var2 "another-value") -Policy :policy:`CMP0140` controls the behavior regarding the arguments of the -command. + multi_scopes(var1 var2) + # Now var1 will hold "new-value" and var2 will be unset -Note that a :command:`macro <macro>`, unlike a :command:`function <function>`, -is expanded in place and therefore cannot handle ``return()``. + block(SCOPE_FOR VARIABLES) + # This return() will set var1 in the directory scope that included us + # via add_subdirectory(). The surrounding block() here does not limit + # propagation to the current file, but the block() in the parent + # directory scope does prevent propagation going any further. + set(var1 "block-nested") + return(PROPAGATE var1) + endblock() See Also ^^^^^^^^ diff --git a/Help/prop_tgt/MSVC_DEBUG_INFORMATION_FORMAT-VALUES.txt b/Help/prop_tgt/MSVC_DEBUG_INFORMATION_FORMAT-VALUES.txt index 889d97a..7f19bc0 100644 --- a/Help/prop_tgt/MSVC_DEBUG_INFORMATION_FORMAT-VALUES.txt +++ b/Help/prop_tgt/MSVC_DEBUG_INFORMATION_FORMAT-VALUES.txt @@ -8,8 +8,9 @@ Compile with ``-ZI`` or equivalent flag(s) to produce a program database that supports the Edit and Continue feature. -The value is ignored on non-MSVC compilers, but an unsupported value will -be rejected as an error when using a compiler targeting the MSVC ABI. +The value is ignored on compilers not targeting the MSVC ABI, but an +unsupported value will be rejected as an error when using a compiler +targeting the MSVC ABI. The value may also be the empty string (``""``), in which case no debug information format flag will be added explicitly by CMake. diff --git a/Help/prop_tgt/MSVC_RUNTIME_LIBRARY-VALUES.txt b/Help/prop_tgt/MSVC_RUNTIME_LIBRARY-VALUES.txt index 6c61341..5f8b82d 100644 --- a/Help/prop_tgt/MSVC_RUNTIME_LIBRARY-VALUES.txt +++ b/Help/prop_tgt/MSVC_RUNTIME_LIBRARY-VALUES.txt @@ -11,8 +11,9 @@ Compile with ``-MDd`` or equivalent flag(s) to use a multi-threaded dynamically-linked runtime library. -The value is ignored on non-MSVC compilers but an unsupported value will -be rejected as an error when using a compiler targeting the MSVC ABI. +The value is ignored on compilers not targeting the MSVC ABI, but an +unsupported value will be rejected as an error when using a compiler +targeting the MSVC ABI. The value may also be the empty string (``""``) in which case no runtime library selection flag will be added explicitly by CMake. Note that with diff --git a/Help/variable/CMAKE_TASKING_TOOLSET.rst b/Help/variable/CMAKE_TASKING_TOOLSET.rst index 940606b..6bd1479 100644 --- a/Help/variable/CMAKE_TASKING_TOOLSET.rst +++ b/Help/variable/CMAKE_TASKING_TOOLSET.rst @@ -8,12 +8,15 @@ Select the Tasking toolset which provides the compiler Architecture compilers are provided by different toolchains with incompatible versioning schemes. Set this variable in a :variable:`toolchain file <CMAKE_TOOLCHAIN_FILE>` so CMake can detect -the compiler and version correctly. If no toolset is specified, +the compiler features correctly. If no toolset is specified, ``Standalone`` is assumed. -Projects that can be built with different architectures and/or toolsets must -take :variable:`CMAKE_TASKING_TOOLSET` and -:variable:`CMAKE_<LANG>_COMPILER_ARCHITECTURE_ID` into account to qualify +Due to the different versioning schemes, the compiler version +(:variable:`CMAKE_<LANG>_COMPILER_VERSION`) depends on the toolset and +architecture in use. If projects can be built with multiple toolsets or +architectures, the specified :variable:`CMAKE_TASKING_TOOLSET` and the +automatically determined :variable:`CMAKE_<LANG>_COMPILER_ARCHITECTURE_ID` +must be taken into account when comparing against the :variable:`CMAKE_<LANG>_COMPILER_VERSION`. ``TriCore`` diff --git a/Modules/Compiler/Tasking.cmake b/Modules/Compiler/Tasking.cmake index 419db63..5bf066e 100644 --- a/Modules/Compiler/Tasking.cmake +++ b/Modules/Compiler/Tasking.cmake @@ -17,44 +17,12 @@ set(BUILD_SHARED_LIBS FALSE CACHE BOOL "") set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") set(CMAKE_LINK_SEARCH_START_STATIC TRUE) -function(__tasking_set_processor_list lang out_var) - execute_process(COMMAND "${CMAKE_${lang}_COMPILER}" --cpu-list - OUTPUT_VARIABLE processor_list - ERROR_VARIABLE processor_list) - string(REGEX MATCHALL " +([A-Za-z0-9_]+)[^\n]+\n" processor_list "${processor_list}") - list(POP_FRONT processor_list) - string(REGEX REPLACE " +([A-Za-z0-9_]+)[^\n]+\n" "\\1" processor_list "${processor_list}") - set(${out_var} "${processor_list}" PARENT_SCOPE) -endfunction() - -function(__tasking_check_processor processor list out_var) - string(TOLOWER "${processor}" processor) - if(processor IN_LIST list) - set(${out_var} TRUE PARENT_SCOPE) - else() - set(${out_var} FALSE PARENT_SCOPE) - endif() -endfunction() - if(NOT CMAKE_TASKING_TOOLSET) set(CMAKE_TASKING_TOOLSET "Standalone") endif() macro(__compiler_tasking lang) - if(CMAKE_SYSTEM_PROCESSOR) - if(NOT _TASKING_${lang}_PROCESSOR_LIST) - __tasking_set_processor_list(${lang} _TASKING_${lang}_PROCESSOR_LIST) - endif() - __tasking_check_processor(${CMAKE_SYSTEM_PROCESSOR} "${_TASKING_${lang}_PROCESSOR_LIST}" _TASKING_${lang}_VALID_PROCESSOR) - if(${_TASKING_${lang}_VALID_PROCESSOR}) - string(APPEND CMAKE_${lang}_FLAGS_INIT " -C${CMAKE_SYSTEM_PROCESSOR}") - else() - message(FATAL_ERROR "Invalid processor ${CMAKE_SYSTEM_PROCESSOR} specified.\n" - "Supported processors: ${_TASKING_${lang}_PROCESSOR_LIST}") - endif() - endif() - set(CMAKE_${lang}_VERBOSE_FLAG "-v") set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "--pic") set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Wl" " ") diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index 352c4cc..f66ffcf 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -404,6 +404,7 @@ if(WIN32 AND NOT CYGWIN) PATH_SUFFIXES "lib/MinGW" "lib" + "lib64" ) find_library(SSL_EAY @@ -414,6 +415,7 @@ if(WIN32 AND NOT CYGWIN) PATH_SUFFIXES "lib/MinGW" "lib" + "lib64" ) mark_as_advanced(SSL_EAY LIB_EAY) diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 3d38e73..e54ccfc 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -281,7 +281,7 @@ cmStateSnapshot cmState::Reset() it->CompileOptions.clear(); it->LinkOptions.clear(); it->LinkDirectories.clear(); - it->DirectoryEnd = pos; + it->CurrentScope = pos; it->NormalTargetNames.clear(); it->ImportedTargetNames.clear(); it->Properties.Clear(); @@ -819,7 +819,7 @@ cmStateSnapshot cmState::CreateBaseSnapshot() pos->CompileOptionsPosition = 0; pos->LinkOptionsPosition = 0; pos->LinkDirectoriesPosition = 0; - pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->BuildSystemDirectory->CurrentScope = pos; pos->Policies = this->PolicyStack.Root(); pos->PolicyRoot = this->PolicyStack.Root(); pos->PolicyScope = this->PolicyStack.Root(); @@ -846,7 +846,7 @@ cmStateSnapshot cmState::CreateBuildsystemDirectorySnapshot( originSnapshot.Position->BuildSystemDirectory); pos->ExecutionListFile = this->ExecutionListFiles.Push(originSnapshot.Position->ExecutionListFile); - pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->BuildSystemDirectory->CurrentScope = pos; pos->Policies = originSnapshot.Position->Policies; pos->PolicyRoot = originSnapshot.Position->Policies; pos->PolicyScope = originSnapshot.Position->Policies; @@ -876,7 +876,7 @@ cmStateSnapshot cmState::CreateDeferCallSnapshot( pos->ExecutionListFile = this->ExecutionListFiles.Push( originSnapshot.Position->ExecutionListFile, fileName); assert(originSnapshot.Position->Vars.IsValid()); - pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->BuildSystemDirectory->CurrentScope = pos; pos->PolicyScope = originSnapshot.Position->Policies; return { this, pos }; } @@ -891,7 +891,7 @@ cmStateSnapshot cmState::CreateFunctionCallSnapshot( pos->Keep = false; pos->ExecutionListFile = this->ExecutionListFiles.Push( originSnapshot.Position->ExecutionListFile, fileName); - pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->BuildSystemDirectory->CurrentScope = pos; pos->PolicyScope = originSnapshot.Position->Policies; assert(originSnapshot.Position->Vars.IsValid()); cmLinkedTree<cmDefinitions>::iterator origin = originSnapshot.Position->Vars; @@ -910,7 +910,7 @@ cmStateSnapshot cmState::CreateMacroCallSnapshot( pos->ExecutionListFile = this->ExecutionListFiles.Push( originSnapshot.Position->ExecutionListFile, fileName); assert(originSnapshot.Position->Vars.IsValid()); - pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->BuildSystemDirectory->CurrentScope = pos; pos->PolicyScope = originSnapshot.Position->Policies; return { this, pos }; } @@ -925,7 +925,7 @@ cmStateSnapshot cmState::CreateIncludeFileSnapshot( pos->ExecutionListFile = this->ExecutionListFiles.Push( originSnapshot.Position->ExecutionListFile, fileName); assert(originSnapshot.Position->Vars.IsValid()); - pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->BuildSystemDirectory->CurrentScope = pos; pos->PolicyScope = originSnapshot.Position->Policies; return { this, pos }; } @@ -938,6 +938,7 @@ cmStateSnapshot cmState::CreateVariableScopeSnapshot( pos->ScopeParent = originSnapshot.Position; pos->SnapshotType = cmStateEnums::VariableScopeType; pos->Keep = false; + pos->BuildSystemDirectory->CurrentScope = pos; pos->PolicyScope = originSnapshot.Position->Policies; assert(originSnapshot.Position->Vars.IsValid()); @@ -957,7 +958,7 @@ cmStateSnapshot cmState::CreateInlineListFileSnapshot( pos->Keep = true; pos->ExecutionListFile = this->ExecutionListFiles.Push( originSnapshot.Position->ExecutionListFile, fileName); - pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->BuildSystemDirectory->CurrentScope = pos; pos->PolicyScope = originSnapshot.Position->Policies; return { this, pos }; } @@ -969,7 +970,7 @@ cmStateSnapshot cmState::CreatePolicyScopeSnapshot( this->SnapshotData.Push(originSnapshot.Position, *originSnapshot.Position); pos->SnapshotType = cmStateEnums::PolicyScopeType; pos->Keep = false; - pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->BuildSystemDirectory->CurrentScope = pos; pos->PolicyScope = originSnapshot.Position->Policies; return { this, pos }; } @@ -989,7 +990,7 @@ cmStateSnapshot cmState::Pop(cmStateSnapshot const& originSnapshot) prevPos->BuildSystemDirectory->LinkOptions.size(); prevPos->LinkDirectoriesPosition = prevPos->BuildSystemDirectory->LinkDirectories.size(); - prevPos->BuildSystemDirectory->DirectoryEnd = prevPos; + prevPos->BuildSystemDirectory->CurrentScope = prevPos; if (!pos->Keep && this->SnapshotData.IsLast(pos)) { if (pos->Vars != prevPos->Vars) { diff --git a/Source/cmStatePrivate.h b/Source/cmStatePrivate.h index fd46eed..ec14834 100644 --- a/Source/cmStatePrivate.h +++ b/Source/cmStatePrivate.h @@ -62,7 +62,7 @@ struct cmStateDetail::PolicyStackEntry : public cmPolicies::PolicyMap struct cmStateDetail::BuildsystemDirectoryStateType { - cmStateDetail::PositionType DirectoryEnd; + cmStateDetail::PositionType CurrentScope; std::string Location; std::string OutputLocation; diff --git a/Source/cmStateSnapshot.cxx b/Source/cmStateSnapshot.cxx index c51650a..cb5f11f 100644 --- a/Source/cmStateSnapshot.cxx +++ b/Source/cmStateSnapshot.cxx @@ -64,7 +64,7 @@ bool cmStateSnapshot::IsValid() const cmStateSnapshot cmStateSnapshot::GetBuildsystemDirectory() const { - return { this->State, this->Position->BuildSystemDirectory->DirectoryEnd }; + return { this->State, this->Position->BuildSystemDirectory->CurrentScope }; } cmStateSnapshot cmStateSnapshot::GetBuildsystemDirectoryParent() const @@ -76,7 +76,7 @@ cmStateSnapshot cmStateSnapshot::GetBuildsystemDirectoryParent() const cmStateDetail::PositionType parentPos = this->Position->DirectoryParent; if (parentPos != this->State->SnapshotData.Root()) { snapshot = cmStateSnapshot(this->State, - parentPos->BuildSystemDirectory->DirectoryEnd); + parentPos->BuildSystemDirectory->CurrentScope); } return snapshot; @@ -177,9 +177,9 @@ cmPolicies::PolicyStatus cmStateSnapshot::GetPolicy(cmPolicies::PolicyID id, while (true) { assert(dir.IsValid()); cmLinkedTree<cmStateDetail::PolicyStackEntry>::iterator leaf = - dir->DirectoryEnd->Policies; + dir->CurrentScope->Policies; cmLinkedTree<cmStateDetail::PolicyStackEntry>::iterator root = - dir->DirectoryEnd->PolicyRoot; + dir->CurrentScope->PolicyRoot; for (; leaf != root; ++leaf) { if (parent_scope) { parent_scope = false; @@ -190,7 +190,7 @@ cmPolicies::PolicyStatus cmStateSnapshot::GetPolicy(cmPolicies::PolicyID id, return status; } } - cmStateDetail::PositionType e = dir->DirectoryEnd; + cmStateDetail::PositionType e = dir->CurrentScope; cmStateDetail::PositionType p = e->DirectoryParent; if (p == this->State->SnapshotData.Root()) { break; diff --git a/Tests/RunCMake/block/Scope-POLICIES.cmake b/Tests/RunCMake/block/Scope-POLICIES.cmake index 789b3d9..9536a99 100644 --- a/Tests/RunCMake/block/Scope-POLICIES.cmake +++ b/Tests/RunCMake/block/Scope-POLICIES.cmake @@ -2,6 +2,9 @@ set(VAR1 "OUTER1") set(VAR2 "OUTER2") +set(VARSUB1 "OUTERSUB1") +set(VARSUB2 "OUTERSUB2") + cmake_policy(SET CMP0139 NEW) # create a block with a new scope for policies @@ -9,6 +12,7 @@ block(SCOPE_FOR POLICIES) set(VAR1 "INNER1") unset(VAR2) set(VAR3 "INNER3") + add_subdirectory(Scope) cmake_policy(SET CMP0139 OLD) endblock() @@ -23,6 +27,12 @@ endif() if(NOT DEFINED VAR3 OR NOT VAR3 STREQUAL "INNER3") message(SEND_ERROR "block/endblock: VAR3 has unexpected value: ${VAR3}") endif() +if(NOT DEFINED VARSUB1 OR NOT VARSUB1 STREQUAL "SUBDIR1") + message(SEND_ERROR "block/endblock: VARSUB1 has unexpected value: ${VARSUB1}") +endif() +if(NOT DEFINED VARSUB2 OR NOT VARSUB2 STREQUAL "SUBDIR2") + message(SEND_ERROR "block/endblock: VARSUB2 has unexpected value: ${VARSUB2}") +endif() cmake_policy(GET CMP0139 CMP0139_STATUS) if(NOT CMP0139_STATUS STREQUAL "NEW") diff --git a/Tests/RunCMake/block/Scope-VARIABLES.cmake b/Tests/RunCMake/block/Scope-VARIABLES.cmake index 140e638..ac8da14 100644 --- a/Tests/RunCMake/block/Scope-VARIABLES.cmake +++ b/Tests/RunCMake/block/Scope-VARIABLES.cmake @@ -8,16 +8,20 @@ set(VAR5 "OUTER5") set(VAR6 "CACHE6" CACHE STRING "") set(VAR6 "OUTER6") +set(VARSUB1 "OUTERSUB1") +set(VARSUB2 "OUTERSUB2") + cmake_policy(SET CMP0139 NEW) # create a block with a new scope for variables -block(SCOPE_FOR VARIABLES PROPAGATE VAR3 VAR4 VAR5 VAR6 VAR7) +block(SCOPE_FOR VARIABLES PROPAGATE VAR3 VAR4 VAR5 VAR6 VAR7 VARSUB2) set(VAR1 "INNER1") set(VAR2 "INNER2" PARENT_SCOPE) set(VAR3 "INNER3") unset(VAR4) unset(VAR6) set(VAR7 "INNER7") + add_subdirectory(Scope) cmake_policy(SET CMP0139 OLD) endblock() @@ -45,6 +49,12 @@ endif() if(NOT DEFINED VAR7 OR NOT VAR7 STREQUAL "INNER7") message(SEND_ERROR "block/endblock: VAR7 has unexpected value: ${VAR7}") endif() +if(NOT DEFINED VARSUB1 OR NOT VARSUB1 STREQUAL "OUTERSUB1") + message(SEND_ERROR "block/endblock: VARSUB1 has unexpected value: ${VARSUB1}") +endif() +if(NOT DEFINED VARSUB2 OR NOT VARSUB2 STREQUAL "SUBDIR2") + message(SEND_ERROR "block/endblock: VARSUB2 has unexpected value: ${VARSUB2}") +endif() cmake_policy(GET CMP0139 CMP0139_STATUS) if(NOT CMP0139_STATUS STREQUAL "OLD") diff --git a/Tests/RunCMake/block/Scope.cmake b/Tests/RunCMake/block/Scope.cmake index e1af50a..ef43df6 100644 --- a/Tests/RunCMake/block/Scope.cmake +++ b/Tests/RunCMake/block/Scope.cmake @@ -8,16 +8,20 @@ set(VAR5 "OUTER5") set(VAR6 "CACHE6" CACHE STRING "") set(VAR6 "OUTER6") +set(VARSUB1 "OUTERSUB1") +set(VARSUB2 "OUTERSUB2") + cmake_policy(SET CMP0139 NEW) # create a block with a new scope for variables and policies -block(PROPAGATE VAR3 VAR4 VAR5 VAR6 VAR7) +block(PROPAGATE VAR3 VAR4 VAR5 VAR6 VAR7 VARSUB2) set(VAR1 "INNER1") set(VAR2 "INNER2" PARENT_SCOPE) set(VAR3 "INNER3") unset(VAR4) unset(VAR6) set(VAR7 "INNER7") + add_subdirectory(Scope) cmake_policy(SET CMP0139 OLD) endblock() @@ -45,6 +49,12 @@ endif() if(NOT DEFINED VAR7 OR NOT VAR7 STREQUAL "INNER7") message(SEND_ERROR "block/endblock: VAR6 has unexpected value: ${VAR7}") endif() +if(NOT DEFINED VARSUB1 OR NOT VARSUB1 STREQUAL "OUTERSUB1") + message(SEND_ERROR "block/endblock: VARSUB1 has unexpected value: ${VARSUB1}") +endif() +if(NOT DEFINED VARSUB2 OR NOT VARSUB2 STREQUAL "SUBDIR2") + message(SEND_ERROR "block/endblock: VARSUB2 has unexpected value: ${VARSUB2}") +endif() cmake_policy(GET CMP0139 CMP0139_STATUS) if(NOT CMP0139_STATUS STREQUAL "NEW") diff --git a/Tests/RunCMake/block/Scope/CMakeLists.txt b/Tests/RunCMake/block/Scope/CMakeLists.txt new file mode 100644 index 0000000..afd79e3 --- /dev/null +++ b/Tests/RunCMake/block/Scope/CMakeLists.txt @@ -0,0 +1,2 @@ +set(VARSUB1 "SUBDIR1" PARENT_SCOPE) +set(VARSUB2 "SUBDIR2" PARENT_SCOPE) |