]> Creatis software - FrontAlgorithms.git/blob - cmake/fpaBaseConfig.cmake
3fdc8ab5569efd9b133906e7d6ccb12c54c7d51a
[FrontAlgorithms.git] / cmake / fpaBaseConfig.cmake
1 ## =======================================================================
2 ## == Force c++11 language version                                      ==
3 ## == NOTE: It seems that by default on Visual Studio Compiler supports ==
4 ## ==       c++11, so it only need to be tested on other OS.            ==
5 ## =======================================================================
6
7 if(NOT MSVC)
8   include(CheckCXXCompilerFlag)
9   check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11)
10   if(COMPILER_SUPPORTS_CXX11)
11     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
12   else(COMPILER_SUPPORTS_CXX11)
13     check_cxx_compiler_flag("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
14     if(COMPILER_SUPPORTS_CXX0X)
15       set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
16     else(COMPILER_SUPPORTS_CXX0X)
17       message(
18         FATAL_ERROR
19         "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support."
20         )
21     endif(COMPILER_SUPPORTS_CXX0X)
22   endif(COMPILER_SUPPORTS_CXX11)
23 endif(NOT MSVC)
24
25 ## ===================================================
26 ## == Prepare header generator to build shared libs ==
27 ## ===================================================
28
29 include(GenerateExportHeader)
30
31 ## ==================================================
32 ## == Do not allow to build inside the source tree ==
33 ## ==================================================
34
35 if(PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR})
36   message(FATAL_ERROR "Building in the source tree is not allowed.")
37 endif(PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR})
38
39 ## =================================================
40 ## == Where to put targets (executables and libs) ==
41 ## =================================================
42
43 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})
44 set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR})
45 mark_as_advanced(
46   CMAKE_BACKWARDS_COMPATIBILITY
47   EXECUTABLE_OUTPUT_PATH
48   LIBRARY_OUTPUT_PATH
49   )
50
51 ## eof - $RCSfile$