+## =======================================================================
+## == 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})