diff --git a/CMake/elastixExportTarget.cmake b/CMake/elastixExportTarget.cmake index e895f2752..2980020af 100644 --- a/CMake/elastixExportTarget.cmake +++ b/CMake/elastixExportTarget.cmake @@ -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} diff --git a/CMakeLists.txt b/CMakeLists.txt index 786fae25f..04ad83ae9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() #--------------------------------------------------------------------- @@ -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() #--------------------------------------------------------------------- @@ -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} ) diff --git a/Core/CMakeLists.txt b/Core/CMakeLists.txt index 1b371e84a..818d378dd 100644 --- a/Core/CMakeLists.txt +++ b/Core/CMakeLists.txt @@ -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 @@ -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 @@ -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} diff --git a/Core/Main/GTesting/CMakeLists.txt b/Core/Main/GTesting/CMakeLists.txt index e81c6e968..983a7cb5b 100644 --- a/Core/Main/GTesting/CMakeLists.txt +++ b/Core/Main/GTesting/CMakeLists.txt @@ -5,7 +5,7 @@ add_executable(ElastixLibGTest target_link_libraries( ElastixLibGTest GTest::GTest GTest::Main - elastix + elastix_lib ${ITK_LIBRARIES} ) diff --git a/ElastixConfig.cmake.in b/ElastixConfig.cmake.in index 70193fde0..bb2be7e01 100644 --- a/ElastixConfig.cmake.in +++ b/ElastixConfig.cmake.in @@ -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@ ) diff --git a/Testing/CI/Azure/ci.yml b/Testing/CI/Azure/ci.yml index ea6eeabe9..7e9b756e9 100644 --- a/Testing/CI/Azure/ci.yml +++ b/Testing/CI/Azure/ci.yml @@ -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' @@ -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' @@ -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' diff --git a/Testing/CMakeLists.txt b/Testing/CMakeLists.txt index 37a6d2cc3..71e7bed9a 100644 --- a/Testing/CMakeLists.txt +++ b/Testing/CMakeLists.txt @@ -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 $ ) + -p $ ) set_tests_properties( ${testname}_COMPARE_LANDMARKS PROPERTIES DEPENDS ${testname}_OUTPUT ) endif() @@ -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 ) diff --git a/Testing/Dashboard/elxDashboard_LKEB_win10-64_VS2015.cmake b/Testing/Dashboard/elxDashboard_LKEB_win10-64_VS2015.cmake index 59e672721..e776502f1 100644 --- a/Testing/Dashboard/elxDashboard_LKEB_win10-64_VS2015.cmake +++ b/Testing/Dashboard/elxDashboard_LKEB_win10-64_VS2015.cmake @@ -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