Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics: use C++ type names
[simgrid.git] / CMakeLists.txt
index 766957c..daeb9d8 100644 (file)
@@ -66,34 +66,22 @@ include(${CMAKE_HOME_DIRECTORY}/tools/cmake/Option.cmake)
 
 ### SMPI vs. Fortran
 if ((NOT DEFINED enable_smpi) OR enable_smpi) 
-  if(enable_fortran)
-    include(FindGFortran)
-  else()
-    SET(SMPI_FORTRAN 0)
-  endif()
+  # First unset the compiler in case we're re-running cmake over a previous
+  # configuration where it was saved as smpiff
+  unset(CMAKE_Fortran_COMPILER)
   
-  if(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 
-    # doesn'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)
+  SET(SMPI_FORTRAN 0)
+  if(enable_fortran)
     enable_language(Fortran OPTIONAL)
   endif()
+  
+  if(CMAKE_Fortran_COMPILER)
+    # Fortran compiler detected: save it, then replace by smpiff
+    set(SAVED_Fortran_COMPILER "${CMAKE_Fortran_COMPILER}" CACHE FILEPATH "The real Fortran compiler")
+    set(CMAKE_Fortran_COMPILER smpiff)
+    set(SMPI_FORTRAN 1)
+  endif(CMAKE_Fortran_COMPILER)
+
 endif()
 
 #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
@@ -303,7 +291,9 @@ endif()
 CHECK_LIBRARY_EXISTS(rt      clock_gettime           "" HAVE_POSIX_GETTIME)
 
 CHECK_LIBRARY_EXISTS(pthread pthread_create          "" HAVE_PTHREAD)
-CHECK_LIBRARY_EXISTS(pthread sem_init                "" HAVE_SEM_INIT_LIB)
+if(NOT APPLE) # OS X El Capitan deprecates this function
+  CHECK_LIBRARY_EXISTS(pthread sem_init                "" HAVE_SEM_INIT_LIB)
+endif()
 CHECK_LIBRARY_EXISTS(pthread sem_open                "" HAVE_SEM_OPEN_LIB)
 set(HAVE_PTHREAD_SETAFFINITY 0)
 CHECK_LIBRARY_EXISTS(pthread pthread_setaffinity_np  "" HAVE_PTHREAD_SETAFFINITY)
@@ -537,6 +527,8 @@ if(HAVE_PTHREAD)
       endif()
     endif()
     file(REMOVE sem_init)
+  else() 
+    set(HAVE_SEM_INIT 0)  
   endif()
 
   if(NOT HAVE_SEM_OPEN AND NOT HAVE_SEM_INIT)
@@ -891,6 +883,9 @@ endforeach()
 ### Setup the distrib
 include(${CMAKE_HOME_DIRECTORY}/tools/cmake/Distrib.cmake)
 
+### Build the docs if asked to
+include(${CMAKE_HOME_DIRECTORY}/tools/cmake/Documentation.cmake)
+
 ### Print the result of configuration
 message("")
 message("##########################################")
@@ -940,7 +935,7 @@ else()
 endif()
 endif()
 if(CMAKE_Fortran_COMPILER)
-  message("        Compiler: Fortran ...........: ${CMAKE_Fortran_COMPILER} (id: ${CMAKE_Fortran_COMPILER_ID})")
+  message("        Compiler: Fortran ...........: ${SAVED_Fortran_COMPILER} (id: ${CMAKE_Fortran_COMPILER_ID})")
   message("                version .............: ${CMAKE_Fortran_COMPILER_VERSION}")
 endif()
 message("        Linker: .....................: ${CMAKE_LINKER}")