Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics
[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
20 ### SET THE LIBRARY EXTENSION
21 if(APPLE)
22         set(LIB_EXE "dylib")
23 else(APPLE)
24         set(LIB_EXE "so")
25 endif(APPLE)
26
27 ### Set some variables for Cmake
28 SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
29
30 if("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_HOME_DIRECTORY}")
31         set(INCLUDES
32         ${CMAKE_HOME_DIRECTORY}
33         ${CMAKE_HOME_DIRECTORY}/include
34         ${CMAKE_HOME_DIRECTORY}/src
35         ${CMAKE_HOME_DIRECTORY}/src/include
36         )
37 else("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_HOME_DIRECTORY}")
38         set(INCLUDES
39         ${CMAKE_HOME_DIRECTORY}
40         ${CMAKE_HOME_DIRECTORY}/include
41         ${CMAKE_HOME_DIRECTORY}/src
42         ${CMAKE_HOME_DIRECTORY}/src/include
43         ${CMAKE_BINARY_DIR}
44         ${CMAKE_BINARY_DIR}/include
45         ${CMAKE_BINARY_DIR}/src
46         )
47 endif("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_HOME_DIRECTORY}")
48
49 set(INCLUDES ${INCLUDES} ${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_HOME_DIRECTORY}/src/include ${CMAKE_HOME_DIRECTORY}/src ${CMAKE_CURRENT_BINARY_DIR}/src)
50 if(WIN32)
51     set(INCLUDES ${INCLUDES} ${CMAKE_HOME_DIRECTORY}/include/xbt ${CMAKE_HOME_DIRECTORY}/src/xbt) #for win32_ucontext.[ch]
52 endif(WIN32)
53 set(CMAKE_SOURCE_DIR ${PROJECT_SOURCE_DIRECTORY})
54
55 if(NOT CMAKE_CROSSCOMPILING AND EXISTS /usr/include/)
56         set(INCLUDES ${INCLUDES} /usr/include/)
57 endif(NOT CMAKE_CROSSCOMPILING AND EXISTS /usr/include/)
58
59 ### Check 32bits or 64bits
60 INCLUDE (CheckTypeSize)
61 CHECK_TYPE_SIZE("long" SIZEOF_LONG)
62 IF(SIZEOF_LONG EQUAL 4)
63   SET(ARCH_32_BITS 1)
64 ELSE(SIZEOF_LONG EQUAL 4)
65   SET(ARCH_32_BITS 0)
66 ENDIF(SIZEOF_LONG EQUAL 4)
67
68 if(WIN32)
69
70         set(INCLUDES_MORE $ENV{INCLUDE})
71         string(REPLACE "\\" "/" INCLUDES_MORE "${INCLUDES_MORE}")
72         foreach(include_dir ${INCLUDES_MORE})
73             if(IS_DIRECTORY ${include_dir})
74                 string(REGEX MATCH ".*[ ].*" testoki "${include_dir}")
75                 if(testoki)
76                         string(REPLACE " " "\\ " include_dir "${include_dir}")
77                     set(INCLUDES ${INCLUDES} \"${include_dir}\")
78                 else(testoki)
79                     set(INCLUDES ${INCLUDES} ${include_dir})
80                 endif(testoki)
81             else(IS_DIRECTORY ${include_dir})
82                 message(FATAL_ERROR "${include_dir} not find")
83             endif(IS_DIRECTORY ${include_dir})
84         endforeach(include_dir ${INCLUDES_MORE})
85
86     if(BORLAND)                 ### BORLAND COMPILER
87             set(__BORLANDC__ 1)
88             set(CMAKE_COMPILER_IS_GNUCC 0)
89             set(MSVC 0)
90             set(_XBT_BORLANDC_COMPILER 1)
91     endif(BORLAND)
92     
93     if(MSVC)    ### MicroSoftVisualC COMPILER
94             set(__VISUALC__ 1)
95             set(BORLAND 0)
96             set(CMAKE_COMPILER_IS_GNUCC 0)
97             set(_XBT_VISUALC_COMPILER 1)
98             set(_MSC_VER 1)
99         set(__STRICT_ANSI__ 1)
100         set(_M_IX86 1)
101     endif(MSVC)
102     
103     if(CMAKE_COMPILER_IS_GNUCC)
104         set(__GNUC__ 1)
105         exec_program("${CMAKE_C_COMPILER} --version" OUTPUT_VARIABLE "COMPILER_C_VERSION")
106         string(REGEX MATCH "[0-9].[0-9].[0-9]" COMPILER_C_VERSION "${COMPILER_C_VERSION}")
107         string(REGEX MATCH "^[0-9]" COMPILER_C_MAJOR_VERSION "${COMPILER_C_VERSION}")
108         string(REGEX MATCH "^[0-9].[0-9]" COMPILER_C_MINOR_VERSION "${COMPILER_C_VERSION}")
109         string(REGEX REPLACE "^${COMPILER_C_MAJOR_VERSION}." "" COMPILER_C_MINOR_VERSION "${COMPILER_C_MINOR_VERSION}")
110         if(COMPILER_C_MAJOR_VERSION)
111            # set(__GNUC__ ${COMPILER_C_MAJOR_VERSION})
112         endif(COMPILER_C_MAJOR_VERSION)
113         if(COMPILER_C_MINOR_VERSION)
114            # set(__GNUC_MINOR__ ${COMPILER_C_MINOR_VERSION})
115         endif(COMPILER_C_MINOR_VERSION)
116         set(MSVC 0)
117             set(BORLAND 0)
118     endif(CMAKE_COMPILER_IS_GNUCC)
119     
120     if(ARCH_32_BITS)    ### Arch 32bits
121         set(_WIN32 1)
122     else(ARCH_32_BITS)  ### Arch 64bits
123         set(_WIN64 1)
124     endif(ARCH_32_BITS)
125     
126     set(_XBT_WIN32 1)
127     
128     message("Be sure all those variables are correctely set.")
129     message("   -- C_COMPILER                   $ENV{CC}")
130     message("   -- CXX_COMPILER                 $ENV{CXX}")    
131     message("   -- INCLUDE                      $ENV{INCLUDE}")
132     message("   -- LIB                          $ENV{LIB}")
133     message("   -- MAKE_PROGRAM                 ${CMAKE_MAKE_PROGRAM}")
134     message("   -- CMAKE_BUILD_TOOL             ${CMAKE_BUILD_TOOL}")
135     message("   -- LINKER                       ${CMAKE_LINKER}")
136     message("   -- CMAKE_GENERATOR              ${CMAKE_GENERATOR}")
137     message("   -- INCLUDES                     ${INCLUDES}")
138     message("   -- BORLAND                      ${BORLAND}")
139     message("   -- VISUALC                      ${MSVC}")
140     message("   -- GNUC                         ${CMAKE_COMPILER_IS_GNUCC}\n\n")
141     
142 endif(WIN32)
143
144 include_directories(${INCLUDES})
145
146
147 ### Determine the assembly flavor that we need today
148 include(CMakeDetermineSystem)
149 set(PROCESSOR_${CMAKE_SYSTEM_PROCESSOR} 1)
150
151 ### Setup Options
152 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Option.cmake)
153
154 ### Make the *.h files with *.h.in files
155 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/CompleteInFiles.cmake)
156
157 ### Define source packages for Libs 
158 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/DefinePackages.cmake)
159
160 ### Build some Maintainer files
161 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MaintainerMode.cmake)
162 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/UnitTesting.cmake)
163
164 ### Setup gcc flags
165 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Flags.cmake)
166
167 ### Make Libs and Exes
168 if(WIN32)
169     include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeExeLibWin.cmake)
170 else(WIN32)
171     include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeExeLib.cmake)
172 endif(WIN32)
173
174 ### Make Simgrid.jar and Java examples
175 if(HAVE_JAVA)
176         include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeJava.cmake)
177 endif(HAVE_JAVA)
178
179 ### Make tests
180 if(NOT WIN32)
181 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/AddTests.cmake)
182 else(NOT WIN32)
183 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/AddTestsWin.cmake)
184 endif(NOT WIN32)
185
186 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/CTestConfig.cmake)
187
188 ### Setup the distrib
189 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Distrib.cmake)
190
191 ### Pipol compilation
192 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Pipol.cmake)
193
194 ### Build the doc
195 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/GenerateDoc.cmake)
196
197 ### Print ARGS
198 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/PrintArgs.cmake)
199
200 INCLUDE(Dart)