From d7d94acf083576db02d1127eabf231002852b1d7 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Sun, 15 Sep 2013 15:15:45 +0000 Subject: [PATCH] CMAKE: Bugfix, also allow to call DEAL_II_SETUP_TARGET on object libraries git-svn-id: https://svn.dealii.org/branches/branch_port_the_testsuite@30713 0785d39b-7218-0410-832d-ea1e28bc413d --- .../macro_deal_ii_insource_setup_target.cmake | 51 +++++++++++++++++++ .../macros/macro_deal_ii_pickup_tests.cmake | 2 +- .../macros/macro_deal_ii_setup_target.cmake | 5 +- tests/all-headers/CMakeLists.txt | 16 ++---- tests/build_tests/CMakeLists.txt | 8 +-- 5 files changed, 61 insertions(+), 21 deletions(-) create mode 100644 deal.II/cmake/macros/macro_deal_ii_insource_setup_target.cmake diff --git a/deal.II/cmake/macros/macro_deal_ii_insource_setup_target.cmake b/deal.II/cmake/macros/macro_deal_ii_insource_setup_target.cmake new file mode 100644 index 0000000000..daa070b2ae --- /dev/null +++ b/deal.II/cmake/macros/macro_deal_ii_insource_setup_target.cmake @@ -0,0 +1,51 @@ +## --------------------------------------------------------------------- +## $Id$ +## +## Copyright (C) 2012 - 2013 by the deal.II authors +## +## This file is part of the deal.II library. +## +## The deal.II library is free software; you can use it, redistribute +## it, and/or modify it under the terms of the GNU Lesser General +## Public License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## The full text of the license can be found in the file LICENSE at +## the top level of the deal.II distribution. +## +## --------------------------------------------------------------------- + +# +# This file provides an insource version of the DEAL_II_SETUP_TARGET macro. +# +# Usage: +# DEAL_II_INSOURCE_SETUP_TARGET(target build) +# +# This appends necessary include directories, linker flags, compile +# definitions and the deal.II library link interface to the given target. +# +# + +MACRO(DEAL_II_INSOURCE_SETUP_TARGET _target _build) + + SET_TARGET_PROPERTIES(${_target} PROPERTIES + LINK_FLAGS "${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${_build}}" + COMPILE_DEFINITIONS "${DEAL_II_DEFINITIONS};${DEAL_II_DEFINITIONS_${_build}}" + COMPILE_FLAGS "${DEAL_II_CXX_FLAGS_${_build}}" + LINKER_LANGUAGE "CXX" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${_test_short}" + ) + SET_PROPERTY(TARGET ${_target} APPEND PROPERTY + INCLUDE_DIRECTORIES + "${CMAKE_BINARY_DIR}/include" + "${CMAKE_SOURCE_DIR}/include" + "${CMAKE_SOURCE_DIR}/include/deal.II/" + ) + +GET_PROPERTY(_type TARGET ${_target} PROPERTY TYPE) +IF(NOT "${_type}" STREQUAL "OBJECT_LIBRARY") + TARGET_LINK_LIBRARIES(${_target} + ${DEAL_II_BASE_NAME}${DEAL_II_${_build}_SUFFIX} + ) +ENDIF() + +ENDMACRO() diff --git a/deal.II/cmake/macros/macro_deal_ii_pickup_tests.cmake b/deal.II/cmake/macros/macro_deal_ii_pickup_tests.cmake index 95daf6f6e9..cf5fdc1bb4 100644 --- a/deal.II/cmake/macros/macro_deal_ii_pickup_tests.cmake +++ b/deal.II/cmake/macros/macro_deal_ii_pickup_tests.cmake @@ -15,7 +15,7 @@ ## --------------------------------------------------------------------- # -# A Macro to pick up all tests in a test subdirectory +# A macro to pick up all tests in a test subdirectory # # If TEST_PICKUP_REGEX is set, only tests matching the regex will be # processed. diff --git a/deal.II/cmake/macros/macro_deal_ii_setup_target.cmake b/deal.II/cmake/macros/macro_deal_ii_setup_target.cmake index 28b88dd1d0..df0a3a1387 100644 --- a/deal.II/cmake/macros/macro_deal_ii_setup_target.cmake +++ b/deal.II/cmake/macros/macro_deal_ii_setup_target.cmake @@ -121,7 +121,10 @@ MACRO(DEAL_II_SETUP_TARGET _target) # # Set up the link interface: # - TARGET_LINK_LIBRARIES(${_target} ${DEAL_II_TARGET}) + GET_PROPERTY(_type TARGET ${_target} PROPERTY TYPE) + IF(NOT "${_type}" STREQUAL "OBJECT_LIBRARY") + TARGET_LINK_LIBRARIES(${_target} ${DEAL_II_TARGET}) + ENDIF() # # If DEAL_II_STATIC_EXECUTABLE is set, switch the final link type to diff --git a/tests/all-headers/CMakeLists.txt b/tests/all-headers/CMakeLists.txt index 1c3527c031..c9e9c8204f 100644 --- a/tests/all-headers/CMakeLists.txt +++ b/tests/all-headers/CMakeLists.txt @@ -23,13 +23,9 @@ # SET(_category all-headers) - -FILE(GLOB_RECURSE _header - ${CMAKE_SOURCE_DIR}/include/*.h - ) +FILE(GLOB_RECURSE _header ${CMAKE_SOURCE_DIR}/include/*.h) FOREACH(_full_file ${_header}) - GET_FILENAME_COMPONENT(_file ${_full_file} NAME) # TODO: A more sophisticated way to get the relative include path: @@ -44,15 +40,12 @@ FOREACH(_full_file ${_header}) SET(_test ${_category}/${_path}/${_file}.${_build_lowercase}) SET(_target ${_category}-${_path}-${_file}.${_build_lowercase}) - # + # Respect TEST_PICKUP_REGEX: - # IF( "${TEST_PICKUP_REGEX}" STREQUAL "" OR _test MATCHES "${TEST_PICKUP_REGEX}" ) - # # Add an object library for each header file and build configuration: - # ADD_LIBRARY(${_target} OBJECT EXCLUDE_FROM_ALL test_header.cc) SET_TARGET_PROPERTIES(${_target} PROPERTIES COMPILE_DEFINITIONS "${DEAL_II_DEFINITIONS};${DEAL_II_DEFINITIONS_${_build}}" @@ -65,13 +58,10 @@ FOREACH(_full_file ${_header}) "${CMAKE_SOURCE_DIR}/include/deal.II/" ) SET_PROPERTY(TARGET ${_target} APPEND PROPERTY - COMPILE_DEFINITIONS - HEADER= + COMPILE_DEFINITIONS HEADER= ) - # # And finally add the test: - # ADD_TEST(NAME ${_test} COMMAND ${CMAKE_COMMAND} -DTRGT=${_target} diff --git a/tests/build_tests/CMakeLists.txt b/tests/build_tests/CMakeLists.txt index de7de1e422..99aab0fc5d 100644 --- a/tests/build_tests/CMakeLists.txt +++ b/tests/build_tests/CMakeLists.txt @@ -27,7 +27,6 @@ SET(_category build_tests) - # Run a minimalistic set of steps in debug configuration: SET(_debug_steps step-1 step-2 step-3 step-4 step-5 @@ -44,7 +43,6 @@ SET(_release_steps step-47 step-48 step-49 ) - FILE(GLOB _steps ${CMAKE_SOURCE_DIR}/examples/step-*) FOREACH(_step_full ${_steps}) GET_FILENAME_COMPONENT(_step ${_step_full} NAME) @@ -54,9 +52,7 @@ FOREACH(_step_full ${_steps}) SET(_test ${_category}/${_step}.${_build_lowercase}) - # # Respect TEST_PICKUP_REGEX: - # IF( "${TEST_PICKUP_REGEX}" STREQUAL "" OR _test MATCHES "${TEST_PICKUP_REGEX}" ) @@ -133,16 +129,16 @@ FOREACH(_step_full ${_steps}) ITEM_MATCHES(_match ${_step} ${_${_build_lowercase}_steps}) IF(_match) + # Add a full test (CONFIGURE, BUILD, RUN): SET(_target ${_category}-${_step}.${_build_lowercase}.run) ADD_CUSTOM_TARGET(${_target} DEPENDS ${_step_dir}/run_output) ELSE() + # Add a minimal test (CONFIGURE, BUILD): SET(_target ${_category}-${_step}.${_build_lowercase}.build) ADD_CUSTOM_TARGET(${_target} DEPENDS ${_step_dir}/build_output) ENDIF() - # # And finally add the test: - # ADD_TEST(NAME ${_test} COMMAND ${CMAKE_COMMAND} -DTRGT=${_target} -- 2.39.5