Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add ModelChecker build type
[simgrid.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.6)
2
3 SET(CMAKE_BUILD_TYPE ModelChecker)
4 IF(CMAKE_BUILD_TYPE STREQUAL "ModelChecker") 
5   SET(enable_coverage ON)
6   SET(enable_model-checking ON)
7   SET(enable_lua ON)
8   SET(enable_compile_optimization OFF)
9 ENDIF()
10
11 ### Need to set rc ccompiler before enable language
12 if(WIN32)
13   SET(CMAKE_RC_COMPILER "windres")
14 endif()
15 project(SimGrid C)
16 if (enable_gtnets OR enable_ns3)
17   enable_language(CXX)
18 endif()
19 if (NOT DEFINED enable_smpi OR enable_smpi) # smpi is enabled by default
20   # Call enable_language(Fortran) in order to load the build rules for
21   # this language, needed by teshsuite/smpi/mpich-test/.  Use
22   # CMAKE_FORCE_Fortran_COMPILER to bypass checks for a working
23   # compiler (smpiff don't exist at configure time).
24   include(CMakeForceCompiler)
25   if(NOT COMMAND CMAKE_FORCE_Fortran_COMPILER)
26     MACRO(CMAKE_FORCE_Fortran_COMPILER compiler id)
27       SET(CMAKE_Fortran_COMPILER "${compiler}")
28       SET(CMAKE_Fortran_COMPILER_ID_RUN TRUE)
29       SET(CMAKE_Fortran_COMPILER_ID ${id})
30       SET(CMAKE_Fortran_COMPILER_WORKS TRUE)
31       SET(CMAKE_Fortran_COMPILER_FORCED TRUE)
32
33       # Set old compiler id variables.
34       IF("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU")
35         SET(CMAKE_COMPILER_IS_GNUG77 1)
36       ENDIF("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU")
37     ENDMACRO(CMAKE_FORCE_Fortran_COMPILER)
38   endif()
39   CMAKE_FORCE_Fortran_COMPILER(smpiff smpiff)
40   enable_language(Fortran OPTIONAL)
41 endif()
42
43 set(CMAKE_C_FLAGS "" CACHE TYPE INTERNAL FORCE)
44 set(CMAKE_CXX_FLAGS "" CACHE TYPE INTERNAL FORCE)
45 set(CMAKE_EXE_LINKER_FLAGS "" CACHE TYPE INTERNAL FORCE)
46 set(CMAKE_C_LINK_FLAGS "" CACHE TYPE INTERNAL FORCE)
47 set(CMAKE_Fortran_FLAGS "" CACHE TYPE INTERNAL FORCE)
48 set(CMAKE_Fortran_LINK_FLAGS "" CACHE TYPE INTERNAL FORCE)
49 ## Mapping version number -> version name
50 # 3.5.99 -> alpha1 (oops)
51 # 3.5.9{1,2} -> beta{1,2}
52 # 3.5.9{3,4,5} -> rc{1,2,3}
53 # 3.6.{0,1,2} -> release 3.6, 3.6.1, 3.6.2
54 # 3.7.{0,1} -> release 3.7, 3.7.1
55 # 3.8.{0,1} -> release 3.8, 3.8.1
56 # 3.9.0 -> release 3.9
57
58 set(SIMGRID_VERSION_MAJOR "3")
59 set(SIMGRID_VERSION_MINOR "9")
60 set(SIMGRID_VERSION_PATCH "0")
61
62 if(${SIMGRID_VERSION_PATCH} EQUAL "0")
63   set(release_version "${SIMGRID_VERSION_MAJOR}.${SIMGRID_VERSION_MINOR}")
64 else()
65   set(release_version "${SIMGRID_VERSION_MAJOR}.${SIMGRID_VERSION_MINOR}.${SIMGRID_VERSION_PATCH}")
66 endif()
67 set(libsimgrid_version "${release_version}")
68 set(libsmpi_version "${release_version}")
69 set(GCC_NEED_VERSION "4.0")
70 set(APPLE_NEED_GCC_VERSION "4.6")
71
72 ### SET THE LIBRARY EXTENSION AND GCC VERSION
73 if(APPLE) #MAC
74   set(LIB_EXE "dylib")
75 else()
76   if(WIN32) #WINDOWS
77     set(LIB_EXE "a")
78     set(BIN_EXE ".exe")
79   else() #UNIX
80     set(LIB_EXE "so")
81   endif()
82 endif()
83
84 string(REGEX MATCH "gcc" GCC "${CMAKE_C_COMPILER}")
85 if(GCC)
86   exec_program("${CMAKE_C_COMPILER} --version" OUTPUT_VARIABLE "COMPILER_C_VERSION")
87   exec_program("${CMAKE_CXX_COMPILER} --version" OUTPUT_VARIABLE "COMPILER_CXX_VERSION")
88   string(REGEX MATCH "[0-9].[0-9].[0-9]" COMPILER_C_VERSION "${COMPILER_C_VERSION}")
89   string(REGEX MATCH "[0-9].[0-9].[0-9]" COMPILER_CXX_VERSION "${COMPILER_CXX_VERSION}")
90
91   string(REGEX MATCH "^[0-9].[0-9]" COMPILER_C_VERSION_MAJOR_MINOR "${COMPILER_C_VERSION}")
92   string(REPLACE "${COMPILER_C_VERSION_MAJOR_MINOR}." "" COMPILER_C_VERSION_PATCH "${COMPILER_C_VERSION}")
93
94   if(${GCC_NEED_VERSION} GREATER  COMPILER_C_VERSION_MAJOR_MINOR)
95     message(FATAL_ERROR "Gcc must be to version ${GCC_NEED_VERSION} current version ${COMPILER_C_VERSION_MAJOR_MINOR}")
96   endif()
97 endif()
98
99 string(REGEX MATCH "cl.exe" VBC "${CMAKE_C_COMPILER}")
100 if(VBC)
101   message(FATAL_ERROR "VB is not yet supported by Simgrid.")
102 endif()
103
104 ### Find programs and paths
105 FIND_PROGRAM(GCOV_PATH gcov)
106 include(FindPerl)
107 if(NOT PERL_EXECUTABLE)
108   message(FATAL_ERROR "-- SimGrid cannot be compiled without Perl installed -- sorry. Bailling out.")
109 endif()
110
111 ### Set some variables for Cmake
112 SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
113
114 set(INCLUDES
115   ${CMAKE_HOME_DIRECTORY}
116   ${CMAKE_HOME_DIRECTORY}/include
117   ${CMAKE_HOME_DIRECTORY}/src
118   ${CMAKE_HOME_DIRECTORY}/src/include
119   ${CMAKE_BINARY_DIR}
120   ${CMAKE_BINARY_DIR}/include
121   ${CMAKE_BINARY_DIR}/src
122   )
123
124 if(WIN32)
125   set(INCLUDES ${INCLUDES} ${CMAKE_HOME_DIRECTORY}/include/xbt ${CMAKE_HOME_DIRECTORY}/src/xbt) #for win32_ucontext.[ch]
126 endif()
127 set(CMAKE_SOURCE_DIR ${PROJECT_SOURCE_DIRECTORY})
128
129 if(NOT CMAKE_CROSSCOMPILING AND EXISTS /usr/include/)
130   set(INCLUDES ${INCLUDES} /usr/include/)
131 endif()
132
133 ### Check 32bits or 64bits
134 INCLUDE (CheckTypeSize)
135 CHECK_TYPE_SIZE("void*" SIZEOF_VOIDSTAR)
136 IF(SIZEOF_VOIDSTAR EQUAL 4)
137   SET(ARCH_32_BITS 1)
138 ELSE()
139   SET(ARCH_32_BITS 0)
140 ENDIF()
141
142 if(WIN32)
143
144   #Need env INCLUDE
145   set(CMAKE_INCLUDE_WIN "${CMAKE_C_COMPILER}")
146   set(CMAKE_LIB_WIN "${CMAKE_C_COMPILER}")
147   string(REGEX REPLACE "/bin/gcc.*" "/include"  CMAKE_INCLUDE_WIN "${CMAKE_INCLUDE_WIN}")
148   string(REGEX REPLACE "/bin/gcc.*" "/lib"  CMAKE_LIB_WIN "${CMAKE_LIB_WIN}")
149   set(INCLUDES ${INCLUDES} ${CMAKE_INCLUDE_WIN})
150
151   if(CMAKE_COMPILER_IS_GNUCC)
152     set(__GNUC__ 1)
153     exec_program("${CMAKE_C_COMPILER} --version" OUTPUT_VARIABLE "COMPILER_C_VERSION")
154     string(REGEX MATCH "[0-9].[0-9].[0-9]" COMPILER_C_VERSION "${COMPILER_C_VERSION}")
155     string(REGEX MATCH "^[0-9]" COMPILER_C_MAJOR_VERSION "${COMPILER_C_VERSION}")
156     string(REGEX MATCH "^[0-9].[0-9]" COMPILER_C_MINOR_VERSION "${COMPILER_C_VERSION}")
157     string(REGEX REPLACE "^${COMPILER_C_MAJOR_VERSION}." "" COMPILER_C_MINOR_VERSION "${COMPILER_C_MINOR_VERSION}")
158     if(COMPILER_C_MAJOR_VERSION)
159       # set(__GNUC__ ${COMPILER_C_MAJOR_VERSION})
160     endif()
161     if(COMPILER_C_MINOR_VERSION)
162       # set(__GNUC_MINOR__ ${COMPILER_C_MINOR_VERSION})
163     endif()
164     set(MSVC 0)
165     set(BORLAND 0)
166   else()
167     message(FATAL_ERROR "Please use MinGW to compile SimGrid!")
168   endif()
169
170   if(ARCH_32_BITS)      ### Arch 32bits
171     set(_WIN32 1)
172   else()        ### Arch 64bits
173     set(_WIN64 1)
174   endif()
175
176   set(NSIS_WIN_VERSION $ENV{PROCESSOR_ARCHITEW6432})
177   if(NSIS_WIN_VERSION MATCHES "")
178     set(NSIS_WIN_VERSION $ENV{PROCESSOR_ARCHITECTURE})
179   endif()
180   string(TOLOWER ${NSIS_WIN_VERSION} NSIS_WIN_VERSION)
181
182   set(_XBT_WIN32 1)
183
184   message(STATUS "C_COMPILER                    ${CMAKE_C_COMPILER} ${COMPILER_C_VERSION}")
185   message(STATUS "CXX_COMPILER                  ${CMAKE_CXX_COMPILER} ${COMPILER_CXX_VERSION}")
186   message(STATUS "CMAKE_RC_COMPILER             ${CMAKE_RC_COMPILER}")
187   message(STATUS "INCLUDE                       ${CMAKE_INCLUDE_WIN}")
188   message(STATUS "LIB                           ${CMAKE_LIB_WIN}")
189   message(STATUS "MAKE_PROGRAM                  ${CMAKE_MAKE_PROGRAM}")
190   message(STATUS "CMAKE_BUILD_TOOL              ${CMAKE_BUILD_TOOL}")
191   message(STATUS "LINKER                        ${CMAKE_LINKER}")
192   message(STATUS "CMAKE_GENERATOR               ${CMAKE_GENERATOR}")
193   message(STATUS "BORLAND                       ${BORLAND}")
194   message(STATUS "VISUALC                       ${MSVC}")
195   message(STATUS "GNUC                          ${CMAKE_COMPILER_IS_GNUCC}")
196
197 endif()
198
199 include_directories(${INCLUDES})
200
201 ### Determine the assembly flavor that we need today
202 include(CMakeDetermineSystem)
203 set(PROCESSOR_${CMAKE_SYSTEM_PROCESSOR} 1)
204
205 ### Setup Options
206 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Option.cmake)
207
208 ### Make the *.h files with *.h.in files
209 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/CompleteInFiles.cmake)
210
211 ### Define source packages for Libs
212 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/DefinePackages.cmake)
213
214 ### Build some Maintainer files
215 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MaintainerMode.cmake)
216 if(NOT WIN32)
217   include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/UnitTesting.cmake)
218 endif()
219
220 ### Setup gcc flags
221 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Flags.cmake)
222
223 ### Make Libs
224 if(NOT WIN32)
225   include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeLib.cmake)
226 else()
227   include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeLibWin.cmake)
228 endif()
229
230 ### Make Exes
231 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeExe.cmake)
232
233 ### Make tests
234 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/AddTests.cmake)
235 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/CTestConfig.cmake)
236
237 ### Setup the distrib
238 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Distrib.cmake)
239
240 ### Pipol compilation
241 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Pipol.cmake)
242
243 ### Build the doc
244 if(NOT WIN32)
245   include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/GenerateDoc.cmake)
246 else()
247   include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/GenerateDocWin.cmake)
248 endif()
249
250 ### Print ARGS
251 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/PrintArgs.cmake)
252
253 INCLUDE(Dart)