From dc6bfcf2300cde90fc109b664d2ee665cd94dafb Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 11 May 2009 04:50:32 +0000 Subject: [PATCH] Fix link and link-fail tests in CMake. Statechart's examples depend on numeric. [SVN r52895] --- CMake/BoostCore.cmake | 19 ++++++++----------- CMake/BoostTesting.cmake | 14 ++++++++++++++ CMake/LinkTest/CMakeLists.txt | 2 +- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/CMake/BoostCore.cmake b/CMake/BoostCore.cmake index e89dacf0a..98dc70a2b 100644 --- a/CMake/BoostCore.cmake +++ b/CMake/BoostCore.cmake @@ -326,6 +326,14 @@ macro(boost_library_project LIBNAME) endforeach () endif() + # Create a target -test, which will run all of + # this library's tests. + if (THIS_PROJECT_TESTDIRS) + add_custom_target(${PROJECT_NAME}-test + COMMAND ${CMAKE_CTEST_COMMAND} -R "^${PROJECT_NAME}-*" + MESSAGE "Running tests for Boost.${PROJECT_NAME}...") + endif () + # Include the test directories. foreach(SUBDIR ${THIS_PROJECT_TESTDIRS}) add_subdirectory(${SUBDIR}) @@ -1156,9 +1164,6 @@ macro(boost_add_library LIBNAME) ) set(THIS_LIB_SOURCES ${THIS_LIB_DEFAULT_ARGS}) - string(TOUPPER "${LIBNAME}_COMPILED_LIB" compiled_lib) - set (${compiled_lib} TRUE CACHE INTERNAL "") - if (NOT TEST_INSTALLED_TREE) # A top-level target that refers to all of the variants of the # library, collectively. @@ -1212,9 +1217,6 @@ macro(boost_add_single_library LIBNAME) ) set(THIS_LIB_SOURCES ${THIS_LIB_DEFAULT_ARGS}) - string(TOUPPER "${LIBNAME}_COMPILED_LIB" compiled_lib) - set (${compiled_lib} TRUE CACHE INTERNAL "") - if (NOT TEST_INSTALLED_TREE) boost_select_variant(${LIBNAME} THIS_LIB) if (THIS_LIB_VARIANT) @@ -1382,11 +1384,6 @@ macro(boost_add_executable EXENAME) endforeach(LIB ${THIS_EXE_DEPENDS}) # Build the executable - # TODO: the use of ${PROJECT_NAME}/${EXENAME} is a bit strange. - # It's designed to keep the names of regression tests from one library - # separate from the regression tests of another library, but this can - # be handled better with OUTPUT_NAME. This would also allow us to eliminate - # the directory-creation logic in boost_library_project. if (THIS_PROJECT_IS_TOOL) set(THIS_EXE_NAME ${EXENAME}) else() diff --git a/CMake/BoostTesting.cmake b/CMake/BoostTesting.cmake index 886ed4704..c8792fe13 100644 --- a/CMake/BoostTesting.cmake +++ b/CMake/BoostTesting.cmake @@ -282,6 +282,10 @@ macro(boost_test_run testname) LABELS "${PROJECT_NAME}" ) + # Make sure that the -test target that corresponds to this + # library or tool depends on this test executable. + add_dependencies(${PROJECT_NAME}-test ${THIS_EXE_NAME}) + if (BOOST_TEST_FAIL) set_tests_properties(${BOOST_TEST_TESTNAME} PROPERTIES WILL_FAIL ON) endif () @@ -377,6 +381,15 @@ endmacro(boost_test_compile_fail) macro(boost_test_link testname) boost_test_parse_args(${testname} ${ARGN} LINK) if(BOOST_TEST_OKAY) + # Determine the include directories to pass along to the underlying + # project. + # works but not great + get_directory_property(BOOST_TEST_INCLUDE_DIRS INCLUDE_DIRECTORIES) + set(BOOST_TEST_INCLUDES "") + foreach(DIR ${BOOST_TEST_INCLUDE_DIRS}) + set(BOOST_TEST_INCLUDES "${BOOST_TEST_INCLUDES};${DIR}") + endforeach(DIR ${BOOST_TEST_INCLUDE_DIRS}) + add_test(${BOOST_TEST_TESTNAME} ${CMAKE_CTEST_COMMAND} --build-and-test @@ -385,6 +398,7 @@ macro(boost_test_link testname) --build-generator ${CMAKE_GENERATOR} --build-makeprogram ${CMAKE_MAKE_PROGRAM} --build-project LinkTest + --build-options "-DSOURCE:STRING=${CMAKE_CURRENT_SOURCE_DIR}/${BOOST_TEST_SOURCES}" "-DINCLUDES:STRING=${BOOST_TEST_INCLUDES}" "-DCOMPILE_FLAGS:STRING=${BOOST_TEST_COMPILE_FLAGS}" diff --git a/CMake/LinkTest/CMakeLists.txt b/CMake/LinkTest/CMakeLists.txt index 1f25bb353..c5e2600ed 100644 --- a/CMake/LinkTest/CMakeLists.txt +++ b/CMake/LinkTest/CMakeLists.txt @@ -2,6 +2,6 @@ cmake_minimum_required(VERSION 2.6) project(LinkTest) include_directories (${INCLUDES}) -add_executable(link-test ${SOURCE} COMPILE_FLAGS "${COMPILE_FLAGS}") +add_executable(link-test ${SOURCE}) set_source_files_properties(${SOURCE} PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS}") \ No newline at end of file