]> Creatis software - cpPlugins.git/blobdiff - CMakeLists.txt
...
[cpPlugins.git] / CMakeLists.txt
index d1dc9edefcf3cd2508043fa157506d017e699e24..ea9d71a0d4a2c4a378dbfaa0e3455141d46850a0 100644 (file)
@@ -1,75 +1,73 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
+## =========================================================================
+## @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
+## =========================================================================
 
-## ========================
-## == Project definition ==
-## ========================
+cmake_minimum_required(VERSION 3.0)
 
-SET(prj_NAME cpPlugins)
-SET(prj_MAJOR_VERSION   0)
-SET(prj_MINOR_VERSION   1)
-SET(prj_RELEASE_VERSION 0)
+## == Basic project configuration
+set(prj_NAME cpPlugins)
+set(prj_MAJ 1)
+set(prj_MIN 0)
+set(prj_REL 0)
 
-## ==========================
-## == Some useful policies ==
-## ==========================
+## == Project definition
+project(${prj_NAME} VERSION "${prj_MAJ}.${prj_MIN}.${prj_REL}")
 
-SET(_policies CMP0015 CMP0020 CMP0042)
-FOREACH(_p ${_policies})
-  IF(POLICY ${_p})
-    CMAKE_POLICY(SET ${_p} NEW)
-  ENDIF(POLICY ${_p})
-ENDFOREACH(_p)
+## == Project policies
+set(_new_policies CMP0015 CMP0020 CMP0042 CMP0053)
+set(_old_policies CMP0006)
+foreach(_p ${_new_policies})
+  if(POLICY ${_p})
+    cmake_policy(SET ${_p} NEW)
+  endif(POLICY ${_p})
+endforeach(_p)
+foreach(_p ${_old_policies})
+  if(POLICY ${_p})
+    cmake_policy(SET ${_p} OLD)
+  endif(POLICY ${_p})
+endforeach(_p)
 
-## ===========================
-## == Project configuration ==
-## ===========================
+## == Some general configuration
+include(cmake/cpPlgDefinitions.cmake)
+include(cmake/cpPlgFunctions.cmake)
 
-PROJECT(${prj_NAME})
-SET(
-  prj_VERSION
-  "${prj_MAJOR_VERSION}.${prj_MINOR_VERSION}.${prj_RELEASE_VERSION}"
-  )
-SET(prj_SHORT_VERSION "${prj_MAJOR_VERSION}")
+## == User could choose not to build
+option(cpPlugins_BUILD "Build targets." OFF)
+if(cpPlugins_BUILD)
 
-## =====================================
-## == Functions, packages and options ==
-## =====================================
+  ## == Find ITK
+  find_package(ITK CONFIG REQUIRED)
+  include(${ITK_USE_FILE})
 
-INCLUDE(cmake/Restrictions.cmake)
-INCLUDE(cmake/Options.cmake)
-INCLUDE(cmake/KitwareTools.cmake)
-OPTION(USE_QT4 "Build Qt4-based code" OFF)
-IF(USE_QT4)
-  INCLUDE(cmake/QtTools.cmake)
-  SET(
-    cpPlugins_Qt4_VTKWidget QVTKWidget
-    CACHE STRING "Base Qt4-based vtkRenderWindow"
-    )
-ENDIF(USE_QT4)
-INCLUDE(cmake/Functions.cmake)
+  ## == Find VTK, only if linked against ITK
+  set(cpPlugins_USE_VTK 0)
+  if(ITKVtkGlue_LOADED)
+    find_package(VTK CONFIG REQUIRED)
+    include(${VTK_USE_FILE})
+    set(cpPlugins_USE_VTK 1)
+  endif(ITKVtkGlue_LOADED)
 
-## ===========================
-## == Use all valid subdirs ==
-## ===========================
+  ## == Find Qt5, only if linked against VTK
+  set(cpPlugins_USE_Qt5 0)
+  if(VTK_FOUND)
+    if(Qt5_DIR)
+      find_package(Qt5 CONFIG REQUIRED COMPONENTS Widgets)
+      set(CMAKE_INCLUDE_CURRENT_DIR ON)
+      set(CMAKE_AUTOMOC ON)
+      set(cpPlugins_USE_Qt5 1)
+    endif(Qt5_DIR)
+  endif(VTK_FOUND)
 
-#SET(
-#  _include_dirs
-#  .
-#  lib
-#  lib/Itk2Vtk
-#  lib/Instances
-#  )
-#FOREACH(_dir ${_include_dirs})
-#  INCLUDE_DIRECTORIES(
-#    ${PROJECT_SOURCE_DIR}/${_dir}
-#    ${PROJECT_BINARY_DIR}/${_dir}
-#    )
-#ENDFOREACH(_dir)
+  ## == Build packages
+  subdirs(appli lib)
 
-## ===========================
-## == Build different parts ==
-## ===========================
+endif(cpPlugins_BUILD)
 
-SUBDIRS(appli cmake lib plugins)
+## == Installation commands
+include(cmake/cpPlgInstallCommands.cmake)
+
+## == CMake scripts
+subdirs(cmake)
 
 ## eof - $RCSfile$
+