diff options
Diffstat (limited to 'Tests/RunCMake')
10 files changed, 90 insertions, 0 deletions
diff --git a/Tests/RunCMake/BuildDepends/CustomCommandDepfile.cmake b/Tests/RunCMake/BuildDepends/CustomCommandDepfile.cmake index 19c09c8..c3725a4 100644 --- a/Tests/RunCMake/BuildDepends/CustomCommandDepfile.cmake +++ b/Tests/RunCMake/BuildDepends/CustomCommandDepfile.cmake @@ -24,6 +24,17 @@ add_library(toplib STATIC toplib.c) add_subdirectory(DepfileSubdir) +set(TEST_SPACE 1) +if(CMAKE_GENERATOR STREQUAL "Unix Makefiles") + execute_process(COMMAND "${CMAKE_MAKE_PROGRAM}" no_such_target --version RESULT_VARIABLE res OUTPUT_VARIABLE out ERROR_VARIABLE out) + if(NOT res EQUAL 0 OR NOT out MATCHES "GNU") + set(TEST_SPACE 0) + endif() +endif() +if(TEST_SPACE) + add_subdirectory(DepfileSubdirWithSpace) +endif() + add_custom_command( OUTPUT toplib2.c DEPFILE toplib2.c.d diff --git a/Tests/RunCMake/BuildDepends/DepfileSubdirWithSpace/CMakeLists.txt b/Tests/RunCMake/BuildDepends/DepfileSubdirWithSpace/CMakeLists.txt new file mode 100644 index 0000000..204f740 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/DepfileSubdirWithSpace/CMakeLists.txt @@ -0,0 +1,2 @@ + +add_subdirectory("path with space") diff --git a/Tests/RunCMake/BuildDepends/DepfileSubdirWithSpace/path with space/CMakeLists.txt b/Tests/RunCMake/BuildDepends/DepfileSubdirWithSpace/path with space/CMakeLists.txt new file mode 100644 index 0000000..37c0a57 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/DepfileSubdirWithSpace/path with space/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/dummy.txt" + COMMAND ${CMAKE_COMMAND} -E touch "${CMAKE_CURRENT_BINARY_DIR}/dummy.txt" + DEPFILE dummy.txt.d +) + +add_custom_target(subdir_space ALL + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/dummy.txt" +) diff --git a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake index 514e0f3..abede44 100644 --- a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake +++ b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake @@ -172,6 +172,7 @@ if ("named" IN_LIST CMake_TEST_MODULE_COMPILATION) run_cxx_module_test(simple) run_cxx_module_test(vs-without-flags) run_cxx_module_test(library library-static -DBUILD_SHARED_LIBS=OFF) + run_cxx_module_test(unity-build) run_cxx_module_test(object-library) run_cxx_module_test(generated) run_cxx_module_test(deep-chain) diff --git a/Tests/RunCMake/CXXModules/examples/unity-build/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/unity-build/CMakeLists.txt new file mode 100644 index 0000000..ce1751d --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/unity-build/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.28) +project(cxx_modules_unity CXX) + +include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake") + +set(CMAKE_UNITY_BUILD 1) + +add_executable(unity) +target_sources(unity + PRIVATE + main.cxx + unity1.cxx + unity2.cxx + PRIVATE + FILE_SET CXX_MODULES + BASE_DIRS + "${CMAKE_CURRENT_SOURCE_DIR}" + FILES + importable.cxx) +target_compile_features(unity PUBLIC cxx_std_20) + +set_property(SOURCE unity1.cxx unity2.cxx + PROPERTY + CXX_SCAN_FOR_MODULES 0) + +add_test(NAME unity COMMAND unity) diff --git a/Tests/RunCMake/CXXModules/examples/unity-build/importable.cxx b/Tests/RunCMake/CXXModules/examples/unity-build/importable.cxx new file mode 100644 index 0000000..148b033 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/unity-build/importable.cxx @@ -0,0 +1,10 @@ +module; + +#include "unity.h" + +export module importable; + +export int from_import() +{ + return unity1() + unity2(); +} diff --git a/Tests/RunCMake/CXXModules/examples/unity-build/main.cxx b/Tests/RunCMake/CXXModules/examples/unity-build/main.cxx new file mode 100644 index 0000000..feb38d2 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/unity-build/main.cxx @@ -0,0 +1,6 @@ +import importable; + +int main(int argc, char* argv[]) +{ + return from_import(); +} diff --git a/Tests/RunCMake/CXXModules/examples/unity-build/unity.h b/Tests/RunCMake/CXXModules/examples/unity-build/unity.h new file mode 100644 index 0000000..4a65a4b --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/unity-build/unity.h @@ -0,0 +1,7 @@ +#ifndef unity_h +#define unity_h + +int unity1(); +int unity2(); + +#endif diff --git a/Tests/RunCMake/CXXModules/examples/unity-build/unity1.cxx b/Tests/RunCMake/CXXModules/examples/unity-build/unity1.cxx new file mode 100644 index 0000000..fd1cbb3 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/unity-build/unity1.cxx @@ -0,0 +1,8 @@ +#include "unity.h" + +#define DETECT_UNITY + +int unity1() +{ + return 0; +} diff --git a/Tests/RunCMake/CXXModules/examples/unity-build/unity2.cxx b/Tests/RunCMake/CXXModules/examples/unity-build/unity2.cxx new file mode 100644 index 0000000..0f25cff --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/unity-build/unity2.cxx @@ -0,0 +1,10 @@ +#include "unity.h" + +#ifndef DETECT_UNITY +# error "Should have detected a unity build" +#endif + +int unity2() +{ + return 0; +} |