Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics
[simgrid.git] / CMakeLists.txt
index 9672271..29e9a43 100644 (file)
@@ -11,21 +11,50 @@ set(libsmpi_version "${release_version}")
 ### Find programs and 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(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
-set(INCLUDES "-I${PROJECT_DIRECTORY} -I${PROJECT_DIRECTORY}/include -I${PROJECT_DIRECTORY}/src/include -I${PROJECT_DIRECTORY}/src -I${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_CURRENT_BINARY_DIR}/src)
 if(WIN32)
-    set(INCLUDES "${INCLUDES} -I${PROJECT_DIRECTORY}/include/xbt -I${PROJECT_DIRECTORY}/src/xbt") #for win32_ucontext.[ch]
+    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(EXISTS /usr/include/)
-       set(INCLUDES "${INCLUDES} -I/usr/include/")
-endif(EXISTS /usr/include/)
+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)
@@ -45,9 +74,9 @@ if(WIN32)
                string(REGEX MATCH ".*[ ].*" testoki "${include_dir}")
                if(testoki)
                        string(REPLACE " " "\\ " include_dir "${include_dir}")
-                   set(INCLUDES "${INCLUDES} -I\"${include_dir}\"")
+                   set(INCLUDES ${INCLUDES} \"${include_dir}\")
                else(testoki)
-                   set(INCLUDES "${INCLUDES} -I${include_dir}")
+                   set(INCLUDES ${INCLUDES} ${include_dir})
                endif(testoki)
            else(IS_DIRECTORY ${include_dir})
                message(FATAL_ERROR "${include_dir} not find")
@@ -73,6 +102,17 @@ if(WIN32)
     
     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)
@@ -101,63 +141,60 @@ if(WIN32)
     
 endif(WIN32)
 
-add_definitions (${INCLUDES})
+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/Option.cmake)
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Option.cmake)
 
 ### Make the *.h files with *.h.in files
-include(${PROJECT_DIRECTORY}/buildtools/Cmake/CompleteInFiles.cmake)
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/CompleteInFiles.cmake)
 
 ### Define source packages for Libs 
-include(${PROJECT_DIRECTORY}/buildtools/Cmake/DefinePackages.cmake)
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/DefinePackages.cmake)
 
 ### Build some Maintainer files
-include(${PROJECT_DIRECTORY}/buildtools/Cmake/MaintainerMode.cmake)
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MaintainerMode.cmake)
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/UnitTesting.cmake)
 
 ### Setup gcc flags
-include(${PROJECT_DIRECTORY}/buildtools/Cmake/Flags.cmake)
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Flags.cmake)
 
 ### Make Libs and Exes
 if(WIN32)
-    include(${PROJECT_DIRECTORY}/buildtools/Cmake/MakeExeLibWin.cmake)
+    include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeExeLibWin.cmake)
 else(WIN32)
-    include(${PROJECT_DIRECTORY}/buildtools/Cmake/MakeExeLib.cmake)
+    include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeExeLib.cmake)
 endif(WIN32)
 
-### Build the doc
-if(enable_doc)
-       ADD_CUSTOM_COMMAND(
-         OUTPUT ${PROJECT_DIRECTORY}/doc/html
-         DEPENDS       ${PROJECT_DIRECTORY}/doc/FAQ.doc 
-                               ${PROJECT_DIRECTORY}/buildtools/Cmake/GenerateDoc.cmake 
-                               ${PROJECT_DIRECTORY}/buildtools/Cmake/doc/CMakeLists.txt
-         COMMAND ${CMAKE_MAKE_PROGRAM} html
-         COMMENT "Generating the simgrid documentation..."
-       )
-       ADD_CUSTOM_TARGET(simgrid_documentation ALL
-                         DEPENDS ${PROJECT_DIRECTORY}/doc/html)
-endif(enable_doc)
-
 ### Make Simgrid.jar and Java examples
 if(HAVE_JAVA)
-       include(${PROJECT_DIRECTORY}/buildtools/Cmake/MakeJava.cmake)
+       include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeJava.cmake)
 endif(HAVE_JAVA)
 
 ### Make tests
 if(NOT WIN32)
-include(${PROJECT_DIRECTORY}/buildtools/Cmake/AddTests.cmake)
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/AddTests.cmake)
+else(NOT WIN32)
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/AddTestsWin.cmake)
 endif(NOT WIN32)
 
-include(${PROJECT_DIRECTORY}/buildtools/Cmake/CTestConfig.cmake)
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/CTestConfig.cmake)
 
 ### Setup the distrib
-include(${PROJECT_DIRECTORY}/buildtools/Cmake/Distrib.cmake)
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Distrib.cmake)
 
 ### Pipol compilation
-include(${PROJECT_DIRECTORY}/buildtools/Cmake/Pipol.cmake)
+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/PrintArgs.cmake)
+include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/PrintArgs.cmake)
 
-INCLUDE(Dart)
\ No newline at end of file
+INCLUDE(Dart)