mirror of
https://github.com/reactos/CMake.git
synced 2024-11-23 19:49:51 +00:00
Tests: Enable ConfigSources test on every configuration
Revise the test itself to work in all configurations and verify that certain sources are only built by whatever configuration is tested.
This commit is contained in:
parent
395e5f77fc
commit
9c9e66289a
@ -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)
|
||||
|
@ -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)
|
||||
|
10
Tests/ConfigSources/iface.h
Normal file
10
Tests/ConfigSources/iface.h
Normal file
@ -0,0 +1,10 @@
|
||||
|
||||
int iface_src();
|
||||
|
||||
#ifdef CFG_DEBUG
|
||||
int iface_debug();
|
||||
#endif
|
||||
|
||||
#ifdef CFG_OTHER
|
||||
int iface_other();
|
||||
#endif
|
@ -1,4 +0,0 @@
|
||||
|
||||
int iface_src();
|
||||
|
||||
int iface_debug();
|
@ -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()
|
||||
{
|
||||
|
13
Tests/ConfigSources/iface_other_src.cpp
Normal file
13
Tests/ConfigSources/iface_other_src.cpp
Normal file
@ -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;
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
|
||||
#include "iface_debug.h"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
return iface_src() + iface_debug();
|
||||
}
|
13
Tests/ConfigSources/main_debug.cpp
Normal file
13
Tests/ConfigSources/main_debug.cpp
Normal file
@ -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();
|
||||
}
|
13
Tests/ConfigSources/main_other.cpp
Normal file
13
Tests/ConfigSources/main_other.cpp
Normal file
@ -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();
|
||||
}
|
Loading…
Reference in New Issue
Block a user