Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Prepare to windows.
[simgrid.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.6)
2 project(simgrid CXX C)
3 set(CMAKE_C_FLAGS "" CACHE TYPE INTERNAL FORCE)
4 set(CMAKE_CXX_FLAGS "" CACHE TYPE INTERNAL FORCE)
5 set(CMAKE_EXE_LINKER_FLAGS "" CACHE TYPE INTERNAL FORCE)
6 set(release_version "3.5")
7 set(libsimgrid_version "${release_version}")
8 set(libgras_version "${release_version}")
9 set(libsmpi_version "${release_version}")
10 exec_program("${CMAKE_COMMAND} -E remove -f ${simgrid_BINARY_DIR}/CTestTestfile.cmake" OUTPUT_VARIABLE rmok)
11
12 if(WIN32)
13     message("C_COMPILER                 $ENV{CC}")
14     message("CXX_COMPILER               $ENV{CXX}")
15     message("MAKE_PROGRAM               ${CMAKE_MAKE_PROGRAM}")
16     message("RC_COMPILER                $ENV{RC}")
17     message("INCLUDE                    $ENV{INCLUDE}")
18     message("LIB                                $ENV{LIB}")
19     
20     if(NOT $ENV{CC} OR NOT $ENV{CXX} OR NOT $ENV{INCLUDE} OR NOT $ENV{RC} OR NOT $ENV{LIB})
21         message(FATAL_ERROR "Need to set CC, CXX, RC, INCLUDE and LIB to environment variables.")
22     endif(NOT $ENV{CC} OR NOT $ENV{CXX} OR NOT $ENV{INCLUDE} OR NOT $ENV{RC} OR NOT $ENV{LIB})
23 endif(WIN32)
24
25 ### Find programs and paths
26 find_path(GCOV_PATH NAMES gcov PATHS NO_DEFAULT_PATHS)
27 find_path(VALGRIND_PATH NAMES valgrind  PATHS NO_DEFAULT_PATHS)
28
29 ### SET THE PROJECT_DIRECTORY
30 SET(PROJECT_DIRECTORY "${CMAKE_HOME_DIRECTORY}")
31
32 ### Set some variables for Cmake
33 #SET(PROJECT_SOURCE_DIRECTORY "${PROJECT_DIRECTORY}/src") #this one is evil since it speaks to CPack instead
34 SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
35 set(INCLUDES "-I${PROJECT_DIRECTORY}/include -I${PROJECT_DIRECTORY}/src/include -I${PROJECT_DIRECTORY}/src -I${CMAKE_CURRENT_BINARY_DIR}/src/")
36 set(CMAKE_SOURCE_DIR ${PROJECT_SOURCE_DIRECTORY})
37
38 if(EXISTS /usr/include/)
39         set(INCLUDES "${INCLUDES} -I/usr/include/")
40 endif(EXISTS /usr/include/)
41
42 if(WIN32)
43         set(INCLUDES "${INCLUDES} -I$ENV{INCLUDE}")
44 endif(WIN32)
45
46 if(enable_coverage)
47         add_definitions (${INCLUDES} -fprofile-arcs -ftest-coverage)
48 else(enable_coverage)
49         add_definitions (${INCLUDES})
50 endif(enable_coverage)
51
52 ### Setup Options
53 include(${PROJECT_DIRECTORY}/buildtools/Cmake/src/CMakeOption.txt)
54
55 ### Make the *.h files with *.h.in files
56 include(${PROJECT_DIRECTORY}/buildtools/Cmake/src/CMakeCompleteInFiles.txt)
57
58 ### Define source packages for Libs 
59 include(${PROJECT_DIRECTORY}/buildtools/Cmake/src/CMakeDefinePackages.txt)
60
61 include(${PROJECT_DIRECTORY}/buildtools/Cmake/src/CMakeMaintainerMode.txt)
62
63 ### Setup gcc flags
64 include(${PROJECT_DIRECTORY}/buildtools/Cmake/src/CMakeFlags.txt)
65
66 ### Make Libs and Exes
67 include(${PROJECT_DIRECTORY}/buildtools/Cmake/src/CMakeMakeExeLib.txt)
68
69 ### Make Simgrid.jar and Java examples
70 if(HAVE_JAVA)
71         include(${PROJECT_DIRECTORY}/buildtools/Cmake/src/CMakeJarAndClass.txt)
72 endif(HAVE_JAVA)
73
74 ### Make tests
75 include(${PROJECT_DIRECTORY}/buildtools/Cmake/src/CMakeTest.txt)
76 include(${PROJECT_DIRECTORY}/buildtools/Cmake/src/CTestConfig.cmake)
77
78 ### Setup the distrib
79 include(${PROJECT_DIRECTORY}/buildtools/Cmake/src/CMakeDistrib.txt)
80
81 ### Print ARGS
82 include(${PROJECT_DIRECTORY}/buildtools/Cmake/src/CMakePrintArgs.txt)
83
84 INCLUDE(Dart)
85
86 exec_program("ctest -N" OUTPUT_VARIABLE LIST_OF_TEST)
87 string(REPLACE "\n" ";" LIST_OF_TEST ${LIST_OF_TEST})
88 foreach(test ${LIST_OF_TEST})
89         string(REGEX REPLACE "^.*Test.*project.*" " " test ${test})
90         string(REGEX REPLACE "^.*Total.*Tests:.*" " " test ${test})
91         string(REGEX MATCH "^.*Testing.*" test_ok_1 ${test}) #for ctest version 2.6 (xxx/xxx Testing)
92         string(REGEX MATCH "^.*Test.*\\:+" test_ok_2 ${test}) #for ctest version 2.8 (Test #xxx)
93         if(test_ok_1 OR test_ok_2)
94                 string(REGEX REPLACE "^.*Testing" " " test ${test}) #for ctest version 2.6
95                 string(REGEX REPLACE "^.*Test.*\\:+" " " test ${test}) #for ctest version 2.8
96                 string(STRIP ${test} test)
97                 set_tests_properties(${test} PROPERTIES LABELS "rev${SVN_VERSION}")
98         endif(test_ok_1 OR test_ok_2)
99 endforeach(test ${LIST_OF_TEST})