X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7b1fc0f924fa51df7858aef51a9776452a1b26dd..3d845df082d79ab89649c1a8829eea201ae01085:/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index c7571e1687..105c070e62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 2.6) +# Java requires 2.8.6 -project(SimGrid C) +project(SimGrid C CXX) #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# # Check for the compiler # @@ -10,61 +11,57 @@ project(SimGrid C) if(WIN32) SET(CMAKE_RC_COMPILER "windres") endif() + ## ## Check the C/C++ standard that we need ## See also tools/cmake/Flags.cmake that sets our paranoid warning flags - -enable_language(CXX) - -INCLUDE(CheckCCompilerFlag) -CHECK_C_COMPILER_FLAG(-fstack-cleaner HAVE_C_STACK_CLEANER) - -## Request full debugging flags -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3") -set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g") - -if (CMAKE_COMPILER_IS_GNUCC) - if (COMPILER_CXX_VERSION_MAJOR_MINOR STRLESS "4.7") - message(FATAL_ERROR - "SimGrid needs at least g++ version 4.7 to compile " - "(c++11 support of previous versions is too limited).") +if (MSVC) + message("-- You are compiling SimGrid with MicroSoft Visual C. Good luck.") +else() # gcc or clang + INCLUDE(CheckCCompilerFlag) + CHECK_C_COMPILER_FLAG(-fstack-cleaner HAVE_C_STACK_CLEANER) + + ## Request full debugging flags + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g") + + if (CMAKE_COMPILER_IS_GNUCC) + if (COMPILER_CXX_VERSION_MAJOR_MINOR STRLESS "4.7") + message(FATAL_ERROR + "SimGrid needs at least g++ version 4.7 to compile " + "(c++11 support of previous versions is too limited).") + endif() endif() - if(COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.8") - set (CMAKE_AR gcc-ar) - set (CMAKE_RANLIB gcc-ranlib) + ## We need a decent support of the c++11 standard + include(CheckCXXCompilerFlag) + CHECK_CXX_COMPILER_FLAG("-std=gnu++11" COMPILER_SUPPORTS_CXX11) + if(COMPILER_SUPPORTS_CXX11) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") + else() + message(FATAL_ERROR + "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. " + "Please use a decent C++ compiler.") endif() -endif() - -## We need a decent support of the c++11 standard -include(CheckCXXCompilerFlag) -CHECK_CXX_COMPILER_FLAG("-std=gnu++11" COMPILER_SUPPORTS_CXX11) -if(COMPILER_SUPPORTS_CXX11) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") -else() - message(FATAL_ERROR - "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. " - "Please use a decent C++ compiler.") -endif() - -### And we need C11 standard, too -include(CheckCCompilerFlag) -CHECK_C_COMPILER_FLAG("-std=gnu11" COMPILER_SUPPORTS_C11) -if(COMPILER_SUPPORTS_C11) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11") -else() - message(FATAL_ERROR - "The compiler ${CMAKE_C_COMPILER} has no C11 support. " - "Please use a decent C compiler " - "(note that c++11 support of ${CMAKE_CXX_COMPILER} seems ok).") -endif() -if(APPLE AND ("4.6" GREATER COMPILER_C_VERSION_MAJOR_MINOR)) - ### gcc 4.[1-5] cannot compile ucontext on OSX - message(STATUS "Ucontext can't be used with this version of gcc (must be greater than 4.5)") - set(HAVE_UCONTEXT_H 0) -endif() + ### And we need C11 standard, too + include(CheckCCompilerFlag) + CHECK_C_COMPILER_FLAG("-std=gnu11" COMPILER_SUPPORTS_C11) + if(COMPILER_SUPPORTS_C11) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11") + else() + message(FATAL_ERROR + "The compiler ${CMAKE_C_COMPILER} has no C11 support. " + "Please use a decent C compiler " + "(note that c++11 support of ${CMAKE_CXX_COMPILER} seems ok).") + endif() + if(APPLE AND ("4.6" GREATER COMPILER_C_VERSION_MAJOR_MINOR)) + ### gcc 4.[1-5] cannot compile ucontext on OSX + message(STATUS "Ucontext can't be used with this version of gcc (must be greater than 4.5)") + set(HAVE_UCONTEXT_H 0) + endif() +endif() # NOT MSVC ### SMPI vs. Fortran if ((NOT DEFINED enable_smpi OR enable_smpi) AND NOT APPLE) # smpi is enabled by default @@ -140,11 +137,6 @@ endif() exec_program("${CMAKE_LINKER} --version" OUTPUT_VARIABLE "LINKER_VERSION") string(REGEX MATCH "[0-9].[0-9]*" LINKER_VERSION "${LINKER_VERSION}") -string(REGEX MATCH "cl.exe" VBC "${CMAKE_C_COMPILER}") -if(VBC) - message("VB is not yet supported by Simgrid. Proceed with extrem caution") -endif() - ### Find programs and paths FIND_PROGRAM(GCOV_PATH gcov) include(FindPerl) @@ -210,14 +202,6 @@ if(WIN32) if(COMPILER_C_MINOR_VERSION) # set(__GNUC_MINOR__ ${COMPILER_C_MINOR_VERSION}) endif() - else() - message("You REALLY should use MinGW to compile SimGrid on Windows!") - endif() - - if(ARCH_32_BITS) ### Arch 32bits - set(_WIN32 1) - else() ### Arch 64bits - set(_WIN64 1) endif() set(NSIS_WIN_VERSION $ENV{PROCESSOR_ARCHITEW6432}) @@ -258,8 +242,10 @@ include(${CMAKE_HOME_DIRECTORY}/tools/cmake/DefinePackages.cmake) include(${CMAKE_HOME_DIRECTORY}/tools/cmake/MaintainerMode.cmake) include(${CMAKE_HOME_DIRECTORY}/tools/cmake/UnitTesting.cmake) -### Setup gcc flags -include(${CMAKE_HOME_DIRECTORY}/tools/cmake/Flags.cmake) +### Setup gcc & clang flags +if (NOT MSVC) + include(${CMAKE_HOME_DIRECTORY}/tools/cmake/Flags.cmake) +endif() ### Make Libs if(NOT WIN32) @@ -268,6 +254,10 @@ else() include(${CMAKE_HOME_DIRECTORY}/tools/cmake/MakeLibWin.cmake) endif() +if(enable_java) + include(${CMAKE_HOME_DIRECTORY}/tools/cmake/MakeJava.cmake) +endif() + ### Make Exes include(${CMAKE_HOME_DIRECTORY}/tools/cmake/MakeExe.cmake)