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