]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Introduce a dealii:: namespace for targets and harmonize naming 14467/head
authorMatthias Maier <tamiko@43-1.org>
Thu, 24 Nov 2022 13:42:42 +0000 (07:42 -0600)
committerMatthias Maier <tamiko@43-1.org>
Sat, 26 Nov 2022 16:26:44 +0000 (10:26 -0600)
The top-level targets are now named dealii_debug and dealii_release (and
their exported counterparts dealii::dealii_debug and
dealii::dealii_release).

cmake/config/CMakeLists.txt
cmake/macros/macro_deal_ii_insource_setup_target.cmake
cmake/setup_deal_ii.cmake
contrib/python-bindings/source/CMakeLists.txt
doc/developers/cmake-internals.html
source/CMakeLists.txt

index db465e340b9e4a28ef13a49187d76ce5d11b910b..c7be0c2ee19a261b9f26dfac26074e84a180523f 100644 (file)
@@ -84,6 +84,7 @@ strip_flag(DEAL_II_CXX_FLAGS "-Wsuggest-override")
 #
 
 foreach(_build ${DEAL_II_BUILD_TYPES})
+  string(TOLOWER ${_build} _build_lowercase)
 
   if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "DebugRelease")
     set(_keyword "general")
@@ -113,7 +114,7 @@ foreach(_build ${DEAL_II_BUILD_TYPES})
     )
   list(APPEND CONFIG_LIBRARIES ${_keyword} \${DEAL_II_LIBRARIES_${_build}})
 
-  set(CONFIG_TARGET_${_build} ${DEAL_II_BASE_NAME}${DEAL_II_${_build}_SUFFIX})
+  set(CONFIG_TARGET_${_build} ${DEAL_II_NAMESPACE}::${DEAL_II_NAMESPACE}_${_build_lowercase})
   list(APPEND CONFIG_TARGET ${_keyword} \${DEAL_II_TARGET_${_build}})
 endforeach()
 
index 4009669a45979d9651de98a94ce4ffdbdac6e68a..9febffccda95c3f048c417eb8dfaf1aaa81ec144 100644 (file)
@@ -25,6 +25,7 @@
 #
 
 macro(DEAL_II_INSOURCE_SETUP_TARGET _target _build)
+  string(TOLOWER ${_build} _build_lowercase)
 
   set_target_properties(${_target} PROPERTIES
     LINK_FLAGS "${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${_build}}"
@@ -64,9 +65,7 @@ macro(DEAL_II_INSOURCE_SETUP_TARGET _target _build)
 
 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}
-    )
+  target_link_libraries(${_target} ${DEAL_II_NAMESPACE}_${_build_lowercase})
 endif()
 
 endmacro()
index 670efd87f7f198e0c115d1b4258aa90b39ac43e4..58d32fb75666303de2ee6c6f7265b43f2c780e21 100644 (file)
@@ -36,6 +36,8 @@
 #     DEAL_II_VERSION
 #
 # Information about paths, install locations and names:
+
+#     DEAL_II_NAMESPACE               *)
 #
 #     DEAL_II_PROJECT_CONFIG_NAME     *)
 #     DEAL_II_BASE_NAME               *)
