Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics
[simgrid.git] / CMakeLists.txt
index d9bd622..29e9a43 100644 (file)
 cmake_minimum_required(VERSION 2.6)
-exec_program("rm ${Project_BINARY_DIR}/CTestTestfile.cmake" OUTPUT_VARIABLE rmok)
-SET(CMAKE_LANGUAGE "Cxx")
-SET(PROJECT_NAME "Simgrid")
-SET(PROJECT_LABEL "Simgrid")
+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")
 set(libsimgrid_version "${release_version}")
 set(libgras_version "${release_version}")
 set(libsmpi_version "${release_version}")
 
 ### Find programs and paths
-find_program(SH_EXE NAMES sh)
-find_program(SED_EXE NAMES sed)
-find_program(PWD_EXE NAMES pwd)
-find_path(GCC_PATH NAMES gcc PATHS NO_DEFAULT_PATHS)
-find_path(GCOV_PATH NAMES gcov PATHS NO_DEFAULT_PATHS)
-find_path(VALGRIND_PATH        NAMES valgrind  PATHS NO_DEFAULT_PATHS)
+FIND_PROGRAM(GCOV_PATH gcov)
+FIND_PROGRAM(VALGRIND_PATH valgrind)
+include(FindPerl)
+if(NOT PERL_EXECUTABLE)
+       message(FATAL_ERROR "-- SimGrid cannot be compiled without Perl installed -- sorry. Bailling out.")
+endif(NOT PERL_EXECUTABLE)
 
-### SET THE PROJECT_DIRECTORY
-SET(PROJECT_DIRECTORY "${CMAKE_HOME_DIRECTORY}")
+
+### SET THE LIBRARY EXTENSION
+if(APPLE)
+       set(LIB_EXE "dylib")
+else(APPLE)
+       set(LIB_EXE "so")
+endif(APPLE)
 
 ### Set some variables for Cmake
-SET(PROJECT_SOURCE_DIRECTORY "${PROJECT_DIRECTORY}/src")
-set(EXECUTABLE_OUTPUT_PATH "${PROJECT_DIRECTORY}/bin")
-set(LIBRARY_OUTPUT_PATH "${PROJECT_DIRECTORY}/src/.libs")
-set(INCLUDES "-I${PROJECT_DIRECTORY}/include -I${PROJECT_DIRECTORY}/src/include -I${PROJECT_DIRECTORY}/src -I/usr/include/ -L${gtnets_path}/lib")
+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_CURRENT_BINARY_DIR}/src)
+if(WIN32)
+    set(INCLUDES ${INCLUDES} ${CMAKE_HOME_DIRECTORY}/include/xbt ${CMAKE_HOME_DIRECTORY}/src/xbt) #for win32_ucontext.[ch]
+endif(WIN32)
 set(CMAKE_SOURCE_DIR ${PROJECT_SOURCE_DIRECTORY})
 
-
-if(enable_coverage)
-       add_definitions (${INCLUDES} -fprofile-arcs -ftest-coverage)
-else(enable_coverage)
-       add_definitions (${INCLUDES})
-endif(enable_coverage)
+if(NOT CMAKE_CROSSCOMPILING AND EXISTS /usr/include/)
+       set(INCLUDES ${INCLUDES} /usr/include/)
+endif(NOT CMAKE_CROSSCOMPILING AND EXISTS /usr/include/)
+
+### Check 32bits or 64bits
+INCLUDE (CheckTypeSize)
+CHECK_TYPE_SIZE("long" SIZEOF_LONG)
+IF(SIZEOF_LONG EQUAL 4)
+  SET(ARCH_32_BITS 1)
+ELSE(SIZEOF_LONG EQUAL 4)
+  SET(ARCH_32_BITS 0)
+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})
+
+    if(BORLAND)                        ### BORLAND COMPILER
+           set(__BORLANDC__ 1)
+           set(CMAKE_COMPILER_IS_GNUCC 0)
+           set(MSVC 0)
+           set(_XBT_BORLANDC_COMPILER 1)
+    endif(BORLAND)
+    
+    if(MSVC)   ### MicroSoftVisualC COMPILER
+           set(__VISUALC__ 1)
+           set(BORLAND 0)
+           set(CMAKE_COMPILER_IS_GNUCC 0)
+           set(_XBT_VISUALC_COMPILER 1)
+           set(_MSC_VER 1)
+        set(__STRICT_ANSI__ 1)
+        set(_M_IX86 1)
+    endif(MSVC)
+    
+    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(COMPILER_C_MAJOR_VERSION)
+        if(COMPILER_C_MINOR_VERSION)
+           # set(__GNUC_MINOR__ ${COMPILER_C_MINOR_VERSION})
+        endif(COMPILER_C_MINOR_VERSION)
+        set(MSVC 0)
+           set(BORLAND 0)
+    endif(CMAKE_COMPILER_IS_GNUCC)
+    
+    if(ARCH_32_BITS)   ### Arch 32bits
+        set(_WIN32 1)
+    else(ARCH_32_BITS) ### Arch 64bits
+        set(_WIN64 1)
+    endif(ARCH_32_BITS)
+    
+    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")
+    
+endif(WIN32)
+
+include_directories(${INCLUDES})
+
+
+### Determine the assembly flavor that we need today
+include(CMakeDetermineSystem)
+set(PROCESSOR_${CMAKE_SYSTEM_PROCESSOR} 1)
 
 ### Setup Options
