diff options
68 files changed, 465 insertions, 70 deletions
diff --git a/Help/command/file.rst b/Help/command/file.rst index b0d4792..73d4cfa 100644 --- a/Help/command/file.rst +++ b/Help/command/file.rst @@ -65,7 +65,10 @@ Parse a list of ASCII strings from ``<filename>`` and store it in Consider only strings that match the given regular expression. ``ENCODING <encoding-type>`` - Consider strings of a given encoding. "UTF-8" is currently supported. + Consider strings of a given encoding. Currently supported encodings are: + UTF-8, UTF-16LE, UTF-16BE, UTF-32LE, UTF-32BE. If the ENCODING option + is not provided and the file has a Byte Order Mark, the ENCODING option + will be defaulted to respect the Byte Order Mark. For example, the code diff --git a/Help/command/link_libraries.rst b/Help/command/link_libraries.rst index d690c9b..fd5dc37 100644 --- a/Help/command/link_libraries.rst +++ b/Help/command/link_libraries.rst @@ -1,16 +1,19 @@ link_libraries -------------- -Deprecated. Use the target_link_libraries() command instead. - Link libraries to all targets added later. :: - link_libraries(library1 <debug | optimized> library2 ...) + link_libraries([item1 [item2 [...]]] + [[debug|optimized|general] <item>] ...) + +Specify libraries or flags to use when linking any targets created later in +the current directory or below by commands such as :command:`add_executable` +or :command:`add_library`. See the :command:`target_link_libraries` command +for meaning of arguments. -Specify a list of libraries to be linked into any following targets -(typically added with the add_executable or add_library calls). This -command is passed down to all subdirectories. The debug and optimized -strings may be used to indicate that the next library listed is to be -used only for that specific type of build. +.. note:: + The :command:`target_link_libraries` command should be preferred whenever + possible. Library dependencies are chained automatically, so directory-wide + specification of link libraries is rarely needed. diff --git a/Help/manual/cmake-commands.7.rst b/Help/manual/cmake-commands.7.rst index 4616dd1..c916f77 100644 --- a/Help/manual/cmake-commands.7.rst +++ b/Help/manual/cmake-commands.7.rst @@ -68,6 +68,7 @@ These commands may be used freely in CMake projects. /command/include /command/install /command/link_directories + /command/link_libraries /command/list /command/load_cache /command/load_command @@ -118,7 +119,6 @@ versions of CMake. Do not use them in new code. /command/install_files /command/install_programs /command/install_targets - /command/link_libraries /command/make_directory /command/output_required_files /command/remove diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index 8dfc16a..da41bbb 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -11,7 +11,7 @@ Synopsis cmake [<options>] (<path-to-source> | <path-to-existing-build>) cmake [(-D<var>=<value>)...] -P <cmake-script-file> cmake --build <dir> [<options>] [-- <build-tool-options>...] - cmake -E <command> [<options>] + cmake -E <command> [<options>...] cmake --find-package <options>... Description @@ -32,17 +32,8 @@ Options .. include:: OPTIONS_BUILD.txt -``-E`` - CMake command mode. - - For true platform independence, CMake provides a list of commands - that can be used on all systems. Run with -E help for the usage - information. Commands available are: chdir, compare_files, copy, - copy_directory, copy_if_different, echo, echo_append, env, environment, - make_directory, md5sum, remove, remove_directory, rename, sleep, tar, time, - touch, touch_nocreate. In addition, some platform specific commands - are available. On Windows: delete_regv, write_regv. On - UNIX: create_symlink. +``-E <command> [<options>...]`` + See `Command-Line Tool Mode`_. ``-L[A][H]`` List non-advanced cached variables. @@ -156,6 +147,111 @@ Options .. include:: OPTIONS_HELP.txt +Command-Line Tool Mode +====================== + +CMake provides builtin command-line tools through the signature:: + + cmake -E <command> [<options>...] + +Run ``cmake -E`` or ``cmake -E help`` for a summary of commands. +Available commands are: + +``chdir <dir> <cmd> [<arg>...]`` + Change the current working directory and run a command. + +``compare_files <file1> <file2>`` + Check if file1 is same as file2. + +``copy <file> <destination>`` + Copy file to destination (either file or directory). + +``copy_directory <source> <destination>`` + Copy directory 'source' content to directory 'destination'. + +``copy_if_different <in-file> <out-file>`` + Copy file if input has changed. + +``echo [<string>...]`` + Displays arguments as text. + +``echo_append [<string>...]`` + Displays arguments as text but no new line. + +``env [--unset=NAME]... [NAME=VALUE]... COMMAND [ARG]...`` + Run command in a modified environment. + +``environment`` + Display the current environment. + +``make_directory <dir>`` + Create a directory. + +``md5sum [<file>...]`` + Compute md5sum of files. + +``remove [-f] [<file>...]`` + Remove the file(s), use ``-f`` to force it. + +``remove_directory <dir>`` + Remove a directory and its contents. + +``rename <oldname> <newname>`` + Rename a file or directory (on one volume). + +``sleep <number>...`` + Sleep for given number of seconds. + +``tar [cxt][vf][zjJ] file.tar [<options>...] [--] [<file>...]`` + Create or extract a tar or zip archive. Options are: + + ``--`` + Stop interpreting options and treat all remaining arguments + as file names even if they start in ``-``. + ``--files-from=<file>`` + Read file names from the given file, one per line. + Blank lines are ignored. Lines may not start in ``-`` + except for ``--add-file=<name>`` to add files whose + names start in ``-``. + ``--mtime=<date>`` + Specify modification time recorded in tarball entries. + +``time <command> [<args>...]`` + Run command and return elapsed time. + +``touch <file>`` + Touch a file. + +``touch_nocreate <file>`` + Touch a file if it exists but do not create it. + +UNIX-specific Command-Line Tools +-------------------------------- + +The following ``cmake -E`` commands are available only on UNIX: + +``create_symlink <old> <new>`` + Create a symbolic link ``<new>`` naming ``<old>``. + +Windows-specific Command-Line Tools +----------------------------------- + +The following ``cmake -E`` commands are available only on Windows: + +``delete_regv <key>`` + Delete Windows registry value. + +``env_vs8_wince <sdkname>`` + Displays a batch file which sets the environment for the provided + Windows CE SDK installed in VS2005. + +``env_vs9_wince <sdkname>`` + Displays a batch file which sets the environment for the provided + Windows CE SDK installed in VS2008. + +``write_regv <key> <value>`` + Write Windows registry value. + See Also ======== diff --git a/Help/release/dev/cmake-E-tar-files-from.rst b/Help/release/dev/cmake-E-tar-files-from.rst new file mode 100644 index 0000000..f6087ff --- /dev/null +++ b/Help/release/dev/cmake-E-tar-files-from.rst @@ -0,0 +1,6 @@ +cmake-E-tar-files-from +---------------------- + +* The :manual:`cmake(1)` ``-E tar`` command learned a new + ``--files-from=<file>`` option to specify file names using + lines in a file to overcome command-line length limits. diff --git a/Help/release/dev/console-pool.rst b/Help/release/dev/console-pool.rst index 19c2f19..1d9bdb8 100644 --- a/Help/release/dev/console-pool.rst +++ b/Help/release/dev/console-pool.rst @@ -5,4 +5,6 @@ console-pool commands learned a new ``USES_TERMINAL`` option to request that the command be given direct access to the terminal if possible. The :generator:`Ninja` generator will places such commands in the - ``console`` pool. + ``console`` pool. Build targets provided by CMake that are meant + for individual interactive use, such as ``install``, are now + placed in this pool. diff --git a/Help/release/dev/file-strings-utf-16.rst b/Help/release/dev/file-strings-utf-16.rst new file mode 100644 index 0000000..f40b63e --- /dev/null +++ b/Help/release/dev/file-strings-utf-16.rst @@ -0,0 +1,5 @@ +file-strings-utf-16 +------------------- + +* The :command:`file(STRINGS)` now supports UTF-16LE, UTF-16BE, + UTF-32LE, UTF-32BE as ``ENCODING`` options. diff --git a/Modules/CTestTargets.cmake b/Modules/CTestTargets.cmake index 5b6e062..1157850 100644 --- a/Modules/CTestTargets.cmake +++ b/Modules/CTestTargets.cmake @@ -67,6 +67,7 @@ if(NOT _CTEST_TARGETS_ADDED) foreach(mode Experimental Nightly Continuous NightlyMemoryCheck) add_custom_target(${mode} ${CMAKE_CTEST_COMMAND} ${__conf_types} -D ${mode} + USES_TERMINAL ) set_property(TARGET ${mode} PROPERTY RULE_LAUNCH_CUSTOM "") set_property(TARGET ${mode} PROPERTY FOLDER "CTestDashboardTargets") @@ -82,6 +83,7 @@ if(NOT _CTEST_TARGETS_ADDED) ) add_custom_target(${mode}${testtype} ${CMAKE_CTEST_COMMAND} ${__conf_types} -D ${mode}${testtype} + USES_TERMINAL ) set_property(TARGET ${mode}${testtype} PROPERTY RULE_LAUNCH_CUSTOM "") set_property(TARGET ${mode}${testtype} PROPERTY FOLDER "CTestDashboardTargets") @@ -94,6 +96,7 @@ if(NOT _CTEST_TARGETS_ADDED) if(CTEST_TEST_TARGET_ALIAS) add_custom_target(${CTEST_TEST_TARGET_ALIAS} ${CMAKE_CTEST_COMMAND} ${__conf_types} + USES_TERMINAL ) endif() endif() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index edd2e5a..5db595c 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 1) -set(CMake_VERSION_PATCH 20150127) +set(CMake_VERSION_PATCH 20150128) #set(CMake_VERSION_RC 1) diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index 0574681..b8077f2 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -119,7 +119,7 @@ CMakeSetupDialog::CMakeSetupDialog() QAction* showChangesAction = ToolsMenu->addAction(tr("&Show My Changes")); QObject::connect(showChangesAction, SIGNAL(triggered(bool)), this, SLOT(showUserChanges())); -#if defined(Q_WS_MAC) +#if defined(Q_WS_MAC) || defined(Q_OS_MAC) this->InstallForCommandLineAction = ToolsMenu->addAction(tr("&Install For Command Line Use")); QObject::connect(this->InstallForCommandLineAction, SIGNAL(triggered(bool)), diff --git a/Source/QtDialog/CMakeSetupDialog.ui b/Source/QtDialog/CMakeSetupDialog.ui index 98da249..b04bd93 100644 --- a/Source/QtDialog/CMakeSetupDialog.ui +++ b/Source/QtDialog/CMakeSetupDialog.ui @@ -134,7 +134,7 @@ </property> <property name="sizeHint" stdset="0"> <size> - <width>40</width> + <width>12</width> <height>23</height> </size> </property> diff --git a/Source/QtDialog/QMacInstallDialog.cxx b/Source/QtDialog/QMacInstallDialog.cxx index 8b8c531..fa7df43 100644 --- a/Source/QtDialog/QMacInstallDialog.cxx +++ b/Source/QtDialog/QMacInstallDialog.cxx @@ -15,11 +15,11 @@ QMacInstallDialog::QMacInstallDialog(QWidget*w) { this->Internals = new QMacInstallDialogInternals; this->Internals->setupUi(this); - QObject::connect(this->Internals->choosePathButton, SIGNAL(pressed()), + QObject::connect(this->Internals->choosePathButton, SIGNAL(clicked(bool)), this, SLOT(ShowBrowser())); - QObject::connect(this->Internals->skipInstallButton, SIGNAL(pressed()), + QObject::connect(this->Internals->skipInstallButton, SIGNAL(clicked(bool)), this, SLOT(SkipInstall())); - QObject::connect(this->Internals->doInstallButton, SIGNAL(pressed()), + QObject::connect(this->Internals->doInstallButton, SIGNAL(clicked(bool)), this, SLOT(DoInstall())); this->Internals->InstallPrefix->setText("/usr/bin/"); diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index f125292..579e715 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -472,7 +472,13 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args) bool have_regex = false; bool newline_consume = false; bool hex_conversion_enabled = true; - bool utf8_encoding = false; + enum { encoding_none = cmsys::FStream::BOM_None, + encoding_utf8 = cmsys::FStream::BOM_UTF8, + encoding_utf16le = cmsys::FStream::BOM_UTF16LE, + encoding_utf16be = cmsys::FStream::BOM_UTF16BE, + encoding_utf32le = cmsys::FStream::BOM_UTF32LE, + encoding_utf32be = cmsys::FStream::BOM_UTF32BE}; + int encoding = encoding_none; int arg_mode = arg_none; for(unsigned int i=3; i < args.size(); ++i) { @@ -599,7 +605,23 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args) { if(args[i] == "UTF-8") { - utf8_encoding = true; + encoding = encoding_utf8; + } + else if(args[i] == "UTF-16LE") + { + encoding = encoding_utf16le; + } + else if(args[i] == "UTF-16BE") + { + encoding = encoding_utf16be; + } + else if(args[i] == "UTF-32LE") + { + encoding = encoding_utf32le; + } + else if(args[i] == "UTF-32BE") + { + encoding = encoding_utf32be; } else { @@ -647,6 +669,23 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args) return false; } + //If BOM is found and encoding was not specified, use the BOM + int bom_found = cmsys::FStream::ReadBOM(fin); + if(encoding == encoding_none && bom_found != cmsys::FStream::BOM_None) + { + encoding = bom_found; + } + + unsigned int bytes_rem = 0; + if(encoding == encoding_utf16le || encoding == encoding_utf16be) + { + bytes_rem = 1; + } + if(encoding == encoding_utf32le || encoding == encoding_utf32be) + { + bytes_rem = 3; + } + // Parse strings out of the file. int output_size = 0; std::vector<std::string> strings; @@ -658,6 +697,25 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args) std::string current_str; int c = fin.get(); + for(unsigned int i=0; i<bytes_rem; ++i) + { + int c1 = fin.get(); + if(!fin) + { + fin.putback(static_cast<char>(c1)); + break; + } + c = (c << 8) | c1; + } + if(encoding == encoding_utf16le) + { + c = ((c & 0xFF) << 8) | ((c & 0xFF00) >> 8); + } + else if(encoding == encoding_utf32le) + { + c = (((c & 0xFF) << 24) | ((c & 0xFF00) << 8) | + ((c & 0xFF0000) >> 8) | ((c & 0xFF000000) >> 24)); + } if(c == '\r') { @@ -673,7 +731,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args) // c is guaranteed to fit in char by the above if... current_str += static_cast<char>(c); } - else if(utf8_encoding) + else if(encoding == encoding_utf8) { // Check for UTF-8 encoded string (up to 4 octets) static const unsigned char utf8_check_table[3][2] = diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index dd3b1ec..4c95a9f 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2191,7 +2191,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) = this->CreateGlobalTarget(this->GetPackageTargetName(), "Run CPack packaging tool...", &cpackCommandLines, depends, - workingDir.c_str(), /*uses_terminal*/false); + workingDir.c_str(), /*uses_terminal*/true); } // CPack source const char* packageSourceTargetName = this->GetPackageSourceTargetName(); @@ -2215,7 +2215,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) = this->CreateGlobalTarget(packageSourceTargetName, "Run CPack packaging tool for source...", &cpackCommandLines, depends, - workingDir.c_str(), /*uses_terminal*/false); + workingDir.c_str(), /*uses_terminal*/true); } } @@ -2241,7 +2241,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) (*targets)[this->GetTestTargetName()] = this->CreateGlobalTarget(this->GetTestTargetName(), "Running tests...", &cpackCommandLines, depends, 0, - /*uses_terminal*/false); + /*uses_terminal*/true); } //Edit Cache @@ -2296,7 +2296,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) (*targets)[rebuildCacheTargetName] = this->CreateGlobalTarget( rebuildCacheTargetName, "Running CMake to regenerate build system...", - &cpackCommandLines, depends, 0, /*uses_terminal*/false); + &cpackCommandLines, depends, 0, /*uses_terminal*/true); } //Install @@ -2377,7 +2377,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) (*targets)[this->GetInstallTargetName()] = this->CreateGlobalTarget( this->GetInstallTargetName(), "Install the project...", - &cpackCommandLines, depends, 0, /*uses_terminal*/false); + &cpackCommandLines, depends, 0, /*uses_terminal*/true); // install_local if(const char* install_local = this->GetInstallLocalTargetName()) @@ -2393,7 +2393,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) (*targets)[install_local] = this->CreateGlobalTarget( install_local, "Installing only the local directory...", - &cpackCommandLines, depends, 0, /*uses_terminal*/false); + &cpackCommandLines, depends, 0, /*uses_terminal*/true); } // install_strip @@ -2410,7 +2410,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) (*targets)[install_strip] = this->CreateGlobalTarget( install_strip, "Installing the project stripped...", - &cpackCommandLines, depends, 0, /*uses_terminal*/false); + &cpackCommandLines, depends, 0, /*uses_terminal*/true); } } } diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 29d8206..652e451 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -437,7 +437,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) return false; } } - std::cerr << "loading initial cache file " << path << "\n"; + std::cout << "loading initial cache file " << path << "\n"; this->ReadListFile(args, path.c_str()); } else if(arg.find("-P",0) == 0) diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 7ca3eb3..28fcd27 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -94,6 +94,51 @@ void CMakeCommandUsage(const char* program) cmSystemTools::Error(errorStream.str().c_str()); } +static bool cmTarFilesFrom(std::string const& file, + std::vector<std::string>& files) +{ + if (cmSystemTools::FileIsDirectory(file)) + { + std::ostringstream e; + e << "-E tar --files-from= file '" << file << "' is a directory"; + cmSystemTools::Error(e.str().c_str()); + return false; + } + cmsys::ifstream fin(file.c_str()); + if (!fin) + { + std::ostringstream e; + e << "-E tar --files-from= file '" << file << "' not found"; + cmSystemTools::Error(e.str().c_str()); + return false; + } + std::string line; + while (cmSystemTools::GetLineFromStream(fin, line)) + { + if (line.empty()) + { + continue; + } + if (cmHasLiteralPrefix(line, "--add-file=")) + { + files.push_back(line.substr(11)); + } + else if (cmHasLiteralPrefix(line, "-")) + { + std::ostringstream e; + e << "-E tar --files-from='" << file << "' file invalid line:\n" + << line << "\n"; + cmSystemTools::Error(e.str().c_str()); + return false; + } + else + { + files.push_back(line); + } + } + return true; +} + int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) { // IF YOU ADD A NEW COMMAND, DOCUMENT IT ABOVE and in cmakemain.cxx @@ -744,6 +789,14 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) { mtime = arg.substr(8); } + else if (cmHasLiteralPrefix(arg, "--files-from=")) + { + std::string const& files_from = arg.substr(13); + if (!cmTarFilesFrom(files_from, files)) + { + return 1; + } + } else { cmSystemTools::Error("Unknown option to -E tar: ", arg.c_str()); diff --git a/Tests/CompileDefinitions/CMakeLists.txt b/Tests/CompileDefinitions/CMakeLists.txt index 930d220..13d1b01 100644 --- a/Tests/CompileDefinitions/CMakeLists.txt +++ b/Tests/CompileDefinitions/CMakeLists.txt @@ -1,6 +1,4 @@ - cmake_minimum_required(VERSION 2.8) - project(CompileDefinitions) if ("${CMAKE_GENERATOR}" STREQUAL "Visual Studio 6") @@ -19,8 +17,8 @@ set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "BUILD_CONFIG_NAME=\"$<CONFIGURATION>\"" ) -add_subdirectory(add_definitions_command) +add_subdirectory(add_def_cmd) add_subdirectory(target_prop) -add_subdirectory(add_definitions_command_with_target_prop) +add_subdirectory(add_def_cmd_tprop) add_executable(CompileDefinitions runtest.c) diff --git a/Tests/CompileDefinitions/add_definitions_command/CMakeLists.txt b/Tests/CompileDefinitions/add_def_cmd/CMakeLists.txt index 23e0134..2bce602 100644 --- a/Tests/CompileDefinitions/add_definitions_command/CMakeLists.txt +++ b/Tests/CompileDefinitions/add_def_cmd/CMakeLists.txt @@ -1,6 +1,3 @@ - -project(add_definitions_command) - add_definitions(-DCMAKE_IS_FUN -DCMAKE_IS=Fun -DCMAKE_IS_="Fun") if (NOT NO_SPACES_IN_DEFINE_VALUES) add_definitions(-DCMAKE_IS_REALLY="Very Fun") @@ -12,4 +9,4 @@ endif() add_definitions(-DCMAKE_IS_FUN -DCMAKE_IS=Fun) add_definitions(-DBUILD_IS_DEBUG=$<CONFIG:Debug> -DBUILD_IS_NOT_DEBUG=$<NOT:$<CONFIG:Debug>>) -add_executable(add_definitions_command_executable ../compiletest.cpp) +add_executable(add_def_cmd_exe ../compiletest.cpp) diff --git a/Tests/CompileDefinitions/add_def_cmd_tprop/CMakeLists.txt b/Tests/CompileDefinitions/add_def_cmd_tprop/CMakeLists.txt new file mode 100644 index 0000000..4ef8a09 --- /dev/null +++ b/Tests/CompileDefinitions/add_def_cmd_tprop/CMakeLists.txt @@ -0,0 +1,16 @@ +add_definitions(-DCMAKE_IS_FUN -DCMAKE_IS=Fun) + +add_executable(add_def_cmd_tprop_exe ../compiletest.cpp) + +set_target_properties(add_def_cmd_tprop_exe PROPERTIES COMPILE_DEFINITIONS CMAKE_IS_="Fun") + +if (NOT NO_SPACES_IN_DEFINE_VALUES) + set_property(TARGET add_def_cmd_tprop_exe APPEND PROPERTY COMPILE_DEFINITIONS CMAKE_IS_REALLY="Very Fun") +endif() + +add_definitions(-DCMAKE_IS_FUN) + +set_property(TARGET add_def_cmd_tprop_exe APPEND PROPERTY COMPILE_DEFINITIONS CMAKE_IS=Fun CMAKE_IS_="Fun") + +add_definitions(-DBUILD_IS_DEBUG=$<CONFIG:Debug>) +set_property(TARGET add_def_cmd_tprop_exe APPEND PROPERTY COMPILE_DEFINITIONS BUILD_IS_NOT_DEBUG=$<NOT:$<CONFIG:Debug>>) diff --git a/Tests/CompileDefinitions/add_definitions_command_with_target_prop/CMakeLists.txt b/Tests/CompileDefinitions/add_definitions_command_with_target_prop/CMakeLists.txt deleted file mode 100644 index 55108db..0000000 --- a/Tests/CompileDefinitions/add_definitions_command_with_target_prop/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ - -project(add_definitions_command_with_target_prop) - -add_definitions(-DCMAKE_IS_FUN -DCMAKE_IS=Fun) - -add_executable(add_definitions_command_with_target_prop_executable ../compiletest.cpp) - -set_target_properties(add_definitions_command_with_target_prop_executable PROPERTIES COMPILE_DEFINITIONS CMAKE_IS_="Fun") - -if (NOT NO_SPACES_IN_DEFINE_VALUES) - set_property(TARGET add_definitions_command_with_target_prop_executable APPEND PROPERTY COMPILE_DEFINITIONS CMAKE_IS_REALLY="Very Fun") -endif() - -add_definitions(-DCMAKE_IS_FUN) - -set_property(TARGET add_definitions_command_with_target_prop_executable APPEND PROPERTY COMPILE_DEFINITIONS CMAKE_IS=Fun CMAKE_IS_="Fun") - -add_definitions(-DBUILD_IS_DEBUG=$<CONFIG:Debug>) -set_property(TARGET add_definitions_command_with_target_prop_executable APPEND PROPERTY COMPILE_DEFINITIONS BUILD_IS_NOT_DEBUG=$<NOT:$<CONFIG:Debug>>) diff --git a/Tests/CompileFeatures/genex_test.cpp b/Tests/CompileFeatures/genex_test.cpp index d9c8eec..2161bca 100644 --- a/Tests/CompileFeatures/genex_test.cpp +++ b/Tests/CompileFeatures/genex_test.cpp @@ -1,9 +1,24 @@ +#ifndef EXPECT_FINAL +# error EXPECT_FINAL not defined +#endif +#ifndef EXPECT_INHERITING_CONSTRUCTORS +# error EXPECT_INHERITING_CONSTRUCTORS not defined +#endif +#ifndef EXPECT_INHERITING_CONSTRUCTORS_AND_FINAL +# error EXPECT_INHERITING_CONSTRUCTORS_AND_FINAL not defined +#endif +#ifndef EXPECT_OVERRIDE_CONTROL +# error EXPECT_OVERRIDE_CONTROL not defined +#endif #if !HAVE_OVERRIDE_CONTROL #if EXPECT_OVERRIDE_CONTROL #error "Expect override control feature" #endif #else +#if !EXPECT_OVERRIDE_CONTROL +#error "Expect no override control feature" +#endif struct A { diff --git a/Tests/ExternalProjectLocal/CMakeLists.txt b/Tests/ExternalProjectLocal/CMakeLists.txt index 9476ab4..e1a67db 100644 --- a/Tests/ExternalProjectLocal/CMakeLists.txt +++ b/Tests/ExternalProjectLocal/CMakeLists.txt @@ -15,7 +15,7 @@ endif() set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMakePredefinedTargets-in-ExternalProjectTest") -set(base "${CMAKE_BINARY_DIR}/CMakeExternals") +set(base "${CMAKE_BINARY_DIR}/Ext") set(binary_base "${base}/Build") set_property(DIRECTORY PROPERTY EP_BASE ${base}) set_property(DIRECTORY PROPERTY EP_STEP_TARGETS configure build test) diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features-result.txt b/Tests/RunCMake/CommandLine/E_tar-bad-from1-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features-result.txt +++ b/Tests/RunCMake/CommandLine/E_tar-bad-from1-result.txt diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from1-stderr.txt b/Tests/RunCMake/CommandLine/E_tar-bad-from1-stderr.txt new file mode 100644 index 0000000..d67431d --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_tar-bad-from1-stderr.txt @@ -0,0 +1 @@ +^CMake Error: -E tar --files-from= file 'bad' not found$ diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from2-result.txt b/Tests/RunCMake/CommandLine/E_tar-bad-from2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_tar-bad-from2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from2-stderr.txt b/Tests/RunCMake/CommandLine/E_tar-bad-from2-stderr.txt new file mode 100644 index 0000000..d1d278c --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_tar-bad-from2-stderr.txt @@ -0,0 +1 @@ +^CMake Error: -E tar --files-from= file '\.' is a directory$ diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from3-result.txt b/Tests/RunCMake/CommandLine/E_tar-bad-from3-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_tar-bad-from3-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from3-stderr.txt b/Tests/RunCMake/CommandLine/E_tar-bad-from3-stderr.txt new file mode 100644 index 0000000..147bd80 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_tar-bad-from3-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: -E tar --files-from='.*/Tests/RunCMake/CommandLine/E_tar-bad-from3.txt' file invalid line: +-add-file=option-typo$ diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from3.txt b/Tests/RunCMake/CommandLine/E_tar-bad-from3.txt new file mode 100644 index 0000000..5bad1c3 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_tar-bad-from3.txt @@ -0,0 +1 @@ +-add-file=option-typo diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from4-result.txt b/Tests/RunCMake/CommandLine/E_tar-bad-from4-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_tar-bad-from4-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from4-stderr.txt b/Tests/RunCMake/CommandLine/E_tar-bad-from4-stderr.txt new file mode 100644 index 0000000..1417d4d --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_tar-bad-from4-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: archive_read_disk_entry_from_file 'does-not-exist':.* +CMake Error: Problem creating tar: bad.tar$ diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from4.txt b/Tests/RunCMake/CommandLine/E_tar-bad-from4.txt new file mode 100644 index 0000000..4b97f79 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_tar-bad-from4.txt @@ -0,0 +1,2 @@ + +does-not-exist diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from5-result.txt b/Tests/RunCMake/CommandLine/E_tar-bad-from5-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_tar-bad-from5-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from5-stderr.txt b/Tests/RunCMake/CommandLine/E_tar-bad-from5-stderr.txt new file mode 100644 index 0000000..1417d4d --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_tar-bad-from5-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: archive_read_disk_entry_from_file 'does-not-exist':.* +CMake Error: Problem creating tar: bad.tar$ diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from5.txt b/Tests/RunCMake/CommandLine/E_tar-bad-from5.txt new file mode 100644 index 0000000..9ea755b --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_tar-bad-from5.txt @@ -0,0 +1,2 @@ + +--add-file=does-not-exist diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index 2994f16..2be6651 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -2,6 +2,11 @@ include(RunCMake) run_cmake_command(E_tar-bad-opt1 ${CMAKE_COMMAND} -E tar cvf bad.tar --bad) run_cmake_command(E_tar-bad-mtime1 ${CMAKE_COMMAND} -E tar cvf bad.tar --mtime=bad .) +run_cmake_command(E_tar-bad-from1 ${CMAKE_COMMAND} -E tar cvf bad.tar --files-from=bad) +run_cmake_command(E_tar-bad-from2 ${CMAKE_COMMAND} -E tar cvf bad.tar --files-from=.) +run_cmake_command(E_tar-bad-from3 ${CMAKE_COMMAND} -E tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/E_tar-bad-from3.txt) +run_cmake_command(E_tar-bad-from4 ${CMAKE_COMMAND} -E tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/E_tar-bad-from4.txt) +run_cmake_command(E_tar-bad-from5 ${CMAKE_COMMAND} -E tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/E_tar-bad-from5.txt) run_cmake_command(E_tar-end-opt1 ${CMAKE_COMMAND} -E tar cvf bad.tar -- --bad) run_cmake_command(E_tar-end-opt2 ${CMAKE_COMMAND} -E tar cvf bad.tar --) run_cmake_command(E_tar-mtime ${CMAKE_COMMAND} -E tar cvf bad.tar "--mtime=1970-01-01 00:00:00 UTC") diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugCommand-result.txt b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugCommand-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugCommand-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features-stderr.txt b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugCommand-stderr.txt index d819d15..1f2c113 100644 --- a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features-stderr.txt +++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugCommand-stderr.txt @@ -1,4 +1,4 @@ -CMake Error at NotAFeature_OriginDebug_target_compile_features.cmake:4 \(target_compile_features\): +CMake Error at NotAFeature_OriginDebugCommand.cmake:4 \(target_compile_features\): target_compile_features specified unknown feature "not_a_feature" for target "somelib". Call Stack \(most recent call first\): diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features.cmake b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugCommand.cmake index 467d9a1..467d9a1 100644 --- a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features.cmake +++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugCommand.cmake diff --git a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake index 1892a5c..376f75a 100644 --- a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake @@ -6,7 +6,7 @@ run_cmake(NotAFeatureTransitive) run_cmake(NotAFeature_OriginDebug) run_cmake(NotAFeature_OriginDebugGenex) run_cmake(NotAFeature_OriginDebugTransitive) -run_cmake(NotAFeature_OriginDebug_target_compile_features) +run_cmake(NotAFeature_OriginDebugCommand) run_cmake(generate_feature_list) file(READ diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index 23f2f97..33b745d 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -79,6 +79,7 @@ function(run_cmake test) set(msg "${msg}Result is [${actual_result}], not [${expect_result}].\n") endif() foreach(o out err) + string(REGEX REPLACE "\r\n" "\n" actual_std${o} "${actual_std${o}}") string(REGEX REPLACE "(^|\n)(==[0-9]+==[^\n]*\n)+" "\\1" actual_std${o} "${actual_std${o}}") string(REGEX REPLACE "\n+$" "" actual_std${o} "${actual_std${o}}") set(expect_${o} "") diff --git a/Tests/RunCMake/configure_file/RerunCMake-rerun-stderr.txt b/Tests/RunCMake/configure_file/RerunCMake-rerun-stderr.txt new file mode 100644 index 0000000..26e07b6 --- /dev/null +++ b/Tests/RunCMake/configure_file/RerunCMake-rerun-stderr.txt @@ -0,0 +1 @@ +^Running CMake on RerunCMake$ diff --git a/Tests/RunCMake/configure_file/RerunCMake-rerun-stdout.txt b/Tests/RunCMake/configure_file/RerunCMake-rerun-stdout.txt new file mode 100644 index 0000000..34c873c --- /dev/null +++ b/Tests/RunCMake/configure_file/RerunCMake-rerun-stdout.txt @@ -0,0 +1,3 @@ +-- Configuring done +-- Generating done +-- Build files have been written to: .*/Tests/RunCMake/configure_file/RerunCMake-build diff --git a/Tests/RunCMake/configure_file/RerunCMake-stderr.txt b/Tests/RunCMake/configure_file/RerunCMake-stderr.txt new file mode 100644 index 0000000..26e07b6 --- /dev/null +++ b/Tests/RunCMake/configure_file/RerunCMake-stderr.txt @@ -0,0 +1 @@ +^Running CMake on RerunCMake$ diff --git a/Tests/RunCMake/configure_file/RerunCMake-stdout.txt b/Tests/RunCMake/configure_file/RerunCMake-stdout.txt new file mode 100644 index 0000000..34c873c --- /dev/null +++ b/Tests/RunCMake/configure_file/RerunCMake-stdout.txt @@ -0,0 +1,3 @@ +-- Configuring done +-- Generating done +-- Build files have been written to: .*/Tests/RunCMake/configure_file/RerunCMake-build diff --git a/Tests/RunCMake/configure_file/RerunCMake.cmake b/Tests/RunCMake/configure_file/RerunCMake.cmake new file mode 100644 index 0000000..890cc1f --- /dev/null +++ b/Tests/RunCMake/configure_file/RerunCMake.cmake @@ -0,0 +1,8 @@ +message("Running CMake on RerunCMake") # write to stderr if cmake reruns +configure_file( + "${CMAKE_CURRENT_BINARY_DIR}/ConfigureFileInput.txt.in" + "${CMAKE_CURRENT_BINARY_DIR}/ConfigureFileOutput.txt" + @ONLY + ) +# make sure CMakeCache.txt is newer than ConfigureFileOutput.txt +execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1) diff --git a/Tests/RunCMake/configure_file/RunCMakeTest.cmake b/Tests/RunCMake/configure_file/RunCMakeTest.cmake index c010256..489652b 100644 --- a/Tests/RunCMake/configure_file/RunCMakeTest.cmake +++ b/Tests/RunCMake/configure_file/RunCMakeTest.cmake @@ -7,3 +7,37 @@ run_cmake(UTF16BE-BOM) run_cmake(UTF32LE-BOM) run_cmake(UTF32BE-BOM) run_cmake(UnknownArg) + +if(RunCMake_GENERATOR MATCHES "Make") + # Use a single build tree for a few tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/RerunCMake-build) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + set(in_conf "${RunCMake_TEST_BINARY_DIR}/ConfigureFileInput.txt.in") + file(WRITE "${in_conf}" "1") + + message(STATUS "RerunCMake: first configuration...") + run_cmake(RerunCMake) + run_cmake_command(RerunCMake-nowork ${CMAKE_COMMAND} --build .) + + execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1) # handle 1s resolution + message(STATUS "RerunCMake: touch configure_file input...") + file(WRITE "${in_conf}" "1") + run_cmake_command(RerunCMake-rerun ${CMAKE_COMMAND} --build .) + run_cmake_command(RerunCMake-nowork ${CMAKE_COMMAND} --build .) + + execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1) # handle 1s resolution + message(STATUS "RerunCMake: modify configure_file input...") + file(WRITE "${in_conf}" "2") + run_cmake_command(RerunCMake-rerun ${CMAKE_COMMAND} --build .) + run_cmake_command(RerunCMake-nowork ${CMAKE_COMMAND} --build .) + + message(STATUS "RerunCMake: remove configure_file output...") + file(REMOVE "${RunCMake_TEST_BINARY_DIR}/ConfigureFileOutput.txt") + run_cmake_command(RerunCMake-rerun ${CMAKE_COMMAND} --build .) + run_cmake_command(RerunCMake-nowork ${CMAKE_COMMAND} --build .) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) +endif() diff --git a/Tests/RunCMake/string/RunCMakeTest.cmake b/Tests/RunCMake/string/RunCMakeTest.cmake index fc913c6..89f7ea5 100644 --- a/Tests/RunCMake/string/RunCMakeTest.cmake +++ b/Tests/RunCMake/string/RunCMakeTest.cmake @@ -12,3 +12,8 @@ run_cmake(UuidMissingTypeValue) run_cmake(UuidBadType) run_cmake(RegexClear) + +run_cmake(UTF-16BE) +run_cmake(UTF-16LE) +run_cmake(UTF-32BE) +run_cmake(UTF-32LE) diff --git a/Tests/RunCMake/string/UTF-16BE-stderr.txt b/Tests/RunCMake/string/UTF-16BE-stderr.txt new file mode 100644 index 0000000..8254f87 --- /dev/null +++ b/Tests/RunCMake/string/UTF-16BE-stderr.txt @@ -0,0 +1,2 @@ +Hello World +Hello World diff --git a/Tests/RunCMake/string/UTF-16BE.cmake b/Tests/RunCMake/string/UTF-16BE.cmake new file mode 100644 index 0000000..da986c0 --- /dev/null +++ b/Tests/RunCMake/string/UTF-16BE.cmake @@ -0,0 +1,4 @@ +file(STRINGS UTF-16BE.txt str ENCODING UTF-16BE LENGTH_MINIMUM 4) +message("${str}") +file(STRINGS UTF-16BE.txt str LENGTH_MINIMUM 4) +message("${str}") diff --git a/Tests/RunCMake/string/UTF-16BE.txt b/Tests/RunCMake/string/UTF-16BE.txt Binary files differnew file mode 100644 index 0000000..9d976bc --- /dev/null +++ b/Tests/RunCMake/string/UTF-16BE.txt diff --git a/Tests/RunCMake/string/UTF-16LE-stderr.txt b/Tests/RunCMake/string/UTF-16LE-stderr.txt new file mode 100644 index 0000000..8254f87 --- /dev/null +++ b/Tests/RunCMake/string/UTF-16LE-stderr.txt @@ -0,0 +1,2 @@ +Hello World +Hello World diff --git a/Tests/RunCMake/string/UTF-16LE.cmake b/Tests/RunCMake/string/UTF-16LE.cmake new file mode 100644 index 0000000..326d848 --- /dev/null +++ b/Tests/RunCMake/string/UTF-16LE.cmake @@ -0,0 +1,4 @@ +file(STRINGS UTF-16LE.txt str ENCODING UTF-16LE LENGTH_MINIMUM 4) +message("${str}") +file(STRINGS UTF-16LE.txt str LENGTH_MINIMUM 4) +message("${str}") diff --git a/Tests/RunCMake/string/UTF-16LE.txt b/Tests/RunCMake/string/UTF-16LE.txt Binary files differnew file mode 100644 index 0000000..ebba874 --- /dev/null +++ b/Tests/RunCMake/string/UTF-16LE.txt diff --git a/Tests/RunCMake/string/UTF-32BE-stderr.txt b/Tests/RunCMake/string/UTF-32BE-stderr.txt new file mode 100644 index 0000000..8254f87 --- /dev/null +++ b/Tests/RunCMake/string/UTF-32BE-stderr.txt @@ -0,0 +1,2 @@ +Hello World +Hello World diff --git a/Tests/RunCMake/string/UTF-32BE.cmake b/Tests/RunCMake/string/UTF-32BE.cmake new file mode 100644 index 0000000..debdeaa --- /dev/null +++ b/Tests/RunCMake/string/UTF-32BE.cmake @@ -0,0 +1,4 @@ +file(STRINGS UTF-32BE.txt str ENCODING UTF-32BE LENGTH_MINIMUM 4) +message("${str}") +file(STRINGS UTF-32BE.txt str LENGTH_MINIMUM 4) +message("${str}") diff --git a/Tests/RunCMake/string/UTF-32BE.txt b/Tests/RunCMake/string/UTF-32BE.txt Binary files differnew file mode 100644 index 0000000..6725fbb --- /dev/null +++ b/Tests/RunCMake/string/UTF-32BE.txt diff --git a/Tests/RunCMake/string/UTF-32LE-stderr.txt b/Tests/RunCMake/string/UTF-32LE-stderr.txt new file mode 100644 index 0000000..8254f87 --- /dev/null +++ b/Tests/RunCMake/string/UTF-32LE-stderr.txt @@ -0,0 +1,2 @@ +Hello World +Hello World diff --git a/Tests/RunCMake/string/UTF-32LE.cmake b/Tests/RunCMake/string/UTF-32LE.cmake new file mode 100644 index 0000000..22aab5f --- /dev/null +++ b/Tests/RunCMake/string/UTF-32LE.cmake @@ -0,0 +1,4 @@ +file(STRINGS UTF-32LE.txt str ENCODING UTF-32LE LENGTH_MINIMUM 4) +message("${str}") +file(STRINGS UTF-32LE.txt str LENGTH_MINIMUM 4) +message("${str}") diff --git a/Tests/RunCMake/string/UTF-32LE.txt b/Tests/RunCMake/string/UTF-32LE.txt Binary files differnew file mode 100644 index 0000000..cf5102f --- /dev/null +++ b/Tests/RunCMake/string/UTF-32LE.txt diff --git a/Tests/RunCMake/try_compile/RerunCMake-nowork-ninja-no-console-stdout.txt b/Tests/RunCMake/try_compile/RerunCMake-nowork-ninja-no-console-stdout.txt new file mode 100644 index 0000000..e600b9b --- /dev/null +++ b/Tests/RunCMake/try_compile/RerunCMake-nowork-ninja-no-console-stdout.txt @@ -0,0 +1 @@ +^ninja: no work to do\.$ diff --git a/Tests/RunCMake/try_compile/RerunCMake-rerun-ninja-no-console-stdout.txt b/Tests/RunCMake/try_compile/RerunCMake-rerun-ninja-no-console-stdout.txt new file mode 100644 index 0000000..b0438f5 --- /dev/null +++ b/Tests/RunCMake/try_compile/RerunCMake-rerun-ninja-no-console-stdout.txt @@ -0,0 +1,5 @@ +Running CMake on RerunCMake +FALSE +-- Configuring done +-- Generating done +-- Build files have been written to: .*/Tests/RunCMake/try_compile/RerunCMake-build diff --git a/Tests/RunCMake/try_compile/RerunCMake-rerun-stderr.txt b/Tests/RunCMake/try_compile/RerunCMake-rerun-stderr.txt new file mode 100644 index 0000000..88e54b1 --- /dev/null +++ b/Tests/RunCMake/try_compile/RerunCMake-rerun-stderr.txt @@ -0,0 +1,2 @@ +^Running CMake on RerunCMake +FALSE$ diff --git a/Tests/RunCMake/try_compile/RerunCMake-rerun-stdout.txt b/Tests/RunCMake/try_compile/RerunCMake-rerun-stdout.txt new file mode 100644 index 0000000..9c78b26 --- /dev/null +++ b/Tests/RunCMake/try_compile/RerunCMake-rerun-stdout.txt @@ -0,0 +1,3 @@ +-- Configuring done +-- Generating done +-- Build files have been written to: .*/Tests/RunCMake/try_compile/RerunCMake-build diff --git a/Tests/RunCMake/try_compile/RerunCMake-stderr.txt b/Tests/RunCMake/try_compile/RerunCMake-stderr.txt new file mode 100644 index 0000000..45d305a --- /dev/null +++ b/Tests/RunCMake/try_compile/RerunCMake-stderr.txt @@ -0,0 +1,2 @@ +^Running CMake on RerunCMake +TRUE$ diff --git a/Tests/RunCMake/try_compile/RerunCMake-stdout.txt b/Tests/RunCMake/try_compile/RerunCMake-stdout.txt new file mode 100644 index 0000000..9c78b26 --- /dev/null +++ b/Tests/RunCMake/try_compile/RerunCMake-stdout.txt @@ -0,0 +1,3 @@ +-- Configuring done +-- Generating done +-- Build files have been written to: .*/Tests/RunCMake/try_compile/RerunCMake-build diff --git a/Tests/RunCMake/try_compile/RerunCMake.cmake b/Tests/RunCMake/try_compile/RerunCMake.cmake new file mode 100644 index 0000000..5a9f1d4 --- /dev/null +++ b/Tests/RunCMake/try_compile/RerunCMake.cmake @@ -0,0 +1,7 @@ +message("Running CMake on RerunCMake") # write to stderr if cmake reruns +enable_language(C) +try_compile(res + "${CMAKE_CURRENT_BINARY_DIR}" + SOURCES "${CMAKE_CURRENT_BINARY_DIR}/TryCompileInput.c" + ) +message("${res}") diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake index 06096b2..6cdbafa 100644 --- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake +++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake @@ -17,3 +17,36 @@ run_cmake(NonSourceCopyFile) run_cmake(NonSourceCompileDefinitions) run_cmake(CMP0056) + +if(RunCMake_GENERATOR MATCHES "Make|Ninja") + # Use a single build tree for a few tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/RerunCMake-build) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + set(in_tc "${RunCMake_TEST_BINARY_DIR}/TryCompileInput.c") + file(WRITE "${in_tc}" "int main(void) { return 0; }\n") + + # Older Ninja keeps all rerun output on stdout + set(ninja "") + if(RunCMake_GENERATOR STREQUAL "Ninja") + execute_process(COMMAND ${RunCMake_MAKE_PROGRAM} --version + OUTPUT_VARIABLE ninja_version OUTPUT_STRIP_TRAILING_WHITESPACE) + if(ninja_version VERSION_LESS 1.5) + set(ninja -ninja-no-console) + endif() + endif() + + message(STATUS "RerunCMake: first configuration...") + run_cmake(RerunCMake) + run_cmake_command(RerunCMake-nowork${ninja} ${CMAKE_COMMAND} --build .) + + execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1) # handle 1s resolution + message(STATUS "RerunCMake: modify try_compile input...") + file(WRITE "${in_tc}" "does-not-compile\n") + run_cmake_command(RerunCMake-rerun${ninja} ${CMAKE_COMMAND} --build .) + run_cmake_command(RerunCMake-nowork${ninja} ${CMAKE_COMMAND} --build .) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) +endif() |