+#find_package(Eigen3 CONFIG REQUIRED)
+#include(${EIGEN3_USE_FILE})
+
## =========================================================================
-## @author Leonardo Florez Valencia
-## @email florez-l@javeriana.edu.co
+## @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
## =========================================================================
cmake_minimum_required(VERSION 3.0)
-## ========================
-## == Project definition ==
-## ========================
-
-set(prj_MAJ_VER 0)
-set(prj_MIN_VER 1)
-set(prj_REL_VER 0)
-set(prj_VER "${prj_MAJ_VER}.${prj_MIN_VER}.${prj_REL_VER}")
-set(prj_SHORT_VER "${prj_MAJ_VER}")
-project(fpa VERSION ${prj_VER})
+## == Basic project configuration
+set(prj_NAME fpa)
+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}")
+## == Project policies
set(_policies CMP0015 CMP0020 CMP0042 CMP0053)
foreach(_p ${_policies})
if(POLICY ${_p})
endif(POLICY ${_p})
endforeach(_p)
-## =========================================================
-## == If working on a MacOSX, activate the use of RPATH's ==
-## == Furthermore: prepare the type of executables ==
-## =========================================================
-
-set(EXECUTABLE_TYPE "" CACHE STRING "Executable linking." FORCE)
-if(APPLE)
- set(EXECUTABLE_TYPE "MACOSX_BUNDLE" CACHE STRING "Executable linking." FORCE)
- set(CMAKE_MACOSX_RPATH true CACHE BOOL "Use RPATH's on MacOSX." FORCE)
- mark_as_advanced(CMAKE_MACOSX_RPATH)
-elseif(WIN32)
- set(EXECUTABLE_TYPE "WIN32" CACHE STRING "Executable linking." FORCE)
-endif(APPLE)
-mark_as_advanced(EXECUTABLE_TYPE)
-
-## =======================================================================
-## == Force c++11 language version ==
-## == NOTE: It seems that by default on Visual Studio Compiler supports ==
-## == c++11, so it only need to be tested on other OS. ==
-## =======================================================================
-
-if(NOT MSVC)
- include(CheckCXXCompilerFlag)
- check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11)
- if(COMPILER_SUPPORTS_CXX11)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
- else(COMPILER_SUPPORTS_CXX11)
- check_cxx_compiler_flag("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
- if(COMPILER_SUPPORTS_CXX0X)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
- else(COMPILER_SUPPORTS_CXX0X)
- message(
- FATAL_ERROR
- "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support."
- )
- endif(COMPILER_SUPPORTS_CXX0X)
- endif(COMPILER_SUPPORTS_CXX11)
-endif(NOT MSVC)
-
-## ===================================================
-## == Prepare header generator to build shared libs ==
-## ===================================================
-
-include(GenerateExportHeader)
-
-## ==================================================
-## == Do not allow to build inside the source tree ==
-## ==================================================
-
-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})
-
-## =================================================
-## == Where to put targets (executables and libs) ==
-## =================================================
-
-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
- )
-
-## ===========================================
-## == Find needed packages and dependencies ==
-## ===========================================
-
-find_package(ITK CONFIG REQUIRED)
-include(${ITK_USE_FILE})
-if(ITKVtkGlue_LOADED)
- find_package(VTK CONFIG REQUIRED)
- include(${VTK_USE_FILE})
-endif(ITKVtkGlue_LOADED)
-
-find_package(Eigen3 CONFIG REQUIRED)
-include(${EIGEN3_USE_FILE})
-
-## =========================
-## == Installation values ==
-## =========================
-
-set(config_install_dir "lib/cmake/${PROJECT_NAME}")
-set(include_install_dir "include")
-set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
-set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake")
-set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake")
-set(targets_export_name "${PROJECT_NAME}Targets")
-set(namespace "${PROJECT_NAME}::")
-
-## ===========================
-## == Build different parts ==
-## ===========================
-
-subdirs(appli lib tests)
-
-## ===============================
-## == Global installation rules ==
-## ===============================
-
-include(CMakePackageConfigHelpers)
-write_basic_package_version_file(
- "${version_config}" COMPATIBILITY SameMajorVersion
- )
-configure_package_config_file(
- "cmake/${PROJECT_NAME}Config.cmake.in"
- "${project_config}"
- INSTALL_DESTINATION "${config_install_dir}"
- )
-install(
- EXPORT "${targets_export_name}"
- NAMESPACE "${namespace}"
- DESTINATION "${config_install_dir}"
- )
-install(
- FILES "${project_config}"
- DESTINATION "${config_install_dir}"
- )
+## == Some general configuration
+include(cmake/Definitions.cmake)
+include(cmake/Functions.cmake)
+
+## == Find cpPlugins
+find_package(cpPlugins CONFIG)
+if(NOT cpPlugins_FOUND)
+ ## == Find individual ITK (for a minimal build)
+ find_package(ITK CONFIG REQUIRED)
+ include(${ITK_USE_FILE})
+endif(NOT cpPlugins_FOUND)
+
+## == Find eigen3
+find_package(Eigen3 CONFIG)
+if(Eigen3_FOUND)
+ include(${EIGEN3_USE_FILE})
+endif(Eigen3_FOUND)
+
+## == Build packages
+subdirs(lib examples)
+
+## == Installation commands
+include(cmake/InstallCommands.cmake)
## eof - $RCSfile$
--- /dev/null
+## =========================================================================
+## @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
+## =========================================================================
+
+## == If working on a MacOSX, activate the use of RPATH's
+## == Furthermore: prepare the type of executables
+set(EXECUTABLE_TYPE "" CACHE STRING "Executable linking." FORCE)
+if(APPLE)
+ set(EXECUTABLE_TYPE "MACOSX_BUNDLE" CACHE STRING "Executable linking." FORCE)
+ set(CMAKE_MACOSX_RPATH true CACHE BOOL "Use RPATH's on MacOSX." FORCE)
+ mark_as_advanced(CMAKE_MACOSX_RPATH)
+elseif(WIN32)
+ set(EXECUTABLE_TYPE "WIN32" CACHE STRING "Executable linking." FORCE)
+endif(APPLE)
+mark_as_advanced(EXECUTABLE_TYPE)
+
+## == Force c++11
+if(NOT MSVC)
+ include(CheckCXXCompilerFlag)
+ check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11)
+ if(COMPILER_SUPPORTS_CXX11)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+ else(COMPILER_SUPPORTS_CXX11)
+ check_cxx_compiler_flag("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
+ if(COMPILER_SUPPORTS_CXX0X)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
+ else(COMPILER_SUPPORTS_CXX0X)
+ message(
+ FATAL_ERROR
+ "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support."
+ )
+ endif(COMPILER_SUPPORTS_CXX0X)
+ endif(COMPILER_SUPPORTS_CXX11)
+endif(NOT MSVC)
+
+## == Prepare header generator to build shared libs
+include(GenerateExportHeader)
+
+## == Do not allow to build inside the source tree
+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})
+
+## == Where to put targets (executables and libs)
+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
+ )
+
+## eof - $RCSfile$
--- /dev/null
+## =========================================================================
+## @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
+## =========================================================================
+
+## -------------------------------------------------------------------------
+function(BuildLibrary lib typ src maj min rel)
+
+## -- Get sources
+set(_files)
+foreach(_s ${src})
+
+ ## -- Canonicalize path
+ get_filename_component(_p "${_s}" ABSOLUTE)
+
+ ## -- Check type of input
+ if(IS_DIRECTORY ${_p})
+ file(GLOB _f "${_p}/*")
+ foreach(_x ${_f})
+ if(NOT IS_DIRECTORY ${_x})
+ list(APPEND _files ${_x})
+ endif(NOT IS_DIRECTORY ${_x})
+ endforeach(_x)
+ else(IS_DIRECTORY ${_p})
+ list(APPEND _files ${_p})
+ endif(IS_DIRECTORY ${_p})
+
+endforeach(_s)
+
+## -- Process sources
+set(_cpp)
+set(_hpp)
+set(_qui)
+foreach(_f ${_files})
+
+ ## -- Separate filename from extension
+ string(REGEX REPLACE "\\.[^.]*$" "" _name ${_f})
+ string(REPLACE ${_name} "" _ext ${_f})
+ set(_out_name ${_name})
+ set(_out_ext ${_ext})
+
+ ## -- Process .in files
+ string(COMPARE EQUAL "${_ext}" ".in" _in_cmp)
+ if(_in_cmp)
+ string(REPLACE ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} _out ${_name})
+ configure_file(${_f} ${_out} @ONLY)
+ string(REGEX REPLACE "\\.[^.]*$" "" _out_name ${_out})
+ string(REPLACE ${_out_name} "" _out_ext ${_out})
+ endif(_in_cmp)
+
+ ## -- Now, get real extension
+ string(SUBSTRING ${_out_ext} 0 2 _ext_cmp)
+
+ ## -- Process .c?? files
+ string(COMPARE EQUAL "${_ext_cmp}" ".c" _c_cmp)
+ if(_c_cmp)
+ list(APPEND _cpp ${_out_name}${_out_ext})
+ endif(_c_cmp)
+
+ ## -- Process .h?? files
+ string(COMPARE EQUAL "${_ext_cmp}" ".h" _h_cmp)
+ if(_h_cmp)
+ list(APPEND _hpp ${_out_name}${_out_ext})
+ endif(_h_cmp)
+
+ ## -- Process .ui files
+ string(COMPARE EQUAL "${_out_ext}" ".ui" _u_cmp)
+ if(_u_cmp)
+ list(APPEND _qui ${_out_name}${_out_ext})
+ endif(_u_cmp)
+
+endforeach(_f)
+
+## -- Process Qt ui files
+list(LENGTH _qui _qui_len)
+if(${_qui_len} GREATER 0)
+ qt5_wrap_ui(_qui_hpp ${_qui})
+endif(${_qui_len} GREATER 0)
+
+## -- Real build
+add_library(${lib} ${typ} ${_cpp} ${_hpp} ${_qui_hpp})
+
+## -- Header creation
+generate_export_header(${lib})
+set_property(TARGET ${lib} PROPERTY VERSION "${maj}.${min}.${rel}")
+set_property(TARGET ${lib} PROPERTY SOVERSION ${maj})
+set_property(TARGET ${lib} PROPERTY INTERFACE_${lib}_MAJOR_VERSION ${maj})
+set_property(TARGET ${lib} APPEND PROPERTY COMPATIBLE_INTERFACE_STRING ${maj})
+
+## -- Link library
+target_link_libraries(${lib} PUBLIC ${ARGN})
+
+## -- Installation rules
+option(${lib}_INSTALL_DEVEL "Install development files for ${lib}" OFF)
+string(COMPARE EQUAL "${type}" "SHARED" _cmp)
+if(_cmp OR ${lib}_INSTALL_DEVEL)
+ install(
+ TARGETS ${lib}
+ EXPORT "${targets_export_name}"
+ LIBRARY DESTINATION "lib"
+ ARCHIVE DESTINATION "lib"
+ RUNTIME DESTINATION "bin"
+ INCLUDES DESTINATION "${include_install_dir}"
+ )
+endif(_cmp OR ${lib}_INSTALL_DEVEL)
+if(${lib}_INSTALL_DEVEL)
+ string(TOLOWER ${lib} _lower_lib)
+ set(
+ _install_hdr
+ ${_hpp}
+ ${CMAKE_CURRENT_BINARY_DIR}/${_lower_lib}_export.h
+ )
+ set(_install_dirs)
+ foreach(_h ${_install_hdr})
+ string(REPLACE ${CMAKE_CURRENT_SOURCE_DIR} "" _h_name ${_h})
+ string(COMPARE EQUAL "${_h_name}" "${_h}" _h_cmp)
+ if(_h_cmp)
+ string(REPLACE ${CMAKE_CURRENT_BINARY_DIR} "" _h_name ${_h})
+ endif(_h_cmp)
+ set(_h_out ${include_install_dir}/${lib}${_h_name})
+ get_filename_component(_h_dir ${_h_out} DIRECTORY)
+ install(
+ FILES "${_h}"
+ DESTINATION "${_h_dir}"
+ )
+ endforeach(_h)
+endif(${lib}_INSTALL_DEVEL)
+
+endfunction()
+
+## -------------------------------------------------------------------------
+function(BuildLibraryRecursive lib typ dir maj min rel)
+
+## -- Globbing directory
+file(GLOB_RECURSE _files "${dir}/*")
+
+## -- Build library
+BuildLibrary(${lib} ${typ} "${_files}" ${maj} ${min} ${rel} ${ARGN})
+
+endfunction()
+
+## eof - $RCSfile$
--- /dev/null
+## =========================================================================
+## @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
+## =========================================================================
+
+## =========================
+## == Installation values ==
+## =========================
+
+set(config_install_dir "lib/cmake/${PROJECT_NAME}")
+set(include_install_dir "include")
+set(generated_dir "${PROJECT_BINARY_DIR}/generated")
+set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake")
+set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake")
+set(targets_export_name "${PROJECT_NAME}Targets")
+set(namespace "${PROJECT_NAME}::")
+
+## ===============================
+## == Global installation rules ==
+## ===============================
+
+include(CMakePackageConfigHelpers)
+write_basic_package_version_file(
+ "${version_config}" COMPATIBILITY SameMajorVersion
+ )
+configure_package_config_file(
+ "cmake/${PROJECT_NAME}Config.cmake.in"
+ "${project_config}"
+ INSTALL_DESTINATION "${config_install_dir}"
+ )
+install(
+ EXPORT "${targets_export_name}"
+ NAMESPACE "${namespace}"
+ DESTINATION "${config_install_dir}"
+ )
+install(
+ FILES "${project_config}"
+ DESTINATION "${config_install_dir}"
+ )
+
+## eof - $RCSfile$
## =========================================================================
-## @author Leonardo Florez Valencia
-## @email florez-l@javeriana.edu.co
+## @author Leonardo Florez Valencia (florez-l@javeriana.edu.co)
## =========================================================================
subdirs(image)
## =========================================================================
-## @author Leonardo Florez Valencia
-## @email florez-l@javeriana.edu.co
+## @author Leonardo Florez Valencia (florez-l@javeriana.edu.co)
## =========================================================================
subdirs(RegionGrow RandomWalker Dijkstra)
## =========================================================================
-## @author Leonardo Florez Valencia
-## @email florez-l@javeriana.edu.co
+## @author Leonardo Florez Valencia (florez-l@javeriana.edu.co)
## =========================================================================
-set(_pfx test_fpa_Image_Dijkstra_)
+set(_pfx example_fpa_Image_Dijkstra_)
set(
- _tests
+ _examples
Identity
Invert
Gaussian
)
include_directories(${PROJECT_SOURCE_DIR}/lib ${PROJECT_BINARY_DIR}/lib)
-foreach(_t ${_tests})
+foreach(_t ${_examples})
add_executable(${_pfx}${_t} ${_t}.cxx)
target_link_libraries(${_pfx}${_t} fpa)
endforeach(_t)
## =========================================================================
-## @author Leonardo Florez Valencia
-## @email florez-l@javeriana.edu.co
+## @author Leonardo Florez Valencia (florez-l@javeriana.edu.co)
## =========================================================================
-set(_pfx test_fpa_Image_RandomWalker_)
+set(_pfx example_fpa_Image_RandomWalker_)
set(
- _tests
+ _examples
Gaussian
- Original
- CompareRandomWalkers
)
+if(Eigen3_FOUND)
+ set(
+ _examples
+ ${_examples}
+ Original
+ CompareRandomWalkers
+ )
+endif(Eigen3_FOUND)
include_directories(${PROJECT_SOURCE_DIR}/lib ${PROJECT_BINARY_DIR}/lib)
-foreach(_t ${_tests})
+foreach(_t ${_examples})
add_executable(${_pfx}${_t} ${_t}.cxx)
target_link_libraries(${_pfx}${_t} fpa)
endforeach(_t)
## =========================================================================
-## @author Leonardo Florez Valencia
-## @email florez-l@javeriana.edu.co
+## @author Leonardo Florez Valencia (florez-l@javeriana.edu.co)
## =========================================================================
-set(_pfx test_fpa_Image_RegionGrow_)
+set(_pfx example_fpa_Image_RegionGrow_)
set(
- _tests
+ _examples
Tautology
BinaryThreshold
Mori
)
include_directories(${PROJECT_SOURCE_DIR}/lib ${PROJECT_BINARY_DIR}/lib)
-foreach(_t ${_tests})
+foreach(_t ${_examples})
add_executable(${_pfx}${_t} ${_t}.cxx)
target_link_libraries(${_pfx}${_t} fpa)
endforeach(_t)
## =========================================================================
-## @author Leonardo Florez Valencia
-## @email florez-l@javeriana.edu.co
+## @author Leonardo Florez Valencia (florez-l@javeriana.edu.co)
## =========================================================================
+## -- Build libraries
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
## @email florez-l@javeriana.edu.co
## =========================================================================
-configure_file(Version.cxx.in "${CMAKE_CURRENT_BINARY_DIR}/Version.cxx" @ONLY)
-configure_file(Config.h.in "${CMAKE_CURRENT_BINARY_DIR}/Config.h" @ONLY)
-set(_dirs Common DataStructures Filters Functors)
+## -- Set directories
+set(_dirs . Common DataStructures Filters Functors)
if(VTK_FOUND)
list(APPEND _dirs VTK)
endif(VTK_FOUND)
set(_src)
-set(_hdr)
-set(_hrc)
foreach(_d ${_dirs})
- file(GLOB_RECURSE _s "${CMAKE_CURRENT_SOURCE_DIR}/${_d}/*.cxx")
- file(GLOB_RECURSE _h "${CMAKE_CURRENT_SOURCE_DIR}/${_d}/*.h")
- file(GLOB_RECURSE _t "${CMAKE_CURRENT_SOURCE_DIR}/${_d}/*.hxx")
+ file(GLOB_RECURSE _s "${CMAKE_CURRENT_SOURCE_DIR}/${_d}/*")
list(APPEND _src ${_s})
- list(APPEND _hdr ${_h})
- list(APPEND _hrc ${_t})
endforeach(_d)
-## =====================
-## == Compile library ==
-## =====================
-
-add_library(
- fpa SHARED
- "${CMAKE_CURRENT_BINARY_DIR}/Version.cxx"
- "${CMAKE_CURRENT_BINARY_DIR}/Config.h"
- ${_src} ${_hdr} ${_hrc}
- )
-generate_export_header(fpa)
-set_property(TARGET fpa PROPERTY VERSION ${prj_VERSION})
-set_property(TARGET fpa PROPERTY SOVERSION ${prj_SHORT_VERSION})
-set_property(
- TARGET fpa PROPERTY INTERFACE_fpa_MAJOR_VERSION ${prj_MAJ_VERSION}
- )
-set_property(
- TARGET fpa APPEND PROPERTY COMPATIBLE_INTERFACE_STRING ${prj_MAJ_VERSION}
- )
-target_link_libraries(fpa PUBLIC ${ITK_LIBRARIES} ${VTK_LIBRARIES})
-
-## ========================
-## == Installation rules ==
-## ========================
-
-install(
- TARGETS fpa
- EXPORT "${targets_export_name}"
- LIBRARY DESTINATION "lib"
- ARCHIVE DESTINATION "lib"
- RUNTIME DESTINATION "bin"
- INCLUDES DESTINATION "${include_install_dir}"
- )
-install(
- DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
- DESTINATION "${include_install_dir}"
- FILES_MATCHING PATTERN "*.h"
- )
-install(
- DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
- DESTINATION "${include_install_dir}"
- FILES_MATCHING PATTERN "*.hxx"
- )
-install(
- FILES "${CMAKE_CURRENT_BINARY_DIR}/fpa_export.h"
- DESTINATION "${include_install_dir}/fpa"
- )
-install(
- FILES "${CMAKE_CURRENT_BINARY_DIR}/Config.h"
- DESTINATION "${include_install_dir}/fpa"
+## -- Build
+BuildLibrary(
+ fpa SHARED "${_src}"
+ ${prj_MAJ} ${prj_MIN} ${prj_REL}
+ ${ITK_LIBRARIES} ${VTK_LIBRARIES}
)
## eof - $RCSfile$
// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
+// @author Leonardo Florez Valencia (florez-l@javeriana.edu.co)
// =========================================================================
#ifndef __fpa__Config__h__
#define __fpa__Config__h__
+#include <fpa/fpa_export.h>
#include <itkMacro.h>
+#if @Eigen3_FOUND@ == 1
+# define USE_Eigen3
+#endif // @Eigen3_FOUND@ == 1
+
// -------------------------------------------------------------------------
#define fpaTraitsMacro( __t__ ) \
typedef __t__::TInternalTraits::TInputValue TInputValue; \