]> Creatis software - FrontAlgorithms.git/blobdiff - CMakeLists.txt
...
[FrontAlgorithms.git] / CMakeLists.txt
index 2ada831c810ec82b4d9a722f1a2e2efb8ea8232a..2c06df53b35e3284a99aa042e105f8ac6ca930d9 100644 (file)
@@ -1,90 +1,60 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
+CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
 
-IF(POLICY CMP0020)
-  CMAKE_POLICY(SET CMP0020 NEW)
-ENDIF(POLICY CMP0020)
+## ========================
+## == Project definition ==
+## ========================
 
-## ================
-## = Project name =
-## ================
+SET(prj_NAME FrontAlgorithms)
+SET(prj_MAJOR_VERSION   0)
+SET(prj_MINOR_VERSION   1)
+SET(prj_RELEASE_VERSION 0)
 
-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}")
+## ==========================
+## == Some useful policies ==
+## ==========================
 
-## ===========
-## = Options =
-## ===========
+SET(_policies CMP0015 CMP0020 CMP0042)
+FOREACH(_p ${_policies})
+  IF(POLICY ${_p})
+    CMAKE_POLICY(SET ${_p} NEW)
+  ENDIF(POLICY ${_p})
+ENDFOREACH(_p)
 
-OPTION(BUILD_EXAMPLES "Build examples" OFF)
-OPTION(BUILD_SHARED_LIBS "Build shared libs" OFF)
-
-IF(BUILD_SHARED_LIBS)
-  SET(LIB_TYPE SHARED)
-ELSE(BUILD_SHARED_LIBS)
-  SET(LIB_TYPE STATIC)
-ENDIF(BUILD_SHARED_LIBS)
-
-## ============
-## = Packages =
-## ============
-
-INCLUDE(GenerateExportHeader)
-
-FIND_PACKAGE(ITK REQUIRED)
-INCLUDE(${ITK_USE_FILE})
-
-FIND_PACKAGE(VTK REQUIRED)
-INCLUDE(${VTK_USE_FILE})
-
-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)
-
-## ================================================
-## = 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/Restrictions.cmake)
+INCLUDE(cmake/KitwareTools.cmake)
+INCLUDE(cmake/QtTools.cmake)
+INCLUDE(cmake/Functions.cmake)
 
 ## ===========================
-## = Subdirs containing code =
+## == Build different parts ==
 ## ===========================
 
-SUBDIRS(
-  cmake
-  lib
-  appli
-  )
+SUBDIRS(appli lib plugins)
 
 ## eof - $RCSfile$