Test LINK_FLAGS and STATIC_LIBRARY_FLAGS (#10768)

Add a LinkFlags test series to check that these properties work.  Since
no link flag is accepted everywhere we test for presence of flags by
adding a bad flag and looking for the complaint in the test output.
This commit is contained in:
Brad King 2010-05-28 09:47:12 -04:00
parent 159606c366
commit d3303dbc81
4 changed files with 57 additions and 0 deletions

View File

@ -174,6 +174,37 @@ IF(BUILD_TESTING)
ADD_TEST_MACRO(Module.CheckTypeSize CheckTypeSize) ADD_TEST_MACRO(Module.CheckTypeSize CheckTypeSize)
ADD_TEST(LinkFlags-prepare
${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/LinkFlags"
"${CMake_BINARY_DIR}/Tests/LinkFlags"
--build-generator ${CMAKE_TEST_GENERATOR}
--build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
--build-project LinkFlags
--build-target LinkFlags
--build-options -DTEST_CONFIG=\${CTEST_CONFIGURATION_TYPE}
)
LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LinkFlags")
MACRO(ADD_LINK_FLAGS_TEST name depends)
ADD_TEST(LinkFlags-${name}
${CMAKE_CMAKE_COMMAND} --build "${CMake_BINARY_DIR}/Tests/LinkFlags"
--target LinkFlags_${name} --config \${CTEST_CONFIGURATION_TYPE}
)
SET_TESTS_PROPERTIES(LinkFlags-${name} PROPERTIES
PASS_REGULAR_EXPRESSION "BADFLAG" DEPENDS LinkFlags-${depends})
ENDMACRO()
ADD_LINK_FLAGS_TEST(lib prepare)
ADD_LINK_FLAGS_TEST(dll lib)
ADD_LINK_FLAGS_TEST(exe dll)
ADD_LINK_FLAGS_TEST(lib_config exe)
ADD_LINK_FLAGS_TEST(dll_config lib_config)
ADD_LINK_FLAGS_TEST(exe_config dll_config)
# STATIC_LIBRARY_FLAGS_<CONFIG> not yet implemented
SET_TESTS_PROPERTIES(LinkFlags-lib_config PROPERTIES WILL_FAIL 1)
# If we are running right now with a UnixMakefiles based generator, # If we are running right now with a UnixMakefiles based generator,
# build the "Simple" test with the ExtraGenerators, if available # build the "Simple" test with the ExtraGenerators, if available
# This doesn't test whether the generated project files work (unfortunately), # This doesn't test whether the generated project files work (unfortunately),

View File

@ -0,0 +1,24 @@
cmake_minimum_required(VERSION 2.8)
project(LinkFlags C)
string(TOUPPER "${TEST_CONFIG}" TEST_CONFIG_UPPER)
add_library(LinkFlags_lib STATIC LinkFlagsLib.c)
set_property(TARGET LinkFlags_lib PROPERTY STATIC_LIBRARY_FLAGS _BADFLAG_)
add_library(LinkFlags_dll SHARED LinkFlagsLib.c)
set_property(TARGET LinkFlags_dll PROPERTY LINK_FLAGS _BADFLAG_)
add_executable(LinkFlags_exe LinkFlags.c)
set_property(TARGET LinkFlags_exe PROPERTY LINK_FLAGS _BADFLAG_)
add_library(LinkFlags_lib_config STATIC LinkFlagsLib.c)
set_property(TARGET LinkFlags_lib_config PROPERTY STATIC_LIBRARY_FLAGS_${TEST_CONFIG_UPPER} _BADFLAG_${TEST_CONFIG}_)
add_library(LinkFlags_dll_config SHARED LinkFlagsLib.c)
set_property(TARGET LinkFlags_dll_config PROPERTY LINK_FLAGS_${TEST_CONFIG_UPPER} _BADFLAG_${TEST_CONFIG}_)
add_executable(LinkFlags_exe_config LinkFlags.c)
set_property(TARGET LinkFlags_exe_config PROPERTY LINK_FLAGS_${TEST_CONFIG_UPPER} _BADFLAG_${TEST_CONFIG}_)
add_executable(LinkFlags LinkFlags.c)

View File

@ -0,0 +1 @@
int main(void) { return 0; }

View File

@ -0,0 +1 @@
int flags_lib(void) { return 0; }