Logo AND Algorithmique Numérique Distribuée

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