Commit 1e636253 authored by Kasper Marstal's avatar Kasper Marstal
Browse files

WIP: SuperElastix/SuperElastaixSuperBuild config file; ENH: Do not check for...

WIP: SuperElastix/SuperElastaixSuperBuild config file; ENH: Do not check for ITKReview which is not needed anymore; ENH: Update elastix
parent 053a11ea
......@@ -52,6 +52,5 @@ include( ${SUPERELASTIX_USE_FILE} )
find_package( ITK )
include( ${ITK_USE_FILE} )
include( ${ELASTIX_USE_FILE} )
add_subdirectory( CommandLineInterface )
......@@ -29,7 +29,6 @@ set( ${APPLICATION}_SOURCE_FILES
set( ${APPLICATION}_LINK_LIBRARIES
${ITK_LIBRARIES}
elastix transformix
${Boost_LIBRARIES}
)
......
......@@ -46,7 +46,7 @@ include_directories( ${Boost_INCLUDE_DIR} )
# Compile executable
include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/include" )
add_executable( SuperElastix ${COMMANDLINE_SOURCE_FILES} ${COMMANDLINE_HEADER_FILES} )
target_link_libraries( SuperElastix ${SUPERELASTIX_LIBRARIES} ${Boost_LIBRARIES})
target_link_libraries( SuperElastix ${SUPERELASTIX_LIBRARIES} ${Boost_LIBRARIES} ${ITK_LIBRARIES} )
# demo copies SuperElastix executable, image data, configuration files and bat/bash scripts to the DEMO_PREFIX directory
set( DEMO_PREFIX ${PROJECT_BINARY_DIR}/Demo CACHE PATH "Demo files will be copied to this directory" )
......
......@@ -84,6 +84,7 @@ macro( _selxapplication_enable APPLICATION UPSTREAM )
include( ${${APPLICATION}_CMAKE_FILE} )
if( ${APPLICATION}_MODULE_DEPENDENCIES )
# TODO: If we are building as a standalone directory we should just check if enabled instead of enabling
_selxmodule_enable_dependencies( ${APPLICATION}_MODULE_DEPENDENCIES ${APPLICATION} )
endif()
......
......@@ -41,6 +41,7 @@ macro( _selxmodules_initialize )
set( SUPERELASTIX_MODULES )
set( SUPERELASTIX_INCLUDE_DIRS )
set( SUPERELASTIX_LIBRARIES )
set( SUPERELASTIX_LIBRARIY_DIRS )
set( SUPERELASTIX_TEST_SOURCE_FILES )
set( SUPERELASTIX_INTERFACE_DIRS )
......@@ -100,21 +101,17 @@ macro( _selxmodule_enable MODULE UPSTREAM )
list( APPEND SUPERELASTIX_TEST_SOURCE_FILES ${${MODULE}_TEST_SOURCE_FILES} )
endif()
# Header-only modules should not be compiled
if( ${MODULE}_SOURCE_FILES )
add_library( ${MODULE} ${${MODULE}_HEADER_FILES} ${${MODULE}_SOURCE_FILES} )
endif()
if( ${MODULE}_LIBRARIES )
list( APPEND SUPERELASTIX_LIBRARIES ${${MODULE}_LIBRARIES} )
endif()
# Header-only modules should not be compiled
if( ${MODULE}_SOURCE_FILES )
# Check if user accidentally tries to compile header-only library
if( ${MODULE}_LIBRARIES )
list( FIND "${MODULE}" ${MODULE}_LIBRARIES _index )
if( _index GREATER -1 AND NOT ${MODULE}_SOURCE_FILES )
message( FATAL_ERROR "Compilation of header-only module ${MODULE} requested. Remove ${MODULE} from \$\{MODULE\}_LIBRARIES in ${${MODULE}_CMAKE_FILE}" )
endif()
endif()
add_library( ${MODULE} ${${MODULE}_HEADER_FILES} ${${MODULE}_SOURCE_FILES} )
if( ${MODULE}_LIBRARY_DIRS )
list( APPEND SUPERELASTIX_LIBRARY_DIRS ${${MODULE}_LIBRARY_DIRS} )
endif()
message( STATUS "${MODULE} enabled." )
......@@ -129,6 +126,12 @@ macro( _selxmodule_enable_dependencies UPSTREAM MODULES )
endforeach()
endmacro()
macro( _selxmodule_target_file TARGETS )
foreach( TARGET ${${TARGETS}} )
set( ${TARGET}_FILE $<TARGET_FILE:TARGET> )
endforeach()
endmacro()
macro( _selxmodule_disable MODULE )
set( USE_${MODULE} FALSE )
list( FILTER SUPERELASTIX_INCLUDE_DIRS MATCHES EXCLUDE REGEX "(.*)${MODULE}(.*)" )
......
......@@ -22,10 +22,10 @@ cmake_minimum_required( VERSION 3.0.2 )
# ---------------------------------------------------------------------
project( SuperElastix )
set( SUPERELATIX_MAJOR_VERSION 0)
set( SUPERELATIX_MINOR_VERSION 1)
set( SUPERELATIX_PATCH_VERSION 0)
set( SUPERELATIX_VERSION ${SUPERELATIX_MAJOR_VERSION}.${SUPERELATIX_MINOR_VERSION}.${SUPERELATIX_PATCH_VERSION})
set( SUPERELASTIX_MAJOR_VERSION 0)
set( SUPERELASTIX_MINOR_VERSION 1)
set( SUPERELASTIX_PATCH_VERSION 0)
set( SUPERELASTIX_VERSION ${SUPERELASTIX_MAJOR_VERSION}.${SUPERELASTIX_MINOR_VERSION}.${SUPERELASTIX_PATCH_VERSION})
# Place executables in the bin directory
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" )
......@@ -89,22 +89,24 @@ if( NOT CMAKE_BUILD_TYPE )
FORCE )
endif()
# ---------------------------------------------------------------------
# Load SuperBuild settings. Use all system libraries by setting
# USE_SYSTEM_DEPENDENCIES to ON, or use individual system libraries by
# setting USE_SYSTEM_DEPENDENCIES to OFF _and_ USE_SYSTEM_ITK to ON,
# USE_SYSTEM_BOOST to ON, USE_SYSTEM_GTEST to ON or USE_SYSTEM_ELASTIX
# to ON.
if( NOT USE_SYSTEM_DEPENDENCIES )
find_package( SuperElastixSuperBuild REQUIRED )
include( ${SUPERELASTIXSUPERBUILD_USE_FILE} )
endif()
# ---------------------------------------------------------------------
# ITK
find_package( ITK REQUIRED )
include( ${ITK_USE_FILE} )
list( APPEND RequiredITKModules
ITKReview
)
foreach( ITKModule ${RequiredITKModules} )
if( NOT ${ITKModule}_LOADED )
message( FATAL_ERROR "elastix requires that ITK is build with ${ITKModule}. Please rebuild ITK with Module_${ITKModule} set to ON." )
endif()
endforeach()
# ---------------------------------------------------------------------
# Boost Library
......@@ -188,12 +190,8 @@ option( BUILD_READTHEDOCS "Enable building readthedocs.org documentation." OFF )
# ---------------------------------------------------------------------
# Enable other projects to use SuperElastix via CMake's find_packge() and a use-file
set( SUPERELASTIX_CONFIG_DIR ${CMAKE_CURRENT_BINARY_DIR} )
set( SUPERELASTIX_BINARY_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} )
get_directory_property( SUPERELASTIX_INCLUDE_DIRS INCLUDE_DIRECTORIES )
configure_file( SuperElastixConfig.cmake.in SuperElastixConfig.cmake @ONLY IMMEDIATE )
configure_file( UseSuperElastix.cmake.in UseSuperElastix.cmake COPYONLY IMMEDIATE )
# set( SUPERELASTIX_CONFIG_DIR ${CMAKE_CURRENT_BINARY_DIR} )
# set( SUPERELASTIX_BINARY_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} )
# ---------------------------------------------------------------------
# Installation
......@@ -204,25 +202,26 @@ if( WIN32 AND NOT CYGWIN )
else()
set( CMAKE_INSTALL_DIR lib/CMake/SuperElastix )
endif()
# Add all targets to the build-tree export set
export( TARGETS ModuleFilter FILE "${PROJECT_BINARY_DIR}/SuperElastixTargets.cmake" )
# Register the build-tree with a global CMake-registry
export( PACKAGE SuperElastix )
# Create the SuperElastix.cmake files
# ... for the build tree
set( SUPERELASTIX_CONF_INCLUDE_DIRS ${SUPERELASTIX_INCLUDE_DIRS} )
set( SUPERELASTIX_CONF_LIBRARY_DIRS ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} )
set( SUPERELASTIX_CONF_LIBRARIES ${SUPERELASTIX_LIBRARIES} )
set( SUPERELASTIX_INSTALL_INCLUDE_DIRS ${SUPERELASTIX_INCLUDE_DIRS} )
set( SUPERELASTIX_INSTALL_LIBRARY_DIRS ${SUPERELASTIX_LIBRARY_DIRS} )
set( SUPERELASTIX_INSTALL_LIBRARIES ${SUPERELASTIX_LIBRARIES} )
set( SUPERELASTIX_INSTALL_USE_FILE "${PROJECT_BINARY_DIR}/UseSuperElastix.cmake" )
configure_file( SuperElastixConfig.cmake.in "${PROJECT_BINARY_DIR}/SuperElastixConfig.cmake" @ONLY)
configure_file( UseSuperElastix.cmake.in "${SUPERELATIX_USE_FILE}" @ONLY )
# ... for the install tree
set( SUPERELASTIX_CONF_INCLUDE_DIRS include )
set( SUPERELASTIX_CONF_LIBRARY_DIRS lib )
set( SUPERELASTIX_CONF_LIBRARIES "ModuleFilter" )
set( SUPERELASTIX_INSTALL_INCLUDE_DIRS include )
set( SUPERELASTIX_INSTALL_LIBRARY_DIRS lib )
set( SUPERELASTIX_INSTALL_LIBRARIES ModuleFilter ModuleBlueprints ModuleLogger )
set( SUPERELASTIX_INSTALL_USE_FILE "${CMAKE_INSTALL_DIR}/UseSuperElastix.cmake" )
configure_file( SuperElastixConfig.cmake.in "${PROJECT_BINARY_DIR}/install/SuperElastixConfig.cmake" @ONLY)
configure_file( UseSuperElastix.cmake.in "${PROJECT_BINARY_DIR}/install/UserSuperElastix.cmake" @ONLY )
# Create the SuperElastixVersion.cmake file
configure_file( SuperElastixConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/SuperElastixConfigVersion.cmake" @ONLY)
......@@ -231,17 +230,19 @@ configure_file( SuperElastixConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/SuperE
install( FILES
"${PROJECT_BINARY_DIR}/install/SuperElastixConfig.cmake"
"${PROJECT_BINARY_DIR}/SuperElastixConfigVersion.cmake"
"${PROJECT_BINARY_DIR}/install/UserSuperElastix.cmake"
DESTINATION "${CMAKE_INSTALL_DIR}" )
install( FILES
Modules/Filter/include/selxSuperElastixFilter.h
Modules/Filter/include/selxSuperElastixFilterCustomComponents.h
Modules/Filter/include/itkUniquePointerDataObjectDecorator.h
Modules/Filter/include/itkUniquePointerDataObjectDecorator.hxx
Modules/Blueprints/include/selxBlueprint.h
Modules/Logger/include/selxLogger.h
Modules/FileIO/include/selxAnyFileReader.h
Modules/FileIO/include/selxAnyFileWriter.h
DESTINATION include )
install( TARGETS ModuleFilter
install( TARGETS ModuleFilter ModuleBlueprints ModuleLogger
DESTINATION lib )
......@@ -37,7 +37,3 @@ set( ${MODULE}_LIBRARIES
${Boost_LIBRARIES} # graph?
${MODULE}
)
set( ${MODULE}_MODULE_DEPENDENCIES
)
......@@ -54,3 +54,14 @@ set( ${MODULE}_LIBRARIES
elastix
transformix
)
set( ${MODULE}_LIBRARY_DIRS
${ELASTIX_LINK_DIRECTORIES}
)
# https://public.kitware.com/Bug/view.php?id=14311
# add_library( elastix STATIC IMPORTED )
# set_property( TARGET elastix PROPERTY IMPORTED_LOCATION ${ELASTIX_DIR}/src/bin/elastix.a )
#
# add_library( transformix STATIC IMPORTED )
# set_property( TARGET transformix PROPERTY IMPORTED_LOCATION ${ELASTIX_DIR}/src/bin/transformix.a )
......@@ -34,6 +34,6 @@ set( ${MODULE}_TEST_SOURCE_FILES
)
set( ${MODULE}_LIBRARIES
${Boost_LIBRARIES} # log filesystem system time_date thread
${Boost_LIBRARIES}
${MODULE}
)
......@@ -30,7 +30,7 @@ enum SeverityType {
DEBUG,
INFO,
WARNING,
// ERROR,
ERROR,
FATAL
};
......
......@@ -36,6 +36,6 @@ TEST( LoggerTest, Console )
logger->Log( DEBUG, "Console DEBUG message" );
logger->Log( INFO, "Console INFO message" );
logger->Log( WARNING, "Console WARNING message" );
//logger->Log( ERROR, "Console ERROR message");
// logger->Log( ERROR, "Console ERROR message");
logger->Log( FATAL, "Console FATAL message" );
}
......@@ -22,6 +22,11 @@ cmake_minimum_required( VERSION 3.0.2 )
# ---------------------------------------------------------------------
project( SuperElastixSuperBuild )
set( SUPERELASTIXSUPERBUILD_MAJOR_VERSION 0)
set( SUPERELASTIXSUPERBUILD_MINOR_VERSION 1)
set( SUPERELASTIXSUPERBUILD_PATCH_VERSION 0)
set( SUPERELASTIXSUPERBUILD_VERSION ${SUPERELASTIXSUPERBUILD_MAJOR_VERSION}.${SUPERELASTIXSUPERBUILD_MINOR_VERSION}.${SUPERELASTIXSUPERBUILD_PATCH_VERSION})
find_package( Git REQUIRED )
include( ExternalProject )
......@@ -32,8 +37,6 @@ set( CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
)
set( CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH "SuperBuild install directory" FORC )
# ---------------------------------------------------------------------
# SuperElastix SuperBuild configuration
......@@ -128,9 +131,27 @@ else()
include( ExternalGoogleTest )
endif()
# ---------------------------------------------------------------------
# Installation
set( CMAKE_INSTALL_DIR "" )
if( WIN32 AND NOT CYGWIN )
set( CMAKE_INSTALL_DIR CMake )
else()
set( CMAKE_INSTALL_DIR lib/CMake/SuperElastix )
endif()
set( SUPERELASTIXSUPERBUILD_USE_FILE "${PROJECT_BINARY_DIR}/UseSuperElastixSuperBuild.cmake" )
configure_file( SuperElastixSuperBuildConfig.cmake.in "${PROJECT_BINARY_DIR}/SuperElastixSuperBuildConfig.cmake" @ONLY)
configure_file( SuperElastixSuperBuildConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/SuperElastixSuperBuildConfigVersion.cmake.in" @ONLY)
configure_file( UseSuperElastixSuperBuild.cmake.in "${SUPERELASTIXSUPERBUILD_USE_FILE}" @ONLY )
# ---------------------------------------------------------------------
# Build SuperElastix
# configure_file( SuperElastixSuperBuildConfig.cmake.in "${PROJECT_BINARY_DIR}/SuperElastixConfig.cmake" @ONLY)
# configure_file( UseSuperElastix.cmake.in "${SUPERELATIX_USE_FILE}" @ONLY )
include( SuperElastix )
# ---------------------------------------------------------------------
......@@ -142,3 +163,4 @@ endif()
......@@ -25,10 +25,9 @@ ExternalProject_Add( ${proj}
BINARY_DIR ${proj}-build
CMAKE_ARGS
--no-warn-unused-cli
-DSuperElastixSuperBuild_DIR:PATH=${PROJECT_BINARY_DIR}
-DSuperElastix_DIR:PATH=${SuperElastix_DIR}
-DITK_DIR:PATH=${ITK_DIR}
-DELASTIX_USE_FILE:PATH=${ELASTIX_USE_FILE}
-DBOOST_ROOT:PATH=${BOOST_ROOT}
DEPENDS ${SUPERELASTIX_DEPENDENCIES}
INSTALL_COMMAND ""
)
......@@ -19,8 +19,8 @@
set( proj Elastix )
set( ELASTIX_GIT_REPOSITORY http://github.com/kaspermarstal/elastix )
set( ELASTIX_GIT_TAG fa451dd33ac72dbded40dbf408db2c4e958469ac )
set( ELASTIX_GIT_REPOSITORY http://github.com/mstaring/elastix )
set( ELASTIX_GIT_TAG 860faf8f4076060cbb986087a092da9d334f5ff4 )
ExternalProject_Add( ${proj}
GIT_REPOSITORY ${ELASTIX_GIT_REPOSITORY}
......
......@@ -32,7 +32,6 @@ ExternalProject_Add( ${proj}
-DBUILD_EXAMPLES:BOOL=OFF
-DBUILD_TESTING:BOOL=OFF
-DITK_BUILD_DEFAULT_MODULES:BOOL=ON
-DModule_ITKReview:BOOL=ON
-DCMAKE_SKIP_RPATH:BOOL=ON
-DITK_LEGACY_REMOVE:BOOL=ON
-DBUILD_SHARED_LIBS:BOOL=${SUPERELASTIX_BUILD_SHARED_LIBS}
......
......@@ -31,10 +31,7 @@ ExternalProject_Add( ${proj}
-DBUILD_TESTING:BOOL=${BUILD_TESTING}
-DBUILD_INTEGRATION_TESTS:BOOL=${BUILD_INTEGRATION_TESTS}
-DBUILD_LONG_UNIT_TESTS:BOOL=${BUILD_LONG_TESTS}
-DITK_DIR:PATH=${ITK_DIR}
-DBOOST_ROOT:PATH=${BOOST_ROOT}
-DGTEST_ROOT:PATH=${GTEST_ROOT}
-DELASTIX_USE_FILE:PATH=${ELASTIX_USE_FILE}
-DSuperElastixSuperBuild_DIR:PATH=${PROJECT_BINARY_DIR}
DEPENDS ${SUPERELASTIX_DEPENDENCIES}
INSTALL_COMMAND ""
)
......
set( SUPERELASTIXSUPERBUILD_USE_FILE @SUPERELASTIXSUPERBUILD_USE_FILE@ )
set( PACKAGE_VERSION "@SUPERELASTIXSUPERBUILD_VERSION@" )
# Check whether the requested PACKAGE_FIND_VERSION is compatible
if( "${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
set( PACKAGE_VERSION_COMPATIBLE FALSE )
else()
set( PACKAGE_VERSION_COMPATIBLE TRUE )
if ( "${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}" )
set( PACKAGE_VERSION_EXACT TRUE )
endif()
endif()
if( NOT USE_SYSTEM_ITK )
set( ITK_DIR @ITK_DIR@ )
endif()
if( NOT USE_SYSTEM_BOOST )
set( BOOST_ROOT @BOOST_ROOT@ )
endif()
if( NOT USE_SYSTEM_GTEST)
set( GTEST_ROOT @GTEST_ROOT@ )
endif()
if( NOT USE_SYSTEM_ELASTIX )
set( ELASTIX_USE_FILE @ELASTIX_USE_FILE@ )
endif()
get_filename_component( SUPERELASTIX_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH )
set( SUPERELASTIX_DIR @PROJECT_BINARY_DIR@ )
# Add include directories needed to use SuperElastix
set( SUPERELASTIX_INCLUDE_DIRS @SUPERELASTIX_CONF_INCLUDE_DIRS@ )
set( SUPERELASTIX_INCLUDE_DIRS @SUPERELASTIX_INSTALL_INCLUDE_DIRS@ )
# Add include directories needed to use libraries
set( SUPERELASTIX_LIBRARY_DIRS @SUPERELASTIX_CONF_LIBRARY_DIRS@ )
# Add list of SuperElastix library directories
set( SUPERELASTIX_LIBRARY_DIRS @SUPERELASTIX_INSTALL_LIBRARY_DIRS@ )
# Add list of SuperElastix libraries
set( SUPERELASTIX_LIBRARIES @SUPERELASTIX_CONF_LIBRARIES@ )
set( SUPERELASTIX_LIBRARIES @SUPERELASTIX_INSTALL_LIBRARIES@ )
# The location of the SuperElastix use-file
set( SUPERELASTIX_USE_FILE "${SUPERELASTIX_DIR}/UseSuperElastix.cmake")
set( SUPERELASTIX_USE_FILE @SUPERELASTIX_INSTALL_USE_FILE@)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment