Logo AND Algorithmique Numérique Distribuée

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