Logo AND Algorithmique Numérique Distribuée

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