CMake/Tests/RunCMake
Matthew Woehlke ab358d6a85 Improve find_dependency argument handling
Remove highly specialized and totally positional argument handling in
find_dependency macro, and instead just pass arguments through to
find_package. This gives users access to the full suite of arguments
that find_package knows, and is backward compatible with the old
arguments.

Also, rewrite the unit tests for this, since the old tests are
exclusively focused on testing the old argument handling and are no
longer applicable, and add some success tests (the old tests did not
even set up the CMake state in a way that CMake had any hope of ever
finding the test package).
2017-05-22 13:32:43 -04:00
..
add_custom_command Make the add_custom_command output more predictable 2016-09-19 08:49:46 -04:00
add_custom_target Ninja: Fix inter-target order-only dependencies of custom commands 2016-07-20 13:12:24 -04:00
add_dependencies Add a getter for manually added target dependencies 2017-01-16 22:38:24 +01:00
add_subdirectory Xcode: Add targets marked as EXCLUDE_FROM_ALL to project (#16101) 2016-08-31 09:16:44 -04:00
alias_targets Revise C++ coding style using clang-format 2016-05-16 16:05:19 -04:00
Android Android: Add CMAKE_<LANG>_ANDROID_TOOLCHAIN_MACHINE 2016-11-18 10:03:15 -05: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: fix constants symbols export 2017-04-26 22:23:33 +03:00
build_command CTest: Stop telling 'make' to ignore errors with -i 2015-05-12 09:06:49 -04:00
BuildDepends Tests: Add case for IMPLICIT_DEPENDS in custom target 2017-04-26 08:46:11 -04:00
CheckIPOSupported Xcode: Support IPO (LTO) 2017-05-02 18:33:25 +03:00
CheckModules RunCMake: Expect empty output by default. 2014-12-31 16:34:34 +01:00
ClangTidy cmake: Report if the <LANG>_CLANG_TIDY tool exits with non-zero 2016-11-18 09:43:22 -05:00
cmake_minimum_required Drop compatibility with CMake < 2.4 2013-10-23 08:54:31 -04:00
cmake_parse_arguments cmake_parse_arguments: Add additional unit tests 2016-09-28 15:20:42 -04:00
CMP0004 Cygwin: Avoid legacy warnings in RunCMake.* tests 2013-08-13 09:50:15 -04:00
CMP0019 Add deprecation warnings for policies CMP0036 and below 2017-04-21 15:04:33 -04:00
CMP0022 Revise C++ coding style using clang-format 2016-05-16 16:05:19 -04:00
CMP0026 Add deprecation warnings for policies CMP0036 and below 2017-04-21 15:04:33 -04:00
CMP0027 Record more policies on targets when created 2014-03-06 11:05:47 -05:00
CMP0028 Add deprecation warnings for policies CMP0036 and below 2017-04-21 15:04:33 -04:00
CMP0037 Revise C++ coding style using clang-format 2016-05-16 16:05:19 -04:00
CMP0038 Revise C++ coding style using clang-format 2016-05-16 16:05:19 -04:00
CMP0039 RunCMake: Remove unneeded files. 2015-02-09 19:15:04 +01:00
CMP0040 Tests: Fix RunCMake.CMP0040 custom command syntax 2016-08-24 10:56:57 -04:00
CMP0041 Revise C++ coding style using clang-format 2016-05-16 16:05:19 -04:00
CMP0042 Revise C++ coding style using clang-format 2016-05-16 16:05:19 -04:00
CMP0043 Revise C++ coding style using clang-format 2016-05-16 16:05:19 -04:00
CMP0045 Revise C++ coding style using clang-format 2016-05-16 16:05:19 -04:00
CMP0046 Revise C++ coding style using clang-format 2016-05-16 16:05:19 -04:00
CMP0049 Revise C++ coding style using clang-format 2016-05-16 16:05:19 -04:00
CMP0050 Revise C++ coding style using clang-format 2016-05-16 16:05:19 -04:00
CMP0051 Revise C++ coding style using clang-format 2016-05-16 16:05:19 -04:00
CMP0053 tests: test CMP0053 in WARN mode when watching variables 2014-05-22 11:13:29 -04:00
CMP0054 Use string(APPEND) in Tests 2016-07-28 00:43:04 +02:00
CMP0055 RunCMake: Remove unneeded files. 2015-02-09 19:15:04 +01:00
CMP0057 if: Implement new IN_LIST operator 2015-04-30 10:21:19 -04:00
CMP0059 CMP0059: Fix typo in policy description 2016-05-02 15:16:07 -04:00
CMP0060 Link libraries by full path even in implicit directories 2015-04-09 11:29:18 -04:00
CMP0064 CMP0064: Fix recorded version of introduction to be 3.4 2015-09-21 10:05:02 -04:00
CMP0065 Fix typos. 2016-07-10 11:05:56 +02:00
CMP0068 Add policy CMP0068 separate install_name and RPATH settings on macOS 2017-02-14 14:28:07 -07:00
CMP0069 Xcode: Support IPO (LTO) 2017-05-02 18:33:25 +03:00
CommandLine Deprecate Visual Studio 8 2005 generator 2017-04-21 13:45:45 -04:00
CommandLineTar Tests: Consolidate, refactor and extend -E tar tests 2015-04-10 08:32:32 -04:00
CompatibleInterface Revise C++ coding style using clang-format 2016-05-16 16:05:19 -04:00
COMPILE_LANGUAGE-genex Revise C++ coding style using clang-format 2016-05-16 16:05:19 -04:00
CompileDefinitions CompileDefinitions: Add unit test for setting empty content. 2015-07-22 21:23:49 +02:00
CompileFeatures Features: Test cycle diagnostic with language standard meta-feature 2016-11-02 10:01:24 -04:00
CompilerChange Drop use of configure_file IMMEDIATE option 2013-11-13 10:12:17 -05:00
CompilerLauncher Revise C++ coding style using clang-format 2016-05-16 16:05:19 -04:00
CompilerNotFound nmake/jom: Only warn about bad VS environment if compiler not found. 2015-08-06 17:32:43 +00:00
Configure Tolerate removed/replaced CMakeCache.txt with old CMakeFiles/ 2016-11-17 10:29:58 -05:00
configure_file Tests: Add more signature tests to RunCMake.configure_file test 2015-03-09 09:17:59 -04:00
continue Use string(APPEND) in Tests 2016-07-28 00:43:04 +02:00
CPack CPack/Archive: per component filenames support 2017-05-17 00:47:15 +02:00
CPackConfig Introduction of CPACK_VERBATIM_VARIABLES variable 2015-09-20 23:39:03 +02:00
CPackInstallProperties Revise C++ coding style using clang-format 2016-05-16 16:05:19 -04:00
CPackSymlinks Tests: Add case for CPack source package with symlinks 2015-04-06 08:52:54 -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
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_configure: Add QUIET option 2015-02-23 10:01:59 -05:00
ctest_coverage ctest_coverage: Add QUIET option 2015-02-23 10:02:00 -05:00
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_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 Tests: Move CTestTestConfigFileInBuildDir into RunCMake.ctest_start 2015-07-14 09:32:53 -04:00
ctest_submit ctest_submit: Add HTTPHEADER option 2017-05-04 12:21:21 -04:00
ctest_test Tests: Disable parallel test execution while running ctest_test 2015-10-27 21:44:04 +01:00
ctest_upload ctest_upload: Add QUIET option 2015-02-23 10:02:00 -05:00
CTestCommandLine CTest: Properly reset output to avoid duplication with --repeat-until-fail 2017-01-12 11:32:58 +01:00
CTestTimeoutAfterMatch CTest: Optionally use a secondary test timeout after matching output 2016-03-22 11:17:55 -04:00
DisallowedCommands Add deprecation warnings for policies CMP0036 and below 2017-04-21 15:04:33 -04:00
execute_process execute_process: Add ENCODING option for Windows child process output 2016-11-30 09:06:51 -05:00
export export: Reject custom target exports earlier (#15657) 2015-07-21 14:39:10 -04:00
ExportWithoutLanguage Revise C++ coding style using clang-format 2016-05-16 16:05:19 -04:00
ExternalData ExternalData: Add option to recursively match under directories 2015-03-27 14:44:54 -04:00
ExternalProject ExternalProject: Fix regression in passing list to CMAKE_CACHE_ARGS 2016-10-10 14:40:12 -04:00
FeatureSummary FeatureSummary: Add FeatureSummary_<TYPE>_DESCRIPTION global properties 2017-02-06 14:44:24 -05:00
file file: Add COPY/INSTALL option for fixed layout relative to a directory 2017-04-13 16:32:51 -04:00
File_Generate Xcode: Drop support for Xcode versions below 3 2017-04-22 15:19:11 -04:00
find_dependency Improve find_dependency argument handling 2017-05-22 13:32:43 -04:00
find_file Drop find_(library|file|path) prefixes from PATH on non-Windows 2016-05-09 12:58:08 -04:00
find_library find_library: Skip 'lib => lib<arch>' searches if one symlinks the other 2017-02-28 14:56:54 -05:00
find_package cmListFileBacktrace: Refactor storage to provide efficient value semantics 2016-04-18 09:21:19 -04:00
find_path find_path: Fix location of <dir/header.h> in a framework on OS X 2016-06-07 09:04:35 -04:00
find_program Merge topic 'fix-find_program-regression' 2015-11-02 09:09:46 -05:00
FindGTK2 FindGTK2: Add unit test to check variables when run twice 2017-01-25 10:20:35 +01:00
FindMatlab Revise C++ coding style using clang-format 2016-05-16 16:05:19 -04:00
FindPkgConfig Tests: Add x32 tests to test suite 2017-03-08 17:23:30 +00:00
FPHSA RunCMake: Expect empty output by default. 2014-12-31 16:34:34 +01:00
Framework Tests: Fix RunCMake.Framework expectation for universal binaries 2017-05-08 11:38:23 -04:00
GenerateExportHeader GenerateExportHeader: always fill in _EXPORT macros 2017-03-16 15:11:03 -04:00
GeneratorExpression Genex: Add TARGET_BUNDLE_[CONTENT_]_DIR generator expressions 2017-03-30 22:24:54 +02: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 Tests: Use upper-case drive letters in RunCMake.get_filename_component 2016-09-15 08:39:18 -04:00
get_property Tests: Add case for GENERATOR_IS_MULTI_CONFIG 2017-04-04 09:49:01 -04:00
GNUInstallDirs GNUInstallDirs: Add RUNSTATEDIR variable 2017-04-20 17:25:46 +02:00
if cmIfCommand: Reject duplicate else() and misplaced elseif() 2017-03-22 08:42:35 -04:00
IfacePaths Tests: Fix failures when running under the default install prefix (#15566) 2015-05-14 10:07:37 -04:00
include Revise C++ coding style using clang-format 2016-05-16 16:05:19 -04:00
include_directories include_directories: Fix regression in BEFORE option (#15693) 2015-08-21 15:21:37 -04:00
include_external_msproject include_external_msproject: Honor MAP_IMPORTED_CONFIG_<CONFIG> 2017-04-05 13:44:03 -04:00
IncludeWhatYouUse Revise C++ coding style using clang-format 2016-05-16 16:05:19 -04:00
IncompatibleQt Revise C++ coding style using clang-format 2016-05-16 16:05:19 -04:00
install Tests: Add case for install(FILES) with TARGET_OBJECTS 2017-04-26 16:23:12 -04:00
interface_library Allow imported INTERFACE libraries to specify a link library name 2016-11-09 09:45:14 -05:00
Languages Revise C++ coding style using clang-format 2016-05-16 16:05:19 -04:00
LinkStatic Tests: Move LINK_SEARCH_{START,END}_STATIC case to dedicated test 2015-09-02 16:11:29 -04:00
LinkWhatYouUse Add options to run ldd -u -r as a "link-what-you-use" tool 2016-06-17 10:56:40 -04:00
list list: Add FILTER subcommand (#3986) 2016-02-03 11:13:17 -05:00
Make add_custom_command: Add DEPFILE option for Ninja 2016-08-30 09:05:18 -04:00
message cmake: Issue message independent of cmMakefile definition 2016-06-12 18:38:33 +02:00
Ninja Ninja: Fix command concatenation on Windows 2017-05-09 11:34:42 -04:00
no_install_prefix RunCMake: Remove unneeded files. 2015-02-09 19:15:04 +01:00
ObjectLibrary Allow OBJECT libraries to be installed, exported, and imported 2017-04-18 11:36:10 -04:00
ObsoleteQtMacros Revise C++ coding style using clang-format 2016-05-16 16:05:19 -04:00
PolicyScope cmListFileBacktrace: Refactor storage to provide efficient value semantics 2016-04-18 09:21:19 -04:00
PositionIndependentCode Revise C++ coding style using clang-format 2016-05-16 16:05:19 -04:00
project project: Add DESCRIPTION parameter 2017-04-11 10:17:00 -04:00
return return: Add test for returning inside a foreach loop 2014-11-25 14:37:39 -05:00
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 Merge branch 'parent-scope-tests' into variable-pull-failure 2014-10-24 13:34:30 -04:00
set_property cmTarget: Enforce TYPE being a read-only property 2017-01-09 16:00:39 -05:00
string string: Teach TIMESTAMP to treat %% as % 2017-01-27 09:25:37 -05:00
Swift Swift: Remove positive Swift language tests 2015-09-06 18:14:35 +02:00
Syntax Improve error message on unexpected end of file 2016-08-30 13:53:15 -04:00
target_compile_features Revise C++ coding style using clang-format 2016-05-16 16:05:19 -04:00
target_link_libraries Revise C++ coding style using clang-format 2016-05-16 16:05:19 -04:00
TargetObjects Genex: Reject TARGET_OBJECTS on non-object libraries earlier 2017-04-18 10:29:36 -04:00
TargetPolicies Add policy CMP0069 to enforce INTERPROCEDURAL_OPTIMIZATION 2017-03-30 14:56:46 -04:00
TargetPropertyGeneratorExpressions Revise C++ coding style using clang-format 2016-05-16 16:05:19 -04:00
TargetSources Merge topic 'deprecate-policy-old' 2017-04-25 09:39:06 -04:00
ToolchainFile Honor CMAKE_*_LINKER_FLAGS[_<CONFIG>]_INIT set in toolchain files 2016-07-14 15:47:32 -04:00
try_compile CUDA: Port test cases to Windows with MSVC host compiler 2017-01-12 10:39:04 -05:00
try_run Revise C++ coding style using clang-format 2016-05-16 16:05:19 -04:00
variable_watch Cygwin: Avoid legacy warnings in RunCMake.* tests 2013-08-13 09:50:15 -04:00
VisibilityPreset CMP0063: Split unit test by target type. 2015-10-20 23:58:48 +02:00
VS10Project VS: add test for VS_CSHARP_* source file property 2017-03-01 15:31:05 -05:00
VSSolution Drop Visual Studio 7 .NET 2003 generator 2017-04-19 15:28:05 -04:00
while Make error message of standalone endwhile command consistent 2016-11-29 13:53:29 -05:00
WriteCompilerDetectionHeader WCDH: Make it possible to generate multiple files. 2014-11-24 21:54:41 +01:00
XcodeProject Genex: Add TARGET_BUNDLE_[CONTENT_]_DIR generator expressions 2017-03-30 22:24:54 +02:00
CMakeLists.txt Merge topic 'separgs-native' 2017-04-28 09:52:07 -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 Revise C++ coding style using clang-format 2016-05-16 16:05:19 -04:00
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: Split RunCTest helper out of RunCMake.CTest(Submit|Memcheck) 2015-02-19 11:26:44 -05:00
RunCMake.cmake Deprecate Visual Studio 8 2005 generator 2017-04-21 13:45:45 -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``
    Process result expected 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``.