Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions CMake/elastixExportTarget.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,17 @@ function(elastix_export_target tgt)
type STREQUAL "SHARED_LIBRARY")
set_property(TARGET ${tgt} PROPERTY VERSION 1)
set_property(TARGET ${tgt} PROPERTY SOVERSION 1)
set_property(TARGET ${tgt} PROPERTY
OUTPUT_NAME ${tgt}-${ELASTIX_VERSION_MAJOR}.${ELASTIX_VERSION_MINOR})

if ("${tgt}" STREQUAL "elastix_lib")
set_property(TARGET ${tgt} PROPERTY
OUTPUT_NAME elastix-${ELASTIX_VERSION_MAJOR}.${ELASTIX_VERSION_MINOR})
elseif ("${tgt}" STREQUAL "transformix_lib")
set_property(TARGET ${tgt} PROPERTY
OUTPUT_NAME transformix-${ELASTIX_VERSION_MAJOR}.${ELASTIX_VERSION_MINOR})
else()
set_property(TARGET ${tgt} PROPERTY
OUTPUT_NAME ${tgt}-${ELASTIX_VERSION_MAJOR}.${ELASTIX_VERSION_MINOR})
endif()
endif()

export(TARGETS ${tgt}
Expand Down
40 changes: 15 additions & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,33 +34,25 @@ string( REGEX REPLACE "([0-9]+)\\." "" ELASTIX_VERSION_MINOR "${ELASTIX_VERSION}
#---------------------------------------------------------------------
include( CTest )

#---------------------------------------------------------------------
# Generate executable, static library or dynamic library.
mark_as_advanced( ELASTIX_BUILD_EXECUTABLE )
option( ELASTIX_BUILD_EXECUTABLE "Generate executable or library?" ON )

if( NOT ELASTIX_BUILD_EXECUTABLE )

# The following may make smaller and quicker loading libraries,
# that hides unnecessary symbols. Available from CMake 3.0.0.
#set( CMAKE_C_VISIBILITY_PRESET hidden )
#set( CMAKE_CXX_VISIBILITY_PRESET hidden )

mark_as_advanced( BUILD_SHARED_LIBS )
option( BUILD_SHARED_LIBS "Build shared libraries?" OFF )
if( BUILD_SHARED_LIBS )
add_definitions( -D_ELASTIX_USE_SHARED_LIBRARY )
mark_as_advanced( BUILD_SHARED_LIBS )
option( BUILD_SHARED_LIBS "Build shared libraries?" OFF )
if( BUILD_SHARED_LIBS )
add_definitions( -D_ELASTIX_USE_SHARED_LIBRARY )

# We need to make sure that also the ITK is compiled with shared
# libraries on. Related to flag (ITK_)BUILD_SHARED_LIBS. todo
# We need to make sure that also the ITK is compiled with shared
# libraries on. Related to flag (ITK_)BUILD_SHARED_LIBS. todo

# In order to compile a shared library, all static sub-libraries
# need to build position independend code.
# Otherwise an error similar to the following is raised:
# relocation R_X86_64_32S against `.bss' can not be used when
# making a shared object; recompile with -fPIC
set( CMAKE_POSITION_INDEPENDENT_CODE ON )
endif()
# In order to compile a shared library, all static sub-libraries
# need to build position independend code.
# Otherwise an error similar to the following is raised:
# relocation R_X86_64_32S against `.bss' can not be used when
# making a shared object; recompile with -fPIC
set( CMAKE_POSITION_INDEPENDENT_CODE ON )
endif()

#---------------------------------------------------------------------
Expand Down Expand Up @@ -444,9 +436,7 @@ option( ELASTIX_USE_GTEST "Use GoogleTest to test Elastix implementation" OFF )
if( ELASTIX_USE_GTEST )
enable_testing()
add_subdirectory( Common/GTesting )
if( NOT ELASTIX_BUILD_EXECUTABLE )
add_subdirectory( Core/Main/GTesting )
endif()
add_subdirectory( Core/Main/GTesting )
endif()

#---------------------------------------------------------------------
Expand Down Expand Up @@ -597,8 +587,8 @@ export_library_dependencies( ${elxLIBRARY_DEPENDS_FILE} )
# The build settings file. (necessary for elastix?)
#set( ITK_BUILD_SETTINGS_FILE ${ITK_BINARY_DIR}/ITKBuildSettings.cmake )

elastix_export_target( elastix )
elastix_export_target( transformix )
elastix_export_target( elastix_lib )
elastix_export_target( transformix_lib )

foreach( LIB IN LISTS AllComponentLibs )
elastix_export_target( ${LIB} )
Expand Down
136 changes: 60 additions & 76 deletions Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,66 +117,7 @@ elastix_export_target( param )
# Define the mevis dcm tiff lib to which we should link.
set( mevisdcmtifflib mevisdcmtiff )

#---------------------------------------------------------------------
# Create the elastix executable or library.
if( ELASTIX_BUILD_EXECUTABLE )
add_executable( elastix
Main/elastix.cxx
Main/elastix.h
Kernel/elxElastixMain.cxx
Kernel/elxElastixMain.h
${InstallFilesForExecutables}
)
else()
# The library type (STATIC or SHARED) is determined by the parameter
# BUILD_SHARED_LIBS.
add_library( elastix
Main/elxParameterObject.cxx
Main/elxParameterObject.h
Main/elastixlib.cxx
Main/elastixlib.h
Kernel/elxElastixMain.cxx
Kernel/elxElastixMain.h
${InstallFilesForExecutables}
)
endif()

target_compile_definitions(elastix PRIVATE ELX_CMAKE_VERSION="${CMAKE_VERSION}")

#---------------------------------------------------------------------
# Create the transformix executable.

if( ELASTIX_BUILD_EXECUTABLE )
add_executable( transformix
Main/transformix.cxx
Main/elastix.h
Kernel/elxElastixMain.cxx
Kernel/elxElastixMain.h
Kernel/elxTransformixMain.cxx
Kernel/elxTransformixMain.h
${InstallFilesForExecutables}
)
else()
# The library type (STATIC or SHARED) is determined by the parameter
# BUILD_SHARED_LIBS.
add_library( transformix
Main/elxParameterObject.cxx
Main/elxParameterObject.h
Main/transformixlib.cxx
Main/transformixlib.h
Kernel/elxElastixMain.cxx
Kernel/elxElastixMain.h
Kernel/elxTransformixMain.cxx
Kernel/elxTransformixMain.h
${InstallFilesForExecutables}
)
set( ELASTIX_LIBRARIES elastix transformix PARENT_SCOPE )
endif()

#---------------------------------------------------------------------
# Link elastix against other libraries.

target_link_libraries( elastix
set( ELASTIX_TARGET_LINK_LIBRARIES
param
xoutlib
elxCommon
Expand All @@ -185,27 +126,70 @@ target_link_libraries( elastix
${AllComponentLibs}
${ITK_LIBRARIES}
)

if( ELASTIX_USE_OPENCL )
target_link_libraries( elastix elxOpenCL )
set( ELASTIX_TARGET_LINK_LIBRARIES ${ELASTIX_TARGET_LINK_LIBRARIES} elxOpenCL )
endif()

#---------------------------------------------------------------------
# Link transformix against other libraries.
# Create the elastix executable and library.
add_executable( elastix_exe
Main/elastix.cxx
Main/elastix.h
Kernel/elxElastixMain.cxx
Kernel/elxElastixMain.h
${InstallFilesForExecutables}
)
set_target_properties( elastix_exe PROPERTIES OUTPUT_NAME elastix )
target_compile_definitions( elastix_exe PRIVATE ELX_CMAKE_VERSION="${CMAKE_VERSION}" )
target_link_libraries( elastix_exe ${ELASTIX_TARGET_LINK_LIBRARIES} )

# The library type (STATIC or SHARED) is determined by the parameter
# BUILD_SHARED_LIBS.
add_library( elastix_lib
Main/elxParameterObject.cxx
Main/elxParameterObject.h
Main/elastixlib.cxx
Main/elastixlib.h
Kernel/elxElastixMain.cxx
Kernel/elxElastixMain.h
${InstallFilesForExecutables}
)
set_target_properties( elastix_lib PROPERTIES OUTPUT_NAME elastix )
target_compile_definitions( elastix_lib PRIVATE ELX_CMAKE_VERSION="${CMAKE_VERSION}" )
target_link_libraries( elastix_lib ${ELASTIX_TARGET_LINK_LIBRARIES} )

target_link_libraries( transformix
param
xoutlib
elxCommon
elxCore
${mevisdcmtifflib}
${AllComponentLibs}
${ITK_LIBRARIES}
#---------------------------------------------------------------------
# Create the transformix executable.

add_executable( transformix_exe
Main/transformix.cxx
Main/elastix.h
Kernel/elxElastixMain.cxx
Kernel/elxElastixMain.h
Kernel/elxTransformixMain.cxx
Kernel/elxTransformixMain.h
${InstallFilesForExecutables}
)
set_target_properties(transformix_exe PROPERTIES OUTPUT_NAME transformix)
target_link_libraries( transformix_exe ${ELASTIX_TARGET_LINK_LIBRARIES} )

# The library type (STATIC or SHARED) is determined by the parameter
# BUILD_SHARED_LIBS.
add_library( transformix_lib
Main/elxParameterObject.cxx
Main/elxParameterObject.h
Main/transformixlib.cxx
Main/transformixlib.h
Kernel/elxElastixMain.cxx
Kernel/elxElastixMain.h
Kernel/elxTransformixMain.cxx
Kernel/elxTransformixMain.h
${InstallFilesForExecutables}
)
set_target_properties( transformix_lib PROPERTIES OUTPUT_NAME transformix )
target_link_libraries( transformix_lib ${ELASTIX_TARGET_LINK_LIBRARIES} )

if( ELASTIX_USE_OPENCL )
target_link_libraries( transformix elxOpenCL )
endif()
set( ELASTIX_LIBRARIES elastix transformix PARENT_SCOPE )

if( MSVC )
# NOTE: that linker /INCREMENTAL:NO flag makes it impossible to use
Expand All @@ -223,11 +207,11 @@ endif()

if( NOT WIN32 )
# Tell the executables where to find the required .so files.
set_target_properties( elastix transformix
set_target_properties( elastix_exe transformix_exe
PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:${ITK_DIR}" )
endif()

install( TARGETS elastix transformix elxCore
install( TARGETS elastix_lib transformix_lib elxCore
ARCHIVE DESTINATION ${ELASTIX_ARCHIVE_DIR}
LIBRARY DESTINATION ${ELASTIX_LIBRARY_DIR}
RUNTIME DESTINATION ${ELASTIX_RUNTIME_DIR}
Expand Down
2 changes: 1 addition & 1 deletion Core/Main/GTesting/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ add_executable(ElastixLibGTest
target_link_libraries( ElastixLibGTest
GTest::GTest
GTest::Main
elastix
elastix_lib
${ITK_LIBRARIES}
)

Expand Down
1 change: 0 additions & 1 deletion ElastixConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ set( ELASTIX_USE_FILE "${Elastix_DIR}/UseElastix.cmake" )
set( ELASTIX_CONFIG_TARGETS_FILE "${Elastix_DIR}/ElastixTargets.cmake" )

# Set some variables that the user might want to use
set( ELASTIX_BUILD_EXECUTABLE @ELASTIX_BUILD_EXECUTABLE@ )
set( ELASTIX_USE_OPENMP @ELASTIX_USE_OPENMP@ )
set( ELASTIX_USE_OPENCL @ELASTIX_USE_OPENCL@ )
set( ELASTIX_USE_MEVISDICOMTIFF @ELASTIX_USE_MEVISDICOMTIFF@ )
Expand Down
6 changes: 3 additions & 3 deletions Testing/CI/Azure/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- task: CMake@1
displayName: 'CMake Generate Elastix'
inputs:
cmakeArgs: -G "Visual Studio 15 2017 Win64" -T host=x64 -DITK_DIR="$(ITK_BINARY_DIR)" -DBUILD_TESTING=ON -DUSE_ALL_COMPONENTS=ON "$(ELASTIX_SOURCE_DIR)"
cmakeArgs: -G "Visual Studio 15 2017 Win64" -T host=x64 -DITK_DIR="$(ITK_BINARY_DIR)" -DBUILD_TESTING=ON -DELASTIX_USE_GTEST=ON -DUSE_ALL_COMPONENTS=ON "$(ELASTIX_SOURCE_DIR)"
workingDirectory: "$(ELASTIX_BINARY_DIR)"
- task: CMake@1
displayName: 'CMake Build Elastix'
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:
- task: CMake@1
displayName: 'CMake Generate Elastix'
inputs:
cmakeArgs: -DITK_DIR=$(ITK_BINARY_DIR) -DBUILD_TESTING=ON -DUSE_ALL_COMPONENTS=ON $(ELASTIX_SOURCE_DIR)
cmakeArgs: -DITK_DIR=$(ITK_BINARY_DIR) -DBUILD_TESTING=ON -DELASTIX_USE_GTEST=ON -DUSE_ALL_COMPONENTS=ON $(ELASTIX_SOURCE_DIR)
workingDirectory: $(ELASTIX_BINARY_DIR)
- task: CMake@1
displayName: 'CMake Build Elastix'
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
- task: CMake@1
displayName: 'CMake Generate Elastix'
inputs:
cmakeArgs: -DITK_DIR=$(ITK_BINARY_DIR) -DBUILD_TESTING=ON -DUSE_ALL_COMPONENTS=ON $(Build.Repository.LocalPath)
cmakeArgs: -DITK_DIR=$(ITK_BINARY_DIR) -DBUILD_TESTING=ON -DELASTIX_USE_GTEST=ON -DUSE_ALL_COMPONENTS=ON $(Build.Repository.LocalPath)
workingDirectory: $(ELASTIX_BINARY_DIR)
- task: CMake@1
displayName: 'CMake Build Elastix'
Expand Down
12 changes: 5 additions & 7 deletions Testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ macro( elx_add_run_test testbasename howtocompare )
CONFIGURATIONS Release
COMMAND ${python_executable} ${pythonlandmarks}
-b ${baselineTP} -d ${output_dir} -f ${TestDataDir}/3DCT_lung_baseline_landmarks.txt -t 1.0
-p $<TARGET_FILE:transformix> )
-p $<TARGET_FILE:transformix_exe> )
set_tests_properties( ${testname}_COMPARE_LANDMARKS
PROPERTIES DEPENDS ${testname}_OUTPUT )
endif()
Expand Down Expand Up @@ -980,10 +980,8 @@ elx_add_run_test( 3DCT_lung.NC.bspline.ASGD.001d # manual estimation and no adap
-t0 ${TestDataDir}/transformparameters.3DCT_lung.affine.txt
-p ${TestDataDir}/parameters.3D.NC.bspline.ASGD.001d.txt )

if(${ELASTIX_BUILD_EXECUTABLE})
# Test transformix to check memory problem
trx_add_test( TransformixMemoryTest
-in ${TestDataDir}/3DCT_lung_baseline_small.mha
-tp ${TestDataDir}/transformparameters.3DCT_lung.affine.txt )
endif()
# Test transformix to check memory problem
trx_add_test( TransformixMemoryTest
-in ${TestDataDir}/3DCT_lung_baseline_small.mha
-tp ${TestDataDir}/transformparameters.3DCT_lung.affine.txt )

1 change: 0 additions & 1 deletion Testing/Dashboard/elxDashboard_LKEB_win10-64_VS2015.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ set( dashboard_cache "
ITK_DIR:PATH=D:/toolkits/ITK/latest_release/bin_VS2015

// Some elastix settings, defining the configuration:
ELASTIX_BUILD_EXECUTABLE=ON
ELASTIX_BUILD_TESTING:BOOL=ON
ELASTIX_ENABLE_PACKAGER:BOOL=ON
ELASTIX_USE_EIGEN:BOOL=OFF
Expand Down