CMake/Tests/RunCMake
Brad King 528e8af19f Allow a toolchain file to specify a generator toolset
Delay use of CMAKE_GENERATOR_TOOLSET until the CMakeSystem.cmake
file has been configured and loaded during the first project() or
enable_language() command.  This gives the toolchain file named by
CMAKE_TOOLCHAIN_FILE a chance to set CMAKE_GENERATOR_TOOLSET.  This
point is still early enough to set the generator toolset prior to
the initialization of any languages that might use the toolset.

The cmake::GeneratorToolset member variable remains an indication
of what was specified by the -T option or loaded from the cache.
It does not need to be updated based on the toolchain file setting.
The cmMakefile::TryCompile can still pass cmake::GeneratorToolset
into the inner instance because the try-compiled project will do
platform and language initialization using the CMakeSystem module
configured for the outer project.

Extend the RunCMake.GeneratorToolset test with cases that use a
toolchain file to set CMAKE_GENERATOR_TOOLSET.
2014-06-04 14:27:02 -04:00
..
CMP0004 Cygwin: Avoid legacy warnings in RunCMake.* tests 2013-08-13 09:50:15 -04:00
CMP0019 Cygwin: Avoid legacy warnings in RunCMake.* tests 2013-08-13 09:50:15 -04:00
CMP0022 OS X: Add CMP0042 to enable MACOSX_RPATH by default 2014-01-02 13:41:49 -05:00
CMP0026 cmTarget: Evaluate CMP0026 and CMP0051 in calling context 2014-05-09 11:24:15 -04:00
CMP0027 Record more policies on targets when created 2014-03-06 11:05:47 -05:00
CMP0028 Tests: Simplify and document policy scopes in RunCMake.CMP* tests 2014-03-06 11:07:03 -05:00
CMP0037 Policies: omit warnings about unset policies when they are actually set to NEW 2014-03-31 09:45:10 -04:00
CMP0038 Record more policies on targets when created 2014-03-06 11:05:47 -05:00
CMP0039 Policies: omit warnings about unset policies when they are actually set to NEW 2014-03-31 09:45:10 -04:00
CMP0040 Policies: omit warnings about unset policies when they are actually set to NEW 2014-03-31 09:45:10 -04:00
CMP0041 Tests: Simplify and document policy scopes in RunCMake.CMP* tests 2014-03-06 11:07:03 -05:00
CMP0042 Tests: Simplify and document policy scopes in RunCMake.CMP* tests 2014-03-06 11:07:03 -05:00
CMP0043 Tests: Simplify and document policy scopes in RunCMake.CMP* tests 2014-03-06 11:07:03 -05:00
CMP0045 Tests: Simplify and document policy scopes in RunCMake.CMP* tests 2014-03-06 11:07:03 -05:00
CMP0046 Policies: omit warnings about unset policies when they are actually set to NEW 2014-03-31 09:45:10 -04:00
CMP0049 Tests: Simplify and document policy scopes in RunCMake.CMP* tests 2014-03-06 11:07:03 -05:00
CMP0050 Tests: Simplify and document policy scopes in RunCMake.CMP* tests 2014-03-06 11:07:03 -05:00
CMP0051 cmTarget: Evaluate CMP0026 and CMP0051 in calling context 2014-05-09 11:24:15 -04:00
CMP0053 tests: test CMP0053 in WARN mode when watching variables 2014-05-22 11:13:29 -04:00
CPackInstallProperties Add an "installed file" property scope 2014-05-28 12:28:18 -04:00
CTest build_command: Return a "cmake --build" command-line 2013-11-15 14:38:18 -05:00
CheckModules CheckTypeSize: Add unit test to cover the no-C case 2014-03-17 17:36:14 +01:00
CommandLine cmake: Fix --build crash on bad CMAKE_GENERATOR in cache 2014-06-03 11:52:19 -04:00
CompatibleInterface cmTarget: Add GetTransitiveTargetClosure method. 2014-02-24 16:43:24 +01:00
CompileFeatures Features: Enable compiler extensions by default. 2014-05-31 12:16:12 +02:00
CompilerChange Drop use of configure_file IMMEDIATE option 2013-11-13 10:12:17 -05:00
CompilerNotFound Require CMAKE_<LANG>_COMPILER to be found as a full path 2013-10-28 08:36:14 -04:00
Configure Features: Extend concept to C language. 2014-05-15 00:15:18 +02:00
DisallowedCommands Cygwin: Avoid legacy warnings in RunCMake.DisallowedCommands test 2013-10-25 15:07:35 -04:00
ExportWithoutLanguage export(): Process the export() command at generate time. 2013-10-11 12:46:10 +02:00
ExternalData ExternalData: Warn on missing file instead of failing 2014-04-17 09:45:09 -04:00
FPHSA Cygwin: Avoid legacy warnings in RunCMake.* tests 2013-08-13 09:50:15 -04:00
FeatureSummary FeatureSummary: Add unit tests 2014-03-03 19:52:13 +01:00
File_Generate file(GENERATE): Only write the file if content is different. 2014-04-30 15:18:13 +02:00
FindPkgConfig FindPkgConfig: More unit tests 2014-03-17 18:10:59 +01:00
GeneratorExpression Genex: Clarify error message on use with non-binary targets (#14899). 2014-05-29 11:29:31 +02:00
GeneratorToolset Allow a toolchain file to specify a generator toolset 2014-06-04 14:27:02 -04:00
IncompatibleQt Cygwin: Avoid legacy warnings in RunCMake.* tests 2013-08-13 09:50:15 -04:00
Languages Cygwin: Avoid legacy warnings in RunCMake.* tests 2013-08-13 09:50:15 -04:00
ObjectLibrary cmGeneratorTarget: Compute consumed object libraries on demand. 2014-04-02 23:12:56 +02:00
ObsoleteQtMacros Qt4Macros: Port to use message(DEPRECATION) 2013-10-08 18:23:42 +02:00
PositionIndependentCode cmTarget: Report origin of COMPATIBLE_INTERFACE properties. 2013-12-08 07:03:29 +01:00
SolutionGlobalSections Cygwin: Avoid legacy warnings in RunCMake.* tests 2013-08-13 09:50:15 -04:00
Syntax EVIS: Add tests for syntax corner cases and CMP0053 2014-05-08 13:24:49 -04:00
TargetObjects Genex: Only evaluate TARGET_OBJECTS to determine target sources. 2014-04-02 23:12:57 +02:00
TargetPolicies Export: Disallow exported interface includes in src/build tree (#14592). 2014-04-09 10:38:49 +02:00
TargetPropertyGeneratorExpressions Cygwin: Avoid legacy warnings in RunCMake.* tests 2013-08-13 09:50:15 -04:00
TargetSources cmTarget: Fix listing of source files at configure-time. 2014-04-13 10:59:50 +02:00
VisibilityPreset Cygwin: Avoid legacy warnings in RunCMake.* tests 2013-08-13 09:50:15 -04:00
WriteCompilerDetectionHeader Add the WriteCompilerDetectionHeader module. 2014-05-14 13:57:30 -04:00
XcodeProject Xcode: Add source file property to control file type (#14854) 2014-05-15 14:34:52 -04:00
add_dependencies Cygwin: Avoid legacy warnings in RunCMake.* tests 2013-08-13 09:50:15 -04:00
alias_targets Cygwin: Avoid legacy warnings in RunCMake.* tests 2013-08-13 09:50:15 -04:00
build_command Prefer CMAKE_MAKE_PROGRAM over CMAKE_BUILD_TOOL (#14548) 2013-11-18 08:26:23 -05:00
cmake_minimum_required Drop compatibility with CMake < 2.4 2013-10-23 08:54:31 -04:00
configure_file Unicode: check encoding of files given to configure_file. 2014-03-17 14:01:55 -06:00
export export: Implement EXPORT subcommand (#9822) 2013-12-24 13:02:49 +01:00
file file: Report system error on failure to open file 2014-05-20 11:07:51 -04:00
find_dependency Tests: Check find_dependency empty extra arguments 2014-03-13 15:57:03 -04:00
find_package Cygwin: Avoid legacy warnings in RunCMake.* tests 2013-08-13 09:50:15 -04:00
get_filename_component Cygwin: Avoid legacy warnings in RunCMake.* tests 2013-08-13 09:50:15 -04:00
if Cygwin: Avoid legacy warnings in RunCMake.* tests 2013-08-13 09:50:15 -04:00
include Policies: omit warnings about unset policies when they are actually set to NEW 2014-03-31 09:45:10 -04:00
include_directories CMP0052: Make the warning message more informative. 2014-04-17 09:08:24 -04:00
include_external_msproject Cygwin: Avoid legacy warnings in RunCMake.* tests 2013-08-13 09:50:15 -04:00
install InstallRules: added new variable to disable generation of install rules 2014-01-08 16:28:14 +01:00
interface_library Disallow INTERFACE libraries with add_custom_command(TARGET). 2014-03-19 15:51:21 +01:00
list Cygwin: Avoid legacy warnings in RunCMake.* tests 2013-08-13 09:50:15 -04:00
message message: Add a DEPRECATION mode 2013-10-08 18:11:22 +02:00
no_install_prefix Allow disabling adding the install prefix to the prefix search path. 2013-10-31 16:40:24 +01:00
project project: Manage VERSION variables 2014-01-29 09:45:18 -05:00
set RunCMake: Allow specifying the source dir and file to test. 2014-04-06 23:58:35 +02:00
string string: Add CONCAT sub-command 2013-10-21 12:54:20 -04:00
target_compile_features Features: Extend concept to C language. 2014-05-15 00:15:18 +02:00
target_link_libraries Policies: omit warnings about unset policies when they are actually set to NEW 2014-03-31 09:45:10 -04:00
try_compile Cygwin: Avoid legacy warnings in RunCMake.* tests 2013-08-13 09:50:15 -04:00
variable_watch Cygwin: Avoid legacy warnings in RunCMake.* tests 2013-08-13 09:50:15 -04:00
CMakeLists.txt Merge topic 'cpack-properties' 2014-05-28 12:34:36 -04:00
README.rst Tests/RunCMake: Add function to run a specified command-line 2014-01-20 13:46:51 -05:00
RunCMake.cmake RunCMake: Allow specifying the source dir and file to test. 2014-04-06 23:58:35 +02:00

README.rst

This directory contains tests that run CMake to configure a project
but do not actually build anything.  To add a test:

1. Add a subdirectory named for the test, say ``<Test>/``.

2. In ``./CMakeLists.txt`` call ``add_RunCMake_test`` and pass the
   test directory name ``<Test>``.

3. Create script ``<Test>/RunCMakeTest.cmake`` in the directory containing::

    include(RunCMake)
    run_cmake(SubTest1)
    ...
    run_cmake(SubTestN)

   where ``SubTest1`` through ``SubTestN`` are sub-test names each
   corresponding to an independent CMake run and project configuration.

   One may also add calls of the form::

    run_cmake_command(SubTestI ${CMAKE_COMMAND} ...)

   to fully customize the test case command-line.

4. Create file ``<Test>/CMakeLists.txt`` in the directory containing::

    cmake_minimum_required(...)
    project(${RunCMake_TEST} NONE) # or languages needed
    include(${RunCMake_TEST}.cmake)

   where ``${RunCMake_TEST}`` is literal.  A value for ``RunCMake_TEST``
   will be passed to CMake by the ``run_cmake`` macro when running each
   sub-test.

5. Create a ``<Test>/<SubTest>.cmake`` file for each sub-test named
   above containing the actual test code.  Optionally create files
   containing expected test results:

   ``<SubTest>-result.txt``
    Process result expected if not "0"
   ``<SubTest>-stdout.txt``
    Regex matching expected stdout content
   ``<SubTest>-stderr.txt``
    Regex matching expected stderr content
   ``<SubTest>-check.cmake``
    Custom result check.

   Note that trailing newlines will be stripped from actual and expected
   test output before matching against the stdout and stderr expressions.
   The code in ``<SubTest>-check.cmake`` may use variables

   ``RunCMake_TEST_SOURCE_DIR``
    Top of test source tree
   ``RunCMake_TEST_BINARY_DIR``
    Top of test binary tree

   and an failure must store a message in ``RunCMake_TEST_FAILED``.