]> Creatis software - cpPlugins.git/blobdiff - CMakeLists.txt
merge async example
[cpPlugins.git] / CMakeLists.txt
index 93dd1ef88a9b4d8c4f99a417e33e5ae7f2e6dfb4..fd4ebea50ad78735129b0ce6751b1a68d9a7f147 100644 (file)
@@ -6,6 +6,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 
 SET(
   policies
+  CMP0015
   CMP0020
   CMP0042
   )
@@ -35,10 +36,32 @@ SET(
 OPTION(USE_QT4 "Build Qt4-based code" OFF)
 OPTION(BUILD_EXAMPLES "Build examples" OFF)
 
+OPTION(BUILD_SHARED_LIBRARIES "Build libraries as shared" OFF)
+IF(BUILD_SHARED_LIBRARIES)
+  SET(LIBRARY_TYPE SHARED)
+ELSE(BUILD_SHARED_LIBRARIES)
+  SET(LIBRARY_TYPE STATIC)
+ENDIF(BUILD_SHARED_LIBRARIES)
+
 ## ========================
 ## = Packages and options =
 ## ========================
 
+# NOTE: It seems that by default on Visual Studio Compiler supports c++11,
+# so it only need to be test on other O.S.
+IF(NOT MSVC)
+  INCLUDE(CheckCXXCompilerFlag)
+  CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
+  CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
+  IF(COMPILER_SUPPORTS_CXX11)
+    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+  ELSEIF(COMPILER_SUPPORTS_CXX0X)
+    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
+  ELSE()
+    MESSAGE(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
+  ENDIF()
+ENDIF(NOT MSVC)
+
 # Prepare header to build shared libs (windows)
 INCLUDE(GenerateExportHeader)
 
@@ -82,7 +105,7 @@ ENDIF(USE_QT4)
 ## ================================================
 
 IF(PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR})
-  MESSAGE(FATAL_ERROR "Building in the source tree is not allowed")
+  MESSAGE(FATAL_ERROR "Building in the source tree is not allowed.")
 ENDIF(PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR})
 
 ## =====================================
@@ -115,6 +138,22 @@ IF(WIN32 OR APPLE)
     )
 ENDIF(WIN32 OR APPLE)
 
+## =======================
+## = Local bash commands =
+## =======================
+SET(
+  bash_PROGRAMS
+  cpPlugins_createHost
+  )
+
+FOREACH(prog ${bash_PROGRAMS})
+  IF(MSVC)
+    SET(${prog}_APP ${PROJECT_BINARY_DIR}/$(ConfigurationName)/${prog})
+  ELSE(MSVC)
+    SET(${prog}_APP ${PROJECT_BINARY_DIR}/${prog})
+  ENDIF(MSVC)
+ENDFOREACH(prog)
+
 ## ===========================
 ## = Subdirs containing code =
 ## ===========================