-include(${PROJECT_DIRECTORY}/buildtools/Cmake/src/CMakeOption.txt)
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Option.cmake)
 
 ### Make the *.h files with *.h.in files
-include(${PROJECT_DIRECTORY}/buildtools/Cmake/src/CMakeCompleteInFiles.txt)
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/CompleteInFiles.cmake)
 
 ### Define source packages for Libs 
-include(${PROJECT_DIRECTORY}/buildtools/Cmake/src/CMakeDefinePackages.txt)
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/DefinePackages.cmake)
 
-include(${PROJECT_DIRECTORY}/buildtools/Cmake/src/CMakeMaintainerMode.txt)
+### Build some Maintainer files
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MaintainerMode.cmake)
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/UnitTesting.cmake)
 
 ### Setup gcc flags
-include(${PROJECT_DIRECTORY}/buildtools/Cmake/src/CMakeFlags.txt)
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Flags.cmake)
 
 ### Make Libs and Exes
-include(${PROJECT_DIRECTORY}/buildtools/Cmake/src/CMakeMakeExeLib.txt)
+if(WIN32)
+    include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeExeLibWin.cmake)
+else(WIN32)
+    include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeExeLib.cmake)
+endif(WIN32)
 
 ### Make Simgrid.jar and Java examples
 if(HAVE_JAVA)
-       include(${PROJECT_DIRECTORY}/buildtools/Cmake/src/CMakeJarAndClass.txt)
+       include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeJava.cmake)
 endif(HAVE_JAVA)
 
 ### Make tests
-include(${PROJECT_DIRECTORY}/buildtools/Cmake/src/CMakeTest.txt)
-include(${PROJECT_DIRECTORY}/buildtools/Cmake/src/CTestConfig.cmake)
+if(NOT WIN32)
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/AddTests.cmake)
+else(NOT WIN32)
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/AddTestsWin.cmake)
+endif(NOT WIN32)
+
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/CTestConfig.cmake)
 
 ### Setup the distrib
-include(${PROJECT_DIRECTORY}/buildtools/Cmake/src/CMakeDistrib.txt)
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Distrib.cmake)
+
+### Pipol compilation
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Pipol.cmake)
+
+### Build the doc
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/GenerateDoc.cmake)
 
 ### Print ARGS
-include(${PROJECT_DIRECTORY}/buildtools/Cmake/src/CMakePrintArgs.txt)
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/PrintArgs.cmake)
 
 INCLUDE(Dart)
-
-exec_program("ctest -N" OUTPUT_VARIABLE LIST_OF_TEST)
-string(REPLACE "\n" ";" LIST_OF_TEST ${LIST_OF_TEST})
-foreach(test ${LIST_OF_TEST})
-       string(REGEX REPLACE "^.*Test.*project.*" " " test ${test})
-       string(REGEX REPLACE "^.*Total.*Tests:.*" " " test ${test})
-       string(REGEX MATCH "^.*Testing.*" test_ok_1 ${test}) #for ctest version 2.6 (xxx/xxx Testing)
-       string(REGEX MATCH "^.*Test.*\\:+" test_ok_2 ${test}) #for ctest version 2.8 (Test #xxx)
-       if(test_ok_1 OR test_ok_2)
-               string(REGEX REPLACE "^.*Testing" " " test ${test}) #for ctest version 2.6
-               string(REGEX REPLACE "^.*Test.*\\:+" " " test ${test}) #for ctest version 2.8
-               string(STRIP ${test} test)
-               set_tests_properties(${test} PROPERTIES LABELS "rev${SVN_VERSION}")
-       endif(test_ok_1 OR test_ok_2)
-endforeach(test ${LIST_OF_TEST})