]> Creatis software - FrontAlgorithms.git/blobdiff - cmake/fpaBaseConfig.cmake
...
[FrontAlgorithms.git] / cmake / fpaBaseConfig.cmake
diff --git a/cmake/fpaBaseConfig.cmake b/cmake/fpaBaseConfig.cmake
new file mode 100644 (file)
index 0000000..4e9cb25
--- /dev/null
@@ -0,0 +1,65 @@
+## =========================================================
+## == If working on a MacOSX, activate the use of RPATH's ==
+## =========================================================
+
+set(EXECUTABLE_TYPE "" CACHE STRING "Executable linking." FORCE)
+if(APPLE)
+  set(EXECUTABLE_TYPE "MACOSX_BUNDLE" CACHE STRING "Executable linking." FORCE)
+  set(CMAKE_MACOSX_RPATH true CACHE BOOL "Use RPATH's on MacOSX systems." FORCE)
+  mark_as_advanced(CMAKE_MACOSX_RPATH)
+elseif(WIN32)
+  set(EXECUTABLE_TYPE "WIN32" CACHE STRING "Executable linking." FORCE)
+endif(APPLE)
+mark_as_advanced(EXECUTABLE_TYPE)
+
+## =======================================================================
+## == Force c++11 language version                                      ==
+## == NOTE: It seems that by default on Visual Studio Compiler supports ==
+## ==       c++11, so it only need to be tested on other OS.            ==
+## =======================================================================
+
+if(NOT MSVC)
+  include(CheckCXXCompilerFlag)
+  check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11)
+  if(COMPILER_SUPPORTS_CXX11)
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+  else(COMPILER_SUPPORTS_CXX11)
+    check_cxx_compiler_flag("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
+    if(COMPILER_SUPPORTS_CXX0X)
+      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
+    else(COMPILER_SUPPORTS_CXX0X)
+      message(
+        FATAL_ERROR
+        "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support."
+        )
+    endif(COMPILER_SUPPORTS_CXX0X)
+  endif(COMPILER_SUPPORTS_CXX11)
+endif(NOT MSVC)
+
+## ===================================================
+## == Prepare header generator to build shared libs ==
+## ===================================================
+
+include(GenerateExportHeader)
+
+## ==================================================
+## == Do not allow to build inside the source tree ==
+## ==================================================
+
+if(PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR})
+  message(FATAL_ERROR "Building in the source tree is not allowed.")
+endif(PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR})
+
+## =================================================
+## == Where to put targets (executables and libs) ==
+## =================================================
+
+set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})
+set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR})
+mark_as_advanced(
+  CMAKE_BACKWARDS_COMPATIBILITY
+  EXECUTABLE_OUTPUT_PATH
+  LIBRARY_OUTPUT_PATH
+  )
+
+## eof - $RCSfile$