Logo AND Algorithmique Numérique Distribuée

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