Tests/RunCMake/CXXModules: actually generate the source at build time

This tests what is intended to be tested (sources that do not exist
until after the configure has run).
This commit is contained in:
Ben Boeckel
2023-08-07 17:45:40 -04:00
parent 4240e74858
commit 1e9ec93f48
2 changed files with 9 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
CMake Warning \(dev\) at CMakeLists.txt:12 \(target_sources\):
CMake Warning \(dev\) at CMakeLists.txt:16 \(target_sources\):
CMake's C\+\+ module support is experimental. It is meant only for
experimentation and feedback to CMake developers.
This warning is for project developers. Use -Wno-dev to suppress it.

View File

@@ -3,10 +3,14 @@ project(cxx_modules_generated CXX)
include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/importable.cxx.in"
"${CMAKE_CURRENT_BINARY_DIR}/importable.cxx"
COPYONLY)
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/importable.cxx"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/importable.cxx.in"
COMMAND "${CMAKE_COMMAND}"
-E copy_if_different
"${CMAKE_CURRENT_SOURCE_DIR}/importable.cxx.in"
"${CMAKE_CURRENT_BINARY_DIR}/importable.cxx"
COMMENT "Copying 'importable.cxx'")
add_executable(generated)
target_sources(generated