Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove borland-compiler related cruft
[simgrid.git] / CMakeLists.txt
index 621f9f6..a7266eb 100644 (file)
@@ -1,16 +1,58 @@
 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)
-if (enable_gtnets OR enable_ns3)
-  enable_language(CXX)
-endif()
+
+## 
+## Check the C/C++ standard that we need
+##   See also buildtools/Cmake/Flags.cmake that sets our paranoid warning flags
 
 enable_language(CXX)
 
-if (NOT DEFINED enable_smpi OR enable_smpi) # smpi is enabled by default
+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")
+
+## We need a decent support of the c++11 standard
+include(CheckCXXCompilerFlag)
+CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
+if(COMPILER_SUPPORTS_CXX11)
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+else()
+  message(FATAL_ERROR 
+          "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. "
+         "Please use a decent C++ compiler.")
+endif()
+if (CMAKE_COMPILER_IS_GNUCC)
+  if (COMPILER_CXX_VERSION_MAJOR_MINOR STRLESS "4.7")
+    message(FATAL_ERROR
+            "SimGrid needs g++ version 4.7 to compile "
+           "(c++11 support of previous versions is too limited).")
+  endif()
+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
@@ -34,12 +76,6 @@ if (NOT DEFINED enable_smpi OR enable_smpi) # smpi is enabled by default
   enable_language(Fortran OPTIONAL)
 endif()
 
-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(CMAKE_C_LINK_FLAGS "" CACHE TYPE INTERNAL FORCE)
-set(CMAKE_Fortran_FLAGS "" CACHE TYPE INTERNAL FORCE)
-set(CMAKE_Fortran_LINK_FLAGS "" CACHE TYPE INTERNAL FORCE)
 ## Mapping version number -> version name
 # 3.5.99 -> alpha1 (oops)
 # 3.5.9{1,2} -> beta{1,2}
@@ -51,13 +87,14 @@ set(CMAKE_Fortran_LINK_FLAGS "" CACHE TYPE INTERNAL FORCE)
 # 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 "11")
+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  "2014") # Year for copyright information
+set(SIMGRID_VERSION_DATE  "2015") # Year for copyright information
 
 if(${SIMGRID_VERSION_PATCH} EQUAL "0")
   set(release_version "${SIMGRID_VERSION_MAJOR}.${SIMGRID_VERSION_MINOR}")
@@ -65,8 +102,9 @@ 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}\\nCopyright (c) ${SIMGRID_VERSION_DATE}. The Simgrid Team.")
+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}")
@@ -97,8 +135,17 @@ if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
   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()
+  
+  if(COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.8")
+    set (CMAKE_AR gcc-ar)
+    set (CMAKE_RANLIB gcc-ranlib)
+  endif()
+  
 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(FATAL_ERROR "VB is not yet supported by Simgrid.")
@@ -111,6 +158,11 @@ 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)
 
@@ -164,8 +216,6 @@ if(WIN32)
     if(COMPILER_C_MINOR_VERSION)
       # set(__GNUC_MINOR__ ${COMPILER_C_MINOR_VERSION})
     endif()
-    set(MSVC 0)
-    set(BORLAND 0)
   else()
     message(FATAL_ERROR "Please use MinGW to compile SimGrid!")
   endif()
@@ -180,7 +230,9 @@ if(WIN32)
   if(NSIS_WIN_VERSION MATCHES "")
     set(NSIS_WIN_VERSION $ENV{PROCESSOR_ARCHITECTURE})
   endif()
-  string(TOLOWER ${NSIS_WIN_VERSION} NSIS_WIN_VERSION)
+  if(${NSIS_WIN_VERSION})
+    string(TOLOWER ${NSIS_WIN_VERSION} NSIS_WIN_VERSION)
+  endif()
 
   set(_XBT_WIN32 1)
 
@@ -193,8 +245,6 @@ if(WIN32)
   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()
@@ -228,6 +278,10 @@ endif()
 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)