From 09a663f110728a6199a93e5a866f2b3da6c89948 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 18 Nov 2009 09:14:18 -0500 Subject: [PATCH] Use ADD_TEST_28 macro to fix tests with the VS IDE This macro simplifies creation of tests that refer to executables built in the project. We can pass executables as arguments to a test using a CMake 2.8 "generator expression" of the form "$". The macro translates the arguments into something CMake 2.6 understands. This change also fixes the tests so that they run correctly in build trees created for multi-configuration build tools like the VS IDE. These tools place executables in a per-configuration subdirectory so references to executables in test arguments must use a test-time substitution. The ADD_TEST_28 macro handles this automatically. SVN-Revision: 1672 --- CMakeLists.txt | 4 ++++ cpio/test/CMakeLists.txt | 11 ++++++----- libarchive/test/CMakeLists.txt | 5 +++-- tar/test/CMakeLists.txt | 11 ++++++----- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d51f4466e..5031278a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,6 +31,10 @@ SET(SOVERSION 8) # Enable CTest/CDash support include(CTest) +# Provide ADD_TEST_28 macro to approximate CMake 2.8 ADD_TEST(NAME). +# TODO: Require CMake 2.8 and drop this workaround (perhaps late 2010). +INCLUDE(AddTest28) + OPTION(ENABLE_TAR "Enable tar building" ON) OPTION(ENABLE_TAR_SHARED "Enable dynamic build of tar" OFF) OPTION(ENABLE_CPIO "Enable cpio building" ON) diff --git a/cpio/test/CMakeLists.txt b/cpio/test/CMakeLists.txt index ddc69cce3..a822bcdfb 100644 --- a/cpio/test/CMakeLists.txt +++ b/cpio/test/CMakeLists.txt @@ -60,11 +60,12 @@ IF(ENABLE_CPIO AND ENABLE_TEST) # test. We can use that to define the tests for cmake by # defining a DEFINE_TEST macro and reading list.h in. MACRO (DEFINE_TEST _testname) - ADD_TEST("bsdcpio_${_testname}" - bsdcpio_test -vv - -p ${BSDCPIO} - -r ${CMAKE_CURRENT_SOURCE_DIR} - ${_testname}) + ADD_TEST_28( + NAME bsdcpio_${_testname} + COMMAND bsdcpio_test -vv + -p $ + -r ${CMAKE_CURRENT_SOURCE_DIR} + ${_testname}) ENDMACRO (DEFINE_TEST _testname) INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h) diff --git a/libarchive/test/CMakeLists.txt b/libarchive/test/CMakeLists.txt index 682a58cc5..69f494ccb 100644 --- a/libarchive/test/CMakeLists.txt +++ b/libarchive/test/CMakeLists.txt @@ -137,8 +137,9 @@ IF(ENABLE_TEST) # test. We can use that to define the tests for cmake by # defining a DEFINE_TEST macro and reading list.h in. MACRO (DEFINE_TEST _testname) - ADD_TEST("libarchive_${_testname}" - libarchive_test -vv + ADD_TEST_28( + NAME libarchive_${_testname} + COMMAND libarchive_test -vv -r ${CMAKE_CURRENT_SOURCE_DIR} ${_testname}) ENDMACRO (DEFINE_TEST _testname) diff --git a/tar/test/CMakeLists.txt b/tar/test/CMakeLists.txt index fe5f0ba6e..fab67f3de 100644 --- a/tar/test/CMakeLists.txt +++ b/tar/test/CMakeLists.txt @@ -47,11 +47,12 @@ IF(ENABLE_TAR AND ENABLE_TEST) # test. We can use that to define the tests for cmake by # defining a DEFINE_TEST macro and reading list.h in. MACRO (DEFINE_TEST _testname) - ADD_TEST("bsdtar_${_testname}" - bsdtar_test -vv - -p ${BSDTAR} - -r ${CMAKE_CURRENT_SOURCE_DIR} - ${_testname}) + ADD_TEST_28( + NAME bsdtar_${_testname} + COMMAND bsdtar_test -vv + -p $ + -r ${CMAKE_CURRENT_SOURCE_DIR} + ${_testname}) ENDMACRO (DEFINE_TEST _testname) INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h) -- 2.47.3