Logo AND Algorithmique Numérique Distribuée

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