]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Explain why we disable dynamic linking on Windows. 17259/head
authorMarc Fehling <mafehling.git@gmail.com>
Thu, 11 Jul 2024 16:36:49 +0000 (18:36 +0200)
committerMarc Fehling <mafehling.git@gmail.com>
Thu, 11 Jul 2024 16:36:49 +0000 (18:36 +0200)
cmake/checks/check_02_system_features.cmake

index 84bc5e479bec7484d8d38deda69f498d3d33c477..7615691196908a6f0e4dd50b7d80e4a4afec2c92 100644 (file)
@@ -90,7 +90,6 @@ if( CMAKE_SYSTEM_NAME MATCHES "CYGWIN" OR
 endif()
 
 if(CMAKE_SYSTEM_NAME MATCHES "Windows")
-
   #
   # Export DEAL_II_MSVC if we are on a Windows platform:
   #
@@ -99,21 +98,28 @@ if(CMAKE_SYSTEM_NAME MATCHES "Windows")
   #
   # Shared library handling:
   #
+  # We disabled dynamic linking on Windows. The *.dll format only allows
+  # up to 65535 objects or members, i.e., it is limited by a 16bit
+  # descriptor. We need more than that for deal.II. For more information,
+  # look up the linker tools error LNK1189.
+  #
+  # Unfortunately, this means that we are stuck with static linking.
+  # As a consequence each binary will be very large, so we also disable
+  # the compilation of examples.
+  #
+  message(WARNING "\n"
+    "BUILD_SHARED_LIBS forced to OFF\n\n"
+    "DEAL_II_COMPILE_EXAMPLES forced to OFF\n\n"
+    )
+  set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
+  set(DEAL_II_COMPILE_EXAMPLES OFF CACHE BOOL "" FORCE)
 
-  if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
-    # With MinGW we're lucky:
-    enable_if_links(DEAL_II_LINKER_FLAGS "-Wl,--export-all-symbols")
-    enable_if_links(DEAL_II_LINKER_FLAGS "-Wl,--enable-auto-import")
-    enable_if_links(DEAL_II_LINKER_FLAGS "-Wl,--allow-multiple-definition")
-  else()
-    # Otherwise disable shared libraries:
-    message(WARNING "\n"
-      "BUILD_SHARED_LIBS forced to OFF\n\n"
-      )
-    set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
-
-    # And disable compilation of examples:
-    set(DEAL_II_COMPILE_EXAMPLES OFF CACHE BOOL "" FORCE)
+  #
+  # In case we find a solution to enable dynamic linking in the future,
+  # we will most probably want to use the CMake infrastructure to
+  # automatically export symbols on Windows targets.
+  #
+  if(BUILD_SHARED_LIBS)
+    set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
   endif()
-
 endif()

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.