summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitlab/ci/configure_windows_borland_common.cmake3
-rw-r--r--.gitlab/ci/configure_windows_openwatcom_common.cmake3
-rw-r--r--Help/command/export.rst131
-rw-r--r--Help/guide/importing-exporting/MathFunctionsComponents/Config.cmake.in4
-rw-r--r--Help/manual/cmake-packages.7.rst4
-rw-r--r--Help/manual/cmake-variables.7.rst1
-rw-r--r--Help/manual/cmake.1.rst9
-rw-r--r--Help/variable/CMAKE_PLATFORM_NO_VERSIONED_SONAME.rst14
-rw-r--r--Modules/FindMatlab.cmake2
-rw-r--r--Modules/FortranCInterface.cmake9
-rw-r--r--Modules/FortranCInterface/Detect.cmake10
-rw-r--r--Modules/GoogleTestAddTests.cmake41
-rw-r--r--Modules/Internal/CPack/CPackRPM.cmake2
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx7
-rw-r--r--Source/cmGlobalVisualStudio10Generator.h2
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx20
-rw-r--r--Source/cmGlobalVisualStudio7Generator.h2
-rw-r--r--Source/cmGlobalVisualStudio8Generator.cxx2
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx6
-rw-r--r--Source/cmGlobalVisualStudioGenerator.h3
-rw-r--r--Source/cmLocalVisualStudioGenerator.cxx2
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx256
-rw-r--r--Source/cmVisualStudio10TargetGenerator.h7
-rw-r--r--Source/cmVsProjectType.h3
-rw-r--r--Source/cmake.h2
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-discovery-check-test-list.cmake6
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-discovery-flush-script-check-list.cmake5
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTestDiscoveryFlushScript.cmake14
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTestDiscoveryTestList.cmake14
-rw-r--r--Tests/RunCMake/GoogleTest/RunCMakeTest.cmake54
-rw-r--r--Tests/RunCMake/GoogleTest/flush_script_test.cpp19
-rw-r--r--Tests/RunCMake/GoogleTest/test_list_test.cpp18
33 files changed, 546 insertions, 131 deletions
diff --git a/.gitlab/ci/configure_windows_borland_common.cmake b/.gitlab/ci/configure_windows_borland_common.cmake
index 6d66a05..55dce1d 100644
--- a/.gitlab/ci/configure_windows_borland_common.cmake
+++ b/.gitlab/ci/configure_windows_borland_common.cmake
@@ -1,2 +1,5 @@
+set(CMake_TEST_Java OFF CACHE BOOL "")
+
set(configure_no_sccache 1)
+
include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake")
diff --git a/.gitlab/ci/configure_windows_openwatcom_common.cmake b/.gitlab/ci/configure_windows_openwatcom_common.cmake
index 6d66a05..55dce1d 100644
--- a/.gitlab/ci/configure_windows_openwatcom_common.cmake
+++ b/.gitlab/ci/configure_windows_openwatcom_common.cmake
@@ -1,2 +1,5 @@
+set(CMake_TEST_Java OFF CACHE BOOL "")
+
set(configure_no_sccache 1)
+
include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake")
diff --git a/Help/command/export.rst b/Help/command/export.rst
index e8a1fa7..dc69645 100644
--- a/Help/command/export.rst
+++ b/Help/command/export.rst
@@ -1,44 +1,62 @@
export
------
-Export targets from the build tree for use by outside projects.
+Export targets or packages for outside projects to use them directly
+from the current project's build tree, without installation.
+
+See the :command:`install(EXPORT)` command to export targets from an
+install tree.
+
+Synopsis
+^^^^^^^^
+
+.. parsed-literal::
+
+ export(`TARGETS`_ <target>... [...])
+ export(`EXPORT`_ <export-name> [...])
+ export(`PACKAGE`_ <PackageName>)
+
+Exporting Targets
+^^^^^^^^^^^^^^^^^
+
+.. _`export(TARGETS)`:
+.. _TARGETS:
.. code-block:: cmake
- export(EXPORT <export-name> [NAMESPACE <namespace>] [FILE <filename>])
+ export(TARGETS <target>... [NAMESPACE <namespace>]
+ [APPEND] FILE <filename> [EXPORT_LINK_INTERFACE_LIBRARIES])
Creates a file ``<filename>`` that may be included by outside projects to
-import targets from the current project's build tree. This is useful
-during cross-compiling to build utility executables that can run on
-the host platform in one project and then import them into another
-project being compiled for the target platform. If the ``NAMESPACE``
-option is given the ``<namespace>`` string will be prepended to all target
-names written to the file.
-
-Target installations are associated with the export ``<export-name>``
-using the ``EXPORT`` option of the :command:`install(TARGETS)` command.
+import targets named by ``<target>...`` from the current project's build tree.
+This is useful during cross-compiling to build utility executables that can
+run on the host platform in one project and then import them into another
+project being compiled for the target platform.
The file created by this command is specific to the build tree and
should never be installed. See the :command:`install(EXPORT)` command to
-export targets from an installation tree.
+export targets from an install tree.
-The properties set on the generated IMPORTED targets will have the
-same values as the final values of the input TARGETS.
+The options are:
-.. code-block:: cmake
+``NAMESPACE <namespace>``
+ Prepend the ``<namespace>`` string to all target names written to the file.
- export(TARGETS [target1 [target2 [...]]] [NAMESPACE <namespace>]
- [APPEND] FILE <filename> [EXPORT_LINK_INTERFACE_LIBRARIES])
+``APPEND``
+ Append to the file instead of overwriting it. This can be used to
+ incrementally export multiple targets to the same file.
+
+``EXPORT_LINK_INTERFACE_LIBRARIES``
+ Include the contents of the properties named with the pattern
+ ``(IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)?``
+ in the export, even when policy :policy:`CMP0022` is NEW. This is useful
+ to support consumers using CMake versions older than 2.8.12.
-This signature is similar to the ``EXPORT`` signature, but targets are listed
-explicitly rather than specified as an export-name. If the APPEND option is
-given the generated code will be appended to the file instead of overwriting it.
-The EXPORT_LINK_INTERFACE_LIBRARIES keyword, if present, causes the
-contents of the properties matching
-``(IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)?`` to be exported, when
-policy CMP0022 is NEW. If a library target is included in the export
-but a target to which it links is not included the behavior is
-unspecified.
+This signature requires all targets to be listed explicitly. If a library
+target is included in the export, but a target to which it links is not
+included, the behavior is unspecified. See the `export(EXPORT)`_ signature
+to automatically export the same targets from the build tree as
+:command:`install(EXPORT)` would from an install tree.
.. note::
@@ -49,6 +67,50 @@ unspecified.
transitive usage requirements of other targets that link to the
object libraries in their implementation.
+Exporting Targets to Android.mk
+"""""""""""""""""""""""""""""""
+
+.. code-block:: cmake
+
+ export(TARGETS <target>... ANDROID_MK <filename>)
+
+.. versionadded:: 3.7
+
+This signature exports cmake built targets to the android ndk build system
+by creating an ``Android.mk`` file that references the prebuilt targets. The
+Android NDK supports the use of prebuilt libraries, both static and shared.
+This allows cmake to build the libraries of a project and make them available
+to an ndk build system complete with transitive dependencies, include flags
+and defines required to use the libraries. The signature takes a list of
+targets and puts them in the ``Android.mk`` file specified by the
+``<filename>`` given. This signature can only be used if policy
+:policy:`CMP0022` is NEW for all targets given. A error will be issued if
+that policy is set to OLD for one of the targets.
+
+Exporting Targets matching install(EXPORT)
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. _`export(EXPORT)`:
+.. _EXPORT:
+
+.. code-block:: cmake
+
+ export(EXPORT <export-name> [NAMESPACE <namespace>] [FILE <filename>])
+
+Creates a file ``<filename>`` that may be included by outside projects to
+import targets from the current project's build tree. This is the same
+as the `export(TARGETS)`_ signature, except that the targets are not
+explicitly listed. Instead, it exports the targets associated with
+the installation export ``<export-name>``. Target installations may be
+associated with the export ``<export-name>`` using the ``EXPORT`` option
+of the :command:`install(TARGETS)` command.
+
+Exporting Packages
+^^^^^^^^^^^^^^^^^^
+
+.. _`export(PACKAGE)`:
+.. _PACKAGE:
+
.. code-block:: cmake
export(PACKAGE <PackageName>)
@@ -74,20 +136,3 @@ registry.
outside the source and build trees. Set the
:variable:`CMAKE_EXPORT_PACKAGE_REGISTRY` variable to add build directories
to the CMake user package registry.
-
-.. code-block:: cmake
-
- export(TARGETS [target1 [target2 [...]]] [ANDROID_MK <filename>])
-
-.. versionadded:: 3.7
-
-This signature exports cmake built targets to the android ndk build system
-by creating an Android.mk file that references the prebuilt targets. The
-Android NDK supports the use of prebuilt libraries, both static and shared.
-This allows cmake to build the libraries of a project and make them available
-to an ndk build system complete with transitive dependencies, include flags
-and defines required to use the libraries. The signature takes a list of
-targets and puts them in the Android.mk file specified by the ``<filename>``
-given. This signature can only be used if policy CMP0022 is NEW for all
-targets given. A error will be issued if that policy is set to OLD for one
-of the targets.
diff --git a/Help/guide/importing-exporting/MathFunctionsComponents/Config.cmake.in b/Help/guide/importing-exporting/MathFunctionsComponents/Config.cmake.in
index 09f6c35..a535969 100644
--- a/Help/guide/importing-exporting/MathFunctionsComponents/Config.cmake.in
+++ b/Help/guide/importing-exporting/MathFunctionsComponents/Config.cmake.in
@@ -1,9 +1,9 @@
@PACKAGE_INIT@
-set(_supported_components Addition SquareRoot)
+set(_MathFunctions_supported_components Addition SquareRoot)
foreach(_comp ${MathFunctions_FIND_COMPONENTS})
- if (NOT _comp IN_LIST _supported_components)
+ if (NOT _comp IN_LIST _MathFunctions_supported_components)
set(MathFunctions_FOUND False)
set(MathFunctions_NOT_FOUND_MESSAGE "Unsupported component: ${_comp}")
endif()
diff --git a/Help/manual/cmake-packages.7.rst b/Help/manual/cmake-packages.7.rst
index 5c109ff..ed85dc4 100644
--- a/Help/manual/cmake-packages.7.rst
+++ b/Help/manual/cmake-packages.7.rst
@@ -446,10 +446,10 @@ be true. This can be tested with logic in the package configuration file:
include("${CMAKE_CURRENT_LIST_DIR}/ClimbingStatsTargets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/ClimbingStatsMacros.cmake")
- set(_supported_components Plot Table)
+ set(_ClimbingStats_supported_components Plot Table)
foreach(_comp ${ClimbingStats_FIND_COMPONENTS})
- if (NOT ";${_supported_components};" MATCHES ";${_comp};")
+ if (NOT ";${_ClimbingStats_supported_components};" MATCHES ";${_comp};")
set(ClimbingStats_FOUND False)
set(ClimbingStats_NOT_FOUND_MESSAGE "Unsupported component: ${_comp}")
endif()
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index 86e4d4c..5db622c 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -476,6 +476,7 @@ Variables that Control the Build
/variable/CMAKE_PCH_INSTANTIATE_TEMPLATES
/variable/CMAKE_PDB_OUTPUT_DIRECTORY
/variable/CMAKE_PDB_OUTPUT_DIRECTORY_CONFIG
+ /variable/CMAKE_PLATFORM_NO_VERSIONED_SONAME
/variable/CMAKE_POSITION_INDEPENDENT_CODE
/variable/CMAKE_RUNTIME_OUTPUT_DIRECTORY
/variable/CMAKE_RUNTIME_OUTPUT_DIRECTORY_CONFIG
diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst
index 37cf7d8..a584141 100644
--- a/Help/manual/cmake.1.rst
+++ b/Help/manual/cmake.1.rst
@@ -250,16 +250,17 @@ Options
See also the :variable:`CMAKE_FIND_DEBUG_MODE` variable for debugging
a more local part of the project.
-``--debug-find=<pkg>[,...]``
+``--debug-find-pkg=<pkg>[,...]``
Put cmake find commands in a debug mode when running under calls
- to ``find_package(<pkg>)``, where ``<pkg>`` is an entry in the given
- comma-separated list of case-sensitive package names.
+ to :command:`find_package(\<pkg\>) <find_package>`, where ``<pkg>``
+ is an entry in the given comma-separated list of case-sensitive package
+ names.
Like ``--debug-find``, but limiting scope to the specified packages.
``--debug-find-var=<var>[,...]``
Put cmake find commands in a debug mode when called with ``<var>``
- as the return variable, where ``<var>`` is an entry in the given
+ as the result variable, where ``<var>`` is an entry in the given
comma-separated list.
Like ``--debug-find``, but limiting scope to the specified variable names.
diff --git a/Help/variable/CMAKE_PLATFORM_NO_VERSIONED_SONAME.rst b/Help/variable/CMAKE_PLATFORM_NO_VERSIONED_SONAME.rst
new file mode 100644
index 0000000..bf15fc8
--- /dev/null
+++ b/Help/variable/CMAKE_PLATFORM_NO_VERSIONED_SONAME.rst
@@ -0,0 +1,14 @@
+CMAKE_PLATFORM_NO_VERSIONED_SONAME
+----------------------------------
+
+.. versionadded:: 3.1
+
+This variable is used to globally control whether the
+:prop_tgt:`VERSION` and :prop_tgt:`SOVERSION` target
+properties should be used for shared libraries.
+When set to true, adding version information to each
+shared library target is disabled.
+
+By default this variable is set only on platforms where
+CMake knows it is needed. On other platforms, the
+specified properties will be used for shared libraries.
diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake
index 0ca593e..f0e991b 100644
--- a/Modules/FindMatlab.cmake
+++ b/Modules/FindMatlab.cmake
@@ -1353,7 +1353,7 @@ function(_Matlab_get_version_from_root matlab_root matlab_or_mcr matlab_known_ve
${versioninfo_string}
)
- if(CMAKE_MATCH_1 MATCHES "(([0-9])\\.([0-9]))[\\.0-9]*")
+ if(CMAKE_MATCH_1 MATCHES "(([0-9]+)\\.([0-9]+))[\\.0-9]*")
set(_matlab_version_tmp "${CMAKE_MATCH_1}")
endif()
endif()
diff --git a/Modules/FortranCInterface.cmake b/Modules/FortranCInterface.cmake
index 733c723..53df01a 100644
--- a/Modules/FortranCInterface.cmake
+++ b/Modules/FortranCInterface.cmake
@@ -343,6 +343,14 @@ function(FortranCInterface_VERIFY)
set(_desc "Verifying Fortran/${lang} Compiler Compatibility")
message(CHECK_START "${_desc}")
+ # Perform verification with only one architecture.
+ # FIXME: Add try_compile whole-project option to forward architectures.
+ if(CMAKE_OSX_ARCHITECTURES MATCHES "^([^;]+)(;|$)")
+ set(_FortranCInterface_OSX_ARCH "-DCMAKE_OSX_ARCHITECTURES=${CMAKE_MATCH_1}")
+ else()
+ set(_FortranCInterface_OSX_ARCH "")
+ endif()
+
cmake_policy(GET CMP0056 _FortranCInterface_CMP0056)
if(_FortranCInterface_CMP0056 STREQUAL "NEW")
set(_FortranCInterface_EXE_LINKER_FLAGS "-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_EXE_LINKER_FLAGS}")
@@ -365,6 +373,7 @@ function(FortranCInterface_VERIFY)
"-DCMAKE_C_FLAGS_RELEASE:STRING=${CMAKE_C_FLAGS_RELEASE}"
"-DCMAKE_CXX_FLAGS_RELEASE:STRING=${CMAKE_CXX_FLAGS_RELEASE}"
"-DCMAKE_Fortran_FLAGS_RELEASE:STRING=${CMAKE_Fortran_FLAGS_RELEASE}"
+ ${_FortranCInterface_OSX_ARCH}
${_FortranCInterface_EXE_LINKER_FLAGS}
OUTPUT_VARIABLE _output)
file(WRITE "${FortranCInterface_BINARY_DIR}/Verify${lang}/output.txt" "${_output}")
diff --git a/Modules/FortranCInterface/Detect.cmake b/Modules/FortranCInterface/Detect.cmake
index 4d3cb00..72e5544 100644
--- a/Modules/FortranCInterface/Detect.cmake
+++ b/Modules/FortranCInterface/Detect.cmake
@@ -28,6 +28,14 @@ unset(FortranCInterface_VERIFIED_CXX CACHE)
set(_result)
+# Perform detection with only one architecture so that
+# the info strings are not repeated.
+if(CMAKE_OSX_ARCHITECTURES MATCHES "^([^;]+)(;|$)")
+ set(_FortranCInterface_OSX_ARCH "-DCMAKE_OSX_ARCHITECTURES=${CMAKE_MATCH_1}")
+else()
+ set(_FortranCInterface_OSX_ARCH "")
+endif()
+
cmake_policy(GET CMP0056 _FortranCInterface_CMP0056)
if(_FortranCInterface_CMP0056 STREQUAL "NEW")
set(_FortranCInterface_EXE_LINKER_FLAGS "-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_EXE_LINKER_FLAGS}")
@@ -48,11 +56,13 @@ try_compile(FortranCInterface_COMPILED
"-DCMAKE_Fortran_FLAGS:STRING=${CMAKE_Fortran_FLAGS}"
"-DCMAKE_C_FLAGS_RELEASE:STRING=${CMAKE_C_FLAGS_RELEASE}"
"-DCMAKE_Fortran_FLAGS_RELEASE:STRING=${CMAKE_Fortran_FLAGS_RELEASE}"
+ ${_FortranCInterface_OSX_ARCH}
${_FortranCInterface_EXE_LINKER_FLAGS}
OUTPUT_VARIABLE FortranCInterface_OUTPUT)
set(FortranCInterface_COMPILED ${FortranCInterface_COMPILED})
unset(FortranCInterface_COMPILED CACHE)
unset(_FortranCInterface_EXE_LINKER_FLAGS)
+unset(_FortranCInterface_OSX_ARCH)
# Locate the sample project executable.
set(FortranCInterface_EXE)
diff --git a/Modules/GoogleTestAddTests.cmake b/Modules/GoogleTestAddTests.cmake
index cef2e8a..2bd0cc9 100644
--- a/Modules/GoogleTestAddTests.cmake
+++ b/Modules/GoogleTestAddTests.cmake
@@ -9,7 +9,7 @@ set(flush_tests_MODE WRITE)
# Flushes script to ${_CTEST_FILE}
macro(flush_script)
file(${flush_tests_MODE} "${_CTEST_FILE}" "${script}")
- set(flush_tests_MODE APPEND)
+ set(flush_tests_MODE APPEND PARENT_SCOPE)
set(script "")
endmacro()
@@ -20,24 +20,22 @@ macro(flush_tests_buffer)
set(tests_buffer "")
endmacro()
-macro(add_command NAME TEST_NAME)
- set(_args "")
- foreach(_arg ${ARGN})
- if(_arg MATCHES "[^-./:a-zA-Z0-9_]")
- string(APPEND _args " [==[${_arg}]==]")
+function(add_command NAME TEST_NAME)
+ set(args "")
+ foreach(arg ${ARGN})
+ if(arg MATCHES "[^-./:a-zA-Z0-9_]")
+ string(APPEND args " [==[${arg}]==]")
else()
- string(APPEND _args " ${_arg}")
+ string(APPEND args " ${arg}")
endif()
endforeach()
- string(APPEND script "${NAME}(${TEST_NAME} ${_args})\n")
- string(LENGTH "${script}" _script_len)
- if(${_script_len} GREATER "50000")
+ string(APPEND script "${NAME}(${TEST_NAME} ${args})\n")
+ string(LENGTH "${script}" script_len)
+ if(${script_len} GREATER "50000")
flush_script()
endif()
- # Unsets macro local variables to prevent leakage outside of this macro.
- unset(_args)
- unset(_script_len)
-endmacro()
+ set(script "${script}" PARENT_SCOPE)
+endfunction()
function(generate_testname_guards OUTPUT OPEN_GUARD_VAR CLOSE_GUARD_VAR)
set(open_guard "[=[")
@@ -164,7 +162,6 @@ function(gtest_discover_tests_impl)
endif()
string(CONFIGURE "${test_name_template}" testname)
- # sanitize test name for further processing downstream
# unescape []
if(open_sb)
string(REPLACE "${open_sb}" "[" testname "${testname}")
@@ -172,13 +169,9 @@ function(gtest_discover_tests_impl)
if(close_sb)
string(REPLACE "${close_sb}" "]" testname "${testname}")
endif()
- # escape \
- string(REPLACE [[\]] [[\\]] testname "${testname}")
- # escape $
- string(REPLACE [[$]] [[\$]] testname "${testname}")
set(guarded_testname "${open_guard}${testname}${close_guard}")
- # ...and add to script
+ # add to script
add_command(add_test
"${guarded_testname}"
${_TEST_EXECUTOR}
@@ -199,14 +192,14 @@ function(gtest_discover_tests_impl)
"${guarded_testname}"
PROPERTIES
WORKING_DIRECTORY "${_TEST_WORKING_DIR}"
- SKIP_REGULAR_EXPRESSION "\\\\[ SKIPPED \\\\]"
+ SKIP_REGULAR_EXPRESSION "\\[ SKIPPED \\]"
${properties}
)
- # possibly unbalanced square brackets render lists invalid so skip such tests in _TEST_LIST
+ # possibly unbalanced square brackets render lists invalid so skip such tests in ${_TEST_LIST}
if(NOT "${testname}" MATCHES [=[(\[|\])]=])
# escape ;
- string(REPLACE [[;]] [[\;]] testname "${testname}")
+ string(REPLACE [[;]] [[\\;]] testname "${testname}")
list(APPEND tests_buffer "${testname}")
list(LENGTH tests_buffer tests_buffer_length)
if(${tests_buffer_length} GREATER "250")
@@ -221,7 +214,7 @@ function(gtest_discover_tests_impl)
# Create a list of all discovered tests, which users may use to e.g. set
# properties on the tests
flush_tests_buffer()
- add_command(set "" ${_TEST_LIST} ${tests})
+ add_command(set "" ${_TEST_LIST} "${tests}")
# Write CTest script
flush_script()
diff --git a/Modules/Internal/CPack/CPackRPM.cmake b/Modules/Internal/CPack/CPackRPM.cmake
index c72bf6d..cd631b8 100644
--- a/Modules/Internal/CPack/CPackRPM.cmake
+++ b/Modules/Internal/CPack/CPackRPM.cmake
@@ -790,7 +790,7 @@ function(cpack_rpm_variable_fallback OUTPUT_VAR_NAME)
set(FALLBACK_VAR_NAMES ${ARGN})
foreach(variable_name IN LISTS FALLBACK_VAR_NAMES)
- if(${variable_name})
+ if(DEFINED ${variable_name})
set(${OUTPUT_VAR_NAME} "${${variable_name}}" PARENT_SCOPE)
break()
endif()
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 2e1b9fd..c155a03 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,7 +1,7 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 23)
-set(CMake_VERSION_PATCH 20220211)
+set(CMake_VERSION_PATCH 20220216)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index a96f6f0..3301e8c 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -1286,6 +1286,13 @@ cmGlobalVisualStudio10Generator::GenerateBuildCommand(
return makeCommands;
}
+bool cmGlobalVisualStudio10Generator::IsInSolution(
+ const cmGeneratorTarget* gt) const
+{
+ return gt->IsInBuildSystem() &&
+ gt->GetName() != CMAKE_CHECK_BUILD_SYSTEM_TARGET;
+}
+
bool cmGlobalVisualStudio10Generator::Find64BitTools(cmMakefile* mf)
{
if (this->DefaultPlatformToolset == "v100") {
diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h
index 4977a84..2203f71 100644
--- a/Source/cmGlobalVisualStudio10Generator.h
+++ b/Source/cmGlobalVisualStudio10Generator.h
@@ -118,6 +118,8 @@ public:
return this->WindowsTargetPlatformVersion;
}
+ bool IsInSolution(const cmGeneratorTarget* gt) const override;
+
/** Return true if building for WindowsCE */
bool TargetsWindowsCE() const override { return this->SystemIsWindowsCE; }
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index 134937e..1c10fb3 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -359,7 +359,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
// loop over again and write out configurations for each target
// in the solution
for (cmGeneratorTarget const* target : projectTargets) {
- if (!target->IsInBuildSystem()) {
+ if (!this->IsInSolution(target)) {
continue;
}
cmValue expath = target->GetProperty("EXTERNAL_MSPROJECT");
@@ -396,7 +396,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
VisualStudioFolders.clear();
for (cmGeneratorTarget const* target : projectTargets) {
- if (!target->IsInBuildSystem()) {
+ if (!this->IsInSolution(target)) {
continue;
}
bool written = false;
@@ -458,22 +458,6 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
}
}
-void cmGlobalVisualStudio7Generator::WriteTargetDepends(
- std::ostream& fout, OrderedTargetDependSet const& projectTargets)
-{
- for (cmGeneratorTarget const* target : projectTargets) {
- if (!target->IsInBuildSystem()) {
- continue;
- }
- cmValue vcprojName = target->GetProperty("GENERATOR_FILE_NAME");
- if (vcprojName) {
- std::string dir =
- target->GetLocalGenerator()->GetCurrentSourceDirectory();
- this->WriteProjectDepends(fout, *vcprojName, dir, target);
- }
- }
-}
-
void cmGlobalVisualStudio7Generator::WriteFolders(std::ostream& fout)
{
cm::string_view const prefix = "CMAKE_FOLDER_GUID_";
diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h
index 33f1063..a55cf45 100644
--- a/Source/cmGlobalVisualStudio7Generator.h
+++ b/Source/cmGlobalVisualStudio7Generator.h
@@ -148,8 +148,6 @@ protected:
virtual void WriteTargetsToSolution(
std::ostream& fout, cmLocalGenerator* root,
OrderedTargetDependSet const& projectTargets);
- virtual void WriteTargetDepends(
- std::ostream& fout, OrderedTargetDependSet const& projectTargets);
virtual void WriteTargetConfigurations(
std::ostream& fout, std::vector<std::string> const& configs,
OrderedTargetDependSet const& projectTargets);
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index dbd2de9..323ee67 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -392,7 +392,7 @@ void cmGlobalVisualStudio8Generator::WriteProjectDepends(
TargetDependSet const& unordered = this->GetTargetDirectDepends(gt);
OrderedTargetDependSet depends(unordered, std::string());
for (cmTargetDepend const& i : depends) {
- if (!i->IsInBuildSystem()) {
+ if (!this->IsInSolution(i)) {
continue;
}
std::string guid = this->GetGUID(i->GetName());
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index 141b5eb..cddaaa4 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -837,6 +837,12 @@ bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly(
return languages.size() == 1 && *languages.begin() == "Fortran";
}
+bool cmGlobalVisualStudioGenerator::IsInSolution(
+ const cmGeneratorTarget* gt) const
+{
+ return gt->IsInBuildSystem();
+}
+
bool cmGlobalVisualStudioGenerator::TargetCompare::operator()(
cmGeneratorTarget const* l, cmGeneratorTarget const* r) const
{
diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h
index cb1b14b..4f5f100 100644
--- a/Source/cmGlobalVisualStudioGenerator.h
+++ b/Source/cmGlobalVisualStudioGenerator.h
@@ -98,6 +98,9 @@ public:
// return true if target is fortran only
bool TargetIsFortranOnly(const cmGeneratorTarget* gt);
+ // return true if target should be included in solution.
+ virtual bool IsInSolution(const cmGeneratorTarget* gt) const;
+
/** Get the top-level registry key for this VS version. */
std::string GetRegistryBase();
diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx
index 93f01ed..2703c7b 100644
--- a/Source/cmLocalVisualStudioGenerator.cxx
+++ b/Source/cmLocalVisualStudioGenerator.cxx
@@ -252,7 +252,7 @@ std::string cmLocalVisualStudioGenerator::FinishConstructScript(
// Store the script in a string.
std::string script;
- if (useLocal && projectType == VsProjectType::csproj) {
+ if (useLocal && projectType != VsProjectType::vcxproj) {
// This label is not provided by MSBuild for C# projects.
script += newline;
script += this->GetReportErrorLabel();
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index a79337b..be1b0de 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -50,6 +50,40 @@
#include "cmValue.h"
#include "cmVisualStudioGeneratorOptions.h"
+namespace {
+std::string getProjectFileExtension(VsProjectType projectType)
+{
+ switch (projectType) {
+ case VsProjectType::csproj:
+ return ".csproj";
+ case VsProjectType::proj:
+ return ".proj";
+ case VsProjectType::vcxproj:
+ return ".vcxproj";
+ // Valid inputs shouldn't reach here. This default is needed so that all
+ // paths return value (C4715).
+ default:
+ return "";
+ }
+}
+
+VsProjectType computeProjectType(cmGeneratorTarget const* t)
+{
+ if (t->GetName() == CMAKE_CHECK_BUILD_SYSTEM_TARGET) {
+ return VsProjectType::proj;
+ }
+ if (t->IsCSharpOnly()) {
+ return VsProjectType::csproj;
+ }
+ return VsProjectType::vcxproj;
+}
+
+std::string computeProjectFileExtension(cmGeneratorTarget const* t)
+{
+ return getProjectFileExtension(computeProjectType(t));
+}
+}
+
struct cmIDEFlagTable;
static void ConvertToWindowsSlash(std::string& s);
@@ -235,29 +269,6 @@ static bool cmVS10IsTargetsFile(std::string const& path)
return cmSystemTools::Strucmp(ext.c_str(), ".targets") == 0;
}
-static VsProjectType computeProjectType(cmGeneratorTarget const* t)
-{
- if (t->IsCSharpOnly()) {
- return VsProjectType::csproj;
- }
- return VsProjectType::vcxproj;
-}
-
-static std::string computeProjectFileExtension(VsProjectType projectType)
-{
- switch (projectType) {
- case VsProjectType::csproj:
- return ".csproj";
- default:
- return ".vcxproj";
- }
-}
-
-static std::string computeProjectFileExtension(cmGeneratorTarget const* t)
-{
- return computeProjectFileExtension(computeProjectType(t));
-}
-
cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator(
cmGeneratorTarget* target, cmGlobalVisualStudio10Generator* gg)
: GeneratorTarget(target)
@@ -355,7 +366,7 @@ void cmVisualStudio10TargetGenerator::Generate()
this->ProjectType = computeProjectType(this->GeneratorTarget);
this->Managed = this->ProjectType == VsProjectType::csproj;
const std::string ProjectFileExtension =
- computeProjectFileExtension(this->ProjectType);
+ getProjectFileExtension(this->ProjectType);
if (this->ProjectType == VsProjectType::csproj &&
this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY) {
@@ -416,10 +427,12 @@ void cmVisualStudio10TargetGenerator::Generate()
char magic[] = { char(0xEF), char(0xBB), char(0xBF) };
BuildFileStream.write(magic, 3);
- if (this->ProjectType == VsProjectType::csproj &&
- this->GeneratorTarget->IsDotNetSdkTarget() &&
- this->GlobalGenerator->GetVersion() >=
- cmGlobalVisualStudioGenerator::VSVersion::VS16) {
+ if (this->ProjectType == VsProjectType::proj) {
+ this->WriteZeroCheckProj(BuildFileStream);
+ } else if (this->ProjectType == VsProjectType::csproj &&
+ this->GeneratorTarget->IsDotNetSdkTarget() &&
+ this->GlobalGenerator->GetVersion() >=
+ cmGlobalVisualStudioGenerator::VSVersion::VS16) {
this->WriteSdkStyleProjectFile(BuildFileStream);
} else {
this->WriteClassicMsBuildProjectFile(BuildFileStream);
@@ -681,6 +694,8 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile(
.Attribute("Project", VS10_CSharp_DEFAULT_PROPS)
.Attribute("Condition", "Exists('" VS10_CSharp_DEFAULT_PROPS "')");
break;
+ default:
+ break;
}
this->WriteProjectConfigurationValues(e0);
@@ -737,6 +752,8 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile(
case VsProjectType::csproj:
props = VS10_CSharp_USER_PROPS;
break;
+ default:
+ break;
}
if (cmValue p = this->GeneratorTarget->GetProperty("VS_USER_PROPS")) {
props = *p;
@@ -779,6 +796,8 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile(
Elem(e0, "Import").Attribute("Project", VS10_CSharp_TARGETS);
}
break;
+ default:
+ break;
}
this->WriteTargetSpecificReferences(e0);
@@ -944,6 +963,45 @@ void cmVisualStudio10TargetGenerator::WriteSdkStyleProjectFile(
this->WriteProjectReferences(e0);
}
+void cmVisualStudio10TargetGenerator::WriteZeroCheckProj(
+ cmGeneratedFileStream& BuildFileStream)
+{
+ // ZERO_CHECK.proj is an XML file without any imports or targets. This is a
+ // ProjectReference for other targets and therefore, it needs to follow the
+ // ProjectReference protocol as documented here:
+ // https://github.com/dotnet/msbuild/blob/main/documentation/ProjectReference-Protocol.md
+ //
+ // We implement MSBuild target Build from WriteCustomCommand which calls
+ // WriteZeroCheckBuildTarget after setting up the command generator. MSBuild
+ // target Clean is a no-op as we do all the work for ZERO_CHECK on Build.
+ // MSBuild target GetTargetPath is needed and is no-op.
+ // MSBuild targets GetNativeManifest and GetCopyToOutputDirectoryItems are
+ // needed for MSBuild versions below 15.7 and are no-op. MSBuild target
+ // BeforeBuild is needed for supporting GLOBs.
+ BuildFileStream << "<?xml version=\"1.0\" encoding=\""
+ << this->GlobalGenerator->Encoding() << "\"?>";
+ {
+ Elem e0(BuildFileStream, "Project");
+ e0.Attribute("DefaultTargets", "Build");
+ e0.Attribute("ToolsVersion", this->GlobalGenerator->GetToolsVersion());
+ e0.Attribute("xmlns",
+ "http://schemas.microsoft.com/developer/msbuild/2003");
+
+ this->WriteCustomCommands(e0);
+
+ for (const char* targetName :
+ { "Clean", "GetTargetPath", "GetNativeManifest",
+ "GetCopyToOutputDirectoryItems" }) {
+ {
+ Elem e1(e0, "Target");
+ e1.Attribute("Name", targetName);
+ }
+ }
+
+ this->WriteZeroCheckBeforeBuildTarget(e0);
+ }
+}
+
void cmVisualStudio10TargetGenerator::WriteCommonPropertyGroupGlobals(Elem& e1)
{
e1.Attribute("Label", "Globals");
@@ -1659,11 +1717,16 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule(
}
}
}
+ if (this->ProjectType == VsProjectType::proj) {
+ this->WriteZeroCheckBuildTarget(e0, command, source);
+ return;
+ }
+
cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
std::unique_ptr<Elem> spe1;
std::unique_ptr<Elem> spe2;
- if (this->ProjectType != VsProjectType::csproj) {
+ if (this->ProjectType == VsProjectType::vcxproj) {
spe1 = cm::make_unique<Elem>(e0, "ItemGroup");
spe2 = cm::make_unique<Elem>(*spe1, "CustomBuild");
this->WriteSource(*spe2, source);
@@ -3016,6 +3079,134 @@ void cmVisualStudio10TargetGenerator::OutputLinkIncremental(
}
}
+void cmVisualStudio10TargetGenerator::WriteZeroCheckBuildTarget(
+ cmVisualStudio10TargetGenerator::Elem& e0, const cmCustomCommand& command,
+ const cmSourceFile* source)
+{
+ cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
+
+ Elem e1(e0, "Target");
+ e1.Attribute("Name", "Build");
+
+ std::string noConfig{};
+ cmCustomCommandGenerator ccg{ command, noConfig, lg, true };
+ std::string comment = lg->ConstructComment(ccg);
+ comment = cmVS10EscapeComment(comment);
+ std::string script = lg->ConstructScript(ccg);
+ bool symbolic = false;
+ // input files for custom command
+ std::stringstream additional_inputs;
+ {
+ const char* sep = "";
+ if (this->ProjectType == VsProjectType::proj) {
+ // List explicitly the path to primary input.
+ std::string sourceFullPath = source->GetFullPath();
+ ConvertToWindowsSlash(sourceFullPath);
+ additional_inputs << sourceFullPath;
+ sep = ";";
+ }
+
+ // Avoid listing an input more than once.
+ std::set<std::string> unique_inputs;
+ // The source is either implicitly an input or has been added above.
+ unique_inputs.insert(source->GetFullPath());
+
+ for (std::string const& d : ccg.GetDepends()) {
+ std::string dep;
+ if (lg->GetRealDependency(d, noConfig, dep)) {
+ if (!unique_inputs.insert(dep).second) {
+ // already listed
+ continue;
+ }
+ ConvertToWindowsSlash(dep);
+ additional_inputs << sep << dep;
+ sep = ";";
+ if (!symbolic) {
+ if (cmSourceFile* sf = this->Makefile->GetSource(
+ dep, cmSourceFileLocationKind::Known)) {
+ symbolic = sf->GetPropertyAsBool("SYMBOLIC");
+ }
+ }
+ }
+ }
+ }
+ // output files for custom command
+ std::stringstream outputs;
+ {
+ const char* sep = "";
+ for (std::string const& o : ccg.GetOutputs()) {
+ std::string out = o;
+ ConvertToWindowsSlash(out);
+ outputs << sep << out;
+ sep = ";";
+ if (!symbolic) {
+ if (cmSourceFile* sf =
+ this->Makefile->GetSource(o, cmSourceFileLocationKind::Known)) {
+ symbolic = sf->GetPropertyAsBool("SYMBOLIC");
+ }
+ }
+ }
+ }
+ script += lg->FinishConstructScript(this->ProjectType);
+
+ e1.Attribute("Inputs", cmVS10EscapeAttr(additional_inputs.str()));
+ e1.Attribute("Outputs", cmVS10EscapeAttr(outputs.str()));
+
+ e1.SetHasElements();
+
+ if (!comment.empty()) {
+ Elem(e1, "Message").Attribute("Text", comment);
+ }
+ Elem(e1, "Exec").Attribute("Command", script);
+}
+
+void cmVisualStudio10TargetGenerator::WriteZeroCheckBeforeBuildTarget(
+ cmVisualStudio10TargetGenerator::Elem& e0)
+{
+ const auto& commands = this->GeneratorTarget->GetPreBuildCommands();
+ if (commands.empty()) {
+ return;
+ }
+
+ {
+ Elem e1(e0, "Target");
+ e1.Attribute("Name", "BeforeBuild");
+ e1.Attribute("BeforeTargets", "Build");
+
+ cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
+ std::string script;
+ const char* pre = "";
+ std::string comment;
+ for (cmCustomCommand const& cc : commands) {
+ cmCustomCommandGenerator ccg(cc, std::string{}, lg);
+ if (!ccg.HasOnlyEmptyCommandLines()) {
+ comment += pre;
+ comment += lg->ConstructComment(ccg);
+ script += pre;
+ pre = "\n";
+ script += lg->ConstructScript(ccg);
+ }
+ }
+
+ if (script.empty()) {
+ return;
+ }
+
+ script += lg->FinishConstructScript(this->ProjectType);
+ comment = cmVS10EscapeComment(comment);
+ std::string strippedComment = comment;
+ strippedComment.erase(
+ std::remove(strippedComment.begin(), strippedComment.end(), '\t'),
+ strippedComment.end());
+
+ e1.SetHasElements();
+ if (!comment.empty() && !strippedComment.empty()) {
+ Elem(e1, "Message").Attribute("Text", comment);
+ }
+ Elem(e1, "Exec").Attribute("Command", script);
+ }
+}
+
std::vector<std::string> cmVisualStudio10TargetGenerator::GetIncludes(
std::string const& config, std::string const& lang) const
{
@@ -3057,6 +3248,8 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
cm::make_unique<Options>(this->LocalGenerator, Options::CSharpCompiler,
gg->GetCSharpFlagTable());
break;
+ default:
+ break;
}
Options& clOptions = *pOptions;
@@ -3182,6 +3375,8 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
return def.find('=') != std::string::npos;
});
break;
+ default:
+ break;
}
clOptions.AddDefines(targetDefines);
@@ -4308,6 +4503,9 @@ void cmVisualStudio10TargetGenerator::AddLibraries(
this->AdditionalUsingDirectories[config].insert(
cmSystemTools::GetFilenamePath(location));
break;
+ default:
+ // In .proj files, we wouldn't be referencing libraries.
+ break;
}
}
}
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index 8d777a3..5e74779 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -264,6 +264,13 @@ private:
void WriteClassicMsBuildProjectFile(cmGeneratedFileStream& BuildFileStream);
void WriteSdkStyleProjectFile(cmGeneratedFileStream& BuildFileStream);
+ void WriteZeroCheckProj(cmGeneratedFileStream& BuildFileStream);
+ void WriteZeroCheckBuildTarget(cmVisualStudio10TargetGenerator::Elem& e0,
+ const cmCustomCommand& command,
+ const cmSourceFile* source);
+ void WriteZeroCheckBeforeBuildTarget(
+ cmVisualStudio10TargetGenerator::Elem& e0);
+
void WriteCommonPropertyGroupGlobals(
cmVisualStudio10TargetGenerator::Elem& e1);
diff --git a/Source/cmVsProjectType.h b/Source/cmVsProjectType.h
index 8899267..04053a0 100644
--- a/Source/cmVsProjectType.h
+++ b/Source/cmVsProjectType.h
@@ -7,5 +7,6 @@
enum class VsProjectType
{
vcxproj,
- csproj
+ csproj,
+ proj,
};
diff --git a/Source/cmake.h b/Source/cmake.h
index 1187be5..97444b8 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -488,7 +488,7 @@ public:
//! Do we want debug output from the find commands during the cmake run.
bool GetDebugFindOutput() const { return this->DebugFindOutput; }
bool GetDebugFindOutput(std::string const& var) const;
- bool GetDebugFindPkgOutput(std::string const& var) const;
+ bool GetDebugFindPkgOutput(std::string const& pkg) const;
void SetDebugFindOutput(bool b) { this->DebugFindOutput = b; }
void SetDebugFindOutputPkgs(std::string const& args);
void SetDebugFindOutputVars(std::string const& args);
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-check-test-list.cmake b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-check-test-list.cmake
new file mode 100644
index 0000000..94169e7
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-check-test-list.cmake
@@ -0,0 +1,6 @@
+list(LENGTH test_list_test_TESTS LIST_SIZE)
+set(EXPECTED_SIZE 2)
+if(NOT LIST_SIZE EQUAL ${EXPECTED_SIZE})
+ message("TEST_LIST should have ${EXPECTED_SIZE} elements but it has ${LIST_SIZE}")
+ message("The unexpected list: [${test_list_test_TESTS}]")
+endif()
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-flush-script-check-list.cmake b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-flush-script-check-list.cmake
new file mode 100644
index 0000000..1ae222f
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-flush-script-check-list.cmake
@@ -0,0 +1,5 @@
+list(LENGTH flush_script_test_TESTS LIST_SIZE)
+set(EXPECTED_LIST_SIZE 4)
+if(NOT LIST_SIZE EQUAL ${EXPECTED_LIST_SIZE})
+ message("TEST_LIST should have ${EXPECTED_LIST_SIZE} elements but it has ${LIST_SIZE}")
+endif()
diff --git a/Tests/RunCMake/GoogleTest/GoogleTestDiscoveryFlushScript.cmake b/Tests/RunCMake/GoogleTest/GoogleTestDiscoveryFlushScript.cmake
new file mode 100644
index 0000000..2c138c7
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/GoogleTestDiscoveryFlushScript.cmake
@@ -0,0 +1,14 @@
+enable_language(CXX)
+include(GoogleTest)
+
+enable_testing()
+
+include(xcode_sign_adhoc.cmake)
+
+add_executable(flush_script_test flush_script_test.cpp)
+xcode_sign_adhoc(flush_script_test)
+gtest_discover_tests(
+ flush_script_test
+)
+set_property(DIRECTORY APPEND PROPERTY TEST_INCLUDE_FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/GoogleTest-discovery-flush-script-check-list.cmake)
diff --git a/Tests/RunCMake/GoogleTest/GoogleTestDiscoveryTestList.cmake b/Tests/RunCMake/GoogleTest/GoogleTestDiscoveryTestList.cmake
new file mode 100644
index 0000000..5f4f859
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/GoogleTestDiscoveryTestList.cmake
@@ -0,0 +1,14 @@
+enable_language(CXX)
+include(GoogleTest)
+
+enable_testing()
+
+include(xcode_sign_adhoc.cmake)
+
+add_executable(test_list_test test_list_test.cpp)
+xcode_sign_adhoc(test_list_test)
+gtest_discover_tests(
+ test_list_test
+)
+set_property(DIRECTORY APPEND PROPERTY TEST_INCLUDE_FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/GoogleTest-discovery-check-test-list.cmake)
diff --git a/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake b/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake
index 33a4b43..695f562 100644
--- a/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake
+++ b/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake
@@ -236,6 +236,58 @@ function(run_GoogleTest_discovery_multi_config)
endfunction()
+function(run_GoogleTest_discovery_test_list DISCOVERY_MODE)
+ # Use a single build tree for a few tests without cleaning.
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GoogleTest-discovery-test-list-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
+ endif()
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+
+ run_cmake_with_options(GoogleTestDiscoveryTestList -DCMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE=${DISCOVERY_MODE})
+
+ run_cmake_command(GoogleTest-discovery-test-list-build
+ ${CMAKE_COMMAND}
+ --build .
+ --config Debug
+ --target test_list_test
+ )
+
+ run_cmake_command(GoogleTest-discovery-test-list-test
+ ${CMAKE_CTEST_COMMAND}
+ -C Debug
+ --no-label-summary
+ )
+endfunction()
+
+function(run_GoogleTest_discovery_flush_script DISCOVERY_MODE)
+ # Use a single build tree for a few tests without cleaning.
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GoogleTest-discovery-flush-script-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
+ endif()
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+
+ run_cmake_with_options(GoogleTestDiscoveryFlushScript -DCMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE=${DISCOVERY_MODE})
+
+ run_cmake_command(GoogleTest-discovery-flush-script-build
+ ${CMAKE_COMMAND}
+ --build .
+ --config Debug
+ --target flush_script_test
+ )
+
+ run_cmake_command(GoogleTest-discovery-flush-script-test
+ ${CMAKE_CTEST_COMMAND}
+ -C Debug
+ --no-label-summary
+ )
+endfunction()
+
foreach(DISCOVERY_MODE POST_BUILD PRE_TEST)
message("Testing ${DISCOVERY_MODE} discovery mode via CMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE global override...")
run_GoogleTest(${DISCOVERY_MODE})
@@ -246,6 +298,8 @@ foreach(DISCOVERY_MODE POST_BUILD PRE_TEST)
NOT "${DISCOVERY_MODE};${RunCMake_GENERATOR}" MATCHES "^POST_BUILD;Visual Studio 9")
run_GoogleTest_discovery_arg_change(${DISCOVERY_MODE})
endif()
+ run_GoogleTest_discovery_test_list(${DISCOVERY_MODE})
+ run_GoogleTest_discovery_flush_script(${DISCOVERY_MODE})
endforeach()
if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
diff --git a/Tests/RunCMake/GoogleTest/flush_script_test.cpp b/Tests/RunCMake/GoogleTest/flush_script_test.cpp
new file mode 100644
index 0000000..9473bb5
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/flush_script_test.cpp
@@ -0,0 +1,19 @@
+#include <iostream>
+#include <string>
+
+int main(int argc, char** argv)
+{
+ // Note: GoogleTest.cmake doesn't actually depend on Google Test as such;
+ // it only requires that we produces output in the expected format when
+ // invoked with --gtest_list_tests. Thus, we fake that here. This allows us
+ // to test the module without actually needing Google Test.
+ if (argc > 1 && std::string(argv[1]) == "--gtest_list_tests") {
+ std::cout << "flush_script_test.\n";
+ const size_t flushThreshold = 50000;
+ const size_t testCaseNum = 4;
+ std::string testName(flushThreshold / (testCaseNum - 1), 'T');
+ for (size_t i = 0; i < testCaseNum; ++i)
+ std::cout << " " << testName.c_str() << "\n";
+ }
+ return 0;
+}
diff --git a/Tests/RunCMake/GoogleTest/test_list_test.cpp b/Tests/RunCMake/GoogleTest/test_list_test.cpp
new file mode 100644
index 0000000..c9f9512
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/test_list_test.cpp
@@ -0,0 +1,18 @@
+#include <iostream>
+#include <string>
+
+int main(int argc, char** argv)
+{
+ // Note: GoogleTest.cmake doesn't actually depend on Google Test as such;
+ // it only requires that we produces output in the expected format when
+ // invoked with --gtest_list_tests. Thus, we fake that here. This allows us
+ // to test the module without actually needing Google Test.
+ if (argc > 1 && std::string(argv[1]) == "--gtest_list_tests") {
+ std::cout << "test_list_test/test.\n";
+ std::cout << " case/0 # GetParam() = \"semicolon;\"\n";
+ std::cout << " case/1 # GetParam() = 'osb['\n";
+ std::cout << " case/2 # GetParam() = 'csb]'\n";
+ std::cout << " case/3 # GetParam() = 'S p a c e s'\n";
+ }
+ return 0;
+}