]> Creatis software - cpPlugins.git/blobdiff - CMakeLists.txt
...
[cpPlugins.git] / CMakeLists.txt
index c64dad95d30951c6b8b91a26644829d4a2fe0575..16233ddf8ac8e1a01f283964e2cf3094fe9fdef1 100644 (file)
@@ -1,8 +1,20 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 
-IF(POLICY CMP0020)
-  CMAKE_POLICY(SET CMP0020 NEW)
-ENDIF(POLICY CMP0020)
+## ============
+## = Policies =
+## ============
+
+SET(
+  policies
+  CMP0015
+  CMP0020
+  CMP0042
+  )
+FOREACH(policy ${policies})
+  IF(POLICY ${policy})
+    CMAKE_POLICY(SET ${policy} NEW)
+  ENDIF(POLICY ${policy})
+ENDFOREACH(policy)
 
 ## ================
 ## = Project name =
@@ -28,36 +40,42 @@ OPTION(BUILD_EXAMPLES "Build examples" OFF)
 ## = Packages and options =
 ## ========================
 
+# Prepare header to build shared libs (windows)
 INCLUDE(GenerateExportHeader)
 
+# Find ITK and VTK
 FIND_PACKAGE(ITK REQUIRED)
-INCLUDE(${ITK_USE_FILE})
-
 FIND_PACKAGE(VTK REQUIRED)
+
+INCLUDE(${ITK_USE_FILE})
 INCLUDE(${VTK_USE_FILE})
 
+# Do not use itk-vtk glue --> problems ahead!!!
 IF(ITKVtkGlue_LOADED)
   MESSAGE(FATAL_ERROR "ITKVtkGlue module is available. Please re-compile your ITK without it. It could lead to nasty compilation problems... Just waiting for Kitware to solve it.")
 ENDIF(ITKVtkGlue_LOADED)
 
-
+SET(QT4_FOUND "0")
 IF(USE_QT4)
   FIND_PACKAGE(Qt4 REQUIRED)
   INCLUDE(${QT_USE_FILE})
 
-  ## Check for required modules
-  IF(NOT vtkGUISupportQt_LOADED)
-    MESSAGE(
-      FATAL_ERROR
-      "vtkGUISupportQt module is required but not available."
-      )
-  ENDIF(NOT vtkGUISupportQt_LOADED)
-  IF(NOT vtkGUISupportQtOpenGL_LOADED)
-    MESSAGE(
-      FATAL_ERROR
-      "vtkGUISupportQtOpenGL module is required but not available."
-      )
-  ENDIF(NOT vtkGUISupportQtOpenGL_LOADED)
+  ## Check for required vtk-qt4 modules
+  SET(
+    vtk_required_modules
+    vtkGUISupportQt
+    vtkGUISupportQtOpenGL
+    )
+  FOREACH(vtk_module ${vtk_required_modules})
+    IF(NOT ${vtk_module}_LOADED)
+      MESSAGE(
+        FATAL_ERROR
+        "${vtk_module} module is required but not available."
+        )
+      SET(QT4_FOUND "0")
+    ENDIF(NOT ${vtk_module}_LOADED)
+  ENDFOREACH(vtk_module)
+  SET(QT4_FOUND "1")
 ENDIF(USE_QT4)
 
 ## ================================================
@@ -65,7 +83,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})
 
 ## =====================================
@@ -92,11 +110,11 @@ INCLUDE_DIRECTORIES(
   ${PROJECT_BINARY_DIR}/lib/third_party
   ${PROJECT_BINARY_DIR}/lib/third_party/ItkVtkGlue
   )
-IF(WIN32)
+IF(WIN32 OR APPLE)
   INCLUDE_DIRECTORIES(
     ${PROJECT_SOURCE_DIR}/lib/third_party/glext
     )
-ENDIF(WIN32)
+ENDIF(WIN32 OR APPLE)
 
 ## ===========================
 ## = Subdirs containing code =