From 3755863295e03afc9a44cb252140e92e6116c92c Mon Sep 17 00:00:00 2001 From: maier Date: Sat, 26 Oct 2013 09:14:21 +0000 Subject: [PATCH] Bugfix: Simplify project config generation git-svn-id: https://svn.dealii.org/trunk@31432 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/cmake/config/CMakeLists.txt | 103 +++++++++++--------- deal.II/cmake/config/Config.cmake.in | 29 ++---- deal.II/cmake/config/Make.global_options.in | 12 +-- deal.II/cmake/setup_cached_variables.cmake | 26 +++-- deal.II/cmake/setup_deal_ii.cmake | 12 +-- deal.II/cmake/setup_finalize.cmake | 2 +- deal.II/source/CMakeLists.txt | 2 +- 7 files changed, 90 insertions(+), 96 deletions(-) diff --git a/deal.II/cmake/config/CMakeLists.txt b/deal.II/cmake/config/CMakeLists.txt index 4309152d48..eea6fdf8f0 100644 --- a/deal.II/cmake/config/CMakeLists.txt +++ b/deal.II/cmake/config/CMakeLists.txt @@ -21,8 +21,9 @@ # deal.IIConfig.cmake # deal.IIVersionConfig.cmake # -# and copies it (a) to the build directory and (b) prepares it for later -# installation. +# We support two configurations out of which deal.II can be used - directly +# from the build directory or after installation. So we have to prepare +# two distinct set ups. # # @@ -121,7 +122,9 @@ ENDFOREACH() # # For binary dir: # -SET(CONFIG_INCLUDE_DIRS_BINARY + +SET(CONFIG_BUILD_DIR TRUE) +SET(CONFIG_INCLUDE_DIRS \${DEAL_II_PATH}/include \${DEAL_II_PATH}/include/deal.II ${CMAKE_SOURCE_DIR}/include/ @@ -129,10 +132,23 @@ SET(CONFIG_INCLUDE_DIRS_BINARY ${deal_ii_source_includes} ${DEAL_II_USER_INCLUDE_DIRS} ) +CONFIGURE_FILE( + ${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in + ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}Config.cmake + @ONLY + ) +CONFIGURE_FILE( + ${CMAKE_CURRENT_SOURCE_DIR}/ConfigVersion.cmake.in + ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}ConfigVersion.cmake + @ONLY + ) + # # For installation: # -SET(CONFIG_INCLUDE_DIRS_INSTALLATION + +SET(CONFIG_BUILD_DIR FALSE) +SET(CONFIG_INCLUDE_DIRS \${DEAL_II_PATH}/\${DEAL_II_INCLUDE_RELDIR} \${DEAL_II_PATH}/\${DEAL_II_INCLUDE_RELDIR}/deal.II \${DEAL_II_PATH}/\${DEAL_II_INCLUDE_RELDIR}/deal.II/bundled @@ -140,40 +156,45 @@ SET(CONFIG_INCLUDE_DIRS_INSTALLATION ) CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in - ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}Config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_NAME}Config.cmake @ONLY ) +CONFIGURE_FILE( + ${CMAKE_CURRENT_SOURCE_DIR}/ConfigVersion.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_NAME}ConfigVersion.cmake + @ONLY + ) +INSTALL(FILES + ${CMAKE_CURRENT_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_NAME}Config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_NAME}ConfigVersion.cmake + DESTINATION ${DEAL_II_PROJECT_CONFIG_RELDIR} + COMPONENT library + ) + # -# Append feature configuration: +# Append feature configuration to both configuration files: # -SET(_file + +SET(_files ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}Config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_NAME}Config.cmake ) -FILE(APPEND ${_file} - "\n\n#\n# Feature configuration:\n#\n\n" - ) +FOREACH(_file ${_files}) + FILE(APPEND ${_file} + "\n\n#\n# Feature configuration:\n#\n\n" + ) +ENDFOREACH() GET_CMAKE_PROPERTY(res VARIABLES) FOREACH(var ${res}) IF(var MATCHES "DEAL_II_WITH") - FILE(APPEND ${_file} - "SET(${var} ${${var}})\n" - ) + FOREACH(_file ${_files}) + FILE(APPEND ${_file} + "SET(${var} ${${var}})\n" + ) + ENDFOREACH() ENDIF() ENDFOREACH() -CONFIGURE_FILE( - ${CMAKE_CURRENT_SOURCE_DIR}/ConfigVersion.cmake.in - ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}ConfigVersion.cmake - @ONLY - ) - -INSTALL(FILES - ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}Config.cmake - ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}ConfigVersion.cmake - DESTINATION ${DEAL_II_PROJECT_CONFIG_RELDIR} - COMPONENT library - ) - ######################################################################## # # @@ -181,7 +202,6 @@ INSTALL(FILES # # ######################################################################## - IF(DEAL_II_COMPONENT_COMPAT_FILES) # # Transform some cmake lists into a string that the old Makefile @@ -274,8 +294,8 @@ IF(DEAL_II_COMPONENT_COMPAT_FILES) # # For binary dir: # - SET(MAKEFILE_D_BINARY ${CMAKE_BINARY_DIR}) - TO_STRING_AND_ADD_PREFIX(MAKEFILE_INCLUDE_DIRS_BINARY "${CMAKE_INCLUDE_FLAG_CXX}" + SET(MAKEFILE_D ${CMAKE_BINARY_DIR}) + TO_STRING_AND_ADD_PREFIX(MAKEFILE_INCLUDE_DIRS "${CMAKE_INCLUDE_FLAG_CXX}" $(D)/install $(D)/install/deal.II ${CMAKE_SOURCE_DIR}/include/ @@ -283,11 +303,15 @@ IF(DEAL_II_COMPONENT_COMPAT_FILES) ${deal_ii_source_includes} ${DEAL_II_USER_INCLUDE_DIRS} ) + CONFIGURE_FILE( + ${CMAKE_CURRENT_SOURCE_DIR}/Make.global_options.in + ${CMAKE_BINARY_DIR}/${DEAL_II_COMMON_RELDIR}/Make.global_options + ) # # For installation: # - SET(MAKEFILE_D_INSTALLATION ${CMAKE_INSTALL_PREFIX}) - TO_STRING_AND_ADD_PREFIX(MAKEFILE_INCLUDE_DIRS_INSTALLATION "${CMAKE_INCLUDE_FLAG_CXX}" + SET(MAKEFILE_D ${CMAKE_INSTALL_PREFIX}) + TO_STRING_AND_ADD_PREFIX(MAKEFILE_INCLUDE_DIRS "${CMAKE_INCLUDE_FLAG_CXX}" $(D)/${DEAL_II_INCLUDE_RELDIR} $(D)/${DEAL_II_INCLUDE_RELDIR}/deal.II $(D)/${DEAL_II_INCLUDE_RELDIR}/deal.II/bundled @@ -295,25 +319,12 @@ IF(DEAL_II_COMPONENT_COMPAT_FILES) ) CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/Make.global_options.in - ${CMAKE_BINARY_DIR}/${DEAL_II_COMMON_RELDIR}/Make.global_options + ${CMAKE_CURRENT_BINARY_DIR}/Make.global_options ) - INSTALL(FILES ${CMAKE_BINARY_DIR}/${DEAL_II_COMMON_RELDIR}/template-arguments - ${CMAKE_BINARY_DIR}/${DEAL_II_COMMON_RELDIR}/Make.global_options + ${CMAKE_CURRENT_BINARY_DIR}/Make.global_options DESTINATION ${DEAL_II_COMMON_RELDIR} COMPONENT compat_files ) ENDIF() - -FILE(WRITE ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}/binary "") - -# -# And a script to remove it upon installation from the install prefix: -# This is necessary if somebody wants to install into the build directory -# (yes this is a valid use case...). -# -INSTALL(CODE - "FILE(REMOVE ${CMAKE_INSTALL_PREFIX}/${DEAL_II_PROJECT_CONFIG_RELDIR}/binary)" - COMPONENT library - ) diff --git a/deal.II/cmake/config/Config.cmake.in b/deal.II/cmake/config/Config.cmake.in index 8d5cd1a74d..85d469048f 100644 --- a/deal.II/cmake/config/Config.cmake.in +++ b/deal.II/cmake/config/Config.cmake.in @@ -66,20 +66,14 @@ WHILE(NOT "${_path}" STREQUAL "") GET_FILENAME_COMPONENT(_path "${_path}" PATH) ENDWHILE() -# -# Is this project reside in a build directory or at an installed location? -# - -IF(EXISTS ${DEAL_II_PATH}/${DEAL_II_PROJECT_CONFIG_RELDIR}/binary) - SET(DEAL_II_BUILD_DIR TRUE) -ENDIF() - # # Print a message after inclusion of this file: # SET(DEAL_II_PROJECT_CONFIG_INCLUDED TRUE) +SET(DEAL_II_BUILD_DIR @CONFIG_BUILD_DIR@) + IF(NOT ${DEAL_II_PACKAGE_NAME}_FIND_QUIETLY) IF(DEAL_II_BUILD_DIR) MESSAGE(STATUS @@ -152,11 +146,9 @@ SET(DEAL_II_STATIC_EXECUTABLE "@DEAL_II_STATIC_EXECUTABLE@") # # Information about include directories and libraries # -IF(DEAL_II_BUILD_DIR) - SET(DEAL_II_INCLUDE_DIRS "@CONFIG_INCLUDE_DIRS_BINARY@") -ELSE() - SET(DEAL_II_INCLUDE_DIRS "@CONFIG_INCLUDE_DIRS_INSTALLATION@") -ENDIF() + +# Full list of include directories: +SET(DEAL_II_INCLUDE_DIRS "@CONFIG_INCLUDE_DIRS@") # Full list of libraries for the debug target: SET(DEAL_II_LIBRARIES_DEBUG "@CONFIG_LIBRARIES_DEBUG@") @@ -172,12 +164,8 @@ SET(DEAL_II_LIBRARIES "@CONFIG_LIBRARIES@") # Information about library targets # -IF(DEAL_II_BUILD_DIR) - SET(DEAL_II_EXECUTABLE_CONFIG "${DEAL_II_PATH}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}Executables.cmake") - SET(DEAL_II_TARGET_CONFIG "${DEAL_II_PATH}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}BuildTargets.cmake") -ELSE() - SET(DEAL_II_TARGET_CONFIG "${DEAL_II_PATH}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}Targets.cmake") -ENDIF() +# The library targets file: +SET(DEAL_II_TARGET_CONFIG "${DEAL_II_PATH}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}Targets.cmake") # The Debug target: SET(DEAL_II_TARGET_DEBUG "@CONFIG_TARGET_DEBUG@") @@ -187,3 +175,6 @@ SET(DEAL_II_TARGET_RELEASE "@CONFIG_TARGET_RELEASE@") # Full list of targets with "debug" and "optimized" keywords for easy use with TARGET_LINK_LIBRARIES: SET(DEAL_II_TARGET "@CONFIG_TARGET@") + +# Executable targets (such as mesh_converter, expand_instantiations, etc): +SET(DEAL_II_EXECUTABLE_CONFIG "${DEAL_II_PATH}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}Executables.cmake") diff --git a/deal.II/cmake/config/Make.global_options.in b/deal.II/cmake/config/Make.global_options.in index 3ebd2f232a..832a9237b1 100644 --- a/deal.II/cmake/config/Make.global_options.in +++ b/deal.II/cmake/config/Make.global_options.in @@ -23,11 +23,7 @@ # -ifeq ($(wildcard $(D)/@DEAL_II_PROJECT_CONFIG_RELDIR@/binary),) - D = @MAKEFILE_D_INSTALLATION@ -else - D = @MAKEFILE_D_BINARY@ -endif +D = @MAKEFILE_D@ CXX = @CMAKE_CXX_COMPILER@ CXX-ID = @CMAKE_CXX_COMPILER_ID@ @@ -87,11 +83,7 @@ lib-deal2.g = @MAKEFILE_TARGETS_DEBUG@ # Include paths as command line flags -ifeq ($(wildcard $(D)/@DEAL_II_PROJECT_CONFIG_RELDIR@/binary),) - INCLUDE = @MAKEFILE_INCLUDE_DIRS_INSTALLATION@ -else - INCLUDE = @MAKEFILE_INCLUDE_DIRS_BINARY@ -endif +INCLUDE = @MAKEFILE_INCLUDE_DIRS@ # compiler flags for debug and optimized mode diff --git a/deal.II/cmake/setup_cached_variables.cmake b/deal.II/cmake/setup_cached_variables.cmake index 8d476fb437..d69d0df166 100644 --- a/deal.II/cmake/setup_cached_variables.cmake +++ b/deal.II/cmake/setup_cached_variables.cmake @@ -104,14 +104,6 @@ OPTION(DEAL_II_FORCE_AUTODETECTION OFF ) -IF("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") - SET(CMAKE_INSTALL_PREFIX - "${CMAKE_BINARY_DIR}" - CACHE STRING - "Install path prefix, prepended onto install directories." - ) -ENDIF() - ######################################################################## # # @@ -306,6 +298,24 @@ UNSET(ENV{LDFLAGS}) # # ######################################################################## +# +# We do not support installation into the binary directory any more ("too +# much pain, not enough profit"): +# + +IF("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_INSTALL_PREFIX}") + MESSAGE(FATAL_ERROR " +Error CMAKE_INSTALL_PREFIX is equal to CMAKE_BINARY_DIR. +It is not possible to install into the build directory. Please set +CMAKE_INSTALL_PREFIX to a designated install directory different than +CMAKE_BINARY_DIR. +(Please note that you can use deal.II directly out of a build directory +if this is what you tried to do.) +" + ) +ENDIF() + + GET_CMAKE_PROPERTY(_res VARIABLES) FOREACH(_var ${_res}) # diff --git a/deal.II/cmake/setup_deal_ii.cmake b/deal.II/cmake/setup_deal_ii.cmake index 58fbd0e16e..0e5a93301b 100644 --- a/deal.II/cmake/setup_deal_ii.cmake +++ b/deal.II/cmake/setup_deal_ii.cmake @@ -107,17 +107,7 @@ IF(DEAL_II_COMPONENT_COMPAT_FILES) SET_IF_EMPTY(DEAL_II_DOCREADME_RELDIR "") SET_IF_EMPTY(DEAL_II_EXAMPLES_RELDIR "examples") SET_IF_EMPTY(DEAL_II_EXECUTABLE_RELDIR "bin") - IF( "${CMAKE_INSTALL_PREFIX}" STREQUAL "${CMAKE_BINARY_DIR}" AND - (NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") ) - # - # Ensure that in case of an out of source build BINARY_DIR/include != - # INSTALL_PREFIX/include is always true. Otherwise stale headers might - # get included resulting in a failing build. - # - SET_IF_EMPTY(DEAL_II_INCLUDE_RELDIR "include/install") - ELSE() - SET_IF_EMPTY(DEAL_II_INCLUDE_RELDIR "include") - ENDIF() + SET_IF_EMPTY(DEAL_II_INCLUDE_RELDIR "include") SET_IF_EMPTY(DEAL_II_LIBRARY_RELDIR "lib") SET_IF_EMPTY(DEAL_II_PROJECT_CONFIG_RELDIR "${DEAL_II_LIBRARY_RELDIR}/cmake/${DEAL_II_PROJECT_CONFIG_NAME}") ELSE() diff --git a/deal.II/cmake/setup_finalize.cmake b/deal.II/cmake/setup_finalize.cmake index 4c4fc377ff..82a86052d3 100644 --- a/deal.II/cmake/setup_finalize.cmake +++ b/deal.II/cmake/setup_finalize.cmake @@ -81,7 +81,7 @@ FILE(WRITE # Cleanup deal.IITargets.cmake in the build directory: # FILE(REMOVE - ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}BuildTargets.cmake + ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}Targets.cmake ) diff --git a/deal.II/source/CMakeLists.txt b/deal.II/source/CMakeLists.txt index ec1f36db0c..0265ce09f4 100644 --- a/deal.II/source/CMakeLists.txt +++ b/deal.II/source/CMakeLists.txt @@ -93,7 +93,7 @@ FOREACH(build ${DEAL_II_BUILD_TYPES}) ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR} ) EXPORT(TARGETS ${DEAL_II_BASE_NAME}${DEAL_II_${build}_SUFFIX} - FILE ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}BuildTargets.cmake + FILE ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}Targets.cmake APPEND ) -- 2.39.5