Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
333be68663537a5ab2004fb84a3df193b68881ff
[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
15 ### SET THE PROJECT_DIRECTORY
16 SET(PROJECT_DIRECTORY "${CMAKE_HOME_DIRECTORY}")
17
18 ### Set some variables for Cmake
19 SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
20 set(INCLUDES "-I${PROJECT_DIRECTORY} -I${PROJECT_DIRECTORY}/include -I${PROJECT_DIRECTORY}/src/include -I${PROJECT_DIRECTORY}/src -I${CMAKE_CURRENT_BINARY_DIR}/src/")
21 set(CMAKE_SOURCE_DIR ${PROJECT_SOURCE_DIRECTORY})
22
23 if(EXISTS /usr/include/)
24         set(INCLUDES "${INCLUDES} -I/usr/include/")
25 endif(EXISTS /usr/include/)
26
27 ### Check 32bits or 64bits
28 INCLUDE (CheckTypeSize)
29 CHECK_TYPE_SIZE("long" SIZEOF_LONG)
30 IF(SIZEOF_LONG EQUAL 4)
31   SET(ARCH_32_BITS 1)
32 ELSE(SIZEOF_LONG EQUAL 4)
33   SET(ARCH_32_BITS 0)
34 ENDIF(SIZEOF_LONG EQUAL 4)
35
36 if(WIN32)
37
38         set(INCLUDES_MORE $ENV{INCLUDE})
39         string(REPLACE "\\" "/" INCLUDES_MORE "${INCLUDES_MORE}")
40         foreach(include_dir ${INCLUDES_MORE})
41                 set(INCLUDES "${INCLUDES} -I\"${include_dir}\"")
42         endforeach(include_dir ${INCLUDES_MORE})
43         set(INCLUDES "${INCLUDES} -I${PROJECT_DIRECTORY}/include/xbt -I${PROJECT_DIRECTORY}/src/xbt") #for win32_ucontext.[ch]
44
45     if(BORLAND)                 ### BORLAND COMPILER
46             set(__BORLANDC__ 1)
47             set(CMAKE_COMPILER_IS_GNUCC 0)
48             set(MSVC 0)
49             set(_XBT_BORLANDC_COMPILER 1)
50     endif(BORLAND)
51     
52     if(MSVC)    ### MicroSoftVisualC COMPILER
53             set(__VISUALC__ 1)
54             set(BORLAND 0)
55             set(CMAKE_COMPILER_IS_GNUCC 0)
56             set(_XBT_VISUALC_COMPILER 1)
57             set(_MSC_VER 1)
58         set(__STRICT_ANSI__ 1)
59         set(_M_IX86 1)
60     endif(MSVC)
61     
62     if(CMAKE_COMPILER_IS_GNUCC)
63         set(__GNUC__ 1)
64         set(MSVC 0)
65             set(BORLAND 0)
66     endif(CMAKE_COMPILER_IS_GNUCC)
67     
68     if(ARCH_32_BITS)    ### Arch 32bits
69         set(_WIN32 1)
70     else(ARCH_32_BITS)  ### Arch 64bits
71         set(_WIN64 1)
72     endif(ARCH_32_BITS)
73     
74     set(_XBT_WIN32 1)
75     
76     message("Be sure all those variables are correctely set.")
77     message("   -- C_COMPILER                   $ENV{CC}")
78     message("   -- CXX_COMPILER                 $ENV{CXX}")    
79     message("   -- RC_COMPILER                  $ENV{RC}")
80     message("   -- INCLUDE                      $ENV{INCLUDE}")
81     message("   -- LIB                          $ENV{LIB}")
82     message("   -- MAKE_PROGRAM                 ${CMAKE_MAKE_PROGRAM}")
83     message("   -- CMAKE_BUILD_TOOL             ${CMAKE_BUILD_TOOL}")
84     message("   -- LINKER                       ${CMAKE_LINKER}")
85     message("   -- CMAKE_GENERATOR              ${CMAKE_GENERATOR}")
86     message("   -- INCLUDES                     ${INCLUDES}")
87     message("   -- BORLAND                      ${BORLAND}")
88     message("   -- VISUALC                      ${MSVC}")
89     message("   -- GNUC                         ${CMAKE_COMPILER_IS_GNUCC}\n\n")
90     
91 endif(WIN32)
92
93 add_definitions (${INCLUDES})
94
95 ### Setup Options
96 include(${PROJECT_DIRECTORY}/buildtools/Cmake/Option.cmake)
97
98 ### Make the *.h files with *.h.in files
99 include(${PROJECT_DIRECTORY}/buildtools/Cmake/CompleteInFiles.cmake)
100
101 ### Define source packages for Libs 
102 include(${PROJECT_DIRECTORY}/buildtools/Cmake/DefinePackages.cmake)
103
104 ### Build some Maintainer files
105 include(${PROJECT_DIRECTORY}/buildtools/Cmake/MaintainerMode.cmake)
106
107 ### Setup gcc flags
108 include(${PROJECT_DIRECTORY}/buildtools/Cmake/Flags.cmake)
109
110 ### Make Libs and Exes
111 if(WIN32)
112     include(${PROJECT_DIRECTORY}/buildtools/Cmake/MakeExeLibWin.cmake)
113 else(WIN32)
114     include(${PROJECT_DIRECTORY}/buildtools/Cmake/MakeExeLib.cmake)
115 endif(WIN32)
116
117 ### Build the doc
118 if(enable_doc)
119         ADD_CUSTOM_COMMAND(
120           OUTPUT ${PROJECT_DIRECTORY}/doc/html
121           DEPENDS       ${PROJECT_DIRECTORY}/doc/FAQ.doc 
122                                 ${PROJECT_DIRECTORY}/buildtools/Cmake/GenerateDoc.cmake 
123                                 ${PROJECT_DIRECTORY}/buildtools/Cmake/doc/CMakeLists.txt
124           COMMAND ${CMAKE_MAKE_PROGRAM} html
125           COMMENT "Generating the simgrid documentation..."
126         )
127         ADD_CUSTOM_TARGET(simgrid_documentation ALL
128                           DEPENDS ${PROJECT_DIRECTORY}/doc/html)
129 endif(enable_doc)
130
131 ### Make Simgrid.jar and Java examples
132 if(HAVE_JAVA)
133         include(${PROJECT_DIRECTORY}/buildtools/Cmake/MakeJava.cmake)
134 endif(HAVE_JAVA)
135
136 ### Make tests
137 if(NOT WIN32)
138 include(${PROJECT_DIRECTORY}/buildtools/Cmake/AddTests.cmake)
139 include(${PROJECT_DIRECTORY}/buildtools/Cmake/CTestConfig.cmake)
140 endif(NOT WIN32)
141
142 ### Setup the distrib
143 include(${PROJECT_DIRECTORY}/buildtools/Cmake/Distrib.cmake)
144
145 ### Pipol compilation
146 include(${PROJECT_DIRECTORY}/buildtools/Cmake/Pipol.cmake)
147
148 ### Print ARGS
149 include(${PROJECT_DIRECTORY}/buildtools/Cmake/PrintArgs.cmake)
150
151 INCLUDE(Dart)