### Make Libs
-include(FindSupernovae)
-if(enable_supernovae AND HAVE_SUPERNOVAE_TOOLS)
- include(${PROJECT_DIRECTORY}/buildtools/Cmake/Supernovae.cmake)
-else(enable_supernovae AND HAVE_SUPERNOVAE_TOOLS)
- add_library(simgrid SHARED ${simgrid_sources})
- add_library(gras SHARED ${gras_sources})
+# If we need supernovae, rewrite the lib content to use it
+include(${PROJECT_DIRECTORY}/buildtools/Cmake/Supernovae.cmake)
+
+# Declare our libraries
+add_library(simgrid SHARED ${simgrid_sources})
+add_library(gras SHARED ${gras_sources})
+if(enable_lib_static)
+ add_library(simgrid_static STATIC ${simgrid_sources})
+endif(enable_lib_static)
+if(enable_smpi)
+ add_library(smpi SHARED ${SMPI_SRC})
+ if(enable_lib_static)
+ add_library(smpi_static STATIC ${SMPI_SRC})
+ endif(enable_lib_static)
+endif(enable_smpi)
+
+# if supernovaeing, we need some depends to make sure that the source gets generated
+if (enable_supernovae)
+ add_dependencies(simgrid ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_sg.c)
if(enable_lib_static)
- add_library(simgrid_static STATIC ${simgrid_sources})
+ add_dependencies(simgrid_static ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_sg.c)
endif(enable_lib_static)
+ add_dependencies(gras ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_gras.c)
+
if(enable_smpi)
- add_library(smpi SHARED ${SMPI_SRC})
+ add_dependencies(smpi ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_smpi.c)
if(enable_lib_static)
- add_library(smpi_static STATIC ${SMPI_SRC})
+ add_dependencies(smpi_static ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_smpi.c)
endif(enable_lib_static)
endif(enable_smpi)
-endif(enable_supernovae AND HAVE_SUPERNOVAE_TOOLS)
+endif(enable_supernovae)
+
set_target_properties(simgrid PROPERTIES VERSION ${libsimgrid_version})
set_target_properties(gras PROPERTIES VERSION ${libgras_version})
set_target_properties(smpi PROPERTIES VERSION ${libsmpi_version})
endif(enable_smpi)
-set(GRAS_DEP "-lm -lpthread")
-set(SIMGRID_DEP "-lm")
-set(SMPI_DEP "")
+set(GRAS_LDEP "-lm -lpthread")
+set(SIMGRID_LDEP "-lm")
+set(SMPI_LDEP "")
if(APPLE)
- set(SMPI_DEP "-Wl,-U -Wl,_smpi_simulated_main")
+ set(SMPI_LDEP "-Wl,-U -Wl,_smpi_simulated_main")
endif(APPLE)
if(HAVE_PCRE_LIB)
- SET(SIMGRID_DEP "${SIMGRID_DEP} -lpcre")
+ SET(SIMGRID_LDEP "${SIMGRID_LDEP} -lpcre")
endif(HAVE_PCRE_LIB)
if(HAVE_RUBY)
- set(SIMGRID_DEP "${SIMGRID_DEP} -l${RUBY_LIBRARY_NAME} -module")
+ set(SIMGRID_LDEP "${SIMGRID_LDEP} -l${RUBY_LIBRARY_NAME} -module")
endif(HAVE_RUBY)
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
if(pthread)
if(with_context MATCHES pthread)
- SET(SIMGRID_DEP "${SIMGRID_DEP} -lpthread")
+ SET(SIMGRID_LDEP "${SIMGRID_LDEP} -lpthread")
endif(with_context MATCHES pthread)
if(with_context MATCHES windows)
- SET(GRAS_DEP "msg")
+ SET(GRAS_LDEP "msg")
endif(with_context MATCHES windows)
endif(pthread)
if(HAVE_LUA)
- SET(SIMGRID_DEP "${SIMGRID_DEP} -ldl -l${LIB_LUA_NAME}")
+ SET(SIMGRID_LDEP "${SIMGRID_LDEP} -ldl -l${LIB_LUA_NAME}")
endif(HAVE_LUA)
if(HAVE_GRAPHVIZ)
if(HAVE_CGRAPH_LIB)
- SET(SIMGRID_DEP "${SIMGRID_DEP} -lcgraph")
+ SET(SIMGRID_LDEP "${SIMGRID_LDEP} -lcgraph")
else(HAVE_CGRAPH_LIB)
if(HAVE_AGRAPH_LIB)
- SET(SIMGRID_DEP "${SIMGRID_DEP} -lagraph -lcdt")
+ SET(SIMGRID_LDEP "${SIMGRID_LDEP} -lagraph -lcdt")
endif(HAVE_AGRAPH_LIB)
endif(HAVE_CGRAPH_LIB)
endif(HAVE_GRAPHVIZ)
if(HAVE_GTNETS)
- SET(SIMGRID_DEP "${SIMGRID_DEP} -lgtnets")
+ SET(SIMGRID_LDEP "${SIMGRID_LDEP} -lgtnets")
endif(HAVE_GTNETS)
if(HAVE_POSIX_GETTIME)
- SET(SIMGRID_DEP "${SIMGRID_DEP} -lrt")
- SET(GRAS_DEP "${GRAS_DEP} -lrt")
+ SET(SIMGRID_LDEP "${SIMGRID_LDEP} -lrt")
+ SET(GRAS_LDEP "${GRAS_LDEP} -lrt")
endif(HAVE_POSIX_GETTIME)
-target_link_libraries(simgrid ${SIMGRID_DEP})
-target_link_libraries(gras ${GRAS_DEP})
+target_link_libraries(simgrid ${SIMGRID_LDEP})
+target_link_libraries(gras ${GRAS_LDEP})
add_dependencies(gras maintainer_files)
add_dependencies(simgrid maintainer_files)
if(enable_smpi)
- target_link_libraries(smpi simgrid ${SMPI_DEP})
+ target_link_libraries(smpi simgrid ${SMPI_LDEP})
endif(enable_smpi)
if(enable_lib_static)
- target_link_libraries(simgrid_static ${SIMGRID_DEP})
+ target_link_libraries(simgrid_static ${SIMGRID_LDEP})
add_dependencies(simgrid_static maintainer_files)
set_target_properties(simgrid_static PROPERTIES OUTPUT_NAME simgrid)
if(enable_smpi)
- target_link_libraries(smpi_static simgrid ${SMPI_DEP})
+ target_link_libraries(smpi_static simgrid ${SMPI_LDEP})
set_target_properties(smpi_static PROPERTIES OUTPUT_NAME smpi)
endif(enable_smpi)
endif(enable_lib_static)
+++ /dev/null
-find_program(CAT_EXE NAMES cat)
-find_program(GREP_EXE NAMES grep)
-find_program(SED_EXE NAMES sed)
-find_program(ECHO_EXE NAMES echo)
-find_program(SH_EXE NAMES sh)
-
-if(CAT_EXE AND GREP_EXE AND SED_EXE AND ECHO_EXE AND SH_EXE)
- set(HAVE_SUPERNOVAE_TOOLS 1)
-else(CAT_EXE AND GREP_EXE AND SED_EXE AND ECHO_EXE AND SH_EXE)
- if(enable_supernovae)
- message(FATAL "You are missing some elements to use the supernovae compilation mode")
- message("CAT_EXE ${CAT_EXE}")
- message("GREP_EXE ${GREP_EXE}")
- message("SED_EXE ${SED_EXE}")
- message("ECHO_EXE ${ECHO_EXE}")
- message("SH_EXE ${SH_EXE}")
- endif(enable_supernovae)
- set(HAVE_SUPERNOVAE_TOOLS 0)
-endif(CAT_EXE AND GREP_EXE AND SED_EXE AND ECHO_EXE AND SH_EXE)
-
-mark_as_advanced(CAT_EXE)
-mark_as_advanced(GREP_EXE)
-mark_as_advanced(SED_EXE)
-mark_as_advanced(ECHO_EXE)
-mark_as_advanced(SH_EXE)
\ No newline at end of file
#####################################################
### Rebuild the supernovae source files
+if (PERL_EXECUTABLE AND enable_supernovae) # I need supernovae and can use it
-set_source_files_properties(${PROJECT_DIRECTORY}/src/supernovae_sg.c;${PROJECT_DIRECTORY}/src/supernovae_gras.c;${PROJECT_DIRECTORY}/src/supernovae_smpi.c
- PROPERTIES GENERATED true)
+ # supernovae files are generated. I promise
+ set_source_files_properties(${PROJECT_DIRECTORY}/src/supernovae_sg.c
+ PROPERTIES GENERATED true)
+ set_source_files_properties(${PROJECT_DIRECTORY}/src/supernovae_gras.c
+ PROPERTIES GENERATED true)
+ set_source_files_properties(${PROJECT_DIRECTORY}/src/supernovae_smpi.c
+ PROPERTIES GENERATED true)
-exec_program("${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/src/supernovae_sg.c
- ${PROJECT_DIRECTORY}/src/supernovae_gras.c
- ${PROJECT_DIRECTORY}/src/supernovae_smpi.c"
- OUTPUT_VARIABLE "SUPER_OK")
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_sg.c
+ DEPENDS ${PROJECT_DIRECTORY}/src/mk_supernovae.pl ${simgrid_sources}
+ COMMAND perl ${PROJECT_DIRECTORY}/src/mk_supernovae.pl --out=${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_sg.c '--fragile=${simgrid_fragile_sources}' '${simgrid_sources}'
+ WORKING_DIRECTORY ${PROJECT_DIRECTORY}
+ COMMENT "Generating supernovae_sg.c"
+ )
-exec_program("chmod +x ${PROJECT_DIRECTORY}/src/mk_supernovae.pl" OUTPUT_VARIABLE "SUPER_OK")
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_gras.c
+ DEPENDS ${PROJECT_DIRECTORY}/src/mk_supernovae.pl ${gras_sources}
+ COMMAND perl ${PROJECT_DIRECTORY}/src/mk_supernovae.pl --out=${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_gras.c '--fragile=${gras_fragile_sources}' '${gras_sources}'
+ WORKING_DIRECTORY ${PROJECT_DIRECTORY}
+ COMMENT "Generating supernovae_gras.c"
+ )
-ADD_CUSTOM_COMMAND(
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_sg.c
- DEPENDS ${PROJECT_DIRECTORY}/src/mk_supernovae.pl
- COMMAND perl ${PROJECT_DIRECTORY}/src/mk_supernovae.pl --out=${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_sg.c '--fragile=${simgrid_fragile_sources}' '${simgrid_sources}'
- WORKING_DIRECTORY ${PROJECT_DIRECTORY}
- COMMENT "Generating supernovae_sg.c"
-)
-
-ADD_CUSTOM_COMMAND(
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_gras.c
- DEPENDS ${PROJECT_DIRECTORY}/src/mk_supernovae.pl
- COMMAND perl ${PROJECT_DIRECTORY}/src/mk_supernovae.pl --out=${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_gras.c '--fragile=${gras_fragile_sources}' '${gras_sources}'
- WORKING_DIRECTORY ${PROJECT_DIRECTORY}
- COMMENT "Generating supernovae_gras.c"
-)
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_smpi.c
+ DEPENDS ${PROJECT_DIRECTORY}/src/mk_supernovae.pl ${SMPI_SRC}
+ COMMAND perl ${PROJECT_DIRECTORY}/src/mk_supernovae.pl --out=${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_smpi.c '${SMPI_SRC}'
+ WORKING_DIRECTORY ${PROJECT_DIRECTORY}
+ COMMENT "Generating supernovae_smpi.c"
+ )
-ADD_CUSTOM_COMMAND(
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_smpi.c
- DEPENDS ${PROJECT_DIRECTORY}/src/mk_supernovae.pl
- COMMAND perl ${PROJECT_DIRECTORY}/src/mk_supernovae.pl --out=${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_smpi.c '${SMPI_SRC}'
- WORKING_DIRECTORY ${PROJECT_DIRECTORY}
- COMMENT "Generating supernovae_smpi.c"
-)
+ ### Change the content of the libraries so that it contains only supernovae+fragiles
+ set(simgrid_sources
+ ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_sg.c
+ ${simgrid_fragile_sources})
-### Make sure that the libs are built from the supernovae sources
- add_library(simgrid SHARED ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_sg.c ${simgrid_fragile_sources})
- add_dependencies(simgrid ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_sg.c)
-
- if(enable_lib_static)
- add_library(simgrid_static STATIC ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_sg.c ${simgrid_fragile_sources})
- add_dependencies(simgrid_static ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_sg.c)
- endif(enable_lib_static)
-
- add_library(gras SHARED ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_gras.c ${gras_fragile_sources})
- add_dependencies(gras ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_gras.c)
+ set(gras_sources
+ ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_gras.c
+ ${gras_fragile_sources})
- if(enable_smpi)
- add_library(smpi SHARED ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_smpi.c)
- add_dependencies(smpi ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_smpi.c)
- if(enable_lib_static)
- add_library(smpi_static STATIC ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_smpi.c)
- add_dependencies(smpi_static ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_smpi.c)
- endif(enable_lib_static)
- endif(enable_smpi)
+ set(SMPI_SRC
+ ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_smpi.c)
+else(PERL_EXECUTABLE AND enable_supernovae) # I need supernovae and can use it
+ if (enable_supernovae)
+ message(You need Perl to activate supernovae)
+ set(enable_supernovae 0)
+ endif(enable_supernovae)
+endif(PERL_EXECUTABLE AND enable_supernovae) # I need supernovae and can use it