diff options
Diffstat (limited to 'Tests/RunCMake/File_Generate')
14 files changed, 85 insertions, 0 deletions
diff --git a/Tests/RunCMake/File_Generate/GenerateSource-result.txt b/Tests/RunCMake/File_Generate/GenerateSource-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/File_Generate/GenerateSource-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/File_Generate/GenerateSource-stderr.txt b/Tests/RunCMake/File_Generate/GenerateSource-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/File_Generate/GenerateSource-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/File_Generate/GenerateSource.cmake b/Tests/RunCMake/File_Generate/GenerateSource.cmake new file mode 100644 index 0000000..147a7f6 --- /dev/null +++ b/Tests/RunCMake/File_Generate/GenerateSource.cmake @@ -0,0 +1,12 @@ + +enable_language(CXX) + +# Ensure re-generation +file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") + +file(GENERATE + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/main.cpp" + CONTENT "int main() { return 0; }\n" +) + +add_executable(mn "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") diff --git a/Tests/RunCMake/File_Generate/OutputNameMatchesObjects-result.txt b/Tests/RunCMake/File_Generate/OutputNameMatchesObjects-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/File_Generate/OutputNameMatchesObjects-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/File_Generate/OutputNameMatchesObjects-stderr.txt b/Tests/RunCMake/File_Generate/OutputNameMatchesObjects-stderr.txt new file mode 100644 index 0000000..d3aa973 --- /dev/null +++ b/Tests/RunCMake/File_Generate/OutputNameMatchesObjects-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at OutputNameMatchesObjects.cmake:2 \(file\): + Error evaluating generator expression: + + \$<TARGET_OBJECTS:foo> + + The evaluation of the TARGET_OBJECTS generator expression is only suitable + for consumption by CMake. It is not suitable for writing out elsewhere. +Call Stack \(most recent call first\): + CMakeLists.txt:6 \(include\) diff --git a/Tests/RunCMake/File_Generate/OutputNameMatchesObjects.cmake b/Tests/RunCMake/File_Generate/OutputNameMatchesObjects.cmake new file mode 100644 index 0000000..d807450 --- /dev/null +++ b/Tests/RunCMake/File_Generate/OutputNameMatchesObjects.cmake @@ -0,0 +1,10 @@ + +file(GENERATE + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/$<BOOL:$<TARGET_OBJECTS:foo>>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") diff --git a/Tests/RunCMake/File_Generate/OutputNameMatchesOtherSources-result.txt b/Tests/RunCMake/File_Generate/OutputNameMatchesOtherSources-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/File_Generate/OutputNameMatchesOtherSources-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/File_Generate/OutputNameMatchesOtherSources-stderr.txt b/Tests/RunCMake/File_Generate/OutputNameMatchesOtherSources-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/File_Generate/OutputNameMatchesOtherSources-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/File_Generate/OutputNameMatchesOtherSources.cmake b/Tests/RunCMake/File_Generate/OutputNameMatchesOtherSources.cmake new file mode 100644 index 0000000..ce601da --- /dev/null +++ b/Tests/RunCMake/File_Generate/OutputNameMatchesOtherSources.cmake @@ -0,0 +1,14 @@ + +enable_language(CXX) + +file(GENERATE + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/$<BOOL:$<TARGET_PROPERTY:foo,SOURCES>>somefile.cpp" + CONTENT "static const char content[] = \"$<TARGET_PROPERTY:foo,SOURCES>\";\n" +) + +add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/generated.cpp" + COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/generated.cpp" "${CMAKE_CURRENT_BINARY_DIR}") + +add_executable(foo empty.cpp "${CMAKE_CURRENT_BINARY_DIR}/generated.cpp") + +add_executable(bar "${CMAKE_CURRENT_BINARY_DIR}/1somefile.cpp") diff --git a/Tests/RunCMake/File_Generate/OutputNameMatchesSources-result.txt b/Tests/RunCMake/File_Generate/OutputNameMatchesSources-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/File_Generate/OutputNameMatchesSources-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/File_Generate/OutputNameMatchesSources-stderr.txt b/Tests/RunCMake/File_Generate/OutputNameMatchesSources-stderr.txt new file mode 100644 index 0000000..cefb4e5 --- /dev/null +++ b/Tests/RunCMake/File_Generate/OutputNameMatchesSources-stderr.txt @@ -0,0 +1,7 @@ +CMake Error in CMakeLists.txt: + Evaluation output file + + ".*Tests/RunCMake/File_Generate/OutputNameMatchesSources-build/1somefile.cpp" + + depends on the sources of a target it is used in. This is a dependency + loop and is not allowed. diff --git a/Tests/RunCMake/File_Generate/OutputNameMatchesSources.cmake b/Tests/RunCMake/File_Generate/OutputNameMatchesSources.cmake new file mode 100644 index 0000000..2feb9d1 --- /dev/null +++ b/Tests/RunCMake/File_Generate/OutputNameMatchesSources.cmake @@ -0,0 +1,12 @@ + +enable_language(CXX) + +file(GENERATE + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/$<BOOL:$<TARGET_PROPERTY:foo,SOURCES>>somefile.cpp" + CONTENT "static const char content[] = \"$<TARGET_PROPERTY:foo,SOURCES>\";\n" +) + +add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/renamed.cpp" + COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp" "${CMAKE_CURRENT_BINARY_DIR}/renamed.cpp") + +add_executable(foo "${CMAKE_CURRENT_BINARY_DIR}/1somefile.cpp" "${CMAKE_CURRENT_BINARY_DIR}/renamed.cpp") diff --git a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake index 578df81..7db77d4 100644 --- a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake +++ b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake @@ -8,6 +8,14 @@ run_cmake(EmptyCondition1) run_cmake(EmptyCondition2) run_cmake(BadCondition) run_cmake(DebugEvaluate) +run_cmake(GenerateSource) +run_cmake(OutputNameMatchesSources) +run_cmake(OutputNameMatchesObjects) +run_cmake(OutputNameMatchesOtherSources) +file(READ "${RunCMake_BINARY_DIR}/OutputNameMatchesOtherSources-build/1somefile.cpp" file_contents) +if (NOT file_contents MATCHES "generated.cpp.rule") + message(SEND_ERROR "Rule file not in target sources! ${file_contents}") +endif() set(timeformat "%Y%j%H%M%S") diff --git a/Tests/RunCMake/File_Generate/empty.cpp b/Tests/RunCMake/File_Generate/empty.cpp new file mode 100644 index 0000000..bfbbdde --- /dev/null +++ b/Tests/RunCMake/File_Generate/empty.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int empty() +{ + return 0; +} |