[cig-commits] [commit] master: Make sure <link.h> exists before using it. (e4cd7c5)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Thu Oct 2 13:12:23 PDT 2014


Repository : https://github.com/geodynamics/aspect

On branch  : master
Link       : https://github.com/geodynamics/aspect/compare/edfb97aa260e07cee2b465ac2f4d96f9ff1192e8...9e61258edad2e883047165630869524bea482ba0

>---------------------------------------------------------------

commit e4cd7c533f4896939f6e868177729b2f28684b14
Author: Wolfgang Bangerth <bangerth at math.tamu.edu>
Date:   Thu Oct 2 07:10:17 2014 -0500

    Make sure <link.h> exists before using it.


>---------------------------------------------------------------

e4cd7c533f4896939f6e868177729b2f28684b14
 CMakeLists.txt | 13 +++++++++++++
 source/main.cc | 13 ++++++++++---
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c4e8031..5c366fd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -134,6 +134,19 @@ ELSE()
   ENDFOREACH()
 ENDIF()
 
+# See whether we can verify that every plugin we load is compiled against
+# the same deal.II library
+INCLUDE (CheckIncludeFiles)
+CHECK_INCLUDE_FILES ("link.h" _HAVE_LINK_H)
+IF (_HAVE_LINK_H)
+  MESSAGE(STATUS "Enabling checking of compatible deal.II library when loading plugins")
+  FOREACH(_source_file ${TARGET_SRC})
+    SET_PROPERTY(SOURCE ${_source_file}
+      APPEND PROPERTY COMPILE_DEFINITIONS ASPECT_HAVE_LINK_H=1)
+  ENDFOREACH()
+ENDIF()
+
+
 DEAL_II_INVOKE_AUTOPILOT()
 
 MESSAGE(STATUS "Writing config into detailed.log...")
diff --git a/source/main.cc b/source/main.cc
index 247bc01..36e9b9e 100644
--- a/source/main.cc
+++ b/source/main.cc
@@ -27,7 +27,9 @@
 
 #if ASPECT_USE_SHARED_LIBS==1
 #  include <dlfcn.h>
-#  include <link.h>
+#  ifdef ASPECT_HAVE_LINK_H
+#    include <link.h>
+#  endif
 #endif
 
 
@@ -124,6 +126,7 @@ int get_names_of_shared_libs (struct dl_phdr_info *info,
 // has deal.II only once
 void validate_shared_lib_list (const bool before_loading_shared_libs)
 {
+#ifdef ASPECT_HAVE_LINK_H
   // get the list of all shared libs we currently link against
   std::set<std::string> shared_lib_names;
   dl_iterate_phdr(get_names_of_shared_libs, &shared_lib_names);
@@ -170,6 +173,10 @@ void validate_shared_lib_list (const bool before_loading_shared_libs)
       else
         throw aspect::QuietException();
     }
+#else
+  // simply mark the argument as read, to avoid compiler warnings
+  (void)before_loading_shared_libs;
+#endif
 }
 
 
@@ -237,8 +244,8 @@ void possibly_load_shared_libs (const std::string &parameter_filename)
           std::cerr << std::endl << std::endl
                     << "----------------------------------------------------"
                     << std::endl;
-          std::cerr << "You can not load additional shared libraries on " << std::endl
-                    << "systems where you link ASPECT as a static executable."
+          std::cerr << "You can not load plugins through additional shared libraries " << std::endl
+                    << "on systems where you link ASPECT as a static executable."
                     << std::endl
                     << "----------------------------------------------------"
                     << std::endl;



More information about the CIG-COMMITS mailing list