@@ -100,7 +102,11 @@ set(DEAL_II_VERSION ${DEAL_II_VERSION_MAJOR}.${DEAL_II_VERSION_MINOR}.${DEAL_II_
 #                                                                      #
 ########################################################################
 
-set(DEAL_II_PROJECT_CONFIG_NAME "${DEAL_II_PACKAGE_NAME}")
+string(REPLACE "." "" _namespace "${DEAL_II_PACKAGE_NAME}")
+string(TOLOWER "${_namespace}" _namespace)
+set_if_empty(DEAL_II_NAMESPACE "${_namespace}")
+
+set_if_empty(DEAL_II_PROJECT_CONFIG_NAME "${DEAL_II_PACKAGE_NAME}")
 
 string(REPLACE "." "_" _base_name "${DEAL_II_PACKAGE_NAME}")
 set_if_empty(DEAL_II_BASE_NAME "${_base_name}")
index 43f6a75356b9e68e90cc992ad94f63dc9bdbeb7e..1f04fdbaff4f0600405dc31d9bd2d7e5d14fe4a1 100644 (file)
@@ -71,7 +71,7 @@ foreach(_build ${DEAL_II_BUILD_TYPES})
   endif()
 
   target_link_libraries(PyDealII_${_build_lowercase}
-    ${DEAL_II_BASE_NAME}${DEAL_II_${_build}_SUFFIX}
+    ${DEAL_II_NAMESPACE}_${_build_lowercase}
     ${Boost_LIBRARIES}
     ${PYTHON_LIBRARIES}
     )
index 07825d90b62326dded2ef11b434b5d6cc3fc9cf0..e7b65e9f479dafe32cbeadbb46843e783e6ed3f3 100644 (file)
@@ -96,7 +96,7 @@ LIST(APPEND CONFIG_LIBRARIES
   ${CONFIG_LIBRARIES_${_build}}
   )
 
-SET_TARGET_PROPERTIES(${DEAL_II_BASE_NAME}${DEAL_II_${build}_SUFFIX}
+SET_TARGET_PROPERTIES(${DEAL_II_NAMESPACE}_${build_lowercase}
   PROPERTIES
   VERSION ${VERSION}
   SOVERSION ${VERSION}
index 5302be899ee7baf133deeff0a2b3a5d3c305a7e9..83a53336b6e49bc846449d358d888d32bc61d774 100644 (file)
@@ -84,13 +84,13 @@ foreach(build ${DEAL_II_BUILD_TYPES})
 
   get_property(_objects GLOBAL PROPERTY DEAL_II_OBJECTS_${build})
 
-  add_library(${DEAL_II_BASE_NAME}${DEAL_II_${build}_SUFFIX}
+  add_library(${DEAL_II_NAMESPACE}_${build_lowercase}
     dummy.cc # Workaround for a bug in the Xcode generator
     ${_objects}
     )
-  add_dependencies(library ${DEAL_II_BASE_NAME}${DEAL_II_${build}_SUFFIX})
+  add_dependencies(library ${DEAL_II_NAMESPACE}_${build_lowercase})
 
-  set_target_properties(${DEAL_II_BASE_NAME}${DEAL_II_${build}_SUFFIX}
+  set_target_properties(${DEAL_II_NAMESPACE}_${build_lowercase}
     PROPERTIES
     VERSION "${DEAL_II_PACKAGE_VERSION}"
     #
@@ -103,13 +103,16 @@ foreach(build ${DEAL_II_BUILD_TYPES})
     LINKER_LANGUAGE "CXX"
     COMPILE_DEFINITIONS "${DEAL_II_DEFINITIONS};${DEAL_II_DEFINITIONS_${build}}"
     COMPILE_FLAGS "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${build}}"
+    ARCHIVE_OUTPUT_NAME "${DEAL_II_BASE_NAME}${DEAL_II_${build}_SUFFIX}"
+    LIBRARY_OUTPUT_NAME "${DEAL_II_BASE_NAME}${DEAL_II_${build}_SUFFIX}"
+    RUNTIME_OUTPUT_NAME "${DEAL_II_BASE_NAME}${DEAL_II_${build}_SUFFIX}"
     ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${DEAL_II_LIBRARY_RELDIR}"
     LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${DEAL_II_LIBRARY_RELDIR}"
     RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${DEAL_II_EXECUTABLE_RELDIR}"
     )
 
   if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
-    set_target_properties(${DEAL_II_BASE_NAME}${DEAL_II_${build}_SUFFIX}
+    set_target_properties(${DEAL_II_NAMESPACE}_${build_lowercase}
       PROPERTIES
       MACOSX_RPATH OFF
       BUILD_WITH_INSTALL_RPATH OFF
@@ -126,7 +129,7 @@ foreach(build ${DEAL_II_BUILD_TYPES})
   # lib locations for _DEBUG (no support for dynamic linking, _RELEASE will be
   # ignored), but we do it anyhow.
   if (DEAL_II_MSVC)
-    set_target_properties(${DEAL_II_BASE_NAME}${DEAL_II_${build}_SUFFIX}
+    set_target_properties(${DEAL_II_NAMESPACE}_${build_lowercase}
       PROPERTIES
       ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${DEAL_II_LIBRARY_RELDIR}"
       LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${DEAL_II_LIBRARY_RELDIR}"
@@ -138,7 +141,7 @@ foreach(build ${DEAL_II_BUILD_TYPES})
   endif()
 
 
-  target_link_libraries(${DEAL_II_BASE_NAME}${DEAL_II_${build}_SUFFIX}
+  target_link_libraries(${DEAL_II_NAMESPACE}_${build_lowercase}
     ${DEAL_II_LIBRARIES_${build}}
     ${DEAL_II_LIBRARIES}
     )
@@ -146,12 +149,13 @@ foreach(build ${DEAL_II_BUILD_TYPES})
   file(MAKE_DIRECTORY
     ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}
     )
-  export(TARGETS ${DEAL_II_BASE_NAME}${DEAL_II_${build}_SUFFIX}
+  export(TARGETS ${DEAL_II_NAMESPACE}_${build_lowercase}
+    NAMESPACE "${DEAL_II_NAMESPACE}::"
     FILE ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}Targets.cmake
     APPEND
     )
 
-  install(TARGETS ${DEAL_II_BASE_NAME}${DEAL_II_${build}_SUFFIX}
+  install(TARGETS ${DEAL_II_NAMESPACE}_${build_lowercase}
     COMPONENT library
     EXPORT ${DEAL_II_PROJECT_CONFIG_NAME}Targets
     RUNTIME DESTINATION ${DEAL_II_EXECUTABLE_RELDIR}
@@ -161,6 +165,7 @@ foreach(build ${DEAL_II_BUILD_TYPES})
 endforeach()
 
 install(EXPORT ${DEAL_II_PROJECT_CONFIG_NAME}Targets
+  NAMESPACE "${DEAL_II_NAMESPACE}::"
   DESTINATION ${DEAL_II_PROJECT_CONFIG_RELDIR}
   COMPONENT library
   )

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.