]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Some minor refactoring:
authorMatthias Maier <tamiko@43-1.org>
Mon, 12 Nov 2018 16:14:16 +0000 (10:14 -0600)
committerMatthias Maier <tamiko@43-1.org>
Thu, 15 Nov 2018 17:17:44 +0000 (11:17 -0600)
 - remove unnecessary variables
 - fuse for loops
 - adhere to coding styles

cmake/config/CMakeLists.txt
cmake/config/config_base.pc.in [moved from cmake/config/deal.II_base.pc.in with 53% similarity]
cmake/config/config_debug.pc.in [moved from cmake/config/deal.II_debug.pc.in with 73% similarity]
cmake/config/config_release.pc.in [moved from cmake/config/deal.II_release.pc.in with 90% similarity]
cmake/setup_deal_ii.cmake

index 8b558d5e7517090dac9d7e43994c95e7de24fffd..cf6face9678a555693592ebe7ff3213bd7f48e78 100644 (file)
@@ -135,7 +135,6 @@ SET(CONFIG_INCLUDE_DIRS
   ${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
@@ -222,8 +221,13 @@ FOREACH(_name ${_deal_ii_features_sorted})
   ENDFOREACH()
 ENDFOREACH()
 
-#####################################################################
-# pkgconfig files
+
+########################################################################
+#                                                                      #
+#                           pkgconfig files                            #
+#                                                                      #
+########################################################################
+
 #
 # Set up the pkgconfig configuration files consisting of
 #
@@ -244,144 +248,137 @@ ENDFOREACH()
 #
 
 #
-# For binary dir (AKA build dir):
+# Build up the link line from our list of libraries:
 #
 
-set(DEAL_II_PATH_PC ${CMAKE_BINARY_DIR})
+FOREACH(_build ${DEAL_II_BUILD_TYPES})
+  STRING(TOLOWER ${_build} _build_lowercase)
 
-set (CONFIG_INCLUDE_DIRS_PC "")
-foreach(_dir ${CONFIG_INCLUDE_DIRS})
-  string(CONCAT CONFIG_INCLUDE_DIRS_PC "${CONFIG_INCLUDE_DIRS_PC} -I${_dir} "  )
-endforeach()
+  SET(_name "${DEAL_II_BASE_NAME}${DEAL_II_${_build}_SUFFIX}")
 
-# populate the variables
-# CONFIG_LIBRARIES_DEBUG_PC 
-# CONFIG_LIBRARIES_RELEASE_PC
+  SET(CONFIG_RPATH_${_build}_PC "")
+  SET(CONFIG_LIBRARIES_${_build}_PC "-L\${libdir} -l${_name}")
 
-foreach (_build ${DEAL_II_BUILD_TYPES})
-  if(_build MATCHES DEBUG)
-    set(_build "debug")
-  else()
-    set(_build "release")
-  endif()
+  FOREACH(_lib ${DEAL_II_LIBRARIES_${_build}} ${DEAL_II_LIBRARIES})
 
-  string(TOUPPER ${_build} _B)
-  set(PC_LIBRARIES ${CONFIG_LIBRARIES_${_B}})
-  set(CONFIG_LIBRARIES_PC "")
-  foreach(_lib ${PC_LIBRARIES})
-    # _lib can be of two types
-    #  1. something like "/home/alberto/opt/lib/trilinos/lib/libteuchoscore.so"
-    #  2. or simply "m" for the math lib
+    GET_FILENAME_COMPONENT(_name ${_lib} NAME)
+    GET_FILENAME_COMPONENT(_dir ${_lib} PATH)
 
-    get_filename_component(_libname ${_s} NAME)
-    get_filename_component(_libdir ${_s} PATH)
+    IF("${_dir}" STREQUAL "")
+      # ${_lib} is a simple library name, just add it to the link line:
+      SET(_library_string "-l${_lib}")
 
-    if(IS_DIRECTORY ${_libdir}) # i.e., we are in the first case
-      # we have to add -L flag
-      string(CONCAT CONFIG_LIBRARIES_PC " ${CONFIG_LIBRARIES_PC} -L${_libdir} ")
-      # and add the path to the rpath
-      list(APPEND PC_RPATH ${_libdir})
-    endif()
+    ELSE()
+      # ${_lib} is a full library path:
+
+      #
+      # Only append a library directory if it is new ...
+      #
+
+      list (FIND CONFIG_RPATH_${_build}_PC "${_dir}" _index)
+      IF (${_index} EQUAL -1)
+        SET(_library_string "-L${_dir} ")
+        LIST(APPEND CONFIG_RPATH_${_build}_PC ${_dir})
+      ELSE()
+        SET(_library_string "")
+      ENDIF()
 
-    # check if the library name begins with lib
-    # we are dealing with the first case
-    string(SUBSTRING ${_libname} 0 3 _beg)
+      # Recover short name:
+      STRING(REGEX REPLACE
+        "^(${CMAKE_STATIC_LIBRARY_PREFIX}|${CMAKE_SHARED_LIBRARY_PREFIX})"
+        "" _name "${_name}"
+        )
+      STRING(REGEX REPLACE
+        "(${CMAKE_STATIC_LIBRARY_SUFFIX}|${CMAKE_SHARED_LIBRARY_SUFFIX})$"
+        "" _name "${_name}"
+        )
+      SET(_library_string "${_library_string}-l${_name}")
+    ENDIF()
 
-    if(${_beg} MATCHES "lib")
-      string(CONCAT CONFIG_LIBRARIES_PC " ${CONFIG_LIBRARIES_PC} ${_libname} ")
-    else()
-      # second case
-      string(CONCAT CONFIG_LIBRARIES_PC " ${CONFIG_LIBRARIES_PC} -l${_libname} "  )
-    endif()
-  endforeach()
+    SET(CONFIG_LIBRARIES_${_build}_PC
+      "${CONFIG_LIBRARIES_${_build}_PC} ${_library_string}"
+      )
+  ENDFOREACH()
 
-  set(CONFIG_LIBRARIES_${_B}_PC ${CONFIG_LIBRARIES_PC})
-  
-  list(REMOVE_DUPLICATES PC_RPATH)
-  foreach(_dir ${PC_RPATH})
-    string(CONCAT CONFIG_LIBRARIES_${_B}_PC " ${CONFIG_LIBRARIES_${_B}_PC} -Wl,-rpath,${_dir} "  )
-  endforeach()
+  TO_STRING_AND_ADD_PREFIX(CONFIG_RPATH_${_build}_PC
+    "-Wl,-rpath," ${CONFIG_RPATH_${_build}_PC}
+    )
+ENDFOREACH()
 
-endforeach()
 
-configure_file(
-  ${CMAKE_CURRENT_SOURCE_DIR}/deal.II_base.pc.in
-  ${CMAKE_BINARY_DIR}/${DEAL_II_LIBRARY_RELDIR}/pkgconfig/${DEAL_II_PROJECT_CONFIG_NAME}_base.pc
-  @ONLY
+#
+# For binary dir (aka build dir):
+#
+
+SET(CONFIG_PATH_PC "${CMAKE_BINARY_DIR}")
+
+TO_STRING_AND_ADD_PREFIX(CONFIG_INCLUDE_DIRS_PC "-I"
+  \\\${prefix}/include
+  ${CMAKE_SOURCE_DIR}/include
+  ${DEAL_II_BUNDLED_INCLUDE_DIRS}
+  ${DEAL_II_USER_INCLUDE_DIRS}
   )
 
-# generate the requested .pc files
-foreach (_build ${DEAL_II_BUILD_TYPES})
-  if(_build MATCHES DEBUG)
-    set(_build "debug")
-  else()
-    set(_build "release")
-  endif()
-
-  configure_file(
-    ${CMAKE_CURRENT_SOURCE_DIR}/deal.II_${_build}.pc.in
-    ${CMAKE_BINARY_DIR}/${DEAL_II_LIBRARY_RELDIR}/pkgconfig/${DEAL_II_PROJECT_CONFIG_NAME}_${_build}.pc
+FOREACH(_build ${DEAL_II_BUILD_TYPES})
+  STRING(TOLOWER ${_build} _build_lowercase)
+
+  SET(_config_directory "${CMAKE_BINARY_DIR}/${DEAL_II_PKGCONF_RELDIR}")
+
+  CONFIGURE_FILE(
+    ${CMAKE_CURRENT_SOURCE_DIR}/config_${_build_lowercase}.pc.in
+    ${_config_directory}/${DEAL_II_PROJECT_CONFIG_NAME}_${_build_lowercase}.pc
     @ONLY
     )
-endforeach()
+ENDFOREACH()
+
+CONFIGURE_FILE(
+  ${CMAKE_CURRENT_SOURCE_DIR}/config_base.pc.in
+  ${_config_directory}/${DEAL_II_PROJECT_CONFIG_NAME}_base.pc
+  @ONLY
+  )
 
-#############################################################################
 #
 # For installation:
 #
 
-set(DEAL_II_PATH_PC ${CMAKE_INSTALL_PREFIX})
+SET(CONFIG_PATH_PC "${CMAKE_INSTALL_PREFIX}")
 
-set (CONFIG_INCLUDE_DIRS_PC "")
-foreach(_dir ${CONFIG_INCLUDE_DIRS})
-  string(CONCAT CONFIG_INCLUDE_DIRS_PC "${CONFIG_INCLUDE_DIRS_PC} -I${_dir} "  )
-endforeach()
-
-configure_file(
-  ${CMAKE_CURRENT_SOURCE_DIR}/deal.II_base.pc.in
-  ${CMAKE_CURRENT_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_NAME}_base.pc
-  @ONLY
-  )
-
-install(FILES
-  ${CMAKE_CURRENT_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_NAME}_base.pc
-  DESTINATION ${DEAL_II_LIBRARY_RELDIR}/pkgconfig
-  COMPONENT library
+TO_STRING_AND_ADD_PREFIX(CONFIG_INCLUDE_DIRS_PC "-I"
+  \\\${prefix}/include
+  ${CMAKE_SOURCE_DIR}/include
+  ${DEAL_II_BUNDLED_INCLUDE_DIRS}
+  ${DEAL_II_USER_INCLUDE_DIRS}
   )
 
+FOREACH(_build ${DEAL_II_BUILD_TYPES})
+  STRING(TOLOWER ${_build} _build_lowercase)
 
-# generate the requested .pc files
-foreach (_build ${DEAL_II_BUILD_TYPES})
-  if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "DebugRelease")
-    set(_build "general")
-  else()
-    if(_build MATCHES DEBUG)
-      set(_build "debug")
-    else()
-      set(_build "release")
-    endif()
-  endif()
-
-  configure_file(
-    ${CMAKE_CURRENT_SOURCE_DIR}/deal.II_${_build}.pc.in
-    ${CMAKE_CURRENT_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_NAME}_${_build}.pc
+  CONFIGURE_FILE(
+    ${CMAKE_CURRENT_SOURCE_DIR}/config_${_build_lowercase}.pc.in
+    ${CMAKE_CURRENT_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_NAME}_${_build_lowercase}.pc
     @ONLY
     )
-  install(FILES
-    ${CMAKE_CURRENT_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_NAME}_${_build}.pc
-    DESTINATION ${DEAL_II_LIBRARY_RELDIR}/pkgconfig
+  INSTALL(FILES
+    ${CMAKE_CURRENT_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_NAME}_${_build_lowercase}.pc
+    DESTINATION ${DEAL_II_PKGCONF_RELDIR}
     COMPONENT library
     )
-endforeach()
-
-
-
-
-
-
+ENDFOREACH()
 
+CONFIGURE_FILE(
+  ${CMAKE_CURRENT_SOURCE_DIR}/config_base.pc.in
+  ${CMAKE_CURRENT_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_NAME}_base.pc
+  @ONLY
+  )
+INSTALL(FILES
+  ${CMAKE_CURRENT_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_NAME}_base.pc
+  DESTINATION ${DEAL_II_PKGCONF_RELDIR}
+  COMPONENT library
+  )
 
-# end of pkgconfig files
-####################################################################
+#
+# Jobs done.
+#
 
 MESSAGE(STATUS "Setting up project configuration - Done")
+
similarity index 53%
rename from cmake/config/deal.II_base.pc.in
rename to cmake/config/config_base.pc.in
index 81d981162c2bad5c6c3866543a5de9f493ff97ce..cd8573e8b44ddde78bb2594d05b821598d006ce1 100644 (file)
@@ -1,10 +1,10 @@
-DEAL_II_PATH=@DEAL_II_PATH_PC@
-DEAL_II_INCLUDE_RELDIR=@DEAL_II_INCLUDE_RELDIR@
-libdir=${DEAL_II_PATH}/@DEAL_II_LIBRARY_RELDIR@
+prefix=@CONFIG_PATH_PC@
+includedir=${prefix}/@DEAL_II_INCLUDE_RELDIR@
+libdir=${prefix}/@DEAL_II_LIBRARY_RELDIR@
 
 Name: deal.II_base
 Description: base file used by the debug and release versions
 Version: @DEAL_II_VERSION@
 URL: https://github.com/dealii/dealii
 Cflags: @DEAL_II_CXX_FLAGS@ @CONFIG_INCLUDE_DIRS_PC@
-Libs: -L${libdir}  @DEAL_II_LINKER_FLAGS@  
+Libs: @DEAL_II_LINKER_FLAGS@
similarity index 73%
rename from cmake/config/deal.II_debug.pc.in
rename to cmake/config/config_debug.pc.in
index 868cb996a8b0a57b62b7fb97009dd074734131fd..0cd2b153d503c230b20951b71cecfbe1dade3f8b 100644 (file)
@@ -1,10 +1,7 @@
-DEAL_II_PATH=@DEAL_II_PATH_PC@
 Name: deal.II compiled in debug mode
-Description: A C++ software library supporting the creation of finite element codes and an open community of users and developers. 
+Description: A C++ software library supporting the creation of finite element codes and an open community of users and developers.
 Version: @DEAL_II_VERSION@
 URL: https://github.com/dealii/dealii
 Requires: deal.II_base
 Cflags: @DEAL_II_CXX_FLAGS_DEBUG@
-Libs: @DEAL_II_LINKER_FLAGS_DEBUG@  @CONFIG_LIBRARIES_DEBUG_PC@
-
-
+Libs: @DEAL_II_LINKER_FLAGS_DEBUG@  @CONFIG_LIBRARIES_DEBUG_PC@ @CONFIG_RPATH_DEBUG_PC@
similarity index 90%
rename from cmake/config/deal.II_release.pc.in
rename to cmake/config/config_release.pc.in
index daaf6cac57c6dfd0cc8682f71b8e866dcc39a148..208e5e0556c5136911b614aaacb542021df44e90 100644 (file)
@@ -1,8 +1,7 @@
-DEAL_II_PATH=@DEAL_II_PATH_PC@
 Name: deal.II compiled in debug mode
-Description: A C++ software library supporting the creation of finite element codes and an open community of users and developers. 
+Description: A C++ software library supporting the creation of finite element codes and an open community of users and developers.
 Version: @DEAL_II_VERSION@
 URL: https://github.com/dealii/dealii
 Requires: deal.II_base
 Cflags: @DEAL_II_CXX_FLAGS_RELEASE@
-Libs: @DEAL_II_LINKER_FLAGS_RELEASE@  @CONFIG_LIBRARIES_RELEASE_PC@
+Libs: @DEAL_II_LINKER_FLAGS_RELEASE@  @CONFIG_LIBRARIES_RELEASE_PC@ @CONFIG_RPATH_RELEASE_PC@
index 6cd84dd2c27c8d8723d5e5f2f6a8c4b432d76c68..1ab65989bec71563b39e03ee95f02920274f5d9a 100644 (file)
@@ -45,6 +45,7 @@
 #     DEAL_II_EXECUTABLE_RELDIR       *)
 #     DEAL_II_INCLUDE_RELDIR          *)
 #     DEAL_II_LIBRARY_RELDIR          *)
+#     DEAL_II_PKGCONF_RELDIR          *)
 #     DEAL_II_PROJECT_CONFIG_RELDIR   *)
 #     DEAL_II_SHARE_RELDIR            *)
 #     DEAL_II_DOCREADME_RELDIR        *)
@@ -112,6 +113,7 @@ SET_IF_EMPTY(DEAL_II_RELEASE_SUFFIX "")
 SET_IF_EMPTY(DEAL_II_EXECUTABLE_RELDIR "bin")
 SET_IF_EMPTY(DEAL_II_INCLUDE_RELDIR "include")
 SET_IF_EMPTY(DEAL_II_LIBRARY_RELDIR "lib${LIB_SUFFIX}")
+SET_IF_EMPTY(DEAL_II_PKGCONF_RELDIR "${DEAL_II_LIBRARY_RELDIR}/pkgconfig")
 SET_IF_EMPTY(DEAL_II_PROJECT_CONFIG_RELDIR "${DEAL_II_LIBRARY_RELDIR}/cmake/${DEAL_II_PROJECT_CONFIG_NAME}")
 SET_IF_EMPTY(DEAL_II_SHARE_RELDIR "share/${DEAL_II_PACKAGE_NAME}")
 #

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.