Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Setup and use a LD_LIBRARY variable in build.
authordegomme <augustin.degomme@unibas.ch>
Mon, 31 Oct 2016 13:33:02 +0000 (14:33 +0100)
committerdegomme <augustin.degomme@unibas.ch>
Mon, 31 Oct 2016 13:33:02 +0000 (14:33 +0100)
libdl is linux-only, so set this variable as the result of a find_library
command here and let it empty on other systems. From M. Volat.

CMakeLists.txt
tools/cmake/MakeLib.cmake

index daeb9d8..205be01 100644 (file)
@@ -119,6 +119,11 @@ endif()
 execute_process(COMMAND   ${CMAKE_LINKER}   -version    OUTPUT_VARIABLE LINKER_VERSION)
 string(REGEX MATCH "[0-9].[0-9]*" LINKER_VERSION "${LINKER_VERSION}")
 
+### Set the library providing dlopen
+if("${CMAKE_SYSTEM}" MATCHES "Linux")
+  find_library(dl DL_LIBRARY)
+endif("${CMAKE_SYSTEM}" MATCHES "Linux")
+
 ### Find programs and paths
 FIND_PROGRAM(GCOV_PATH gcov)
 include(FindPerl)
@@ -410,7 +415,7 @@ endif()
 ### Check for GNU dynamic linker
 CHECK_INCLUDE_FILE("dlfcn.h" HAVE_DLFCN_H)
 if (HAVE_DLFCN_H)
-  execute_process(COMMAND ${CMAKE_C_COMPILER} ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_gnu_dynlinker.c -ldl -o test_gnu_ld
+  execute_process(COMMAND ${CMAKE_C_COMPILER} ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_gnu_dynlinker.c ${DL_LIBRARY} -o test_gnu_ld
                   WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
                   OUTPUT_VARIABLE HAVE_GNU_LD_compil
   )
index 29c3b56..2a09193 100644 (file)
@@ -53,7 +53,7 @@ if(HAVE_LUA)
     COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/simdag/
     COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE} #for test
     )
-  SET(SIMGRID_DEP "${SIMGRID_DEP} ${LUA_LIBRARY} -ldl")
+  SET(SIMGRID_DEP "${SIMGRID_DEP} ${LUA_LIBRARY} ${DL_LIBRARY}")
 endif()
 
 if(HAVE_PAPI)
@@ -88,7 +88,7 @@ if(HAVE_MC)
 endif()
 
 if(HAVE_MC AND HAVE_GNU_LD)
-  SET(SIMGRID_DEP "${SIMGRID_DEP} -ldl")
+  SET(SIMGRID_DEP "${SIMGRID_DEP} ${DL_LIBRARY}")
 endif()
 
 if(HAVE_NS3)