]> Creatis software - FrontAlgorithms.git/blobdiff - CMakeLists.txt
update
[FrontAlgorithms.git] / CMakeLists.txt
index 84bf1fa26fec2072b04df56f48d037dead74f57e..667002b8fa406ef26186f952e5845a6d9ece29c2 100644 (file)
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
+CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
 
-## ============
-## = Policies =
-## ============
+## ========================
+## == Project definition ==
+## ========================
 
-SET(
-  policies
-  CMP0015
-  CMP0020
-  CMP0042
-  )
-FOREACH(policy ${policies})
-  IF(POLICY ${policy})
-    CMAKE_POLICY(SET ${policy} NEW)
-  ENDIF(POLICY ${policy})
-ENDFOREACH(policy)
-
-## ================
-## = Project name =
-## ================
-
-PROJECT(FrontAlgorithms)
-SET(FrontAlgorithms_MAJOR_VERSION   "0")
-SET(FrontAlgorithms_MINOR_VERSION   "0")
-SET(FrontAlgorithms_RELEASE_VERSION "1")
-SET(FrontAlgorithms_VERSION "${FrontAlgorithms_MAJOR_VERSION}.${FrontAlgorithms_MINOR_VERSION}.${FrontAlgorithms_RELEASE_VERSION}")
-
-## ===========
-## = Options =
-## ===========
-
-OPTION(BUILD_EXAMPLES "Build examples" OFF)
-OPTION(BUILD_SHARED_LIBS "Build shared libs" OFF)
+SET(prj_NAME FrontAlgorithms)
+SET(prj_MAJOR_VERSION   0)
+SET(prj_MINOR_VERSION   1)
+SET(prj_RELEASE_VERSION 0)
+SET(_subdirs lib plugins)
+SET(_policies CMP0015 CMP0020 CMP0042)
 
-IF(BUILD_SHARED_LIBS)
-  SET(LIB_TYPE SHARED)
-ELSE(BUILD_SHARED_LIBS)
-  SET(LIB_TYPE STATIC)
-ENDIF(BUILD_SHARED_LIBS)
+## ==========================
+## == Some useful policies ==
+## ==========================
 
-## ============
-## = Packages =
-## ============
-
-# Prepare header to build shared libs (windows)
-INCLUDE(GenerateExportHeader)
-
-# Find ITK and VTK
-FIND_PACKAGE(ITK REQUIRED)
-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)
-
-OPTION(USE_cpPlugins "Build cpPlugins based stuff" OFF)
-IF(USE_cpPlugins)
-  FIND_PACKAGE(cpPlugins REQUIRED)
-ENDIF(USE_cpPlugins)
+FOREACH(_p ${_policies})
+  IF(POLICY ${_p})
+    CMAKE_POLICY(SET ${_p} NEW)
+  ENDIF(POLICY ${_p})
+ENDFOREACH(_p)
 
-## ================================================
-## = Do not allow to build inside the source tree =
-## ================================================
+## ===========================
+## == Project configuration ==
+## ===========================
 
-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})
+PROJECT(${prj_NAME})
+SET(
+  prj_VERSION
+  "${prj_MAJOR_VERSION}.${prj_MINOR_VERSION}.${prj_RELEASE_VERSION}"
+  )
+SET(prj_SHORT_VERSION "${prj_MAJOR_VERSION}")
 
 ## =====================================
-## = Where to put executables and libs =
+## == Functions, packages and options ==
 ## =====================================
 
-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
-  )
-
-## ==============================
-## = Subdirs containing headers =
-## ==============================
-
-INCLUDE_DIRECTORIES(
-  ${PROJECT_SOURCE_DIR}/lib
-  ${PROJECT_BINARY_DIR}/lib
-  )
+FIND_PACKAGE(cpPlugins QUIET)
+IF(cpPlugins_DIR)
+  OPTION(USE_cpPlugins "Build cpPlugins-based code" ON)
+ELSE(cpPlugins_DIR)
+  OPTION(USE_cpPlugins "Build cpPlugins-based code" OFF)
+  MARK_AS_ADVANCED(FORCE cpPlugins_DIR)
+ENDIF(cpPlugins_DIR)
+IF(USE_cpPlugins)
+  FIND_PACKAGE(cpPlugins)
+  MARK_AS_ADVANCED(CLEAR cpPlugins_DIR)
+ENDIF(USE_cpPlugins)
+INCLUDE(cmake/BaseConfig.cmake)
+INCLUDE(cmake/KitwareTools.cmake)
+INCLUDE(cmake/QtTools.cmake)
+INCLUDE(cmake/Functions.cmake)
 
 ## ===========================
-## = Subdirs containing code =
+## == Build different parts ==
 ## ===========================
 
-SUBDIRS(
-  cmake
-  lib
-  appli
-  )
+FOREACH(_s ${_subdirs})
+  SUBDIRS(${_s})
+ENDFOREACH(_s)
 
 ## eof - $RCSfile$