Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Define correctly variables for windows.
[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_path(GCOV_PATH NAMES gcov PATHS NO_DEFAULT_PATHS)
13 find_path(VALGRIND_PATH NAMES valgrind  PATHS NO_DEFAULT_PATHS)
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         set(INCLUDES_MORE $ENV{INCLUDE})
38         string(REPLACE "\\" "/" INCLUDES_MORE "${INCLUDES_MORE}")
39         foreach(include_dir ${INCLUDES_MORE})
40                 set(INCLUDES "${INCLUDES} -I\"${include_dir}\"")
41         endforeach(include_dir ${INCLUDES_MORE})
42         message("Be sure all those variables are correctely set.")
43     message("   -- C_COMPILER                   $ENV{CC}")
44     message("   -- CXX_COMPILER                 $ENV{CXX}")    
45     message("   -- RC_COMPILER                  $ENV{RC}")
46     message("   -- INCLUDE                      $ENV{INCLUDE}")
47     message("   -- LIB                          $ENV{LIB}")
48     message("   -- MAKE_PROGRAM                 ${CMAKE_MAKE_PROGRAM}")
49     message("   -- CMAKE_BUILD_TOOL             ${CMAKE_BUILD_TOOL}")
50     message("   -- LINKER                       ${CMAKE_LINKER}")
51     message("   -- CMAKE_GENERATOR              ${CMAKE_GENERATOR}")
52     message("   -- INCLUDES                     ${INCLUDES}\n\n")
53     set(__STRICT_ANSI__ 1)
54     set(_MSC_VER 1)
55     set(_XBT_WIN32 1)
56     if(BORLAND)                 ### BORLAND COMPILER
57             set(__BORLANDC__ 1)
58             set(_XBT_BORLANDC_COMPILER 1)
59     endif(BORLAND)
60     if(MSVC_VERSION)    ### MicroSoftVisualC COMPILER
61             set(__VISUALC__ 1)
62             set(_XBT_VISUALC_COMPILER 1)
63     endif(MSVC_VERSION)  
64     if(ARCH_32_BITS)    ### Arch 32bits
65         set(_WIN32 1)
66     else(ARCH_32_BITS)  ### Arch 64bits
67         set(_WIN64 1)
68     endif(ARCH_32_BITS)
69 endif(WIN32)
70
71 add_definitions (${INCLUDES})
72
73 ### Setup Options
74 include(${PROJECT_DIRECTORY}/buildtools/Cmake/Option.cmake)
75
76 ### Make the *.h files with *.h.in files
77 include(${PROJECT_DIRECTORY}/buildtools/Cmake/CompleteInFiles.cmake)
78
79 ### Define source packages for Libs 
80 include(${PROJECT_DIRECTORY}/buildtools/Cmake/DefinePackages.cmake)
81
82 ### Build some Maintainer files
83 include(${PROJECT_DIRECTORY}/buildtools/Cmake/MaintainerMode.cmake)
84
85 ### Setup gcc flags
86 include(${PROJECT_DIRECTORY}/buildtools/Cmake/Flags.cmake)
87
88 ### Make Libs and Exes
89 include(${PROJECT_DIRECTORY}/buildtools/Cmake/MakeExeLib.cmake)
90
91 ### Build the doc
92 if(enable_doc)
93         ADD_CUSTOM_COMMAND(
94           OUTPUT ${PROJECT_DIRECTORY}/doc/html/index.html
95           DEPENDS       ${PROJECT_DIRECTORY}/doc/FAQ.doc 
96                                 ${PROJECT_DIRECTORY}/buildtools/Cmake/GenerateDoc.cmake 
97                                 ${PROJECT_DIRECTORY}/buildtools/Cmake/doc/CMakeLists.txt
98           COMMAND ${CMAKE_MAKE_PROGRAM} html
99           COMMENT "Generating the simgrid documentation..."
100         )
101         ADD_CUSTOM_TARGET(simgrid_documentation ALL
102                           DEPENDS ${PROJECT_DIRECTORY}/doc/html/index.html)
103 endif(enable_doc)
104
105 ### Make Simgrid.jar and Java examples
106 if(HAVE_JAVA)
107         include(${PROJECT_DIRECTORY}/buildtools/Cmake/MakeJava.cmake)
108 endif(HAVE_JAVA)
109
110 ### Make tests
111 include(${PROJECT_DIRECTORY}/buildtools/Cmake/AddTests.cmake)
112 include(${PROJECT_DIRECTORY}/buildtools/Cmake/CTestConfig.cmake)
113
114 ### Setup the distrib
115 include(${PROJECT_DIRECTORY}/buildtools/Cmake/Distrib.cmake)
116
117 ### Print ARGS
118 include(${PROJECT_DIRECTORY}/buildtools/Cmake/PrintArgs.cmake)
119
120 INCLUDE(Dart)