diff options
author | Stephen Kelly <steveire@gmail.com> | 2013-01-02 16:10:04 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2013-05-24 13:02:45 (GMT) |
commit | b983a58bdf1a03a49f2512ac68390888669ac30b (patch) | |
tree | fdef14cc2d264b50e8bb48fbe53e2858852400de /Tests | |
parent | 272431a84ff13eb17cf04389428f57c7fe13e3a2 (diff) | |
download | CMake-b983a58bdf1a03a49f2512ac68390888669ac30b.zip CMake-b983a58bdf1a03a49f2512ac68390888669ac30b.tar.gz CMake-b983a58bdf1a03a49f2512ac68390888669ac30b.tar.bz2 |
file: Add GENERATE command to produce files at generate time
The idea is to write to a temp file which contains generator
expressions, and at generate time, evaluate the generator expressions,
and write the result to a file.
Because executables on Windows are limited in the length of command line
it is possible to use, it is common to write command line arguments to a
file instead and specify the file as a source of arguments.
This new FILE(GENERATE) subcommand allows the use of generator
expressions to create such files so that they can be used with
add_custom_command for example.
Diffstat (limited to 'Tests')
20 files changed, 71 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 402c8a9..53bb8d8 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -86,3 +86,5 @@ if("${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio [^6]") add_RunCMake_test(include_external_msproject) add_RunCMake_test(SolutionGlobalSections) endif() + +add_RunCMake_test(File_Generate) diff --git a/Tests/RunCMake/File_Generate/BadCondition-result.txt b/Tests/RunCMake/File_Generate/BadCondition-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/File_Generate/BadCondition-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/File_Generate/BadCondition-stderr.txt b/Tests/RunCMake/File_Generate/BadCondition-stderr.txt new file mode 100644 index 0000000..bab8368 --- /dev/null +++ b/Tests/RunCMake/File_Generate/BadCondition-stderr.txt @@ -0,0 +1,3 @@ +CMake Error in CMakeLists.txt: + Evaluation file condition \"\$<1:Bad>\" did not evaluate to valid content. + Got \"Bad\". diff --git a/Tests/RunCMake/File_Generate/BadCondition.cmake b/Tests/RunCMake/File_Generate/BadCondition.cmake new file mode 100644 index 0000000..82ad672 --- /dev/null +++ b/Tests/RunCMake/File_Generate/BadCondition.cmake @@ -0,0 +1,5 @@ + +file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output.txt" + INPUT "${CMAKE_CURRENT_SOURCE_DIR}/input.txt" + CONDITION $<1:Bad> +) diff --git a/Tests/RunCMake/File_Generate/CMakeLists.txt b/Tests/RunCMake/File_Generate/CMakeLists.txt new file mode 100644 index 0000000..e8db6b0 --- /dev/null +++ b/Tests/RunCMake/File_Generate/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/File_Generate/CommandConflict-result.txt b/Tests/RunCMake/File_Generate/CommandConflict-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/File_Generate/CommandConflict-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/File_Generate/CommandConflict-stderr.txt b/Tests/RunCMake/File_Generate/CommandConflict-stderr.txt new file mode 100644 index 0000000..da97ba4 --- /dev/null +++ b/Tests/RunCMake/File_Generate/CommandConflict-stderr.txt @@ -0,0 +1 @@ +CMake Error: File to be generated by multiple different commands: .*CommandConflict-build/output_.*.txt diff --git a/Tests/RunCMake/File_Generate/CommandConflict.cmake b/Tests/RunCMake/File_Generate/CommandConflict.cmake new file mode 100644 index 0000000..d57bc12 --- /dev/null +++ b/Tests/RunCMake/File_Generate/CommandConflict.cmake @@ -0,0 +1,9 @@ + +file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output_$<CONFIGURATION>.txt" + INPUT "${CMAKE_CURRENT_SOURCE_DIR}/input.txt" + CONDITION $<CONFIG:$<CONFIGURATION>> +) +file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output_$<CONFIGURATION>.txt" + INPUT "${CMAKE_CURRENT_SOURCE_DIR}/input.txt" + CONDITION $<CONFIG:$<CONFIGURATION>> +) diff --git a/Tests/RunCMake/File_Generate/DebugEvaluate.cmake b/Tests/RunCMake/File_Generate/DebugEvaluate.cmake new file mode 100644 index 0000000..1fa9b62 --- /dev/null +++ b/Tests/RunCMake/File_Generate/DebugEvaluate.cmake @@ -0,0 +1,5 @@ + +file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output.txt" + INPUT "${CMAKE_CURRENT_SOURCE_DIR}/input.txt" + CONDITION $<CONFIG:Debug> +) diff --git a/Tests/RunCMake/File_Generate/EmptyCondition1-result.txt b/Tests/RunCMake/File_Generate/EmptyCondition1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/File_Generate/EmptyCondition1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/File_Generate/EmptyCondition1-stderr.txt b/Tests/RunCMake/File_Generate/EmptyCondition1-stderr.txt new file mode 100644 index 0000000..9fe39cc --- /dev/null +++ b/Tests/RunCMake/File_Generate/EmptyCondition1-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at EmptyCondition1.cmake:2 \(file\): + file Incorrect arguments to GENERATE subcommand. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/File_Generate/EmptyCondition1.cmake b/Tests/RunCMake/File_Generate/EmptyCondition1.cmake new file mode 100644 index 0000000..8574a5f --- /dev/null +++ b/Tests/RunCMake/File_Generate/EmptyCondition1.cmake @@ -0,0 +1,5 @@ + +file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output.txt" + INPUT "${CMAKE_CURRENT_SOURCE_DIR}/input.txt" + CONDITION +) diff --git a/Tests/RunCMake/File_Generate/EmptyCondition2-result.txt b/Tests/RunCMake/File_Generate/EmptyCondition2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/File_Generate/EmptyCondition2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/File_Generate/EmptyCondition2-stderr.txt b/Tests/RunCMake/File_Generate/EmptyCondition2-stderr.txt new file mode 100644 index 0000000..73d5f25 --- /dev/null +++ b/Tests/RunCMake/File_Generate/EmptyCondition2-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at EmptyCondition2.cmake:2 \(file\): + file CONDITION of sub-command GENERATE must not be empty if specified. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/File_Generate/EmptyCondition2.cmake b/Tests/RunCMake/File_Generate/EmptyCondition2.cmake new file mode 100644 index 0000000..626bfb4 --- /dev/null +++ b/Tests/RunCMake/File_Generate/EmptyCondition2.cmake @@ -0,0 +1,5 @@ + +file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output.txt" + INPUT "${CMAKE_CURRENT_SOURCE_DIR}/input.txt" + CONDITION "" +) diff --git a/Tests/RunCMake/File_Generate/OutputConflict-result.txt b/Tests/RunCMake/File_Generate/OutputConflict-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/File_Generate/OutputConflict-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/File_Generate/OutputConflict-stderr.txt b/Tests/RunCMake/File_Generate/OutputConflict-stderr.txt new file mode 100644 index 0000000..dbd39de --- /dev/null +++ b/Tests/RunCMake/File_Generate/OutputConflict-stderr.txt @@ -0,0 +1,5 @@ +CMake Error in CMakeLists.txt: + Evaluation file to be written multiple times for different configurations + with different content: + + .*output.txt diff --git a/Tests/RunCMake/File_Generate/OutputConflict.cmake b/Tests/RunCMake/File_Generate/OutputConflict.cmake new file mode 100644 index 0000000..7f3e8c7 --- /dev/null +++ b/Tests/RunCMake/File_Generate/OutputConflict.cmake @@ -0,0 +1,4 @@ + +file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output.txt" + INPUT "${CMAKE_CURRENT_SOURCE_DIR}/input.txt" +) diff --git a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake new file mode 100644 index 0000000..f07431c --- /dev/null +++ b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake @@ -0,0 +1,10 @@ +include(RunCMake) + +run_cmake(CommandConflict) +if("${RunCMake_GENERATOR}" MATCHES "Visual Studio" OR "${RunCMake_GENERATOR}" MATCHES "XCode" ) + run_cmake(OutputConflict) +endif() +run_cmake(EmptyCondition1) +run_cmake(EmptyCondition2) +run_cmake(BadCondition) +run_cmake(DebugEvaluate) diff --git a/Tests/RunCMake/File_Generate/input.txt b/Tests/RunCMake/File_Generate/input.txt new file mode 100644 index 0000000..3db429d --- /dev/null +++ b/Tests/RunCMake/File_Generate/input.txt @@ -0,0 +1 @@ +Some $<$<CONFIG:Debug>:conflicting> $<$<NOT:$<CONFIG:Debug>>:content> |