Logo AND Algorithmique Numérique Distribuée

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