Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
trace earlier, simix may start the process before returning the flow control
[simgrid.git] / CMakeLists.txt
index afea7e7..ae43da2 100644 (file)
 cmake_minimum_required(VERSION 2.6)
+### Need to set rc ccompiler before enable language
+if(WIN32)
+    SET(CMAKE_RC_COMPILER "windres")
+endif(WIN32)
 project(simgrid CXX C)
 set(CMAKE_C_FLAGS "" CACHE TYPE INTERNAL FORCE)
 set(CMAKE_CXX_FLAGS "" CACHE TYPE INTERNAL FORCE)
 set(CMAKE_EXE_LINKER_FLAGS "" CACHE TYPE INTERNAL FORCE)
-set(release_version "3.5")
+### Version 3.5.99, aka 3.6 svn
+set(SIMGRID_VERSION_MAJOR "3")
+set(SIMGRID_VERSION_MINOR "5")
+set(SIMGRID_VERSION_PATCH "99")
+set(release_version "${SIMGRID_VERSION_MAJOR}.${SIMGRID_VERSION_MINOR}")
 set(libsimgrid_version "${release_version}")
 set(libgras_version "${release_version}")
 set(libsmpi_version "${release_version}")
+set(GCC_NEED_VERSION "4.0")
+
+### SET THE LIBRARY EXTENSION AND GCC VERSION
+if(APPLE) #MAC
+    set(GCC_NEED_VERSION "4.5")
+       set(LIB_EXE "dylib")
+else(APPLE)
+    if(WIN32) #WINDOWS
+        set(LIB_EXE "a")
+    else(WIN32) #UNIX
+           set(LIB_EXE "so")
+    endif(WIN32)
+endif(APPLE)
+
+string(REGEX MATCH "gcc" GCC "${CMAKE_C_COMPILER}")
+if(GCC)
+       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(${GCC_NEED_VERSION} GREATER  COMPILER_C_VERSION_MAJOR_MINOR)
+endif(GCC)
+
+string(REGEX MATCH "cl.exe" VBC "${CMAKE_C_COMPILER}")
+if(VBC)
+    message(FATAL_ERROR "VB is not yet supported by Simgrid.")
+endif(VBC)
 
 ### Find programs and paths
 FIND_PROGRAM(GCOV_PATH gcov)
-FIND_PROGRAM(VALGRIND_PATH valgrind)
 include(FindPerl)
 if(NOT PERL_EXECUTABLE)
-       message(FATAL_ERROR "-- SIMGRID NEED PERL")
+       message(FATAL_ERROR "-- SimGrid cannot be compiled without Perl installed -- sorry. Bailling out.")
 endif(NOT PERL_EXECUTABLE)
 
-
-### SET THE LIBRARY EXTENSION
-if(APPLE)
-       set(LIB_EXE "dylib")
-else(APPLE)
-       set(LIB_EXE "so")
-endif(APPLE)
+if(CMAKE_CACHE_MAJOR_VERSION EQUAL "2" AND CMAKE_CACHE_MINOR_VERSION GREATER "7") #need cmake version 2.8
+       get_filename_component(TRUE_CMAKE_HOME_DIRECTORY "${CMAKE_HOME_DIRECTORY}" REALPATH)
+       get_filename_component(TRUE_CMAKE_BINARY_DIR "${CMAKE_BINARY_DIR}" REALPATH)
+       if(${TRUE_CMAKE_HOME_DIRECTORY} STREQUAL ${CMAKE_HOME_DIRECTORY})
+       else(${TRUE_CMAKE_HOME_DIRECTORY} STREQUAL ${CMAKE_HOME_DIRECTORY})
+               message(STATUS "Change link path '${CMAKE_HOME_DIRECTORY}' to true path '${TRUE_CMAKE_HOME_DIRECTORY}'")
+               set(CMAKE_HOME_DIRECTORY "${TRUE_CMAKE_HOME_DIRECTORY}" CACHE TYPE INTERNAL FORCE)
+               set(CMAKE_SOURCE_DIR "${TRUE_CMAKE_HOME_DIRECTORY}" CACHE TYPE INTERNAL FORCE)
+       endif(${TRUE_CMAKE_HOME_DIRECTORY} STREQUAL ${CMAKE_HOME_DIRECTORY})
+       
+       if(${TRUE_CMAKE_BINARY_DIR} STREQUAL ${CMAKE_BINARY_DIR})
+       else(${TRUE_CMAKE_BINARY_DIR} STREQUAL ${CMAKE_BINARY_DIR})
+               message(STATUS "Change link path '${CMAKE_BINARY_DIR}' to true path '${TRUE_CMAKE_BINARY_DIR}'")
+               set(CMAKE_BINARY_DIR "${TRUE_CMAKE_BINARY_DIR}" CACHE TYPE INTERNAL FORCE)
+       endif(${TRUE_CMAKE_BINARY_DIR} STREQUAL ${CMAKE_BINARY_DIR})    
+endif(CMAKE_CACHE_MAJOR_VERSION EQUAL "2" AND CMAKE_CACHE_MINOR_VERSION GREATER "7")
 
 ### Set some variables for Cmake
-SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
-set(INCLUDES ${PROJECT_BINARY_DIR} ${PROJECT_BINARY_DIR}/include ${PROJECT_BINARY_DIR}/src/include ${PROJECT_BINARY_DIR}/src)
-set(INCLUDES ${INCLUDES} ${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_HOME_DIRECTORY}/src/include ${CMAKE_HOME_DIRECTORY}/src ${CMAKE_CURRENT_BINARY_DIR}/src)
+SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
+
+if("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_HOME_DIRECTORY}")
+       set(INCLUDES
+       ${CMAKE_HOME_DIRECTORY}
+       ${CMAKE_HOME_DIRECTORY}/include
+       ${CMAKE_HOME_DIRECTORY}/src
+       ${CMAKE_HOME_DIRECTORY}/src/include
+       )
+else("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_HOME_DIRECTORY}")
+       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
+       )
+endif("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_HOME_DIRECTORY}")
+
+set(INCLUDES ${INCLUDES} ${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_HOME_DIRECTORY}/src/include ${CMAKE_HOME_DIRECTORY}/src ${CMAKE_BINARY_DIR}/src)
 if(WIN32)
     set(INCLUDES ${INCLUDES} ${CMAKE_HOME_DIRECTORY}/include/xbt ${CMAKE_HOME_DIRECTORY}/src/xbt) #for win32_ucontext.[ch]
 endif(WIN32)
@@ -48,22 +116,13 @@ ENDIF(SIZEOF_LONG EQUAL 4)
 
 if(WIN32)
 
-       set(INCLUDES_MORE $ENV{INCLUDE})
-       string(REPLACE "\\" "/" INCLUDES_MORE "${INCLUDES_MORE}")
-       foreach(include_dir ${INCLUDES_MORE})
-           if(IS_DIRECTORY ${include_dir})
-               string(REGEX MATCH ".*[ ].*" testoki "${include_dir}")
-               if(testoki)
-                       string(REPLACE " " "\\ " include_dir "${include_dir}")
-                   set(INCLUDES ${INCLUDES} \"${include_dir}\")
-               else(testoki)
-                   set(INCLUDES ${INCLUDES} ${include_dir})
-               endif(testoki)
-           else(IS_DIRECTORY ${include_dir})
-               message(FATAL_ERROR "${include_dir} not find")
-           endif(IS_DIRECTORY ${include_dir})
-       endforeach(include_dir ${INCLUDES_MORE})
-
+    #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(BORLAND)                        ### BORLAND COMPILER
            set(__BORLANDC__ 1)
            set(CMAKE_COMPILER_IS_GNUCC 0)
@@ -106,24 +165,27 @@ if(WIN32)
     
     set(_XBT_WIN32 1)
     
-    message("Be sure all those variables are correctely set.")
-    message("  -- C_COMPILER                   $ENV{CC}")
-    message("  -- CXX_COMPILER                 $ENV{CXX}")    
-    message("  -- INCLUDE                      $ENV{INCLUDE}")
-    message("  -- LIB                          $ENV{LIB}")
-    message("  -- MAKE_PROGRAM                 ${CMAKE_MAKE_PROGRAM}")
-    message("  -- CMAKE_BUILD_TOOL             ${CMAKE_BUILD_TOOL}")
-    message("  -- LINKER                       ${CMAKE_LINKER}")
-    message("  -- CMAKE_GENERATOR              ${CMAKE_GENERATOR}")
-    message("  -- INCLUDES                     ${INCLUDES}")
-    message("  -- BORLAND                      ${BORLAND}")
-    message("  -- VISUALC                      ${MSVC}")
-    message("  -- GNUC                         ${CMAKE_COMPILER_IS_GNUCC}\n\n")
-    
+    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 "BORLAND                    ${BORLAND}")
+    message(STATUS "VISUALC                    ${MSVC}")
+    message(STATUS "GNUC                               ${CMAKE_COMPILER_IS_GNUCC}")
+   
 endif(WIN32)
 
 include_directories(${INCLUDES})
 
+### Determine the assembly flavor that we need today
+include(CMakeDetermineSystem)
+set(PROCESSOR_${CMAKE_SYSTEM_PROCESSOR} 1)
+
 ### Setup Options
 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Option.cmake)
 
@@ -135,33 +197,25 @@ include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/DefinePackages.cmake)
 
 ### Build some Maintainer files
 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MaintainerMode.cmake)
+if(NOT WIN32)
 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/UnitTesting.cmake)
+endif(NOT WIN32)
 
 ### Setup gcc flags
 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Flags.cmake)
 
-### Make Libs and Exes
-if(WIN32)
-    include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeExeLibWin.cmake)
-else(WIN32)
-    include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeExeLib.cmake)
-endif(WIN32)
-
-### Build the doc
-include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/GenerateDoc.cmake)
-
-### Make Simgrid.jar and Java examples
-if(HAVE_JAVA)
-       include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeJava.cmake)
-endif(HAVE_JAVA)
-
-### Make tests
+### Make Libs
 if(NOT WIN32)
-include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/AddTests.cmake)
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeLib.cmake)
 else(NOT WIN32)
-include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/AddTestsWin.cmake)
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeLibWin.cmake)
 endif(NOT WIN32)
 
+### Make Exes
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeExe.cmake)
+
+### Make tests
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/AddTests.cmake)
 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/CTestConfig.cmake)
 
 ### Setup the distrib
@@ -170,6 +224,10 @@ include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Distrib.cmake)
 ### Pipol compilation
 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Pipol.cmake)
 
+if(NOT WIN32)
+### Build the doc
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/GenerateDoc.cmake)
+endif(NOT WIN32)
 ### Print ARGS
 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/PrintArgs.cmake)