Factor per-config sample targets out of 'Testing' test

Put the source files, build rules, and test scripts for these targets
under Tests/PerConfig and refer to it from Tests/Testing as a
subdirectory.  The targets and scripts will be useful in other tests.
This commit is contained in:
Brad King 2010-12-07 17:36:24 -05:00
parent 4091bca4ec
commit 45e1953c40
7 changed files with 36 additions and 31 deletions

View File

@ -0,0 +1,33 @@
project(PerConfig C)
# Targets with per-configuration names.
ADD_LIBRARY(pcStatic STATIC pcStatic.c)
SET_PROPERTY(TARGET pcStatic PROPERTY RELEASE_POSTFIX -opt)
SET_PROPERTY(TARGET pcStatic PROPERTY DEBUG_POSTFIX -dbg)
ADD_LIBRARY(pcShared SHARED pcShared.c)
SET_PROPERTY(TARGET pcShared PROPERTY RELEASE_POSTFIX -opt)
SET_PROPERTY(TARGET pcShared PROPERTY DEBUG_POSTFIX -dbg)
SET_PROPERTY(TARGET pcShared PROPERTY VERSION 1.2)
SET_PROPERTY(TARGET pcShared PROPERTY SOVERSION 3)
IF(NOT WIN32)
SET(soname_file -DpcShared_soname_file=$<TARGET_SONAME_FILE:pcShared>)
ENDIF()
ADD_EXECUTABLE(perconfig perconfig.c)
TARGET_LINK_LIBRARIES(perconfig pcStatic pcShared)
SET_PROPERTY(TARGET perconfig PROPERTY RELEASE_POSTFIX -opt)
SET_PROPERTY(TARGET perconfig PROPERTY DEBUG_POSTFIX -dbg)
SET(PerConfig_COMMAND
${CMAKE_COMMAND}
-Dconfiguration=$<CONFIGURATION>
-Dperconfig_file_dir=$<TARGET_FILE_DIR:perconfig>
-Dperconfig_file_name=$<TARGET_FILE_NAME:perconfig>
-Dperconfig_file=$<TARGET_FILE:perconfig>
-DpcStatic_file=$<TARGET_FILE:pcStatic>
-DpcStatic_linker_file=$<TARGET_LINKER_FILE:pcStatic>
-DpcShared_file=$<TARGET_FILE:pcShared>
-DpcShared_linker_file=$<TARGET_LINKER_FILE:pcShared>
${soname_file}
-P ${PerConfig_SOURCE_DIR}/perconfig.cmake
)
SET(PerConfig_COMMAND "${PerConfig_COMMAND}" PARENT_SCOPE)

View File

@ -53,35 +53,7 @@ ADD_TEST(testing.1 ${Testing_BINARY_DIR}/bin/testing)
# #
ADD_SUBDIRECTORY(Sub/Sub2) ADD_SUBDIRECTORY(Sub/Sub2)
# Per-config target name test. # Per-config target name and generator expressions.
ADD_LIBRARY(pcStatic STATIC pcStatic.c) ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../PerConfig PerConfig)
SET_PROPERTY(TARGET pcStatic PROPERTY RELEASE_POSTFIX -opt)
SET_PROPERTY(TARGET pcStatic PROPERTY DEBUG_POSTFIX -dbg)
ADD_LIBRARY(pcShared SHARED pcShared.c)
SET_PROPERTY(TARGET pcShared PROPERTY RELEASE_POSTFIX -opt)
SET_PROPERTY(TARGET pcShared PROPERTY DEBUG_POSTFIX -dbg)
SET_PROPERTY(TARGET pcShared PROPERTY VERSION 1.2)
SET_PROPERTY(TARGET pcShared PROPERTY SOVERSION 3)
IF(NOT WIN32)
SET(soname_file -DpcShared_soname_file=$<TARGET_SONAME_FILE:pcShared>)
ENDIF()
ADD_EXECUTABLE(perconfig perconfig.c)
TARGET_LINK_LIBRARIES(perconfig pcStatic pcShared)
SET_PROPERTY(TARGET perconfig PROPERTY RELEASE_POSTFIX -opt)
SET_PROPERTY(TARGET perconfig PROPERTY DEBUG_POSTFIX -dbg)
ADD_TEST(NAME testing.perconfig COMMAND perconfig) ADD_TEST(NAME testing.perconfig COMMAND perconfig)
ADD_TEST(NAME testing.driver COMMAND ${PerConfig_COMMAND})
# Test using a driver script with generator expressions.
ADD_TEST(NAME testing.driver
COMMAND ${CMAKE_COMMAND}
-Dconfiguration=$<CONFIGURATION>
-Dperconfig_file_dir=$<TARGET_FILE_DIR:perconfig>
-Dperconfig_file_name=$<TARGET_FILE_NAME:perconfig>
-Dperconfig_file=$<TARGET_FILE:perconfig>
-DpcStatic_file=$<TARGET_FILE:pcStatic>
-DpcStatic_linker_file=$<TARGET_LINKER_FILE:pcStatic>
-DpcShared_file=$<TARGET_FILE:pcShared>
-DpcShared_linker_file=$<TARGET_LINKER_FILE:pcShared>
${soname_file}
-P ${Testing_SOURCE_DIR}/driver.cmake
)