CMake/Tests/RunCMake
Brad King 2ae880fa8f Genex: Enable COMPILE_LANGUAGE for COMPILE_OPTIONS with Visual Studio
Since commit v3.9.0-rc4~3^2~1 (VS: Fix target_compile_options for CUDA,
2017-06-21), the evaluation of `COMPILE_LANGUAGE` receives the proper
language.  The set of compile flags used for a target's C and C++
sources is based on the linker language.  By default this is always the
C++ flags if any C++ sources appear in the target, and otherwise the C
flags.  Therefore we can define the `COMPILE_LANGUAGE` generator
expression in `COMPILE_OPTIONS` to match the selected language.

This is not exactly the same as for other generators, but is the best VS
can do.  It is also sufficient for many use cases since the set of
allowed flags for C and C++ is almost the same in Visual Studio.
Furthermore, since the VS generator moves many of the flags to
declarative `.vcxproj` elements, it will automatically avoid passing
C++ flags for C sources.

Issue: #17435
2017-11-20 13:51:25 -05:00
..
add_custom_command VS: only add custom command line if it is not empty 2017-09-04 11:42:35 +02:00
add_custom_target
add_dependencies Add a getter for manually added target dependencies 2017-01-16 22:38:24 +01:00
add_executable Defer check for sources within a target until generation. 2017-10-24 08:14:47 -04:00
add_library Teach target_* commands to set INTERFACE properties of IMPORTED targets 2017-10-26 09:11:04 -04:00
add_subdirectory Xcode: Add targets marked as EXCLUDE_FROM_ALL to project (#16101) 2016-08-31 09:16:44 -04:00
alias_targets Add support for IMPORTED GLOBAL targets to be aliased 2017-10-26 09:11:04 -04:00
Android Android: Always add standard include directories last 2017-07-13 10:03:58 -04:00
AndroidMK Android: Record use of C++ by static libs in exported Android.mk files 2016-10-07 15:02:42 -04:00
AndroidTestUtilities AndroidTestUtilities: do not require ExternalData unconditionally 2017-02-04 08:16:24 -05:00
AutoExportDll bindexplib: Revert support for constants symbols 2017-07-10 14:54:07 -04:00
build_command
BuildDepends Tests: Fix RunCMake.BuildDepends on VS 2017 with v90 toolset 2017-08-25 09:55:50 -04:00
CheckIPOSupported IPO: Consider support for each language separately 2017-06-14 10:36:57 -04:00
CheckModules
ClangTidy cmake: Report if the <LANG>_CLANG_TIDY tool exits with non-zero 2016-11-18 09:43:22 -05:00
cmake_minimum_required
cmake_parse_arguments cmake_parse_arguments: Add additional unit tests 2016-09-28 15:20:42 -04:00
CMP0004
CMP0019 Add deprecation warnings for policies CMP0036 and below 2017-04-21 15:04:33 -04:00
CMP0022 Tests: Fix RunCMake.CMP0022 tll case for Debug configuration 2017-05-18 10:18:50 -04:00
CMP0026 Add deprecation warnings for policies CMP0036 and below 2017-04-21 15:04:33 -04:00
CMP0027
CMP0028 Add deprecation warnings for policies CMP0036 and below 2017-04-21 15:04:33 -04:00
CMP0037 Add deprecation warnings for policies CMP0054 and below 2017-11-01 11:46:53 -04:00
CMP0038 Add deprecation warnings for policies CMP0054 and below 2017-11-01 11:46:53 -04:00
CMP0039 Add deprecation warnings for policies CMP0054 and below 2017-11-01 11:46:53 -04:00
CMP0040 Add deprecation warnings for policies CMP0054 and below 2017-11-01 11:46:53 -04:00
CMP0041 Add deprecation warnings for policies CMP0054 and below 2017-11-01 11:46:53 -04:00
CMP0042 Add deprecation warnings for policies CMP0054 and below 2017-11-01 11:46:53 -04:00
CMP0043 Add deprecation warnings for policies CMP0054 and below 2017-11-01 11:46:53 -04:00
CMP0045 Add deprecation warnings for policies CMP0054 and below 2017-11-01 11:46:53 -04:00
CMP0046 Add deprecation warnings for policies CMP0054 and below 2017-11-01 11:46:53 -04:00
CMP0049 Add deprecation warnings for policies CMP0054 and below 2017-11-01 11:46:53 -04:00
CMP0050 Add deprecation warnings for policies CMP0054 and below 2017-11-01 11:46:53 -04:00
CMP0051 Add deprecation warnings for policies CMP0054 and below 2017-11-01 11:46:53 -04:00
CMP0053 Add deprecation warnings for policies CMP0054 and below 2017-11-01 11:46:53 -04:00
CMP0054 Add deprecation warnings for policies CMP0054 and below 2017-11-01 11:46:53 -04:00
CMP0055
CMP0057
CMP0059
CMP0060
CMP0064
CMP0065
CMP0068 Add policy CMP0068 separate install_name and RPATH settings on macOS 2017-02-14 14:28:07 -07:00
CMP0069 IPO: Consider support for each language separately 2017-06-14 10:36:57 -04:00
CommandLine cmcmd: Restore support for running multiple lint tools 2017-10-27 09:26:50 -04:00
CommandLineTar
CompatibleInterface
COMPILE_LANGUAGE-genex Genex: Enable COMPILE_LANGUAGE for COMPILE_OPTIONS with Visual Studio 2017-11-20 13:51:25 -05:00
CompileDefinitions
CompileFeatures CompileFeatures: Makes tests work with meta-feature only 2017-05-29 13:51:45 -04:00
CompilerChange
CompilerLauncher CUDA: Add option to run the compiler through launcher tools 2017-06-09 12:34:39 -04:00
CompilerNotFound
Configure Tolerate removed/replaced CMakeCache.txt with old CMakeFiles/ 2016-11-17 10:29:58 -05:00
configure_file
continue
CPack CPack: enable setting default dir creation permissions 2017-11-08 20:27:11 +01:00
CPackConfig
CPackInstallProperties Tests: Use full output paths in file(GENERATE) calls 2017-06-08 13:31:33 -04:00
CPackSymlinks
Cppcheck Clean up iwyu code to not be one big if statement. 2017-09-13 17:44:49 -04:00
Cpplint Add properties to run the cpplint style checker with the compiler 2017-01-23 14:47:13 -05:00
CrosscompilingEmulator Tests: Check that CROSSCOMPILING_EMULATOR is not used on imported targets 2016-10-28 15:08:08 -04:00
CSharpCustomCommand Vs: fix CSharp custom command by introducing inline MSBuild <Targets>s 2017-06-22 21:40:48 +02:00
CTest Tests: Fix RunCMake.CTest output match to tolerate line number changes 2016-09-27 15:04:27 -04:00
ctest_build ctest_configure: Propagate CTEST_USE_LAUNCHERS from caller to project 2016-10-17 11:15:36 -04:00
ctest_cmake_error CTest: Add CAPTURE_CMAKE_ERROR val to ctest_* commands 2016-09-20 13:14:20 -04:00
ctest_configure
ctest_coverage
ctest_disabled_test cmCTestTestHandler: indicate why a test did not run 2017-04-24 15:42:40 -04:00
ctest_fixtures Add ctest options for limiting which tests fixtures add 2017-05-02 01:54:13 +10:00
ctest_labels_for_subprojects CTest: Weight reported test times by PROCESSORS in summaries 2017-09-08 10:03:01 -04:00
ctest_memcheck ctest_memcheck: Fix sanitizers when MemoryCheckSanitizerOptions is empty 2017-01-23 10:50:38 -05:00
ctest_skipped_test cmCTestTestHandler: indicate why a test did not run 2017-04-24 15:42:40 -04:00
ctest_start
ctest_submit ctest_submit: Add HTTPHEADER option 2017-05-04 12:21:21 -04:00
ctest_test
ctest_upload
CTestCommandLine Tests: Remove incorrect use of 'test-timeout' option 2017-11-10 07:52:05 -05:00
CTestTimeoutAfterMatch
DisallowedCommands Add deprecation warnings for policies CMP0036 and below 2017-04-21 15:04:33 -04:00
execute_process execute_process: Add option to get results of every child 2017-06-10 08:03:06 -04:00
export
ExportWithoutLanguage
ExternalData
ExternalProject ExternalProject: Prevent COMMAND from being treated as a true keyword 2017-09-02 17:53:16 +10:00
FeatureSummary FeatureSummary: Add FeatureSummary_<TYPE>_DESCRIPTION global properties 2017-02-06 14:44:24 -05:00
FetchContent FetchContent: Add tests 2017-10-17 08:10:19 +11:00
file Add testcases for file(DOWNLOAD|UPLOAD) netrc options 2017-10-18 15:21:42 -04:00
File_Generate Genex: Enable COMPILE_LANGUAGE for file(GENERATE) with Visual Studio 2017-11-17 14:31:07 -05:00
find_dependency Improve find_dependency argument handling 2017-05-22 13:32:43 -04:00
find_file
find_library find_library: Skip 'lib => lib<arch>' searches if one symlinks the other 2017-02-28 14:56:54 -05:00
find_package Merge branch 'find-package_root-disable' into release-3.9 2017-08-10 09:27:19 -04:00
find_path
find_program
FindBoost FindBoost: Improve messages when a Boost CMake package is found 2017-09-29 10:10:01 -04:00
FindGTK2 FindGTK2: Add unit test to check variables when run twice 2017-01-25 10:20:35 +01:00
FindMatlab
FindPkgConfig Tests: Add x32 tests to test suite 2017-03-08 17:23:30 +00:00
foreach Tests: Add test for bad foreach inside a function 2017-11-16 11:10:05 -05:00
FPHSA FPHSA: fix typo in comment 2017-09-14 08:21:38 -04:00
Framework Tests: Fix RunCMake.Framework ios arch for Xcode 9 2017-10-03 09:09:08 -04:00
GenerateExportHeader HP-UX: Drop support for building CMake on HP-UX 2017-08-07 09:16:09 -04:00
GeneratorExpression VS,Xcode: Add CMakeLists.txt sources without mutating targets 2017-10-18 14:24:07 -04:00
GeneratorInstance VS: Select and save a VS 2017 instance persistently 2017-10-19 10:20:12 -04:00
GeneratorPlatform VS15: Add Visual Studio 15 generator 2016-09-07 15:49:08 -04:00
GeneratorToolset Xcode: Drop support for Xcode versions below 3 2017-04-22 15:19:11 -04:00
get_filename_component get_filename_component: Revise PROGRAM/PROGRAM_ARGS split semantics 2017-09-13 10:47:04 -04:00
get_property Add new target-property IMPORTED_GLOBAL. 2017-11-07 15:08:41 +01:00
GetPrerequisites GetPrerequisites: Restore behavior on missing binary of not clearing list 2017-09-26 07:31:33 -04:00
GNUInstallDirs Tests: Fix RunCMake.GNUInstallDirs on BSD platforms 2017-06-02 16:26:30 -04:00
GoogleTest Add dynamic test discovery for for Google Test 2017-07-27 09:47:28 -04:00
if cmIfCommand: Reject duplicate else() and misplaced elseif() 2017-03-22 08:42:35 -04:00
IfacePaths Add deprecation warnings for policies CMP0054 and below 2017-11-01 11:46:53 -04:00
include
include_directories
include_external_msproject include_external_msproject: Honor MAP_IMPORTED_CONFIG_<CONFIG> 2017-04-05 13:44:03 -04:00
include_guard include_guard: add tests for the feature 2017-06-22 11:13:26 +03:00
IncludeWhatYouUse
IncompatibleQt
install Tests: Add case for install(FILES) with TARGET_OBJECTS 2017-04-26 16:23:12 -04:00
interface_library cmTargetPropCommandBase: Fix typo in error message 2017-10-26 09:11:00 -04:00
Languages
LinkStatic
LinkWhatYouUse
list
Make add_custom_command: Add DEPFILE option for Ninja 2016-08-30 09:05:18 -04:00
message Fix trivial typos in text 2017-11-03 10:25:05 -04:00
MultiLint cmcmd: Restore support for running multiple lint tools 2017-10-27 09:26:50 -04:00
Ninja Ninja: Fix command concatenation on Windows 2017-05-09 11:34:42 -04:00
no_install_prefix
ObjectLibrary Diagnose object library self-reference 2017-07-14 14:05:22 -04:00
ObsoleteQtMacros
PolicyScope
PositionIndependentCode
project Add deprecation warnings for policies CMP0054 and below 2017-11-01 11:46:53 -04:00
return
RuntimePath Tests: Add case for RPATH exclusion of symlinks to implicit directories 2017-03-02 08:36:32 -05:00
separate_arguments separgs: Add a NATIVE_COMMAND mode 2017-04-26 20:34:06 +02:00
set
set_property Add new target-property IMPORTED_GLOBAL. 2017-11-07 15:08:41 +01:00
string Timestamp: support %A and %B 2017-09-07 13:36:11 -04:00
Swift
Syntax Add deprecation warnings for policies CMP0054 and below 2017-11-01 11:46:53 -04:00
target_compile_features Teach target_* commands to set INTERFACE properties of IMPORTED targets 2017-10-26 09:11:04 -04:00
target_link_libraries Teach target_* commands to set INTERFACE properties of IMPORTED targets 2017-10-26 09:11:04 -04:00
TargetObjects Tests: Use full output paths in file(GENERATE) calls 2017-06-08 13:31:33 -04:00
TargetPolicies CMP0037: Allow test and package targets when features are not enabled 2017-10-30 10:21:31 -04:00
TargetPropertyGeneratorExpressions
TargetSources VS,Xcode: Add CMakeLists.txt sources without mutating targets 2017-10-18 14:24:07 -04:00
test_include_dirs Add TEST_INCLUDE_DIR[S] unit test 2017-07-12 13:28:21 -04:00
ToolchainFile
try_compile CUDA: Port test cases to Windows with MSVC host compiler 2017-01-12 10:39:04 -05:00
try_run
variable_watch test: Added additional unit test to variable_watch 2017-09-21 11:09:24 -04:00
VisibilityPreset
VS10Project Merge topic 'vs_csharp_prop_for_all_extensions' 2017-06-15 10:22:12 -04:00
VSSolution VS: Add SolutionGuid to generated .sln files 2017-07-11 10:41:28 -04:00
while Make error message of standalone endwhile command consistent 2016-11-29 13:53:29 -05:00
WriteCompilerDetectionHeader
XcodeProject Xcode: Add option to generate only topmost project file 2017-10-31 17:09:26 +01:00
CMakeLists.txt Tests: Add test for bad foreach inside a function 2017-11-16 11:10:05 -05:00
exit_code.c execute_process: Add option to get results of every child 2017-06-10 08:03:06 -04:00
pseudo_cppcheck.c Clean up iwyu code to not be one big if statement. 2017-09-13 17:44:49 -04:00
pseudo_cpplint.c Add properties to run the cpplint style checker with the compiler 2017-01-23 14:47:13 -05:00
pseudo_emulator_custom_command.c Fix custom command target substitution with CROSSCOMPILING_EMULATOR 2016-10-28 15:08:03 -04:00
pseudo_emulator.c
pseudo_iwyu.c cmake: Comment why we ignore the include-what-you-use return code 2016-11-18 09:43:19 -05:00
pseudo_tidy.c cmake: Report if the <LANG>_CLANG_TIDY tool exits with non-zero 2016-11-18 09:43:22 -05:00
README.rst Tests: Update RunCMake/README.rst to clarify meaning of -result.txt 2017-09-14 14:15:26 -04:00
RunCMake.cmake Add infrastructure for generators to select a build tool instance 2017-10-19 10:20:08 -04:00
RunCTest.cmake Update tests that expect uncompressed output 2016-11-08 15:58:29 -05:00

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.

   Alternatively, if the test is to cover running ``ctest -S`` then use::

    include(RunCTest)
    run_ctest(SubTest1)
    ...
    run_ctest(SubTestN)

   and create ``test.cmake.in``, ``CTestConfig.cmake.in``, and
   ``CMakeLists.txt.in`` files to be configured for each case.

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``
    Regex matching expected process result, if not ``0``
   ``<SubTest>-stdout.txt``
    Regex matching expected stdout content
   ``<SubTest>-stderr.txt``
    Regex matching expected stderr content, if not ``^$``
   ``<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``.