diff options
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeLists.txt | 4 | ||||
-rw-r--r-- | Tests/ConfigSources/CMakeLists.txt | 22 | ||||
-rw-r--r-- | Tests/ConfigSources/iface.h | 10 | ||||
-rw-r--r-- | Tests/ConfigSources/iface_debug.h | 4 | ||||
-rw-r--r-- | Tests/ConfigSources/iface_debug_src.cpp | 8 | ||||
-rw-r--r-- | Tests/ConfigSources/iface_other_src.cpp | 13 | ||||
-rw-r--r-- | Tests/ConfigSources/main.cpp | 7 | ||||
-rw-r--r-- | Tests/ConfigSources/main_debug.cpp | 13 | ||||
-rw-r--r-- | Tests/ConfigSources/main_other.cpp | 13 | ||||
-rw-r--r-- | Tests/RunCMake/PrecompileHeaders/DisabledPch-check.cmake | 16 | ||||
-rw-r--r-- | Tests/RunCMake/PrecompileHeaders/PchMultilanguage-check.cmake | 17 | ||||
-rw-r--r-- | Tests/RunCMake/PrecompileHeaders/PchMultilanguage.cmake | 9 | ||||
-rw-r--r-- | Tests/RunCMake/PrecompileHeaders/PchPrologueEpilogue-check.cmake | 4 | ||||
-rw-r--r-- | Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake | 1 |
14 files changed, 108 insertions, 33 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index ed20b91..32b580b 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -451,8 +451,8 @@ if(BUILD_TESTING) ADD_TEST_MACRO(StagingPrefix StagingPrefix) ADD_TEST_MACRO(ImportedSameName ImportedSameName) ADD_TEST_MACRO(InterfaceLibrary InterfaceLibrary) - if (CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]") - set(ConfigSources_BUILD_OPTIONS -DCMAKE_BUILD_TYPE=Debug) + if(NOT _isMultiConfig) + set(ConfigSources_BUILD_OPTIONS -DCMAKE_BUILD_TYPE=$<CONFIGURATION>) ADD_TEST_MACRO(ConfigSources ConfigSources) endif() ADD_TEST_MACRO(SourcesProperty SourcesProperty) diff --git a/Tests/ConfigSources/CMakeLists.txt b/Tests/ConfigSources/CMakeLists.txt index 748aad8..f5dd276 100644 --- a/Tests/ConfigSources/CMakeLists.txt +++ b/Tests/ConfigSources/CMakeLists.txt @@ -1,17 +1,21 @@ - cmake_minimum_required(VERSION 3.0) - -project(ConfigSources) +project(ConfigSources CXX) add_library(iface INTERFACE) -set_property(TARGET iface PROPERTY INTERFACE_SOURCES +target_sources(iface INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/iface_src.cpp" "$<$<CONFIG:Debug>:${CMAKE_CURRENT_SOURCE_DIR}/iface_debug_src.cpp>" - "$<$<CONFIG:Release>:${CMAKE_CURRENT_SOURCE_DIR}/does_not_exist.cpp>" -) + "$<$<NOT:$<CONFIG:Debug>>:${CMAKE_CURRENT_SOURCE_DIR}/iface_other_src.cpp>" + "$<$<CONFIG:NotAConfig>:${CMAKE_CURRENT_SOURCE_DIR}/does_not_exist.cpp>" + ) +target_compile_definitions(iface INTERFACE + "$<$<CONFIG:Debug>:CFG_DEBUG>" + "$<$<NOT:$<CONFIG:Debug>>:CFG_OTHER>" + ) add_executable(ConfigSources - $<$<CONFIG:Debug>:main.cpp> - $<$<CONFIG:Release>:does_not_exist.cpp> -) + $<$<CONFIG:Debug>:main_debug.cpp> + $<$<NOT:$<CONFIG:Debug>>:main_other.cpp> + $<$<CONFIG:NotAConfig>:does_not_exist.cpp> + ) target_link_libraries(ConfigSources iface) diff --git a/Tests/ConfigSources/iface.h b/Tests/ConfigSources/iface.h new file mode 100644 index 0000000..810456c --- /dev/null +++ b/Tests/ConfigSources/iface.h @@ -0,0 +1,10 @@ + +int iface_src(); + +#ifdef CFG_DEBUG +int iface_debug(); +#endif + +#ifdef CFG_OTHER +int iface_other(); +#endif diff --git a/Tests/ConfigSources/iface_debug.h b/Tests/ConfigSources/iface_debug.h deleted file mode 100644 index a23d737..0000000 --- a/Tests/ConfigSources/iface_debug.h +++ /dev/null @@ -1,4 +0,0 @@ - -int iface_src(); - -int iface_debug(); diff --git a/Tests/ConfigSources/iface_debug_src.cpp b/Tests/ConfigSources/iface_debug_src.cpp index 63b22fc..010059f 100644 --- a/Tests/ConfigSources/iface_debug_src.cpp +++ b/Tests/ConfigSources/iface_debug_src.cpp @@ -1,5 +1,11 @@ +#ifndef CFG_DEBUG +# error "This source should only be compiled in a Debug configuration." +#endif +#ifdef CFG_OTHER +# error "This source should not be compiled in a non-Debug configuration." +#endif -#include "iface_debug.h" +#include "iface.h" int iface_debug() { diff --git a/Tests/ConfigSources/iface_other_src.cpp b/Tests/ConfigSources/iface_other_src.cpp new file mode 100644 index 0000000..8ffdfbb --- /dev/null +++ b/Tests/ConfigSources/iface_other_src.cpp @@ -0,0 +1,13 @@ +#ifndef CFG_OTHER +# error "This source should only be compiled in a non-Debug configuration." +#endif +#ifdef CFG_DEBUG +# error "This source should not be compiled in a Debug configuration." +#endif + +#include "iface.h" + +int iface_other() +{ + return 0; +} diff --git a/Tests/ConfigSources/main.cpp b/Tests/ConfigSources/main.cpp deleted file mode 100644 index 71af72f..0000000 --- a/Tests/ConfigSources/main.cpp +++ /dev/null @@ -1,7 +0,0 @@ - -#include "iface_debug.h" - -int main(int argc, char** argv) -{ - return iface_src() + iface_debug(); -} diff --git a/Tests/ConfigSources/main_debug.cpp b/Tests/ConfigSources/main_debug.cpp new file mode 100644 index 0000000..9b1e68a --- /dev/null +++ b/Tests/ConfigSources/main_debug.cpp @@ -0,0 +1,13 @@ +#ifndef CFG_DEBUG +# error "This source should only be compiled in a Debug configuration." +#endif +#ifdef CFG_OTHER +# error "This source should not be compiled in a non-Debug configuration." +#endif + +#include "iface.h" + +int main(int argc, char** argv) +{ + return iface_src() + iface_debug(); +} diff --git a/Tests/ConfigSources/main_other.cpp b/Tests/ConfigSources/main_other.cpp new file mode 100644 index 0000000..3184a19 --- /dev/null +++ b/Tests/ConfigSources/main_other.cpp @@ -0,0 +1,13 @@ +#ifndef CFG_OTHER +# error "This source should only be compiled in a non-Debug configuration." +#endif +#ifdef CFG_DEBUG +# error "This source should not be compiled in a Debug configuration." +#endif + +#include "iface.h" + +int main(int argc, char** argv) +{ + return iface_src() + iface_other(); +} diff --git a/Tests/RunCMake/PrecompileHeaders/DisabledPch-check.cmake b/Tests/RunCMake/PrecompileHeaders/DisabledPch-check.cmake index fa37c2c..8cf0fc9 100644 --- a/Tests/RunCMake/PrecompileHeaders/DisabledPch-check.cmake +++ b/Tests/RunCMake/PrecompileHeaders/DisabledPch-check.cmake @@ -1,17 +1,17 @@ if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) - set(foo_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foo.dir/CMakeFiles/foo.dir/cmake_pch.h") - set(foobar_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/CMakeFiles/foobar.dir/cmake_pch.h") + set(foo_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foo.dir/CMakeFiles/foo.dir/cmake_pch.h") + set(foobar_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/CMakeFiles/foobar.dir/cmake_pch.h") else() - set(foo_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foo.dir/cmake_pch.h") - set(foobar_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/cmake_pch.h") + set(foo_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foo.dir/cmake_pch.h") + set(foobar_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/cmake_pch.h") endif() if (NOT EXISTS ${foo_pch_header}) - set(RunCMake_TEST_FAILED "Generated foo pch header ${foo_pch_header} does not exist") - return() + set(RunCMake_TEST_FAILED "Generated foo pch header ${foo_pch_header} does not exist") + return() endif() if (EXISTS ${foobar_pch_header}) - set(RunCMake_TEST_FAILED "Generated foobar pch header ${foobar_pch_header} should not exist") - return() + set(RunCMake_TEST_FAILED "Generated foobar pch header ${foobar_pch_header} should not exist") + return() endif() diff --git a/Tests/RunCMake/PrecompileHeaders/PchMultilanguage-check.cmake b/Tests/RunCMake/PrecompileHeaders/PchMultilanguage-check.cmake new file mode 100644 index 0000000..44fe2da --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/PchMultilanguage-check.cmake @@ -0,0 +1,17 @@ +if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(foobar_pch_h_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/CMakeFiles/foobar.dir/cmake_pch.h") + set(foobar_pch_hxx_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/CMakeFiles/foobar.dir/cmake_pch.hxx") +else() + set(foobar_pch_h_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/cmake_pch.h") + set(foobar_pch_hxx_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/cmake_pch.hxx") +endif() + +if (NOT EXISTS ${foobar_pch_h_header}) + set(RunCMake_TEST_FAILED "Generated foobar C pch header ${foobar_pch_h_header} does not exist") + return() +endif() + +if (NOT EXISTS ${foobar_pch_hxx_header}) + set(RunCMake_TEST_FAILED "Generated foobar C++ pch header ${foobar_pch_hxx_header} does not exist") + return() +endif() diff --git a/Tests/RunCMake/PrecompileHeaders/PchMultilanguage.cmake b/Tests/RunCMake/PrecompileHeaders/PchMultilanguage.cmake new file mode 100644 index 0000000..7a837da --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/PchMultilanguage.cmake @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.15) +project(PchMultilanguage C CXX) + +add_executable(foobar + foo.c + main.cpp +) +target_include_directories(foobar PUBLIC include) +target_precompile_headers(foobar PRIVATE "<stddef.h>") diff --git a/Tests/RunCMake/PrecompileHeaders/PchPrologueEpilogue-check.cmake b/Tests/RunCMake/PrecompileHeaders/PchPrologueEpilogue-check.cmake index fd82607..ba220f3 100644 --- a/Tests/RunCMake/PrecompileHeaders/PchPrologueEpilogue-check.cmake +++ b/Tests/RunCMake/PrecompileHeaders/PchPrologueEpilogue-check.cmake @@ -1,7 +1,7 @@ if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) - set(main_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/main.dir/CMakeFiles/main.dir/cmake_pch.hxx") + set(main_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/main.dir/CMakeFiles/main.dir/cmake_pch.hxx") else() - set(main_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/main.dir/cmake_pch.hxx") + set(main_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/main.dir/cmake_pch.hxx") endif() file(STRINGS ${main_pch_header} main_pch_header_strings) diff --git a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake index bd3b1b8..ec13663 100644 --- a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake +++ b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake @@ -18,3 +18,4 @@ run_cmake(PchPrologueEpilogue) run_test(SkipPrecompileHeaders) run_test(PchReuseFrom) run_test(PchReuseFromSubdir) +run_cmake(PchMultilanguage) |