Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
further doxygen cleanups
[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
8 enable_language(CXX)
9
10 INCLUDE(CheckCCompilerFlag)
11 CHECK_C_COMPILER_FLAG(-fstack-cleaner HAVE_C_STACK_CLEANER)
12
13 if (APPLE) #MAC
14   set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
15   set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
16 endif()
17
18 if ((NOT DEFINED enable_smpi OR enable_smpi) AND NOT APPLE) # smpi is enabled by default
19   # Call enable_language(Fortran) in order to load the build rules for
20   # this language, needed by teshsuite/smpi/mpich-test/.  Use
21   # CMAKE_FORCE_Fortran_COMPILER to bypass checks for a working
22   # compiler (smpiff don't exist at configure time).
23   include(CMakeForceCompiler)
24   if(NOT COMMAND CMAKE_FORCE_Fortran_COMPILER)
25     MACRO(CMAKE_FORCE_Fortran_COMPILER compiler id)
26       SET(CMAKE_Fortran_COMPILER "${compiler}")
27       SET(CMAKE_Fortran_COMPILER_ID_RUN TRUE)
28       SET(CMAKE_Fortran_COMPILER_ID ${id})
29       SET(CMAKE_Fortran_COMPILER_WORKS TRUE)
30       SET(CMAKE_Fortran_COMPILER_FORCED TRUE)
31
32       # Set old compiler id variables.
33       IF("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU")
34         SET(CMAKE_COMPILER_IS_GNUG77 1)
35       ENDIF("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU")
36     ENDMACRO(CMAKE_FORCE_Fortran_COMPILER)
37   endif()
38   CMAKE_FORCE_Fortran_COMPILER(smpiff smpiff)
39   enable_language(Fortran OPTIONAL)
40 endif()
41
42 ## Mapping version number -> version name
43 # 3.5.99 -> alpha1 (oops)
44 # 3.5.9{1,2} -> beta{1,2}
45 # 3.5.9{3,4,5} -> rc{1,2,3}
46 # 3.6.{0,1,2} -> release 3.6, 3.6.1, 3.6.2
47 # 3.7.{0,1} -> release 3.7, 3.7.1
48 # 3.8.{0,1} -> release 3.8, 3.8.1
49 # 3.9.0 -> release 3.9
50 # 3.9.90 -> release 3.10pre1
51 # 3.10.0 -> release 3.10
52 # 3.11.0 -> release 3.11
53 # 3.12.0 -> release 3.12
54
55 set(SIMGRID_VERSION_MAJOR "3")
56 set(SIMGRID_VERSION_MINOR "12")
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  "2015") # 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) 2004-${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   
101   if(COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.8")
102     set (CMAKE_AR gcc-ar)
103     set (CMAKE_RANLIB gcc-ranlib)
104   endif()
105   
106 endif()
107
108 exec_program("${CMAKE_LINKER} --version" OUTPUT_VARIABLE "LINKER_VERSION")
109 string(REGEX MATCH "[0-9].[0-9]*" LINKER_VERSION "${LINKER_VERSION}")
110
111 string(REGEX MATCH "cl.exe" VBC "${CMAKE_C_COMPILER}")
112 if(VBC)
113   message(FATAL_ERROR "VB is not yet supported by Simgrid.")
114 endif()
115
116 ### Find programs and paths
117 FIND_PROGRAM(GCOV_PATH gcov)
118 include(FindPerl)
119 if(NOT PERL_EXECUTABLE)
120   message(FATAL_ERROR "-- SimGrid cannot be compiled without Perl installed -- sorry. Bailling out.")
121 endif()
122
123 ### Set some variables for Cmake
124 SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
125
126 set(INCLUDES
127   ${CMAKE_HOME_DIRECTORY}
128   ${CMAKE_HOME_DIRECTORY}/include
129   ${CMAKE_HOME_DIRECTORY}/src
130   ${CMAKE_HOME_DIRECTORY}/src/include
131   ${CMAKE_BINARY_DIR}
132   ${CMAKE_BINARY_DIR}/include
133   ${CMAKE_BINARY_DIR}/src
134   )
135
136 if(WIN32)
137   set(INCLUDES ${INCLUDES} ${CMAKE_HOME_DIRECTORY}/include/xbt ${CMAKE_HOME_DIRECTORY}/src/xbt) #for win32_ucontext.[ch]
138 endif()
139 set(CMAKE_SOURCE_DIR ${PROJECT_SOURCE_DIRECTORY})
140
141 if(NOT CMAKE_CROSSCOMPILING AND EXISTS /usr/include/)
142   set(INCLUDES ${INCLUDES} /usr/include/)
143 endif()
144
145 ### Check 32bits or 64bits
146 INCLUDE (CheckTypeSize)
147 CHECK_TYPE_SIZE("void*" SIZEOF_VOIDSTAR)
148 IF(SIZEOF_VOIDSTAR EQUAL 4)
149   SET(ARCH_32_BITS 1)
150 ELSE()
151   SET(ARCH_32_BITS 0)
152 ENDIF()
153
154 if(WIN32)
155
156   #Need env INCLUDE
157   set(CMAKE_INCLUDE_WIN "${CMAKE_C_COMPILER}")
158   set(CMAKE_LIB_WIN "${CMAKE_C_COMPILER}")
159   string(REGEX REPLACE "/bin/gcc.*" "/include"  CMAKE_INCLUDE_WIN "${CMAKE_INCLUDE_WIN}")
160   string(REGEX REPLACE "/bin/gcc.*" "/lib"  CMAKE_LIB_WIN "${CMAKE_LIB_WIN}")
161   set(INCLUDES ${INCLUDES} ${CMAKE_INCLUDE_WIN})
162
163   if(CMAKE_COMPILER_IS_GNUCC)
164     set(__GNUC__ 1)
165     exec_program("${CMAKE_C_COMPILER} --version" OUTPUT_VARIABLE "COMPILER_C_VERSION")
166     string(REGEX MATCH "[0-9].[0-9].[0-9]" COMPILER_C_VERSION "${COMPILER_C_VERSION}")
167     string(REGEX MATCH "^[0-9]" COMPILER_C_MAJOR_VERSION "${COMPILER_C_VERSION}")
168     string(REGEX MATCH "^[0-9].[0-9]" COMPILER_C_MINOR_VERSION "${COMPILER_C_VERSION}")
169     string(REGEX REPLACE "^${COMPILER_C_MAJOR_VERSION}." "" COMPILER_C_MINOR_VERSION "${COMPILER_C_MINOR_VERSION}")
170     if(COMPILER_C_MAJOR_VERSION)
171       # set(__GNUC__ ${COMPILER_C_MAJOR_VERSION})
172     endif()
173     if(COMPILER_C_MINOR_VERSION)
174       # set(__GNUC_MINOR__ ${COMPILER_C_MINOR_VERSION})
175     endif()
176     set(MSVC 0)
177     set(BORLAND 0)
178   else()
179     message(FATAL_ERROR "Please use MinGW to compile SimGrid!")
180   endif()
181
182   if(ARCH_32_BITS)      ### Arch 32bits
183     set(_WIN32 1)
184   else()        ### Arch 64bits
185     set(_WIN64 1)
186   endif()
187
188   set(NSIS_WIN_VERSION $ENV{PROCESSOR_ARCHITEW6432})
189   if(NSIS_WIN_VERSION MATCHES "")
190     set(NSIS_WIN_VERSION $ENV{PROCESSOR_ARCHITECTURE})
191   endif()
192   if(${NSIS_WIN_VERSION})
193     string(TOLOWER ${NSIS_WIN_VERSION} NSIS_WIN_VERSION)
194   endif()
195
196   set(_XBT_WIN32 1)
197
198   message(STATUS "C_COMPILER                    ${CMAKE_C_COMPILER} ${COMPILER_C_VERSION}")
199   message(STATUS "CXX_COMPILER                  ${CMAKE_CXX_COMPILER} ${COMPILER_CXX_VERSION}")
200   message(STATUS "CMAKE_RC_COMPILER             ${CMAKE_RC_COMPILER}")
201   message(STATUS "INCLUDE                       ${CMAKE_INCLUDE_WIN}")
202   message(STATUS "LIB                           ${CMAKE_LIB_WIN}")
203   message(STATUS "MAKE_PROGRAM                  ${CMAKE_MAKE_PROGRAM}")
204   message(STATUS "CMAKE_BUILD_TOOL              ${CMAKE_BUILD_TOOL}")
205   message(STATUS "LINKER                        ${CMAKE_LINKER}")
206   message(STATUS "CMAKE_GENERATOR               ${CMAKE_GENERATOR}")
207   message(STATUS "BORLAND                       ${BORLAND}")
208   message(STATUS "VISUALC                       ${MSVC}")
209   message(STATUS "GNUC                          ${CMAKE_COMPILER_IS_GNUCC}")
210
211 endif()
212
213 include_directories(${INCLUDES})
214
215 ### Setup Options
216 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Option.cmake)
217
218 ### Make the *.h files with *.h.in files
219 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/CompleteInFiles.cmake)
220
221 ### Define source packages for Libs
222 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/DefinePackages.cmake)
223
224 ### Build some Maintainer files
225 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MaintainerMode.cmake)
226 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/UnitTesting.cmake)
227
228 ### Setup gcc flags
229 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Flags.cmake)
230
231 ### Make Libs
232 if(NOT WIN32)
233   include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeLib.cmake)
234 else()
235   include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeLibWin.cmake)
236 endif()
237
238 ### Make Exes
239 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeExe.cmake)
240
241 ### Make tests
242 if(enable_memcheck_xml)
243   set(enable_memcheck true)
244 endif()
245
246 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/AddTests.cmake)
247 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/CTestConfig.cmake)
248
249 ### Setup the distrib
250 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Distrib.cmake)
251
252 ### Pipol compilation
253 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Pipol.cmake)
254
255 ### Build the doc
256 if(NOT WIN32)
257   include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/GenerateDoc.cmake)
258 else()
259   include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/GenerateDocWin.cmake)
260 endif()
261
262 ### Print ARGS
263 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/PrintArgs.cmake)
264
265 INCLUDE(Dart)