Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a dll for simgrid and protect DLL_EXPORT and DLL_IMPORT from multiple definition
authorunknown <pierre@.(none)>
Thu, 12 Jan 2012 16:24:58 +0000 (17:24 +0100)
committerunknown <pierre@.(none)>
Thu, 12 Jan 2012 16:26:05 +0000 (17:26 +0100)
buildtools/Cmake/MakeLibWin.cmake
buildtools/Cmake/gras_config.h.in
include/simgrid_config.h.in

index 8e3f463..4ffd5a4 100644 (file)
@@ -1,14 +1,16 @@
 ### Make Libs\r
 #>gcc c:\simgrid-trunk\examples\msg\icomms\peer.c -static -Lc:\simgrid-trunk\lib -lsimgrid -Ic:\simgrid-trunk\include -lwsock32        \r
 add_library(simgrid STATIC ${simgrid_sources})\r
 ### Make Libs\r
 #>gcc c:\simgrid-trunk\examples\msg\icomms\peer.c -static -Lc:\simgrid-trunk\lib -lsimgrid -Ic:\simgrid-trunk\include -lwsock32        \r
 add_library(simgrid STATIC ${simgrid_sources})\r
+add_library(simgrid_shared SHARED ${simgrid_sources})\r
 add_library(gras STATIC ${gras_sources})\r
 \r
 add_library(gras STATIC ${gras_sources})\r
 \r
-set_target_properties(gras     PROPERTIES COMPILE_FLAGS "-D_XBT_DLL_STATIC"\r
-                                                     OUTPUT_NAME   "gras")\r
-set_target_properties(simgrid  PROPERTIES COMPILE_FLAGS "-D_XBT_DLL_STATIC"                                                  OUTPUT_NAME   "simgrid")\r
+set_target_properties(gras            PROPERTIES COMPILE_FLAGS "-D_XBT_DLL_STATIC -DDLL_STATIC" VERSION ${libgras_version}    OUTPUT_NAME "gras")\r
+set_target_properties(simgrid         PROPERTIES COMPILE_FLAGS "-D_XBT_DLL_STATIC -DDLL_STATIC" VERSION ${libsimgrid_version} OUTPUT_NAME "simgrid")\r
+set_target_properties(simgrid_shared  PROPERTIES COMPILE_FLAGS "-D_XBT_DLL_EXPORT -DDLL_EXPORT" VERSION ${libsimgrid_version} OUTPUT_NAME "simgrid")\r
 \r
 set(GRAS_DEP "ws2_32 -lpthread")\r
 set(SIMGRID_DEP "ws2_32 -lpcre -lpthread")\r
 \r
 set(GRAS_DEP "ws2_32 -lpthread")\r
 set(SIMGRID_DEP "ws2_32 -lpcre -lpthread")\r
+set(SIMGRID_SHARED_DEP "ws2_32 -lpthread")\r
 \r
 if(ARCH_32_BITS)\r
     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32 -march=i486")\r
 \r
 if(ARCH_32_BITS)\r
     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32 -march=i486")\r
@@ -16,5 +18,13 @@ else(ARCH_32_BITS)
         message(FATAL_ERROR "Sorry, Simgrid fails with full 64bits for now! Please contact us.")\r
 endif(ARCH_32_BITS)\r
 \r
         message(FATAL_ERROR "Sorry, Simgrid fails with full 64bits for now! Please contact us.")\r
 endif(ARCH_32_BITS)\r
 \r
+target_link_libraries(gras     ${GRAS_DEP})\r
 target_link_libraries(simgrid  ${SIMGRID_DEP})\r
 target_link_libraries(simgrid  ${SIMGRID_DEP})\r
-target_link_libraries(gras     ${GRAS_DEP})
\ No newline at end of file
+target_link_libraries(simgrid_shared ${SIMGRID_SHARED_DEP} ${PATH_PCRE_LIB})\r
+\r
+find_path(PEXPORTS_PATH NAMES pexports.exe PATHS NO_DEFAULT_PATHS)\r
+message(STATUS "pexports: ${PEXPORTS_PATH}")\r
+if(PEXPORTS_PATH)\r
+add_custom_command(TARGET simgrid_shared POST_BUILD\r
+COMMAND ${PEXPORTS_PATH}/pexports.exe ${CMAKE_BINARY_DIR}/lib/libsimgrid.dll > ${CMAKE_BINARY_DIR}/lib/libsimgrid.ref)\r
+endif(PEXPORTS_PATH)
\ No newline at end of file
index 73e4257..fe82221 100644 (file)
@@ -4,12 +4,18 @@
 /* Set somes variables for Windows compilation */
 
 #ifdef _XBT_DLL_EXPORT
 /* Set somes variables for Windows compilation */
 
 #ifdef _XBT_DLL_EXPORT
-       #define DLL_EXPORT
+       #ifndef DLL_EXPORT
+               #define DLL_EXPORT
+       #endif
 #else
        #ifdef _XBT_DLL_STATIC
 #else
        #ifdef _XBT_DLL_STATIC
-               #define DLL_STATIC
+               #ifndef DLL_STATIC
+                       #define DLL_STATIC
+               #endif
        #else
        #else
-               #define DLL_IMPORT
+               #ifndef DLL_EXPORT
+                       #define DLL_IMPORT
+               #endif
        #endif
 #endif
 
        #endif
 #endif
 
index 0581c3e..03794ce 100644 (file)
@@ -29,12 +29,18 @@ SG_BEGIN_DECL()
 /* take care of DLL usage madness */
 
 #ifdef _XBT_DLL_EXPORT
 /* take care of DLL usage madness */
 
 #ifdef _XBT_DLL_EXPORT
-       #define DLL_EXPORT
+       #ifndef DLL_EXPORT
+               #define DLL_EXPORT
+       #endif
 #else
        #ifdef _XBT_DLL_STATIC
 #else
        #ifdef _XBT_DLL_STATIC
-               #define DLL_STATIC
+               #ifndef DLL_STATIC
+                       #define DLL_STATIC
+               #endif
        #else
        #else
-               #define DLL_IMPORT
+               #ifndef DLL_EXPORT
+                       #define DLL_IMPORT
+               #endif
        #endif
 #endif
 
        #endif
 #endif