]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Bugfix: Simplify project config generation
authorMatthias Maier <tamiko@kyomu.43-1.org>
Sat, 26 Oct 2013 09:14:21 +0000 (09:14 +0000)
committerMatthias Maier <tamiko@kyomu.43-1.org>
Sat, 26 Oct 2013 09:14:21 +0000 (09:14 +0000)
git-svn-id: https://svn.dealii.org/trunk@31432 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/cmake/config/CMakeLists.txt
deal.II/cmake/config/Config.cmake.in
deal.II/cmake/config/Make.global_options.in
deal.II/cmake/setup_cached_variables.cmake
deal.II/cmake/setup_deal_ii.cmake
deal.II/cmake/setup_finalize.cmake
deal.II/source/CMakeLists.txt

index 4309152d48ed22ed71cabbf67230ab6720438918..eea6fdf8f090da5edd0ffd39ed57485776c624a6 100644 (file)
@@ -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
-  )
index 8d5cd1a74dc598907d5949391f8352f6c686c46e..85d469048fd4506b28a58efc0ee00e7612af94e2 100644 (file)
@@ -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")
index 3ebd2f232a20f9d9238b6103e2d425231426ea70..832a9237b1d0acbb4c20f1910a993252cb311d63 100644 (file)
 #
 
 
-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
index 8d476fb437b015c2bcfab15643c405212c218c43..d69d0df166fb4fe7ce9b1cf6ba3434de4876107a 100644 (file)
@@ -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})
   #
index 58fbd0e16efc258a2597c685211fdf5369f45b1b..0e5a93301b5e80ed51445b018b5e475a3fdafc91 100644 (file)
@@ -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()
index 4c4fc377ffafe399405fa791d491be504812317f..82a86052d3bc5c9e9bc887b01c8f52da81d67252 100644 (file)
@@ -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
   )
 
 
index ec1f36db0cbcda70f47908930ef62f4e36ca74a5..0265ce09f462ceb58c008ee4db9ff0c422d64983 100644 (file)
@@ -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
     )
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.