]> Creatis software - FrontAlgorithms.git/blob - cmake/fpaBaseConfig.cmake
4e9cb2505de8a3618cce0998c3a4099396590519
[FrontAlgorithms.git] / cmake / fpaBaseConfig.cmake
1 ## =========================================================
2 ## == If working on a MacOSX, activate the use of RPATH's ==
3 ## =========================================================
4
5 set(EXECUTABLE_TYPE "" CACHE STRING "Executable linking." FORCE)
6 if(APPLE)
7   set(EXECUTABLE_TYPE "MACOSX_BUNDLE" CACHE STRING "Executable linking." FORCE)
8   set(CMAKE_MACOSX_RPATH true CACHE BOOL "Use RPATH's on MacOSX systems." FORCE)
9   mark_as_advanced(CMAKE_MACOSX_RPATH)
10 elseif(WIN32)
11   set(EXECUTABLE_TYPE "WIN32" CACHE STRING "Executable linking." FORCE)
12 endif(APPLE)
13 mark_as_advanced(EXECUTABLE_TYPE)
14
15 ## =======================================================================
16 ## == Force c++11 language version                                      ==
17 ## == NOTE: It seems that by default on Visual Studio Compiler supports ==
18 ## ==       c++11, so it only need to be tested on other OS.            ==
19 ## =======================================================================
20
21 if(NOT MSVC)
22   include(CheckCXXCompilerFlag)
23   check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11)
24   if(COMPILER_SUPPORTS_CXX11)
25     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
26   else(COMPILER_SUPPORTS_CXX11)
27     check_cxx_compiler_flag("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
28     if(COMPILER_SUPPORTS_CXX0X)
29       set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
30     else(COMPILER_SUPPORTS_CXX0X)
31       message(
32         FATAL_ERROR
33         "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support."
34         )
35     endif(COMPILER_SUPPORTS_CXX0X)
36   endif(COMPILER_SUPPORTS_CXX11)
37 endif(NOT MSVC)
38
39 ## ===================================================
40 ## == Prepare header generator to build shared libs ==
41 ## ===================================================
42
43 include(GenerateExportHeader)
44
45 ## ==================================================
46 ## == Do not allow to build inside the source tree ==
47 ## ==================================================
48
49 if(PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR})
50   message(FATAL_ERROR "Building in the source tree is not allowed.")
51 endif(PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR})
52
53 ## =================================================
54 ## == Where to put targets (executables and libs) ==
55 ## =================================================
56
57 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})
58 set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR})
59 mark_as_advanced(
60   CMAKE_BACKWARDS_COMPATIBILITY
61   EXECUTABLE_OUTPUT_PATH
62   LIBRARY_OUTPUT_PATH
63   )
64
65 ## eof - $RCSfile$