summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeCommands/target_link_libraries/CMakeLists.txt4
-rw-r--r--Tests/CMakeCommands/target_link_libraries/SubDirC/CMakeLists.txt9
-rw-r--r--Tests/CMakeCommands/target_link_libraries/SubDirC/SubDirC.c11
-rw-r--r--Tests/CMakeCommands/target_link_libraries/TopDir.c6
-rw-r--r--Tests/CMakeLib/CMakeLists.txt4
-rw-r--r--Tests/CMakeLib/testUVRAII.cxx50
-rw-r--r--Tests/CMakeLib/testUVStreambuf.cxx457
-rw-r--r--Tests/GeneratorExpression/CMakeLists.txt45
-rw-r--r--Tests/MSVCRuntimeLibrary/CMakeLists.txt15
-rw-r--r--Tests/ObjectLibrary/CMakeLists.txt10
-rw-r--r--Tests/RunCMake/File_Generate/OutputNameMatchesObjects-stderr.txt3
-rw-r--r--Tests/RunCMake/File_Generate/OutputNameMatchesObjects.cmake7
-rw-r--r--Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt5
-rw-r--r--Tests/RunCMake/ObjectLibrary/BadSourceExpression3.cmake2
-rw-r--r--Tests/RunCMake/ObjectLibrary/CheckTargetObjects.cmake32
-rw-r--r--Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake5
-rw-r--r--Tests/RunCMake/ObjectLibrary/check_object_files.cmake17
-rw-r--r--Tests/RunCMake/TargetObjects/NotObjlibTarget-stderr.txt9
-rw-r--r--Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake4
-rw-r--r--Tests/RunCMake/VS10Project/RuntimeLibrary-check.cmake4
-rw-r--r--Tests/RunCMake/VS10Project/RuntimeLibrary.cmake4
-rw-r--r--Tests/RunCMake/execute_process/EchoCommand-result.txt1
-rw-r--r--Tests/RunCMake/execute_process/EchoCommand-stderr.txt5
-rw-r--r--Tests/RunCMake/execute_process/EchoCommand-stdout.txt12
-rw-r--r--Tests/RunCMake/execute_process/EchoCommand.cmake41
-rw-r--r--Tests/RunCMake/execute_process/EchoCommand2-result.txt1
-rw-r--r--Tests/RunCMake/execute_process/EchoCommand2-stderr.txt5
-rw-r--r--Tests/RunCMake/execute_process/EchoCommand2-stdout.txt12
-rw-r--r--Tests/RunCMake/execute_process/EchoCommand3-result.txt1
-rw-r--r--Tests/RunCMake/execute_process/EchoCommand3-stderr.txt2
-rw-r--r--Tests/RunCMake/execute_process/RunCMakeTest.cmake8
-rw-r--r--Tests/RunCMake/message/RunCMakeTest.cmake42
-rw-r--r--Tests/RunCMake/message/message-all-loglevels.cmake10
-rw-r--r--Tests/RunCMake/message/message-loglevel-debug-stderr.txt12
-rw-r--r--Tests/RunCMake/message/message-loglevel-debug-stdout.txt3
-rw-r--r--Tests/RunCMake/message/message-loglevel-default-stderr.txt12
-rw-r--r--Tests/RunCMake/message/message-loglevel-default-stdout.txt1
-rw-r--r--Tests/RunCMake/message/message-loglevel-invalid-result.txt1
-rw-r--r--Tests/RunCMake/message/message-loglevel-invalid-stderr.txt1
-rw-r--r--Tests/RunCMake/message/message-loglevel-notice-stderr.txt12
-rw-r--r--Tests/RunCMake/message/message-loglevel-status-stderr.txt12
-rw-r--r--Tests/RunCMake/message/message-loglevel-status-stdout.txt1
-rw-r--r--Tests/RunCMake/message/message-loglevel-trace-stderr.txt12
-rw-r--r--Tests/RunCMake/message/message-loglevel-trace-stdout.txt4
-rw-r--r--Tests/RunCMake/message/message-loglevel-verbose-stderr.txt12
-rw-r--r--Tests/RunCMake/message/message-loglevel-verbose-stdout.txt2
-rw-r--r--Tests/RunCMake/message/message-loglevel-warning-stderr.txt9
-rw-r--r--Tests/SourceGroups/CMakeLists.txt8
48 files changed, 927 insertions, 18 deletions
diff --git a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt
index 85ce1f7..5c704ac 100644
--- a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt
+++ b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt
@@ -134,11 +134,15 @@ assert_property(newsignature1 LINK_LIBRARIES "depC;depB;subdirlib")
#----------------------------------------------------------------------------
# Test cross-directory linking.
cmake_policy(PUSH)
+cmake_policy(SET CMP0022 NEW)
cmake_policy(SET CMP0079 NEW)
add_executable(TopDir TopDir.c)
add_subdirectory(SubDirA)
add_subdirectory(SubDirB)
target_link_libraries(SubDirB TopDirImported)
+add_subdirectory(SubDirC)
+target_link_libraries(SubDirC PRIVATE SubDirC2)
+target_link_libraries(TopDir SubDirC)
add_library(TopDirImported IMPORTED INTERFACE)
target_compile_definitions(TopDirImported INTERFACE DEF_TopDirImported)
cmake_policy(POP)
diff --git a/Tests/CMakeCommands/target_link_libraries/SubDirC/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/SubDirC/CMakeLists.txt
new file mode 100644
index 0000000..54bcc51
--- /dev/null
+++ b/Tests/CMakeCommands/target_link_libraries/SubDirC/CMakeLists.txt
@@ -0,0 +1,9 @@
+add_library(SubDirC STATIC SubDirC.c)
+
+add_library(SubDirC1 INTERFACE)
+target_compile_definitions(SubDirC1 INTERFACE DEF_SubDirC1)
+
+add_library(SubDirC2 INTERFACE)
+target_compile_definitions(SubDirC2 INTERFACE DEF_SubDirC2)
+
+target_link_libraries(SubDirC PRIVATE SubDirC1)
diff --git a/Tests/CMakeCommands/target_link_libraries/SubDirC/SubDirC.c b/Tests/CMakeCommands/target_link_libraries/SubDirC/SubDirC.c
new file mode 100644
index 0000000..c5536dc
--- /dev/null
+++ b/Tests/CMakeCommands/target_link_libraries/SubDirC/SubDirC.c
@@ -0,0 +1,11 @@
+#ifndef DEF_SubDirC1
+# error "DEF_SubDirC1 not defined"
+#endif
+#ifndef DEF_SubDirC2
+# error "DEF_SubDirC2 not defined"
+#endif
+
+int SubDirC(void)
+{
+ return 0;
+}
diff --git a/Tests/CMakeCommands/target_link_libraries/TopDir.c b/Tests/CMakeCommands/target_link_libraries/TopDir.c
index 4706bb9..d8066e5 100644
--- a/Tests/CMakeCommands/target_link_libraries/TopDir.c
+++ b/Tests/CMakeCommands/target_link_libraries/TopDir.c
@@ -7,6 +7,12 @@
#ifdef DEF_TopDirImported
# error "DEF_TopDirImported is defined but should not be!"
#endif
+#ifdef DEF_SubDirC1
+# error "DEF_SubDirC1 defined but should not be"
+#endif
+#ifdef DEF_SubDirC2
+# error "DEF_SubDirC2 defined but should not be"
+#endif
int main(void)
{
diff --git a/Tests/CMakeLib/CMakeLists.txt b/Tests/CMakeLib/CMakeLists.txt
index 031ab01..e04bba2 100644
--- a/Tests/CMakeLib/CMakeLists.txt
+++ b/Tests/CMakeLib/CMakeLists.txt
@@ -16,9 +16,11 @@ set(CMakeLib_TESTS
testXMLSafe.cxx
testFindPackageCommand.cxx
testUVRAII.cxx
+ testUVStreambuf.cxx
)
set(testRST_ARGS ${CMAKE_CURRENT_SOURCE_DIR})
+set(testUVStreambuf_ARGS $<TARGET_FILE:cmake>)
if(WIN32)
list(APPEND CMakeLib_TESTS
@@ -43,7 +45,7 @@ target_link_libraries(testEncoding cmsys)
foreach(testfile ${CMakeLib_TESTS})
get_filename_component(test "${testfile}" NAME_WE)
- add_test(CMakeLib.${test} CMakeLibTests ${test} ${${test}_ARGS})
+ add_test(NAME CMakeLib.${test} COMMAND CMakeLibTests ${test} ${${test}_ARGS})
endforeach()
if(TEST_CompileCommandOutput)
diff --git a/Tests/CMakeLib/testUVRAII.cxx b/Tests/CMakeLib/testUVRAII.cxx
index 1c1da76..2aeaf2c 100644
--- a/Tests/CMakeLib/testUVRAII.cxx
+++ b/Tests/CMakeLib/testUVRAII.cxx
@@ -171,11 +171,59 @@ static bool testAllMoves()
return true;
};
+static bool testLoopReset()
+{
+ bool closed = false;
+ cm::uv_loop_ptr loop;
+ loop.init();
+
+ uv_timer_t timer;
+ uv_timer_init(loop, &timer);
+ timer.data = &closed;
+ uv_close(reinterpret_cast<uv_handle_t*>(&timer), [](uv_handle_t* handle) {
+ auto closedPtr = static_cast<bool*>(handle->data);
+ *closedPtr = true;
+ });
+
+ loop.reset();
+ if (!closed) {
+ std::cerr << "uv_loop_ptr did not finish" << std::endl;
+ return false;
+ }
+
+ return true;
+};
+
+static bool testLoopDestructor()
+{
+ bool closed = false;
+
+ uv_timer_t timer;
+ {
+ cm::uv_loop_ptr loop;
+ loop.init();
+
+ uv_timer_init(loop, &timer);
+ timer.data = &closed;
+ uv_close(reinterpret_cast<uv_handle_t*>(&timer), [](uv_handle_t* handle) {
+ auto closedPtr = static_cast<bool*>(handle->data);
+ *closedPtr = true;
+ });
+ }
+
+ if (!closed) {
+ std::cerr << "uv_loop_ptr did not finish" << std::endl;
+ return false;
+ }
+
+ return true;
+};
+
int testUVRAII(int, char** const)
{
if ((testAsyncShutdown() &&
testAsyncDtor() & testAsyncMove() & testCrossAssignment() &
- testAllMoves()) == 0) {
+ testAllMoves() & testLoopReset() & testLoopDestructor()) == 0) {
return -1;
}
return 0;
diff --git a/Tests/CMakeLib/testUVStreambuf.cxx b/Tests/CMakeLib/testUVStreambuf.cxx
new file mode 100644
index 0000000..39655f3
--- /dev/null
+++ b/Tests/CMakeLib/testUVStreambuf.cxx
@@ -0,0 +1,457 @@
+#include "cmUVStreambuf.h"
+
+#include "cmGetPipes.h"
+#include "cmUVHandlePtr.h"
+
+#include "cm_uv.h"
+
+#include <iostream>
+#include <string>
+#include <vector>
+
+#include <cstring>
+
+#include <stdint.h>
+
+#define TEST_STR_LINE_1 "This string must be exactly 128 characters long so"
+#define TEST_STR_LINE_2 "that we can test CMake's std::streambuf integration"
+#define TEST_STR_LINE_3 "with libuv's uv_stream_t."
+#define TEST_STR TEST_STR_LINE_1 "\n" TEST_STR_LINE_2 "\n" TEST_STR_LINE_3
+
+bool writeDataToStreamPipe(uv_loop_t& loop, cm::uv_pipe_ptr& inputPipe,
+ char* outputData, unsigned int outputDataLength,
+ const char* /* unused */)
+{
+ int err;
+
+ // Create the pipe
+ int pipeHandles[2];
+ if (cmGetPipes(pipeHandles) < 0) {
+ std::cout << "Could not open pipe" << std::endl;
+ return false;
+ }
+
+ cm::uv_pipe_ptr outputPipe;
+ inputPipe.init(loop, 0);
+ outputPipe.init(loop, 0);
+ uv_pipe_open(inputPipe, pipeHandles[0]);
+ uv_pipe_open(outputPipe, pipeHandles[1]);
+
+ // Write data for reading
+ uv_write_t writeReq;
+ struct WriteCallbackData
+ {
+ bool Finished = false;
+ int Status;
+ } writeData;
+ writeReq.data = &writeData;
+ uv_buf_t outputBuf;
+ outputBuf.base = outputData;
+ outputBuf.len = outputDataLength;
+ if ((err = uv_write(&writeReq, outputPipe, &outputBuf, 1,
+ [](uv_write_t* req, int status) {
+ auto data = static_cast<WriteCallbackData*>(req->data);
+ data->Finished = true;
+ data->Status = status;
+ })) < 0) {
+ std::cout << "Could not write to pipe: " << uv_strerror(err) << std::endl;
+ return false;
+ }
+ while (!writeData.Finished) {
+ uv_run(&loop, UV_RUN_ONCE);
+ }
+ if (writeData.Status < 0) {
+ std::cout << "Status is " << uv_strerror(writeData.Status)
+ << ", should be 0" << std::endl;
+ return false;
+ }
+
+ return true;
+}
+
+bool writeDataToStreamProcess(uv_loop_t& loop, cm::uv_pipe_ptr& inputPipe,
+ char* outputData, unsigned int /* unused */,
+ const char* cmakeCommand)
+{
+ int err;
+
+ inputPipe.init(loop, 0);
+ std::vector<std::string> arguments = { cmakeCommand, "-E", "echo_append",
+ outputData };
+ std::vector<const char*> processArgs;
+ for (auto const& arg : arguments) {
+ processArgs.push_back(arg.c_str());
+ }
+ processArgs.push_back(nullptr);
+ std::vector<uv_stdio_container_t> stdio(3);
+ stdio[0].flags = UV_IGNORE;
+ stdio[0].data.stream = nullptr;
+ stdio[1].flags =
+ static_cast<uv_stdio_flags>(UV_CREATE_PIPE | UV_WRITABLE_PIPE);
+ stdio[1].data.stream = inputPipe;
+ stdio[2].flags = UV_IGNORE;
+ stdio[2].data.stream = nullptr;
+
+ struct ProcessExitData
+ {
+ bool Finished = false;
+ int64_t ExitStatus;
+ int TermSignal;
+ } exitData;
+ cm::uv_process_ptr process;
+ auto options = uv_process_options_t();
+ options.file = cmakeCommand;
+ options.args = const_cast<char**>(processArgs.data());
+ options.flags = UV_PROCESS_WINDOWS_HIDE;
+ options.stdio = stdio.data();
+ options.stdio_count = static_cast<int>(stdio.size());
+ options.exit_cb = [](uv_process_t* handle, int64_t exitStatus,
+ int termSignal) {
+ auto data = static_cast<ProcessExitData*>(handle->data);
+ data->Finished = true;
+ data->ExitStatus = exitStatus;
+ data->TermSignal = termSignal;
+ };
+ if ((err = process.spawn(loop, options, &exitData)) < 0) {
+ std::cout << "Could not spawn process: " << uv_strerror(err) << std::endl;
+ return false;
+ }
+ while (!exitData.Finished) {
+ uv_run(&loop, UV_RUN_ONCE);
+ }
+ if (exitData.ExitStatus != 0) {
+ std::cout << "Process exit status is " << exitData.ExitStatus
+ << ", should be 0" << std::endl;
+ return false;
+ }
+ if (exitData.TermSignal != 0) {
+ std::cout << "Process term signal is " << exitData.TermSignal
+ << ", should be 0" << std::endl;
+ return false;
+ }
+
+ return true;
+}
+
+bool testUVStreambufRead(
+ bool (*cb)(uv_loop_t& loop, cm::uv_pipe_ptr& inputPipe, char* outputData,
+ unsigned int outputDataLength, const char* cmakeCommand),
+ const char* cmakeCommand)
+{
+ char outputData[] = TEST_STR;
+ bool success = false;
+ cm::uv_loop_ptr loop;
+ loop.init();
+ cm::uv_pipe_ptr inputPipe;
+ std::vector<char> inputData(128);
+ std::streamsize readLen;
+ std::string line;
+ cm::uv_timer_ptr timer;
+
+ // Create the streambuf
+ cmUVStreambuf inputBuf(64);
+ std::istream inputStream(&inputBuf);
+ if (inputBuf.is_open()) {
+ std::cout << "is_open() is true, should be false" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != -1) {
+ std::cout << "in_avail() returned " << readLen << ", should be -1"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) {
+ std::cout << "sgetn() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+
+ // Perform first read test - read all the data
+ if (!cb(*loop, inputPipe, outputData, 128, cmakeCommand)) {
+ goto end;
+ }
+ inputBuf.open(inputPipe);
+ if (!inputBuf.is_open()) {
+ std::cout << "is_open() is false, should be true" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != 0) {
+ std::cout << "in_avail() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 128) {
+ std::cout << "sgetn() returned " << readLen << ", should be 128"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != 0) {
+ std::cout << "in_avail() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+ if (std::memcmp(inputData.data(), outputData, 128)) {
+ std::cout << "Read data does not match write data" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) {
+ std::cout << "sgetn() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != -1) {
+ std::cout << "in_avail() returned " << readLen << ", should be -1"
+ << std::endl;
+ goto end;
+ }
+ inputData.assign(128, char{});
+ inputBuf.close();
+ if (inputBuf.is_open()) {
+ std::cout << "is_open() is true, should be false" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) {
+ std::cout << "sgetn() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != -1) {
+ std::cout << "in_avail() returned " << readLen << ", should be -1"
+ << std::endl;
+ goto end;
+ }
+
+ // Perform second read test - read some data and then close
+ if (!cb(*loop, inputPipe, outputData, 128, cmakeCommand)) {
+ goto end;
+ }
+ inputBuf.open(inputPipe);
+ if (!inputBuf.is_open()) {
+ std::cout << "is_open() is false, should be true" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != 0) {
+ std::cout << "in_avail() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 64)) != 64) {
+ std::cout << "sgetn() returned " << readLen << ", should be 64"
+ << std::endl;
+ goto end;
+ }
+ if (std::memcmp(inputData.data(), outputData, 64)) {
+ std::cout << "Read data does not match write data" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != 8) {
+ std::cout << "in_avail() returned " << readLen << ", should be 8"
+ << std::endl;
+ goto end;
+ }
+ inputData.assign(128, char{});
+ inputBuf.close();
+ if (inputBuf.is_open()) {
+ std::cout << "is_open() is true, should be false" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != -1) {
+ std::cout << "in_avail() returned " << readLen << ", should be -1"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) {
+ std::cout << "sgetn() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+
+ // Perform third read test - read line by line
+ if (!cb(*loop, inputPipe, outputData, 128, cmakeCommand)) {
+ goto end;
+ }
+ inputBuf.open(inputPipe);
+ if (!inputBuf.is_open()) {
+ std::cout << "is_open() is false, should be true" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != 0) {
+ std::cout << "in_avail() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+
+ if (!std::getline(inputStream, line)) {
+ std::cout << "getline returned false, should be true" << std::endl;
+ goto end;
+ }
+ if (line != TEST_STR_LINE_1) {
+ std::cout << "Line 1 is \"" << line
+ << "\", should be \"" TEST_STR_LINE_1 "\"" << std::endl;
+ goto end;
+ }
+
+ if (!std::getline(inputStream, line)) {
+ std::cout << "getline returned false, should be true" << std::endl;
+ goto end;
+ }
+ if (line != TEST_STR_LINE_2) {
+ std::cout << "Line 2 is \"" << line
+ << "\", should be \"" TEST_STR_LINE_2 "\"" << std::endl;
+ goto end;
+ }
+
+ if (!std::getline(inputStream, line)) {
+ std::cout << "getline returned false, should be true" << std::endl;
+ goto end;
+ }
+ if (line != TEST_STR_LINE_3) {
+ std::cout << "Line 3 is \"" << line
+ << "\", should be \"" TEST_STR_LINE_3 "\"" << std::endl;
+ goto end;
+ }
+
+ if (std::getline(inputStream, line)) {
+ std::cout << "getline returned true, should be false" << std::endl;
+ goto end;
+ }
+
+ inputBuf.close();
+ if (inputBuf.is_open()) {
+ std::cout << "is_open() is true, should be false" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != -1) {
+ std::cout << "in_avail() returned " << readLen << ", should be -1"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) {
+ std::cout << "sgetn() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+
+ // Perform fourth read test - run the event loop outside of underflow()
+ if (!cb(*loop, inputPipe, outputData, 128, cmakeCommand)) {
+ goto end;
+ }
+ inputBuf.open(inputPipe);
+ if (!inputBuf.is_open()) {
+ std::cout << "is_open() is false, should be true" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != 0) {
+ std::cout << "in_avail() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+ uv_run(loop, UV_RUN_DEFAULT);
+ if ((readLen = inputBuf.in_avail()) != 72) {
+ std::cout << "in_avail() returned " << readLen << ", should be 72"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 128) {
+ std::cout << "sgetn() returned " << readLen << ", should be 128"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != 0) {
+ std::cout << "in_avail() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) {
+ std::cout << "sgetn() returned " << readLen << ", should be 128"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != -1) {
+ std::cout << "in_avail() returned " << readLen << ", should be -1"
+ << std::endl;
+ goto end;
+ }
+
+ inputBuf.close();
+ if (inputBuf.is_open()) {
+ std::cout << "is_open() is true, should be false" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != -1) {
+ std::cout << "in_avail() returned " << readLen << ", should be -1"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) {
+ std::cout << "sgetn() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+
+ // Perform fifth read test - close the streambuf in the middle of a read
+ timer.init(*loop, &inputBuf);
+ if (!cb(*loop, inputPipe, outputData, 128, cmakeCommand)) {
+ goto end;
+ }
+ inputBuf.open(inputPipe);
+ if (!inputBuf.is_open()) {
+ std::cout << "is_open() is false, should be true" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != 0) {
+ std::cout << "in_avail() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+ uv_timer_start(timer,
+ [](uv_timer_t* handle) {
+ auto buf = static_cast<cmUVStreambuf*>(handle->data);
+ buf->close();
+ },
+ 0, 0);
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) {
+ std::cout << "sgetn() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+ if (inputBuf.is_open()) {
+ std::cout << "is_open() is true, should be false" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != -1) {
+ std::cout << "in_avail() returned " << readLen << ", should be -1"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) {
+ std::cout << "sgetn() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+
+ success = true;
+
+end:
+ return success;
+}
+
+int testUVStreambuf(int argc, char** const argv)
+{
+ if (argc < 2) {
+ std::cout << "Invalid arguments.\n";
+ return -1;
+ }
+
+ if (!testUVStreambufRead(writeDataToStreamPipe, argv[1])) {
+ std::cout << "While executing testUVStreambufRead() with pipe.\n";
+ return -1;
+ }
+
+ if (!testUVStreambufRead(writeDataToStreamProcess, argv[1])) {
+ std::cout << "While executing testUVStreambufRead() with process.\n";
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt
index df0c78d..5ba0dc0 100644
--- a/Tests/GeneratorExpression/CMakeLists.txt
+++ b/Tests/GeneratorExpression/CMakeLists.txt
@@ -374,4 +374,49 @@ if(NOT CMAKE_GENERATOR STREQUAL Xcode OR NOT CMAKE_OSX_ARCHITECTURES MATCHES "[;
-P "${CMAKE_CURRENT_SOURCE_DIR}/check_object_files.cmake"
DEPENDS objlib
)
+
+
+ add_library(sharedlib SHARED objlib1.c objlib2.c)
+ file(GENERATE
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/sharedlib_files_$<CONFIGURATION>"
+ CONTENT "$<JOIN:$<TARGET_OBJECTS:sharedlib>,\n>\n"
+ )
+
+ add_custom_target(check_sharedlib_objs ALL
+ COMMAND ${CMAKE_COMMAND}
+ "-DOBJLIB_LISTFILE=${CMAKE_CURRENT_BINARY_DIR}/sharedlib_files_$<CONFIGURATION>"
+ -DEXPECTED_NUM_OBJECTFILES=2
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/check_object_files.cmake"
+ DEPENDS sharedlib
+ )
+
+
+ add_library(staticlib STATIC objlib1.c objlib2.c)
+ file(GENERATE
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/staticlib_files_$<CONFIGURATION>"
+ CONTENT "$<JOIN:$<TARGET_OBJECTS:staticlib>,\n>\n"
+ )
+
+ add_custom_target(check_staticlib_objs ALL
+ COMMAND ${CMAKE_COMMAND}
+ "-DOBJLIB_LISTFILE=${CMAKE_CURRENT_BINARY_DIR}/staticlib_files_$<CONFIGURATION>"
+ -DEXPECTED_NUM_OBJECTFILES=2
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/check_object_files.cmake"
+ DEPENDS staticlib
+ )
+
+
+ add_executable(execobjs objlib1.c objlib2.c echo.c)
+ file(GENERATE
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/execobjs_files_$<CONFIGURATION>"
+ CONTENT "$<JOIN:$<TARGET_OBJECTS:execobjs>,\n>\n"
+ )
+
+ add_custom_target(check_exec_objs ALL
+ COMMAND ${CMAKE_COMMAND}
+ "-DOBJLIB_LISTFILE=${CMAKE_CURRENT_BINARY_DIR}/execobjs_files_$<CONFIGURATION>"
+ -DEXPECTED_NUM_OBJECTFILES=3
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/check_object_files.cmake"
+ DEPENDS execobjs
+ )
endif()
diff --git a/Tests/MSVCRuntimeLibrary/CMakeLists.txt b/Tests/MSVCRuntimeLibrary/CMakeLists.txt
index b7a6e86..6994d8d 100644
--- a/Tests/MSVCRuntimeLibrary/CMakeLists.txt
+++ b/Tests/MSVCRuntimeLibrary/CMakeLists.txt
@@ -42,7 +42,22 @@ endfunction()
function(verify lang src)
add_library(default-${lang} ${src})
target_compile_definitions(default-${lang} PRIVATE VERIFY_MT VERIFY_DLL "$<$<CONFIG:Debug>:VERIFY_DEBUG>")
+
verify_combinations(MultiThreaded ${lang} ${src})
+
+ # Test known MSVC default behavior when no flag is given.
+ if(CMAKE_${lang}_COMPILER_ID STREQUAL "MSVC")
+ set(CMAKE_MSVC_RUNTIME_LIBRARY "")
+ add_library(empty-${lang} ${src})
+ if(CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 14)
+ # VS 2005 and above default to multi-threaded.
+ target_compile_definitions(empty-${lang} PRIVATE VERIFY_MT)
+ endif()
+ if(CMAKE_GENERATOR MATCHES "Visual Studio ([^9]|9[0-9])")
+ # VS 2010 and above have a different default runtime library for projects than 'cl'.
+ target_compile_definitions(empty-${lang} PRIVATE VERIFY_DLL)
+ endif()
+ endif()
endfunction()
verify(C verify.c)
diff --git a/Tests/ObjectLibrary/CMakeLists.txt b/Tests/ObjectLibrary/CMakeLists.txt
index 4bffd12..7897ab9 100644
--- a/Tests/ObjectLibrary/CMakeLists.txt
+++ b/Tests/ObjectLibrary/CMakeLists.txt
@@ -62,4 +62,14 @@ add_custom_target(UseABinternalDep COMMAND ${CMAKE_COMMAND} -E touch UseABintern
add_custom_command(TARGET UseABinternal POST_BUILD COMMAND ${CMAKE_COMMAND} -P UseABinternalDep.cmake)
add_dependencies(UseABinternal UseABinternalDep)
+# Test a static library with sources from a different static library
+add_library(UseCstaticObjs STATIC $<TARGET_OBJECTS:Cstatic> $<TARGET_OBJECTS:A> $<TARGET_OBJECTS:Bexport>)
+
+# Test a shared library with sources from a different shared library
+add_library(UseCsharedObjs SHARED $<TARGET_OBJECTS:Cshared> $<TARGET_OBJECTS:A> $<TARGET_OBJECTS:Bexport>)
+
+# Test a shared executable with sources from a different shared library
+add_executable(UseABstaticObjs $<TARGET_OBJECTS:UseABstatic>)
+target_link_libraries(UseABstaticObjs ABstatic)
+
add_subdirectory(ExportLanguages)
diff --git a/Tests/RunCMake/File_Generate/OutputNameMatchesObjects-stderr.txt b/Tests/RunCMake/File_Generate/OutputNameMatchesObjects-stderr.txt
index b08ef5a..4c2e35f 100644
--- a/Tests/RunCMake/File_Generate/OutputNameMatchesObjects-stderr.txt
+++ b/Tests/RunCMake/File_Generate/OutputNameMatchesObjects-stderr.txt
@@ -3,6 +3,7 @@ CMake Error at OutputNameMatchesObjects.cmake:[0-9]+ \(file\):
\$<TARGET_OBJECTS:foo>
- Objects of target "foo" referenced but is not an OBJECT library.
+ Objects of target "foo" referenced but is not an allowed library types
+ \(EXECUTABLE, STATIC, SHARED, MODULE, OBJECT\).
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/File_Generate/OutputNameMatchesObjects.cmake b/Tests/RunCMake/File_Generate/OutputNameMatchesObjects.cmake
index daa7c49..84825fe 100644
--- a/Tests/RunCMake/File_Generate/OutputNameMatchesObjects.cmake
+++ b/Tests/RunCMake/File_Generate/OutputNameMatchesObjects.cmake
@@ -1,11 +1,8 @@
enable_language(CXX)
file(GENERATE
- OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/$<BOOL:$<TARGET_OBJECTS:foo>>somefile.cpp"
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/$<LOWER_CASE:$<CONFIG>/somefile.cpp"
CONTENT "static const char content[] = \"$<TARGET_OBJECTS:foo>\";\n"
)
-add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/input.txt"
- COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/input.txt" "${CMAKE_CURRENT_BINARY_DIR}")
-
-add_executable(foo empty.cpp "${CMAKE_CURRENT_BINARY_DIR}/1somefile.cpp" "${CMAKE_CURRENT_BINARY_DIR}/input.txt")
+add_library(foo INTERFACE )
diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt
index 838b3d8..4dbd861 100644
--- a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt
+++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt
@@ -3,6 +3,7 @@ CMake Error at BadSourceExpression3.cmake:2 \(add_library\):
\$<TARGET_OBJECTS:NotObjLib>
- Objects of target "NotObjLib" referenced but is not an OBJECT library.
+ Objects of target "NotObjLib" referenced but is not an allowed library
+ types \(EXECUTABLE, STATIC, SHARED, MODULE, OBJECT\).
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3.cmake b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3.cmake
index c3d9a62..4e07ea6 100644
--- a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3.cmake
+++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3.cmake
@@ -1,2 +1,2 @@
-add_library(NotObjLib STATIC a.c)
+add_library(NotObjLib INTERFACE)
add_library(A STATIC a.c $<TARGET_OBJECTS:NotObjLib>)
diff --git a/Tests/RunCMake/ObjectLibrary/CheckTargetObjects.cmake b/Tests/RunCMake/ObjectLibrary/CheckTargetObjects.cmake
new file mode 100644
index 0000000..0c85c72
--- /dev/null
+++ b/Tests/RunCMake/ObjectLibrary/CheckTargetObjects.cmake
@@ -0,0 +1,32 @@
+add_library(StaticLib STATIC a.c)
+
+add_custom_command(TARGET StaticLib POST_BUILD
+ VERBATIM
+ COMMAND ${CMAKE_COMMAND}
+ "-DTARGET_OBJECTS=$<TARGET_OBJECTS:StaticLib>"
+ -DEXPECTED_NUM_OBJECTFILES=2
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/check_object_files.cmake"
+ )
+
+add_library(SharedLib SHARED a.c b.c)
+target_compile_definitions(SharedLib PRIVATE REQUIRED)
+
+add_custom_command(TARGET SharedLib POST_BUILD
+ VERBATIM
+ COMMAND ${CMAKE_COMMAND}
+ "-DTARGET_OBJECTS:STRING=$<TARGET_OBJECTS:SharedLib>"
+ -DEXPECTED_NUM_OBJECTFILES=2
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/check_object_files.cmake"
+ )
+
+add_executable(ExecObjs a.c b.c exe.c)
+target_compile_definitions(ExecObjs PRIVATE REQUIRED)
+
+add_custom_target(check_exec_objs ALL
+ VERBATIM
+ COMMAND ${CMAKE_COMMAND}
+ "-DTARGET_OBJECTS=$<TARGET_OBJECTS:ExecObjs>"
+ -DEXPECTED_NUM_OBJECTFILES=3
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/check_object_files.cmake"
+ DEPENDS ExecObjs
+ )
diff --git a/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake b/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake
index 6ca33b8..5ec4018 100644
--- a/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake
+++ b/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake
@@ -37,6 +37,10 @@ function (run_object_lib_build2 name)
run_cmake_command(${name}-build ${CMAKE_COMMAND} --build .)
endfunction ()
+if(NOT (RunCMake_GENERATOR STREQUAL "Xcode" AND "$ENV{CMAKE_OSX_ARCHITECTURES}" MATCHES "[;$]"))
+ run_object_lib_build(CheckTargetObjects)
+endif()
+
run_object_lib_build(LinkObjLHSShared)
run_object_lib_build(LinkObjLHSStatic)
run_object_lib_build(LinkObjRHSShared)
@@ -54,6 +58,7 @@ run_cmake(PostBuild)
run_cmake(PreBuild)
run_cmake(PreLink)
+
function(run_Dependencies)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Dependencies-build)
set(RunCMake_TEST_NO_CLEAN 1)
diff --git a/Tests/RunCMake/ObjectLibrary/check_object_files.cmake b/Tests/RunCMake/ObjectLibrary/check_object_files.cmake
new file mode 100644
index 0000000..3c34229
--- /dev/null
+++ b/Tests/RunCMake/ObjectLibrary/check_object_files.cmake
@@ -0,0 +1,17 @@
+
+if (NOT TARGET_OBJECTS)
+ message(SEND_ERROR "Object not passed as -DTARGET_OBJECTS")
+endif()
+
+foreach(objlib_file IN LISTS objects)
+ message(STATUS "objlib_file: =${objlib_file}=")
+
+ set(file_exists False)
+ if (EXISTS "${objlib_file}")
+ set(file_exists True)
+ endif()
+
+ if (NOT file_exists)
+ message(SEND_ERROR "File \"${objlib_file}\" does not exist!${tried}")
+ endif()
+endforeach()
diff --git a/Tests/RunCMake/TargetObjects/NotObjlibTarget-stderr.txt b/Tests/RunCMake/TargetObjects/NotObjlibTarget-stderr.txt
index a66794c..77c4afd 100644
--- a/Tests/RunCMake/TargetObjects/NotObjlibTarget-stderr.txt
+++ b/Tests/RunCMake/TargetObjects/NotObjlibTarget-stderr.txt
@@ -1,8 +1,9 @@
-CMake Error at NotObjlibTarget.cmake:3 \(file\):
+CMake Error at NotObjlibTarget.cmake:[0-9]+ \(file\):
Error evaluating generator expression:
- \$<TARGET_OBJECTS:StaticLib>
+ \$<TARGET_OBJECTS:IFaceLib>
- Objects of target "StaticLib" referenced but is not an OBJECT library.
+ Objects of target "IFaceLib" referenced but is not an allowed library types
+ \(EXECUTABLE, STATIC, SHARED, MODULE, OBJECT\).
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake b/Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake
index 3bb3e37..9fec369 100644
--- a/Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake
+++ b/Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake
@@ -1,3 +1,3 @@
-add_library(StaticLib empty.cpp)
+add_library(IFaceLib INTERFACE )
-file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/test_output CONTENT $<TARGET_OBJECTS:StaticLib>)
+file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/test_output CONTENT $<TARGET_OBJECTS:IFaceLib>)
diff --git a/Tests/RunCMake/VS10Project/RuntimeLibrary-check.cmake b/Tests/RunCMake/VS10Project/RuntimeLibrary-check.cmake
index 6b43d47..689b35f 100644
--- a/Tests/RunCMake/VS10Project/RuntimeLibrary-check.cmake
+++ b/Tests/RunCMake/VS10Project/RuntimeLibrary-check.cmake
@@ -20,7 +20,7 @@ macro(RuntimeLibrary_check tgt rtl_expect)
endif()
endforeach()
- if(NOT HAVE_Runtimelibrary)
+ if(NOT HAVE_Runtimelibrary AND NOT "${rtl_expect}" STREQUAL "")
set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not have a RuntimeLibrary field.")
return()
endif()
@@ -28,6 +28,8 @@ endmacro()
RuntimeLibrary_check(default-C MultiThreadedDebugDLL)
RuntimeLibrary_check(default-CXX MultiThreadedDebugDLL)
+RuntimeLibrary_check(empty-C "")
+RuntimeLibrary_check(empty-CXX "")
RuntimeLibrary_check(MTd-C MultiThreadedDebug)
RuntimeLibrary_check(MTd-CXX MultiThreadedDebug)
RuntimeLibrary_check(MT-C MultiThreaded)
diff --git a/Tests/RunCMake/VS10Project/RuntimeLibrary.cmake b/Tests/RunCMake/VS10Project/RuntimeLibrary.cmake
index 6c77a25..d7787c8 100644
--- a/Tests/RunCMake/VS10Project/RuntimeLibrary.cmake
+++ b/Tests/RunCMake/VS10Project/RuntimeLibrary.cmake
@@ -6,6 +6,10 @@ enable_language(CXX)
add_library(default-C empty.c)
add_library(default-CXX empty.cxx)
+set(CMAKE_MSVC_RUNTIME_LIBRARY "")
+add_library(empty-C empty.c)
+add_library(empty-CXX empty.cxx)
+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebug")
add_library(MTd-C empty.c)
add_library(MTd-CXX empty.cxx)
diff --git a/Tests/RunCMake/execute_process/EchoCommand-result.txt b/Tests/RunCMake/execute_process/EchoCommand-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/execute_process/EchoCommand-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/execute_process/EchoCommand-stderr.txt b/Tests/RunCMake/execute_process/EchoCommand-stderr.txt
new file mode 100644
index 0000000..f10ece8
--- /dev/null
+++ b/Tests/RunCMake/execute_process/EchoCommand-stderr.txt
@@ -0,0 +1,5 @@
+.*cmake.*-E' 'echo' '-- 2 COMMAND_ECHO STDERR'
+.*cmake.*-E' 'echo' '-- 4 COMMAND_ECHO STDERR'
+.*cmake.*-E' 'echo' '-- 8 COMMAND_ECHO STDOUT COMMAND_ECHO STDERR'
+CMake Error at .*EchoCommand.cmake:.* \(execute_process\):
+ CMAKE_EXECUTE_PROCESS_COMMAND_ECHO set to 'BAD' expected STDERR|STDOUT|NONE$
diff --git a/Tests/RunCMake/execute_process/EchoCommand-stdout.txt b/Tests/RunCMake/execute_process/EchoCommand-stdout.txt
new file mode 100644
index 0000000..0954b3b
--- /dev/null
+++ b/Tests/RunCMake/execute_process/EchoCommand-stdout.txt
@@ -0,0 +1,12 @@
+.*cmake.*-E' 'echo' '-- 1 COMMAND_ECHO STDOUT'
+-- 1 COMMAND_ECHO STDOUT
+-- 2 COMMAND_ECHO STDERR
+.*cmake.* '-E' 'echo' '-- 3 COMMAND_ECHO STDOUT'
+-- 3 COMMAND_ECHO STDOUT
+-- 4 COMMAND_ECHO STDERR
+.*cmake.* '-E' 'echo' '-- 5 COMMAND_ECHO STDOUT'
+-- 5 COMMAND_ECHO STDOUT
+-- 6 COMMAND_ECHO NONE
+.*cmake.* '-E' 'echo' '-- 7 COMMAND_ECHO STDERR COMMAND_ECHO STDOUT'
+-- 7 COMMAND_ECHO STDERR COMMAND_ECHO STDOUT
+-- 8 COMMAND_ECHO STDOUT COMMAND_ECHO STDERR$
diff --git a/Tests/RunCMake/execute_process/EchoCommand.cmake b/Tests/RunCMake/execute_process/EchoCommand.cmake
new file mode 100644
index 0000000..9c7d13d
--- /dev/null
+++ b/Tests/RunCMake/execute_process/EchoCommand.cmake
@@ -0,0 +1,41 @@
+if(CHECK_ERROR_OUTPUT_LOCATION)
+ execute_process(COMMAND ${CMAKE_COMMAND} -E echo
+ "-- 1 COMMAND_ECHO " COMMAND_ECHO )
+endif()
+# test COMMAND_ECHO STDOUT
+execute_process(COMMAND ${CMAKE_COMMAND} -E echo
+ "-- 1 COMMAND_ECHO STDOUT" COMMAND_ECHO STDOUT )
+# test COMMAND_ECHO STDERR
+execute_process(COMMAND ${CMAKE_COMMAND} -E echo
+ "-- 2 COMMAND_ECHO STDERR" COMMAND_ECHO STDERR )
+# test CMAKE_EXECUTE_PROCESS_COMMAND_ECHO STDOUT
+set(CMAKE_EXECUTE_PROCESS_COMMAND_ECHO STDOUT)
+execute_process(COMMAND ${CMAKE_COMMAND} -E echo
+ "-- 3 COMMAND_ECHO STDOUT" )
+# test CMAKE_EXECUTE_PROCESS_COMMAND_ECHO STDERR
+set(CMAKE_EXECUTE_PROCESS_COMMAND_ECHO STDERR)
+execute_process(COMMAND ${CMAKE_COMMAND} -E echo
+ "-- 4 COMMAND_ECHO STDERR" )
+# make sure local will override global settings
+execute_process(COMMAND ${CMAKE_COMMAND} -E echo
+ "-- 5 COMMAND_ECHO STDOUT" COMMAND_ECHO STDOUT )
+execute_process(COMMAND ${CMAKE_COMMAND} -E echo
+ "-- 6 COMMAND_ECHO NONE" COMMAND_ECHO NONE)
+# test both and make sure override works
+execute_process(COMMAND ${CMAKE_COMMAND} -E echo
+ "-- 7 COMMAND_ECHO STDERR COMMAND_ECHO STDOUT" COMMAND_ECHO STDERR
+ COMMAND_ECHO STDOUT)
+execute_process(COMMAND ${CMAKE_COMMAND} -E echo
+ "-- 8 COMMAND_ECHO STDOUT COMMAND_ECHO STDERR" COMMAND_ECHO STDOUT
+ COMMAND_ECHO STDERR)
+
+# check for bad arguments to global and local
+if(CHECK_GLOBAL)
+ # make sure a non STDERR or STDOUT value is an error
+ set(CMAKE_EXECUTE_PROCESS_COMMAND_ECHO BAD)
+ execute_process(COMMAND ${CMAKE_COMMAND} -E echo
+ "-- 9 - 1 CMAKE_EXECUTE_PROCESS_COMMAND_ECHO BAD" )
+else()
+ execute_process(COMMAND ${CMAKE_COMMAND} -E echo
+ "-- 9 - 2 COMMAND_ECHO BAD" COMMAND_ECHO BAD)
+endif()
diff --git a/Tests/RunCMake/execute_process/EchoCommand2-result.txt b/Tests/RunCMake/execute_process/EchoCommand2-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/execute_process/EchoCommand2-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/execute_process/EchoCommand2-stderr.txt b/Tests/RunCMake/execute_process/EchoCommand2-stderr.txt
new file mode 100644
index 0000000..4ae01c4
--- /dev/null
+++ b/Tests/RunCMake/execute_process/EchoCommand2-stderr.txt
@@ -0,0 +1,5 @@
+.*cmake.*-E' 'echo' '-- 2 COMMAND_ECHO STDERR'
+.*cmake.*-E' 'echo' '-- 4 COMMAND_ECHO STDERR'
+.*cmake.*-E' 'echo' '-- 8 COMMAND_ECHO STDOUT COMMAND_ECHO STDERR'
+CMake Error at .*EchoCommand.cmake:.* \(execute_process\):
+ called with 'BAD' expected STDERR|STDOUT|NONE for COMMAND_ECHO.$
diff --git a/Tests/RunCMake/execute_process/EchoCommand2-stdout.txt b/Tests/RunCMake/execute_process/EchoCommand2-stdout.txt
new file mode 100644
index 0000000..0954b3b
--- /dev/null
+++ b/Tests/RunCMake/execute_process/EchoCommand2-stdout.txt
@@ -0,0 +1,12 @@
+.*cmake.*-E' 'echo' '-- 1 COMMAND_ECHO STDOUT'
+-- 1 COMMAND_ECHO STDOUT
+-- 2 COMMAND_ECHO STDERR
+.*cmake.* '-E' 'echo' '-- 3 COMMAND_ECHO STDOUT'
+-- 3 COMMAND_ECHO STDOUT
+-- 4 COMMAND_ECHO STDERR
+.*cmake.* '-E' 'echo' '-- 5 COMMAND_ECHO STDOUT'
+-- 5 COMMAND_ECHO STDOUT
+-- 6 COMMAND_ECHO NONE
+.*cmake.* '-E' 'echo' '-- 7 COMMAND_ECHO STDERR COMMAND_ECHO STDOUT'
+-- 7 COMMAND_ECHO STDERR COMMAND_ECHO STDOUT
+-- 8 COMMAND_ECHO STDOUT COMMAND_ECHO STDERR$
diff --git a/Tests/RunCMake/execute_process/EchoCommand3-result.txt b/Tests/RunCMake/execute_process/EchoCommand3-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/execute_process/EchoCommand3-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/execute_process/EchoCommand3-stderr.txt b/Tests/RunCMake/execute_process/EchoCommand3-stderr.txt
new file mode 100644
index 0000000..e27f1e6
--- /dev/null
+++ b/Tests/RunCMake/execute_process/EchoCommand3-stderr.txt
@@ -0,0 +1,2 @@
+CMake Error at .*EchoCommand.cmake:.*\(execute_process\):
+ execute_process called with no value for COMMAND_ECHO.
diff --git a/Tests/RunCMake/execute_process/RunCMakeTest.cmake b/Tests/RunCMake/execute_process/RunCMakeTest.cmake
index cb40b40..b203aab 100644
--- a/Tests/RunCMake/execute_process/RunCMakeTest.cmake
+++ b/Tests/RunCMake/execute_process/RunCMakeTest.cmake
@@ -16,3 +16,11 @@ endif()
if(EXIT_CODE_EXE)
run_cmake_command(ExitValues ${CMAKE_COMMAND} -DEXIT_CODE_EXE=${EXIT_CODE_EXE} -P ${RunCMake_SOURCE_DIR}/ExitValues.cmake)
endif()
+
+run_cmake_command(EchoCommand ${CMAKE_COMMAND} -DCHECK_GLOBAL=TRUE
+ -P ${RunCMake_SOURCE_DIR}/EchoCommand.cmake)
+run_cmake_command(EchoCommand2 ${CMAKE_COMMAND} -P
+ ${RunCMake_SOURCE_DIR}/EchoCommand.cmake)
+run_cmake_command(EchoCommand3 ${CMAKE_COMMAND}
+ -DCHECK_ERROR_OUTPUT_LOCATION=TRUE -P
+ ${RunCMake_SOURCE_DIR}/EchoCommand.cmake)
diff --git a/Tests/RunCMake/message/RunCMakeTest.cmake b/Tests/RunCMake/message/RunCMakeTest.cmake
index 24dad03..cecfc7f 100644
--- a/Tests/RunCMake/message/RunCMakeTest.cmake
+++ b/Tests/RunCMake/message/RunCMakeTest.cmake
@@ -10,3 +10,45 @@ run_cmake(warnmessage)
# separately
run_cmake(errormessage_deprecated)
run_cmake(errormessage_dev)
+
+run_cmake_command(
+ message-loglevel-invalid
+ ${CMAKE_COMMAND} --loglevel=blah -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake
+ )
+
+# Checking various combinations of `message(...)` and log levels `WARNING` to `TRACE`
+# - no CLI option -> `WARNING` to `STATUS` output
+run_cmake_command(
+ message-loglevel-default
+ ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake
+ )
+# - Only `WARNING` output
+run_cmake_command(
+ message-loglevel-warning
+ ${CMAKE_COMMAND} --loglevel=warning -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake
+ )
+# - Only `WARNING` and `NOTICE` output
+run_cmake_command(
+ message-loglevel-notice
+ ${CMAKE_COMMAND} --loglevel=notice -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake
+ )
+# - `WARNING` to `STATUS` output
+run_cmake_command(
+ message-loglevel-status
+ ${CMAKE_COMMAND} --loglevel=status -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake
+ )
+# - `WARNING` to `VERBOSE` output
+run_cmake_command(
+ message-loglevel-verbose
+ ${CMAKE_COMMAND} --loglevel=verbose -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake
+ )
+# - `WARNING` to `DEBUG` output
+run_cmake_command(
+ message-loglevel-debug
+ ${CMAKE_COMMAND} --loglevel=debug -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake
+ )
+# - `WARNING` to `TRACE` output
+run_cmake_command(
+ message-loglevel-trace
+ ${CMAKE_COMMAND} --loglevel=trace -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake
+ )
diff --git a/Tests/RunCMake/message/message-all-loglevels.cmake b/Tests/RunCMake/message/message-all-loglevels.cmake
new file mode 100644
index 0000000..f8d8841
--- /dev/null
+++ b/Tests/RunCMake/message/message-all-loglevels.cmake
@@ -0,0 +1,10 @@
+# Produce a message for everything except FATAL_ERROR and SEND_ERROR
+message(DEPRECATION "Deprecation warning")
+message(AUTHOR_WARNING "Author warning message")
+message(WARNING "Warning message")
+message("Default NOTICE message")
+message(NOTICE "NOTICE message")
+message(STATUS "STATUS message")
+message(VERBOSE "VERBOSE message")
+message(DEBUG "DEBUG message")
+message(TRACE "TRACE message")
diff --git a/Tests/RunCMake/message/message-loglevel-debug-stderr.txt b/Tests/RunCMake/message/message-loglevel-debug-stderr.txt
new file mode 100644
index 0000000..efec736
--- /dev/null
+++ b/Tests/RunCMake/message/message-loglevel-debug-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Deprecation Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:2 \(message\):
+ Deprecation warning
++
+CMake Warning \(dev\) at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:3 \(message\):
+ Author warning message
+This warning is for project developers\. Use -Wno-dev to suppress it\.
++
+CMake Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:4 \(message\):
+ Warning message
++
+Default NOTICE message
+NOTICE message$
diff --git a/Tests/RunCMake/message/message-loglevel-debug-stdout.txt b/Tests/RunCMake/message/message-loglevel-debug-stdout.txt
new file mode 100644
index 0000000..1452137
--- /dev/null
+++ b/Tests/RunCMake/message/message-loglevel-debug-stdout.txt
@@ -0,0 +1,3 @@
+-- STATUS message
+-- VERBOSE message
+-- DEBUG message
diff --git a/Tests/RunCMake/message/message-loglevel-default-stderr.txt b/Tests/RunCMake/message/message-loglevel-default-stderr.txt
new file mode 100644
index 0000000..efec736
--- /dev/null
+++ b/Tests/RunCMake/message/message-loglevel-default-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Deprecation Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:2 \(message\):
+ Deprecation warning
++
+CMake Warning \(dev\) at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:3 \(message\):
+ Author warning message
+This warning is for project developers\. Use -Wno-dev to suppress it\.
++
+CMake Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:4 \(message\):
+ Warning message
++
+Default NOTICE message
+NOTICE message$
diff --git a/Tests/RunCMake/message/message-loglevel-default-stdout.txt b/Tests/RunCMake/message/message-loglevel-default-stdout.txt
new file mode 100644
index 0000000..809f4cc
--- /dev/null
+++ b/Tests/RunCMake/message/message-loglevel-default-stdout.txt
@@ -0,0 +1 @@
+-- STATUS message
diff --git a/Tests/RunCMake/message/message-loglevel-invalid-result.txt b/Tests/RunCMake/message/message-loglevel-invalid-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/message/message-loglevel-invalid-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/message/message-loglevel-invalid-stderr.txt b/Tests/RunCMake/message/message-loglevel-invalid-stderr.txt
new file mode 100644
index 0000000..f54d0f8
--- /dev/null
+++ b/Tests/RunCMake/message/message-loglevel-invalid-stderr.txt
@@ -0,0 +1 @@
+CMake Error: Invalid level specified for --loglevel
diff --git a/Tests/RunCMake/message/message-loglevel-notice-stderr.txt b/Tests/RunCMake/message/message-loglevel-notice-stderr.txt
new file mode 100644
index 0000000..efec736
--- /dev/null
+++ b/Tests/RunCMake/message/message-loglevel-notice-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Deprecation Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:2 \(message\):
+ Deprecation warning
++
+CMake Warning \(dev\) at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:3 \(message\):
+ Author warning message
+This warning is for project developers\. Use -Wno-dev to suppress it\.
++
+CMake Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:4 \(message\):
+ Warning message
++
+Default NOTICE message
+NOTICE message$
diff --git a/Tests/RunCMake/message/message-loglevel-status-stderr.txt b/Tests/RunCMake/message/message-loglevel-status-stderr.txt
new file mode 100644
index 0000000..efec736
--- /dev/null
+++ b/Tests/RunCMake/message/message-loglevel-status-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Deprecation Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:2 \(message\):
+ Deprecation warning
++
+CMake Warning \(dev\) at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:3 \(message\):
+ Author warning message
+This warning is for project developers\. Use -Wno-dev to suppress it\.
++
+CMake Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:4 \(message\):
+ Warning message
++
+Default NOTICE message
+NOTICE message$
diff --git a/Tests/RunCMake/message/message-loglevel-status-stdout.txt b/Tests/RunCMake/message/message-loglevel-status-stdout.txt
new file mode 100644
index 0000000..809f4cc
--- /dev/null
+++ b/Tests/RunCMake/message/message-loglevel-status-stdout.txt
@@ -0,0 +1 @@
+-- STATUS message
diff --git a/Tests/RunCMake/message/message-loglevel-trace-stderr.txt b/Tests/RunCMake/message/message-loglevel-trace-stderr.txt
new file mode 100644
index 0000000..efec736
--- /dev/null
+++ b/Tests/RunCMake/message/message-loglevel-trace-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Deprecation Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:2 \(message\):
+ Deprecation warning
++
+CMake Warning \(dev\) at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:3 \(message\):
+ Author warning message
+This warning is for project developers\. Use -Wno-dev to suppress it\.
++
+CMake Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:4 \(message\):
+ Warning message
++
+Default NOTICE message
+NOTICE message$
diff --git a/Tests/RunCMake/message/message-loglevel-trace-stdout.txt b/Tests/RunCMake/message/message-loglevel-trace-stdout.txt
new file mode 100644
index 0000000..1cfce6f
--- /dev/null
+++ b/Tests/RunCMake/message/message-loglevel-trace-stdout.txt
@@ -0,0 +1,4 @@
+-- STATUS message
+-- VERBOSE message
+-- DEBUG message
+-- TRACE message
diff --git a/Tests/RunCMake/message/message-loglevel-verbose-stderr.txt b/Tests/RunCMake/message/message-loglevel-verbose-stderr.txt
new file mode 100644
index 0000000..efec736
--- /dev/null
+++ b/Tests/RunCMake/message/message-loglevel-verbose-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Deprecation Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:2 \(message\):
+ Deprecation warning
++
+CMake Warning \(dev\) at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:3 \(message\):
+ Author warning message
+This warning is for project developers\. Use -Wno-dev to suppress it\.
++
+CMake Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:4 \(message\):
+ Warning message
++
+Default NOTICE message
+NOTICE message$
diff --git a/Tests/RunCMake/message/message-loglevel-verbose-stdout.txt b/Tests/RunCMake/message/message-loglevel-verbose-stdout.txt
new file mode 100644
index 0000000..c15d43f
--- /dev/null
+++ b/Tests/RunCMake/message/message-loglevel-verbose-stdout.txt
@@ -0,0 +1,2 @@
+-- STATUS message
+-- VERBOSE message
diff --git a/Tests/RunCMake/message/message-loglevel-warning-stderr.txt b/Tests/RunCMake/message/message-loglevel-warning-stderr.txt
new file mode 100644
index 0000000..c721b06
--- /dev/null
+++ b/Tests/RunCMake/message/message-loglevel-warning-stderr.txt
@@ -0,0 +1,9 @@
+^CMake Deprecation Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:2 \(message\):
+ Deprecation warning
++
+CMake Warning \(dev\) at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:3 \(message\):
+ Author warning message
+This warning is for project developers\. Use -Wno-dev to suppress it\.
++
+CMake Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:4 \(message\):
+ Warning message$
diff --git a/Tests/SourceGroups/CMakeLists.txt b/Tests/SourceGroups/CMakeLists.txt
index 813774d..a5740bb 100644
--- a/Tests/SourceGroups/CMakeLists.txt
+++ b/Tests/SourceGroups/CMakeLists.txt
@@ -42,8 +42,16 @@ set(tree_files_with_prefix ${root}/tree_prefix_foo.c
set(tree_files_with_empty_prefix ${root}/tree_empty_prefix_foo.c
tree_empty_prefix_bar.c)
+set(tree_files_which_are_actually_directories ${root}
+ ${root}/
+ ${root}/sub1
+ ${root}/sub1/)
+
source_group(TREE ${root} FILES ${tree_files_without_prefix})
+# Should not crash and not add any files - just silently ignore the directories
+source_group(TREE ${root} FILES ${tree_files_which_are_actually_directories})
+
source_group(FILES ${tree_files_with_prefix} PREFIX tree_root/subgroup TREE ${root})
source_group(PREFIX "" FILES ${tree_files_with_empty_prefix} TREE ${root})