Logo AND Algorithmique Numérique Distribuée

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