-cmake_minimum_required(VERSION 2.8)
-project(SimGrid-Java C)
-set(UPDATE_TYPE svn)
-set(CMAKE_C_FLAGS "" CACHE TYPE INTERNAL FORCE)
-set(CMAKE_EXE_LINKER_FLAGS "" CACHE TYPE INTERNAL FORCE)
-set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/lib")
-set(soversion 1)
-
-set(SIMGRID_JAVA_VERSION_MAJOR "1")
-set(SIMGRID_JAVA_VERSION_MINOR "0")
-set(SIMGRID_JAVA_VERSION_PATCH "0")
-set(DIST_NAME ${PROJECT_NAME}-${SIMGRID_JAVA_VERSION_MAJOR}.${SIMGRID_JAVA_VERSION_MINOR})
-
-########
-## GCC #
-########
-exec_program("${CMAKE_C_COMPILER} --version" OUTPUT_VARIABLE "COMPILER_C_VERSION")
-string(REGEX MATCH "[0-9].[0-9].[0-9]" COMPILER_C_VERSION "${COMPILER_C_VERSION}")
-string(REGEX MATCH "^[0-9].[0-9]" COMPILER_C_VERSION_MAJOR_MINOR "${COMPILER_C_VERSION}")
-string(REPLACE "${COMPILER_C_VERSION_MAJOR_MINOR}." "" COMPILER_C_VERSION_PATCH "${COMPILER_C_VERSION}")
-
-########
-## GIT #
-########
-if(EXISTS ${CMAKE_HOME_DIRECTORY}/.git/)
-exec_program("git remote | head -n 1" OUTPUT_VARIABLE remote RETURN_VALUE ret)
-exec_program("git config --get remote.${remote}.url" OUTPUT_VARIABLE url RETURN_VALUE ret)
-
-if(url)
- exec_program("git --git-dir=${CMAKE_HOME_DIRECTORY}/.git log --oneline -1" OUTPUT_VARIABLE "GIT_VERSION")
- message(STATUS "Git version: ${GIT_VERSION}")
- exec_program("git --git-dir=${CMAKE_HOME_DIRECTORY}/.git log -n 1 --format=%ai ." OUTPUT_VARIABLE "GIT_DATE")
- message(STATUS "Git date: ${GIT_DATE}")
- string(REGEX REPLACE " .*" "" GIT_VERSION "${GIT_VERSION}")
- STRING(REPLACE " +0000" "" GIT_DATE ${GIT_DATE})
- STRING(REPLACE " " "~" GIT_DATE ${GIT_DATE})
- STRING(REPLACE ":" "-" GIT_DATE ${GIT_DATE})
-endif(url)
-endif(EXISTS ${CMAKE_HOME_DIRECTORY}/.git/)
-
-#########
-# CDASH #
-#########
-SET(DROP_METHOD "http")
-SET(DROP_SITE "cdash.inria.fr/CDash")
-SET(DROP_LOCATION "/submit.php?project=simgrid")
-SET(DROP_SITE_CDASH TRUE)
-SET(TRIGGER_SITE "http://cdash.inria.fr/CDash/cgi-bin/Submit-Random-TestingResults.cgi")
-SET(BUILDNAME "SimGrid-Java" CACHE TYPE INTERNAL FORCE)
-set(osname ${CMAKE_SYSTEM_NAME})
-set(cpu ${CMAKE_SYSTEM_PROCESSOR})
-set(DISTRIB2 ${CMAKE_SYSTEM_VERSION})
-SET(SITE "${osname}_${DISTRIB2}_${cpu}")
-SET(CTEST_SITE "${osname}_${DISTRIB2}_${cpu}")
-SET(CTEST_PROJECT_NAME "${PROJECT_NAME}")
-SET(CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE "3000000")
-SET(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE "3000000")
-set(PIPOL_IMAGE $ENV{PIPOL_IMAGE})
-if(NOT ${PIPOL_IMAGE} MATCHES "\n")
-set(SITE ${PIPOL_IMAGE})
-endif(NOT ${PIPOL_IMAGE} MATCHES "\n")
-message(STATUS "SITE : ${SITE}")
-message(STATUS "BUILDNAME : ${BUILDNAME}")
-
-###############################
-# Test the build dependencies #
-###############################
-include(FindSimGrid.cmake)
-include(FindJavaSG.cmake)
-
-###############################
-# Declare our package content #
-###############################
-set(JMSG_C_SRC
- src/smx_context_java.h
- src/smx_context_java.c
- src/jxbt_utilities.c
- src/jxbt_utilities.h
- src/jmsg.c
- src/jmsg.h
- src/jmsg_host.c
- src/jmsg_host.h
- src/jmsg_process.c
- src/jmsg_process.h
- src/jmsg_task.c
- src/jmsg_task.h
- src/jmsg_application_handler.c
- src/jmsg_application_handler.h
-)
-
-set(JMSG_JAVA_SRC
- org/simgrid/msg/ApplicationHandler.java
- org/simgrid/msg/Host.java
- org/simgrid/msg/HostFailureException.java
- org/simgrid/msg/HostNotFoundException.java
- org/simgrid/msg/JniException.java
- org/simgrid/msg/Msg.java
- org/simgrid/msg/MsgException.java
- org/simgrid/msg/MsgNative.java
- org/simgrid/msg/NativeException.java
- org/simgrid/msg/Process.java
- org/simgrid/msg/ProcessNotFoundException.java
- org/simgrid/msg/Sem.java
- org/simgrid/msg/Task.java
- org/simgrid/msg/TaskCancelledException.java
- org/simgrid/msg/TimeoutException.java
- org/simgrid/msg/TransferFailureException.java
-)
-
-set(JAVA_EXAMPLES
- examples/mutualExclusion/centralized/MutexCentral.java
- examples/mutualExclusion/centralized/GrantTask.java
- examples/mutualExclusion/centralized/Coordinator.java
- examples/mutualExclusion/centralized/ReleaseTask.java
- examples/mutualExclusion/centralized/Node.java
- examples/mutualExclusion/centralized/RequestTask.java
- examples/basic/FinalizeTask.java
- examples/basic/Forwarder.java
- examples/basic/Master.java
- examples/basic/BasicTest.java
- examples/basic/Slave.java
- examples/commTime/FinalizeTask.java
- examples/commTime/Master.java
- examples/commTime/Slave.java
- examples/commTime/CommTimeTest.java
- examples/pingPong/PingPongTask.java
- examples/pingPong/Sender.java
- examples/pingPong/Receiver.java
- examples/pingPong/PingPongTest.java
- examples/master_slave_bypass/Master.java
- examples/master_slave_bypass/MsBypass.java
- examples/master_slave_bypass/Slave.java
- examples/master_slave_bypass/FinalizeTask.java
- examples/master_slave_kill/Master.java
- examples/master_slave_kill/MsKill.java
- examples/master_slave_kill/Slave.java
- examples/master_slave_kill/FinalizeTask.java
-)
-
-set(CMAKE_SRC
-${CMAKE_HOME_DIRECTORY}/ChangeLog
-${CMAKE_HOME_DIRECTORY}/CMakeLists.txt
-${CMAKE_HOME_DIRECTORY}/FindJavaSG.cmake
-${CMAKE_HOME_DIRECTORY}/FindSimGrid.cmake
-)
-
-set(XML_FILES
- examples/commTime/commTimeDeployment.xml
- examples/mutualExclusion/ring3.xml
- examples/mutualExclusion/centralized/mutex_centralized_deployment.xml
- examples/platform.xml
- examples/pingPong/pingPongDeployment.xml
- examples/basic/basicDeployment.xml
- examples/basic/deploy.xml
- examples/master_slave_bypass/platform.xml
- examples/master_slave_kill/platform.xml
-)
-
-set(source_to_pack
-${CMAKE_SRC}
-${JMSG_C_SRC}
-${JMSG_JAVA_SRC}
-${JAVA_EXAMPLES}
-${XML_FILES}
-)
-
-string(REPLACE "org/" "${CMAKE_HOME_DIRECTORY}/org/" JAVA_FILES "${JMSG_JAVA_SRC}")
-string(REPLACE "org/" "${CMAKE_HOME_DIRECTORY}/classes/org/" JMSG_JAVA_SRC_CLASS "${JMSG_JAVA_SRC}")
-string(REPLACE ".java" ".class" JMSG_JAVA_SRC_CLASS "${JMSG_JAVA_SRC_CLASS}")
-string(REPLACE "examples/" "${CMAKE_HOME_DIRECTORY}/examples/" JAVA_EXAMPLES_CLASS "${JAVA_EXAMPLES}")
-string(REPLACE ".java" ".class" JAVA_EXAMPLES_CLASS "${JAVA_EXAMPLES_CLASS}")
-
-#########
-# FLAGS #
-#########
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing -Wno-format-nonliteral -Werror ")
-set(INCLUDE_PATH "-I${CMAKE_HOME_DIRECTORY}/src -I${SIMGRID_INCLUDES}")
-set(LIB_PATH "-L${SIMGRID_LIB}")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${INCLUDE_PATH} ${LIB_PATH} -DMSG_USE_DEPRECATED")
-
-if(COMPILER_C_VERSION_MAJOR_MINOR MATCHES "4.6")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unused-but-set-variable ")
-endif(COMPILER_C_VERSION_MAJOR_MINOR MATCHES "4.6")
-
-
-###########
-# TARGETS #
-###########
-# SG_java
-add_library(SG_java SHARED ${JMSG_C_SRC})
-target_link_libraries(SG_java -lsimgrid)
-set_target_properties(SG_java PROPERTIES VERSION ${soversion})
+cmake_minimum_required(VERSION 2.6)
+
+### Need to set rc ccompiler before enable language
+if(WIN32)
+ SET(CMAKE_RC_COMPILER "windres")
+endif()
+project(SimGrid C)
+
+##
+## Check the C/C++ standard that we need
+## See also buildtools/Cmake/Flags.cmake that sets our paranoid warning flags
+
+enable_language(CXX)
+
+INCLUDE(CheckCCompilerFlag)
+CHECK_C_COMPILER_FLAG(-fstack-cleaner HAVE_C_STACK_CLEANER)
+
+## Request full debugging flags
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
+set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g")
+
+if (CMAKE_COMPILER_IS_GNUCC)
+ if (COMPILER_CXX_VERSION_MAJOR_MINOR STRLESS "4.7")
+ message(FATAL_ERROR
+ "SimGrid needs at least g++ version 4.7 to compile "
+ "(c++11 support of previous versions is too limited).")
+ endif()
+endif()
+
+## We need a decent support of the c++11 standard
+include(CheckCXXCompilerFlag)
+CHECK_CXX_COMPILER_FLAG("-std=gnu++11" COMPILER_SUPPORTS_CXX11)
+if(COMPILER_SUPPORTS_CXX11)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
+else()
+ message(FATAL_ERROR
+ "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. "
+ "Please use a decent C++ compiler.")
+endif()
+
+### And we need C11 standard, too
+include(CheckCCompilerFlag)
+CHECK_C_COMPILER_FLAG("-std=gnu11" COMPILER_SUPPORTS_C11)
+if(COMPILER_SUPPORTS_C11)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11")
+else()
+ message(FATAL_ERROR
+ "The compiler ${CMAKE_C_COMPILER} has no C11 support. "
+ "Please use a decent C compiler "
+ "(note that c++11 support of ${CMAKE_CXX_COMPILER} seems ok).")
+endif()
+
+### SMPI vs. Fortran
+if ((NOT DEFINED enable_smpi OR enable_smpi) AND NOT APPLE) # smpi is enabled by default
+ # Call enable_language(Fortran) in order to load the build rules for
+ # this language, needed by teshsuite/smpi/mpich-test/. Use
+ # CMAKE_FORCE_Fortran_COMPILER to bypass checks for a working
+ # compiler (smpiff don't exist at configure time).
+ include(CMakeForceCompiler)
+ if(NOT COMMAND CMAKE_FORCE_Fortran_COMPILER)
+ MACRO(CMAKE_FORCE_Fortran_COMPILER compiler id)
+ SET(CMAKE_Fortran_COMPILER "${compiler}")
+ SET(CMAKE_Fortran_COMPILER_ID_RUN TRUE)
+ SET(CMAKE_Fortran_COMPILER_ID ${id})
+ SET(CMAKE_Fortran_COMPILER_WORKS TRUE)
+ SET(CMAKE_Fortran_COMPILER_FORCED TRUE)
+
+ # Set old compiler id variables.
+ IF("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU")
+ SET(CMAKE_COMPILER_IS_GNUG77 1)
+ ENDIF("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU")
+ ENDMACRO(CMAKE_FORCE_Fortran_COMPILER)
+ endif()
+ CMAKE_FORCE_Fortran_COMPILER(smpiff smpiff)
+ enable_language(Fortran OPTIONAL)
+endif()
+
+## Mapping version number -> version name
+# 3.5.99 -> alpha1 (oops)
+# 3.5.9{1,2} -> beta{1,2}
+# 3.5.9{3,4,5} -> rc{1,2,3}
+# 3.6.{0,1,2} -> release 3.6, 3.6.1, 3.6.2
+# 3.7.{0,1} -> release 3.7, 3.7.1
+# 3.8.{0,1} -> release 3.8, 3.8.1
+# 3.9.0 -> release 3.9
+# 3.9.90 -> release 3.10pre1
+# 3.10.0 -> release 3.10
+# 3.11.0 -> release 3.11
+# 3.12.0 -> release 3.12
+
+set(SIMGRID_VERSION_MAJOR "3")
+set(SIMGRID_VERSION_MINOR "12")
+set(SIMGRID_VERSION_PATCH "0")
+set(SIMGRID_VERSION_EXTRA "-devel") # Extra words to add to version string (e.g. -rc1)
+
+set(SIMGRID_VERSION_DATE "2015") # Year for copyright information
+
+if(${SIMGRID_VERSION_PATCH} EQUAL "0")
+ set(release_version "${SIMGRID_VERSION_MAJOR}.${SIMGRID_VERSION_MINOR}")
+else()
+ set(release_version "${SIMGRID_VERSION_MAJOR}.${SIMGRID_VERSION_MINOR}.${SIMGRID_VERSION_PATCH}")
+endif()
+
+set(SIMGRID_VERSION_STRING "SimGrid version ${release_version}${SIMGRID_VERSION_EXTRA}")
+set(SIMGRID_VERSION_BANNER
+ "SIMGRID_VERSION_STRING\\nCopyright (c) 2004-${SIMGRID_VERSION_DATE}. The Simgrid Team.")
+
+set(libsimgrid_version "${release_version}")
+set(libsimgrid-java_version "${release_version}")
+set(GCC_NEED_VERSION "4.0")
+set(APPLE_NEED_GCC_VERSION "4.6")
+
+### SET THE LIBRARY EXTENSION AND GCC VERSION
+if(APPLE) #MAC
+ set(LIB_EXE "dylib")
+else()
+ if(WIN32) #WINDOWS
+ set(LIB_EXE "a")
+ set(BIN_EXE ".exe")
+ else() #UNIX
+ set(LIB_EXE "so")
+ endif()
+endif()
+
+if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
+ exec_program("${CMAKE_C_COMPILER} --version" OUTPUT_VARIABLE "COMPILER_C_VERSION")
+ exec_program("${CMAKE_CXX_COMPILER} --version" OUTPUT_VARIABLE "COMPILER_CXX_VERSION")
+ string(REGEX MATCH "[0-9].[0-9].[0-9]" COMPILER_C_VERSION "${COMPILER_C_VERSION}")
+ string(REGEX MATCH "[0-9].[0-9].[0-9]" COMPILER_CXX_VERSION "${COMPILER_CXX_VERSION}")
+
+ string(REGEX MATCH "^[0-9].[0-9]" COMPILER_C_VERSION_MAJOR_MINOR "${COMPILER_C_VERSION}")
+ string(REPLACE "${COMPILER_C_VERSION_MAJOR_MINOR}." "" COMPILER_C_VERSION_PATCH "${COMPILER_C_VERSION}")
+
+ if(${GCC_NEED_VERSION} GREATER COMPILER_C_VERSION_MAJOR_MINOR)
+ message(FATAL_ERROR "Gcc must be to version ${GCC_NEED_VERSION} current version ${COMPILER_C_VERSION_MAJOR_MINOR}")
+ endif()
-# java_classes
-add_custom_command(
- OUTPUT ${JMSG_JAVA_SRC_CLASS}
- DEPENDS ${JMSG_JAVA_SRC}
- COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_HOME_DIRECTORY}/classes/"
- COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/classes/
- -cp ${CMAKE_HOME_DIRECTORY}/classes/ ${JAVA_FILES}
- COMMENT "Compiling java sources of core library..."
-)
-add_custom_target(java_classes ALL
- DEPENDS ${JMSG_JAVA_SRC_CLASS}
-)
-
-# simgrid_jar
-add_custom_target(simgrid_jar ALL
- COMMAND ${JAVA_ARCHIVE} -cvf ${CMAKE_HOME_DIRECTORY}/simgrid.jar .
- COMMENT "Building simgrid.jar..."
- WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/classes
-)
-
-# simgrid_java_examples
-add_custom_command(
- COMMENT "Build examples for java"
- OUTPUT ${JAVA_EXAMPLES_CLASS}
- DEPENDS ${JAVA_EXAMPLES}
- COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/basic/*.java
- COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/pingPong/*.java
- COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/commTime/*.java
- COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/centralized/*.java
- COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/master_slave_bypass/*.java
- COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/master_slave_kill/*.java
-)
-
-add_custom_target(simgrid_java_examples ALL
- DEPENDS ${JAVA_EXAMPLES_CLASS}
-)
-
-########################
-# Declare dependencies #
-########################
-add_dependencies(simgrid_jar java_classes)
-add_dependencies(simgrid_java_examples simgrid_jar SG_java)
-
-SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
-${CMAKE_HOME_DIRECTORY}/simgrid.jar
-)
-
-#####################
-# Declare our tests #
-#####################
-INCLUDE(CTest)
-ENABLE_TESTING()
-
-ADD_TEST(basic
-java -cp .:${CMAKE_HOME_DIRECTORY}/examples:${CMAKE_HOME_DIRECTORY}/simgrid.jar basic/BasicTest ${CMAKE_HOME_DIRECTORY}/examples/platform.xml ${CMAKE_HOME_DIRECTORY}/examples/basic/basicDeployment.xml
-)
-ADD_TEST(pingPong
-java -cp .:${CMAKE_HOME_DIRECTORY}/examples:${CMAKE_HOME_DIRECTORY}/simgrid.jar pingPong/PingPongTest ${CMAKE_HOME_DIRECTORY}/examples/platform.xml ${CMAKE_HOME_DIRECTORY}/examples/pingPong/pingPongDeployment.xml
-)
-ADD_TEST(CommTime
-java -cp .:${CMAKE_HOME_DIRECTORY}/examples:${CMAKE_HOME_DIRECTORY}/simgrid.jar commTime/CommTimeTest ${CMAKE_HOME_DIRECTORY}/examples/platform.xml ${CMAKE_HOME_DIRECTORY}/examples/commTime/commTimeDeployment.xml
-)
-ADD_TEST(mutualExclusion
-java -cp .:${CMAKE_HOME_DIRECTORY}/examples:${CMAKE_HOME_DIRECTORY}/simgrid.jar mutualExclusion/centralized/MutexCentral ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/ring3.xml ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/centralized/mutex_centralized_deployment.xml
-)
-ADD_TEST(bypass
-java -cp .:${CMAKE_HOME_DIRECTORY}/examples:${CMAKE_HOME_DIRECTORY}/simgrid.jar master_slave_bypass/MsBypass ${CMAKE_HOME_DIRECTORY}/examples/master_slave_bypass/platform.xml
-)
-ADD_TEST(kill
-java -cp .:${CMAKE_HOME_DIRECTORY}/examples:${CMAKE_HOME_DIRECTORY}/simgrid.jar master_slave_kill/MsKill ${CMAKE_HOME_DIRECTORY}/examples/master_slave_kill/platform.xml
-)
-#Don't forget to put new test in this list!!!
-set(test_list basic pingPong CommTime mutualExclusion bypass kill)
-
-##########################################
-# Set the DYLD_LIBRARY_PATH for mac #
-##########################################
-if(APPLE)
- if($ENV{DYLD_LIBRARY_PATH} STREQUAL "")
- set_tests_properties(${test_list}
- PROPERTIES ENVIRONMENT "DYLD_LIBRARY_PATH=${CMAKE_HOME_DIRECTORY}/lib:${SIMGRID_LIB}")
- else($ENV{DYLD_LIBRARY_PATH} STREQUAL "")
- set_tests_properties(${test_list}
- PROPERTIES ENVIRONMENT "DYLD_LIBRARY_PATH=$ENV{DYLD_LIBRARY_PATH}:${CMAKE_HOME_DIRECTORY}/lib:${SIMGRID_LIB}")
- endif($ENV{DYLD_LIBRARY_PATH} STREQUAL "")
-endif(APPLE)
-
-##########################################
-# Set the LD_LIBRARY_PATH for our tests #
-##########################################
-if($ENV{LD_LIBRARY_PATH} STREQUAL "")
- set_tests_properties(${test_list}
- PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_HOME_DIRECTORY}/lib:${SIMGRID_LIB}")
-else($ENV{LD_LIBRARY_PATH} STREQUAL "")
- set_tests_properties(${test_list}
- PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:${CMAKE_HOME_DIRECTORY}/lib:${SIMGRID_LIB}")
-endif($ENV{LD_LIBRARY_PATH} STREQUAL "")
-
-###########
-# Install #
-###########
-install(TARGETS SG_java
- DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/java/)
-install(FILES ${CMAKE_HOME_DIRECTORY}/simgrid.jar
- DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/java/)
-
-
-#########
-# Dist #
-#########
-
-add_custom_target(dist-dir
- COMMENT "Generating the distribution directory"
- COMMAND test -e ${DIST_NAME}/ && chmod -R a+w ${DIST_NAME}/ || true
- COMMAND ${CMAKE_COMMAND} -E remove_directory ${DIST_NAME}/
- COMMAND ${CMAKE_COMMAND} -E make_directory ${DIST_NAME}
-)
-
-set(dirs_in_tarball "")
-foreach(file ${source_to_pack})
-
- # This damn prefix is still set somewhere (seems to be in subdirs)
- string(REPLACE "${CMAKE_HOME_DIRECTORY}/" "" file "${file}")
+ if(COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.8")
+ set (CMAKE_AR gcc-ar)
+ set (CMAKE_RANLIB gcc-ranlib)
+ endif()
- # Create the directory on need
- get_filename_component(file_location ${file} PATH)
- string(REGEX MATCH ";${file_location};" OPERATION "${dirs_in_tarball}")
- if(NOT OPERATION)
- set(dirs_in_tarball "${dirs_in_tarball};${file_location};")
- add_custom_command(
- TARGET dist-dir
- COMMAND ${CMAKE_COMMAND} -E make_directory ${DIST_NAME}/${file_location}/
- )
- endif(NOT OPERATION)
-
- # Actually copy the file
- add_custom_command(
- TARGET dist-dir
- COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/${file} ${DIST_NAME}/${file_location}/
- )
-endforeach(file ${source_to_pack})
-
-add_custom_target(dist
- DEPENDS ${CMAKE_BINARY_DIR}/${DIST_NAME}.tar.gz
- COMMENT "Generated ${DIST_NAME}"
-)
-add_custom_command(
- OUTPUT ${CMAKE_BINARY_DIR}/${DIST_NAME}.tar.gz
- COMMENT "Compressing the archive from the distribution directory"
- COMMAND ${CMAKE_COMMAND} -E tar cf ${DIST_NAME}.tar ${DIST_NAME}/
- COMMAND gzip -9v ${DIST_NAME}.tar
- COMMAND ${CMAKE_COMMAND} -E remove_directory ${DIST_NAME}/
-)
-add_dependencies(dist dist-dir)
-
-########
-# NOTE #
-########
-file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Testing/Notes/)
-file(WRITE ${CMAKE_BINARY_DIR}/Testing/Notes/Build "GIT version : ${GIT_VERSION}\n")
-file(APPEND ${CMAKE_BINARY_DIR}/Testing/Notes/Build "Release : ${DIST_NAME}\n")
-file(APPEND ${CMAKE_BINARY_DIR}/Testing/Notes/Build "Pipol user : $ENV{PIPOL_USER}\n")
-file(APPEND ${CMAKE_BINARY_DIR}/Testing/Notes/Build "Pipol image : $ENV{PIPOL_IMAGE}\n")
-
-#######
-# DOC #
-#######
-set(WARNING "This file is generated, don't edit it!")
-set(srcdir ${CMAKE_HOME_DIRECTORY})
-include(GenerateDoc.cmake)
+endif()
+
+exec_program("${CMAKE_LINKER} --version" OUTPUT_VARIABLE "LINKER_VERSION")
+string(REGEX MATCH "[0-9].[0-9]*" LINKER_VERSION "${LINKER_VERSION}")
+
+string(REGEX MATCH "cl.exe" VBC "${CMAKE_C_COMPILER}")
+if(VBC)
+ message("VB is not yet supported by Simgrid. Proceed with extrem caution")
+endif()
+
+### Find programs and paths
+FIND_PROGRAM(GCOV_PATH gcov)
+include(FindPerl)
+if(NOT PERL_EXECUTABLE)
+ message(FATAL_ERROR "-- SimGrid cannot be compiled without Perl installed -- sorry. Bailling out.")
+endif()
+
+if (APPLE)
+ set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
+ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
+endif()
+
+### Set some variables for Cmake
+SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
+
+set(INCLUDES
+ ${CMAKE_HOME_DIRECTORY}
+ ${CMAKE_HOME_DIRECTORY}/include
+ ${CMAKE_HOME_DIRECTORY}/src
+ ${CMAKE_HOME_DIRECTORY}/src/include
+ ${CMAKE_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}/include
+ ${CMAKE_BINARY_DIR}/src
+ )
+
+if(WIN32)
+ set(INCLUDES ${INCLUDES} ${CMAKE_HOME_DIRECTORY}/include/xbt ${CMAKE_HOME_DIRECTORY}/src/xbt) #for win32_ucontext.[ch]
+endif()
+set(CMAKE_SOURCE_DIR ${PROJECT_SOURCE_DIRECTORY})
+
+if(NOT CMAKE_CROSSCOMPILING AND EXISTS /usr/include/)
+ set(INCLUDES ${INCLUDES} /usr/include/)
+endif()
+
+### Check 32bits or 64bits
+INCLUDE (CheckTypeSize)
+CHECK_TYPE_SIZE("void*" SIZEOF_VOIDSTAR)
+IF(SIZEOF_VOIDSTAR EQUAL 4)
+ SET(ARCH_32_BITS 1)
+ELSE()
+ SET(ARCH_32_BITS 0)
+ENDIF()
+
+if(WIN32)
+
+ #Need env INCLUDE
+ set(CMAKE_INCLUDE_WIN "${CMAKE_C_COMPILER}")
+ set(CMAKE_LIB_WIN "${CMAKE_C_COMPILER}")
+ string(REGEX REPLACE "/bin/gcc.*" "/include" CMAKE_INCLUDE_WIN "${CMAKE_INCLUDE_WIN}")
+ string(REGEX REPLACE "/bin/gcc.*" "/lib" CMAKE_LIB_WIN "${CMAKE_LIB_WIN}")
+ set(INCLUDES ${INCLUDES} ${CMAKE_INCLUDE_WIN})
+
+ if(CMAKE_COMPILER_IS_GNUCC)
+ set(__GNUC__ 1)
+ exec_program("${CMAKE_C_COMPILER} --version" OUTPUT_VARIABLE "COMPILER_C_VERSION")
+ string(REGEX MATCH "[0-9].[0-9].[0-9]" COMPILER_C_VERSION "${COMPILER_C_VERSION}")
+ string(REGEX MATCH "^[0-9]" COMPILER_C_MAJOR_VERSION "${COMPILER_C_VERSION}")
+ string(REGEX MATCH "^[0-9].[0-9]" COMPILER_C_MINOR_VERSION "${COMPILER_C_VERSION}")
+ string(REGEX REPLACE "^${COMPILER_C_MAJOR_VERSION}." "" COMPILER_C_MINOR_VERSION "${COMPILER_C_MINOR_VERSION}")
+ if(COMPILER_C_MAJOR_VERSION)
+ # set(__GNUC__ ${COMPILER_C_MAJOR_VERSION})
+ endif()
+ if(COMPILER_C_MINOR_VERSION)
+ # set(__GNUC_MINOR__ ${COMPILER_C_MINOR_VERSION})
+ endif()
+ else()
+ message("You REALLY should use MinGW to compile SimGrid on Windows!")
+ endif()
+
+ if(ARCH_32_BITS) ### Arch 32bits
+ set(_WIN32 1)
+ else() ### Arch 64bits
+ set(_WIN64 1)
+ endif()
+
+ set(NSIS_WIN_VERSION $ENV{PROCESSOR_ARCHITEW6432})
+ if(NSIS_WIN_VERSION MATCHES "")
+ set(NSIS_WIN_VERSION $ENV{PROCESSOR_ARCHITECTURE})
+ endif()
+ if(${NSIS_WIN_VERSION})
+ string(TOLOWER ${NSIS_WIN_VERSION} NSIS_WIN_VERSION)
+ endif()
+
+ set(_XBT_WIN32 1)
+
+ message(STATUS "C_COMPILER ${CMAKE_C_COMPILER} ${COMPILER_C_VERSION}")
+ message(STATUS "CXX_COMPILER ${CMAKE_CXX_COMPILER} ${COMPILER_CXX_VERSION}")
+ message(STATUS "CMAKE_RC_COMPILER ${CMAKE_RC_COMPILER}")
+ message(STATUS "INCLUDE ${CMAKE_INCLUDE_WIN}")
+ message(STATUS "LIB ${CMAKE_LIB_WIN}")
+ message(STATUS "MAKE_PROGRAM ${CMAKE_MAKE_PROGRAM}")
+ message(STATUS "CMAKE_BUILD_TOOL ${CMAKE_BUILD_TOOL}")
+ message(STATUS "LINKER ${CMAKE_LINKER}")
+ message(STATUS "CMAKE_GENERATOR ${CMAKE_GENERATOR}")
+ message(STATUS "GNUC ${CMAKE_COMPILER_IS_GNUCC}")
+
+endif()
+
+include_directories(${INCLUDES})
+
+### Setup Options
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Option.cmake)
+
+### Make the *.h files with *.h.in files
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/CompleteInFiles.cmake)
+
+### Define source packages for Libs
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/DefinePackages.cmake)
+
+### Build some Maintainer files
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MaintainerMode.cmake)
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/UnitTesting.cmake)
+
+### Setup gcc flags
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Flags.cmake)
+
+### Make Libs
+if(NOT WIN32)
+ include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeLib.cmake)
+else()
+ include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeLibWin.cmake)
+endif()
+
+### Make Exes
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeExe.cmake)
+
+### Make tests
+if(enable_memcheck_xml)
+ set(enable_memcheck true)
+endif()
+
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/AddTests.cmake)
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/CTestConfig.cmake)
+
+### Setup the distrib
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Distrib.cmake)
+
+### Pipol compilation
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Pipol.cmake)
+
+### Build the doc
+if(NOT WIN32)
+ include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/GenerateDoc.cmake)
+else()
+ include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/GenerateDocWin.cmake)
+endif()
+
+### Print ARGS
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/PrintArgs.cmake)
+
+INCLUDE(Dart)