From 45e1953c4037d4492668651ae3bbfd6a4a875bc1 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 7 Dec 2010 17:36:24 -0500 Subject: [PATCH] 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. --- Tests/PerConfig/CMakeLists.txt | 33 ++++++++++++++++++ Tests/{Testing => PerConfig}/pcShared.c | 0 Tests/{Testing => PerConfig}/pcShared.h | 0 Tests/{Testing => PerConfig}/pcStatic.c | 0 Tests/{Testing => PerConfig}/perconfig.c | 0 .../perconfig.cmake} | 0 Tests/Testing/CMakeLists.txt | 34 ++----------------- 7 files changed, 36 insertions(+), 31 deletions(-) create mode 100644 Tests/PerConfig/CMakeLists.txt rename Tests/{Testing => PerConfig}/pcShared.c (100%) rename Tests/{Testing => PerConfig}/pcShared.h (100%) rename Tests/{Testing => PerConfig}/pcStatic.c (100%) rename Tests/{Testing => PerConfig}/perconfig.c (100%) rename Tests/{Testing/driver.cmake => PerConfig/perconfig.cmake} (100%) diff --git a/Tests/PerConfig/CMakeLists.txt b/Tests/PerConfig/CMakeLists.txt new file mode 100644 index 000000000..a45abc8e2 --- /dev/null +++ b/Tests/PerConfig/CMakeLists.txt @@ -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=$) +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=$ + -Dperconfig_file_dir=$ + -Dperconfig_file_name=$ + -Dperconfig_file=$ + -DpcStatic_file=$ + -DpcStatic_linker_file=$ + -DpcShared_file=$ + -DpcShared_linker_file=$ + ${soname_file} + -P ${PerConfig_SOURCE_DIR}/perconfig.cmake + ) +SET(PerConfig_COMMAND "${PerConfig_COMMAND}" PARENT_SCOPE) diff --git a/Tests/Testing/pcShared.c b/Tests/PerConfig/pcShared.c similarity index 100% rename from Tests/Testing/pcShared.c rename to Tests/PerConfig/pcShared.c diff --git a/Tests/Testing/pcShared.h b/Tests/PerConfig/pcShared.h similarity index 100% rename from Tests/Testing/pcShared.h rename to Tests/PerConfig/pcShared.h diff --git a/Tests/Testing/pcStatic.c b/Tests/PerConfig/pcStatic.c similarity index 100% rename from Tests/Testing/pcStatic.c rename to Tests/PerConfig/pcStatic.c diff --git a/Tests/Testing/perconfig.c b/Tests/PerConfig/perconfig.c similarity index 100% rename from Tests/Testing/perconfig.c rename to Tests/PerConfig/perconfig.c diff --git a/Tests/Testing/driver.cmake b/Tests/PerConfig/perconfig.cmake similarity index 100% rename from Tests/Testing/driver.cmake rename to Tests/PerConfig/perconfig.cmake diff --git a/Tests/Testing/CMakeLists.txt b/Tests/Testing/CMakeLists.txt index f85740705..815b52b58 100644 --- a/Tests/Testing/CMakeLists.txt +++ b/Tests/Testing/CMakeLists.txt @@ -53,35 +53,7 @@ ADD_TEST(testing.1 ${Testing_BINARY_DIR}/bin/testing) # ADD_SUBDIRECTORY(Sub/Sub2) -# Per-config target name test. -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=$) -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) +# Per-config target name and generator expressions. +ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../PerConfig PerConfig) ADD_TEST(NAME testing.perconfig COMMAND perconfig) - -# Test using a driver script with generator expressions. -ADD_TEST(NAME testing.driver - COMMAND ${CMAKE_COMMAND} - -Dconfiguration=$ - -Dperconfig_file_dir=$ - -Dperconfig_file_name=$ - -Dperconfig_file=$ - -DpcStatic_file=$ - -DpcStatic_linker_file=$ - -DpcShared_file=$ - -DpcShared_linker_file=$ - ${soname_file} - -P ${Testing_SOURCE_DIR}/driver.cmake - ) +ADD_TEST(NAME testing.driver COMMAND ${PerConfig_COMMAND})