Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update pipol files
[simgrid.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.6)
2 project(simgrid CXX C)
3 set(CMAKE_C_FLAGS "" CACHE TYPE INTERNAL FORCE)
4 set(CMAKE_CXX_FLAGS "" CACHE TYPE INTERNAL FORCE)
5 set(CMAKE_EXE_LINKER_FLAGS "" CACHE TYPE INTERNAL FORCE)
6 set(release_version "3.5")
7 set(libsimgrid_version "${release_version}")
8 set(libgras_version "${release_version}")
9 set(libsmpi_version "${release_version}")
10
11 ### Find programs and paths
12 FIND_PROGRAM(GCOV_PATH gcov)
13 FIND_PROGRAM(VALGRIND_PATH valgrind)
14 include(FindPerl)
15 if(NOT PERL_EXECUTABLE)
16         message(FATAL_ERROR "-- SimGrid cannot be compiled without Perl installed -- sorry. Bailling out.")
17 endif(NOT PERL_EXECUTABLE)
18
19 if(NOT WIN32)
20         exec_program("${CMAKE_COMMAND} -E chdir \"${CMAKE_HOME_DIRECTORY}\" pwd -LP" OUTPUT_VARIABLE TRUE_CMAKE_HOME_DIRECTORY)
21         if(${TRUE_CMAKE_HOME_DIRECTORY} STREQUAL ${CMAKE_HOME_DIRECTORY})
22         else(${TRUE_CMAKE_HOME_DIRECTORY} STREQUAL ${CMAKE_HOME_DIRECTORY})
23                 message(STATUS "Change link path '${CMAKE_HOME_DIRECTORY}' to true path '${TRUE_CMAKE_HOME_DIRECTORY}'")
24                 set(CMAKE_HOME_DIRECTORY "${TRUE_CMAKE_HOME_DIRECTORY}" CACHE TYPE INTERNAL FORCE)
25                 set(CMAKE_SOURCE_DIR "${TRUE_CMAKE_HOME_DIRECTORY}" CACHE TYPE INTERNAL FORCE)
26         endif(${TRUE_CMAKE_HOME_DIRECTORY} STREQUAL ${CMAKE_HOME_DIRECTORY})
27         
28         exec_program("${CMAKE_COMMAND} -E chdir \"${CMAKE_BINARY_DIR}\" pwd -LP" OUTPUT_VARIABLE TRUE_CMAKE_BINARY_DIR)
29         if(${TRUE_CMAKE_BINARY_DIR} STREQUAL ${CMAKE_BINARY_DIR})
30         else(${TRUE_CMAKE_BINARY_DIR} STREQUAL ${CMAKE_BINARY_DIR})
31                 message(STATUS "Change link path '${CMAKE_BINARY_DIR}' to true path '${TRUE_CMAKE_BINARY_DIR}'")
32                 set(CMAKE_BINARY_DIR "${TRUE_CMAKE_BINARY_DIR}" CACHE TYPE INTERNAL FORCE)
33         endif(${TRUE_CMAKE_BINARY_DIR} STREQUAL ${CMAKE_BINARY_DIR})    
34 endif(NOT WIN32)
35
36 ### SET THE LIBRARY EXTENSION
37 if(APPLE)
38         set(LIB_EXE "dylib")
39 else(APPLE)
40     if(WIN32)
41         set(LIB_EXE "a")
42     else(WIN32)
43             set(LIB_EXE "so")
44     endif(WIN32)
45 endif(APPLE)
46
47 ### Set some variables for Cmake
48 SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
49
50 if("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_HOME_DIRECTORY}")
51         set(INCLUDES
52         ${CMAKE_HOME_DIRECTORY}
53         ${CMAKE_HOME_DIRECTORY}/include
54         ${CMAKE_HOME_DIRECTORY}/src
55         ${CMAKE_HOME_DIRECTORY}/src/include
56         )
57 else("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_HOME_DIRECTORY}")
58         set(INCLUDES
59         ${CMAKE_HOME_DIRECTORY}
60         ${CMAKE_HOME_DIRECTORY}/include
61         ${CMAKE_HOME_DIRECTORY}/src
62         ${CMAKE_HOME_DIRECTORY}/src/include
63         ${CMAKE_BINARY_DIR}
64         ${CMAKE_BINARY_DIR}/include
65         ${CMAKE_BINARY_DIR}/src
66         )
67 endif("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_HOME_DIRECTORY}")
68
69 set(INCLUDES ${INCLUDES} ${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_HOME_DIRECTORY}/src/include ${CMAKE_HOME_DIRECTORY}/src ${CMAKE_BINARY_DIR}/src)
70 if(WIN32)
71     set(INCLUDES ${INCLUDES} ${CMAKE_HOME_DIRECTORY}/include/xbt ${CMAKE_HOME_DIRECTORY}/src/xbt) #for win32_ucontext.[ch]
72 endif(WIN32)
73 set(CMAKE_SOURCE_DIR ${PROJECT_SOURCE_DIRECTORY})
74
75 if(NOT CMAKE_CROSSCOMPILING AND EXISTS /usr/include/)
76         set(INCLUDES ${INCLUDES} /usr/include/)
77 endif(NOT CMAKE_CROSSCOMPILING AND EXISTS /usr/include/)
78
79 ### Check 32bits or 64bits
80 INCLUDE (CheckTypeSize)
81 CHECK_TYPE_SIZE("long" SIZEOF_LONG)
82 IF(SIZEOF_LONG EQUAL 4)
83   SET(ARCH_32_BITS 1)
84 ELSE(SIZEOF_LONG EQUAL 4)
85   SET(ARCH_32_BITS 0)
86 ENDIF(SIZEOF_LONG EQUAL 4)
87
88 if(WIN32)
89
90         set(INCLUDES_MORE $ENV{INCLUDE})
91         string(REPLACE "\\" "/" INCLUDES_MORE "${INCLUDES_MORE}")
92         foreach(include_dir ${INCLUDES_MORE})
93             if(IS_DIRECTORY ${include_dir})
94                 string(REGEX MATCH ".*[ ].*" testoki "${include_dir}")
95                 if(testoki)
96                         string(REPLACE " " "\\ " include_dir "${include_dir}")
97                     set(INCLUDES ${INCLUDES} \"${include_dir}\")
98                 else(testoki)
99                     set(INCLUDES ${INCLUDES} ${include_dir})
100                 endif(testoki)
101             else(IS_DIRECTORY ${include_dir})
102                 message(FATAL_ERROR "${include_dir} not find")
103             endif(IS_DIRECTORY ${include_dir})
104         endforeach(include_dir ${INCLUDES_MORE})
105
106     if(BORLAND)                 ### BORLAND COMPILER
107             set(__BORLANDC__ 1)
108             set(CMAKE_COMPILER_IS_GNUCC 0)
109             set(MSVC 0)
110             set(_XBT_BORLANDC_COMPILER 1)
111     endif(BORLAND)
112     
113     if(MSVC)    ### MicroSoftVisualC COMPILER
114             set(__VISUALC__ 1)
115             set(BORLAND 0)
116             set(CMAKE_COMPILER_IS_GNUCC 0)
117             set(_XBT_VISUALC_COMPILER 1)
118             set(_MSC_VER 1)
119         set(__STRICT_ANSI__ 1)
120         set(_M_IX86 1)
121     endif(MSVC)
122     
123     if(CMAKE_COMPILER_IS_GNUCC)
124         set(__GNUC__ 1)
125         exec_program("${CMAKE_C_COMPILER} --version" OUTPUT_VARIABLE "COMPILER_C_VERSION")
126         string(REGEX MATCH "[0-9].[0-9].[0-9]" COMPILER_C_VERSION "${COMPILER_C_VERSION}")
127         string(REGEX MATCH "^[0-9]" COMPILER_C_MAJOR_VERSION "${COMPILER_C_VERSION}")
128         string(REGEX MATCH "^[0-9].[0-9]" COMPILER_C_MINOR_VERSION "${COMPILER_C_VERSION}")
129         string(REGEX REPLACE "^${COMPILER_C_MAJOR_VERSION}." "" COMPILER_C_MINOR_VERSION "${COMPILER_C_MINOR_VERSION}")
130         if(COMPILER_C_MAJOR_VERSION)
131            # set(__GNUC__ ${COMPILER_C_MAJOR_VERSION})
132         endif(COMPILER_C_MAJOR_VERSION)
133         if(COMPILER_C_MINOR_VERSION)
134            # set(__GNUC_MINOR__ ${COMPILER_C_MINOR_VERSION})
135         endif(COMPILER_C_MINOR_VERSION)
136         set(MSVC 0)
137             set(BORLAND 0)
138     endif(CMAKE_COMPILER_IS_GNUCC)
139     
140     if(ARCH_32_BITS)    ### Arch 32bits
141         set(_WIN32 1)
142     else(ARCH_32_BITS)  ### Arch 64bits
143         set(_WIN64 1)
144     endif(ARCH_32_BITS)
145     
146     set(_XBT_WIN32 1)
147     
148     message(STATUS "C_COMPILER                  $ENV{CC}")
149     message(STATUS "CXX_COMPILER                        $ENV{CXX}")    
150     message(STATUS "INCLUDE                     $ENV{INCLUDE}")
151     message(STATUS "LIB                         $ENV{LIB}")
152     message(STATUS "MAKE_PROGRAM                        ${CMAKE_MAKE_PROGRAM}")
153     message(STATUS "CMAKE_BUILD_TOOL            ${CMAKE_BUILD_TOOL}")
154     message(STATUS "LINKER                      ${CMAKE_LINKER}")
155     message(STATUS "CMAKE_GENERATOR             ${CMAKE_GENERATOR}")
156     message(STATUS "BORLAND                     ${BORLAND}")
157     message(STATUS "VISUALC                     ${MSVC}")
158     message(STATUS "GNUC                                ${CMAKE_COMPILER_IS_GNUCC}")
159    
160 endif(WIN32)
161
162 include_directories(${INCLUDES})
163
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 Simgrid.jar and Java examples
198 if(HAVE_JAVA)
199         include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeJava.cmake)
200 endif(HAVE_JAVA)
201
202 ### Make tests
203 if(NOT WIN32)
204 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/AddTests.cmake)
205 else(NOT WIN32)
206
207 endif(NOT WIN32)
208
209 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/CTestConfig.cmake)
210
211 ### Setup the distrib
212 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Distrib.cmake)
213
214 ### Pipol compilation
215 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Pipol.cmake)
216
217 if(NOT WIN32)
218 ### Build the doc
219 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/GenerateDoc.cmake)
220 endif(NOT WIN32)
221 ### Print ARGS
222 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/PrintArgs.cmake)
223
224 INCLUDE(Dart)