Skip to content

Commit

Permalink
ENH: Support remote and external building
Browse files Browse the repository at this point in the history
Fixed / simplied paths and variable to support both building as an ITK
remote module (via ITK / CMake) as well as building by pointing to a
pre-compiled ITK.
  • Loading branch information
aylward committed Mar 11, 2020
1 parent 0bff6cb commit ac4b205
Show file tree
Hide file tree
Showing 65 changed files with 45 additions and 176 deletions.
47 changes: 28 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,12 @@ set( TubeTK_ITK_COMPONENTS
ITKStatistics
ITKTransform
)

####
# Find ITK
####
find_package( ITK COMPONENTS ${TubeTK_ITK_COMPONENTS} REQUIRED )
if( NOT ITK_SOURCE_DIR )
find_package( ITK COMPONENTS ${TubeTK_ITK_COMPONENTS} REQUIRED )
mark_as_advanced( CLEAR ITK_DIR )
if( NOT ITK_FOUND )
find_package( ITK )
Expand All @@ -147,8 +151,8 @@ if( NOT ITK_SOURCE_DIR )
set( ITK_DIR "NOT_FOUND" CACHE PATH
"Path to ITK installation/build directory." FORCE )
endif()
include( ${ITK_USE_FILE} )
endif()
include( ${ITK_USE_FILE} )

####
# Find Python
Expand Down Expand Up @@ -259,48 +263,53 @@ set( TubeTKLib_INCLUDE_DIRS
$<INSTALL_INTERFACE:include/TubeTKLib/Registration>
$<INSTALL_INTERFACE:include/TubeTKLib/Segmentation> )

set( TubeTKLib_LIBRARY_DIRS
${TubeTK_BINARY_DIR}/bin
${TubeTK_BINARY_DIR}/lib )
#set( TubeTKLib_LIBRARY_DIRS
#${TubeTK_BINARY_DIR}/bin
#${TubeTK_BINARY_DIR}/lib )

####
# TubeTK includes TubeTKLib's libraries and include directories
####
set( TubeTK_LIBRARIES
TubeTK
${TubeTKLib_LIBRARIES} )

set( TubeTK_INCLUDE_DIRS
${TubeTK_SOURCE_DIR}/include
$<INSTALL_INTERFACE:include>
${TubeTKLib_INCLUDE_DIRS} )

set( TubeTK_LIBRARY_DIRS
${TubeTK_BINARY_DIR}/bin
${TubeTK_BINARY_DIR}/lib
${TubeTK_EXECUTABLE_DIRS} )
#set( TubeTK_LIBRARY_DIRS
#${TubeTK_BINARY_DIR}/bin
#${TubeTK_BINARY_DIR}/lib
#${TubeTK_EXECUTABLE_DIRS} )

set( TubeTK_SYSTEM_INCLUDE_DIRS ${TubeTK_INCLUDE_DIRS} )
set( TubeTK_SYSTEM_LIBRARY_DIRS ${TubeTK_LIBRARY_DIRS} )
#set( TubeTK_SYSTEM_LIBRARY_DIRS ${TubeTK_LIBRARY_DIRS} )

####
# Build base library and optional components
####
find_package( ITK COMPONENTS ${TubeTK_ITK_COMPONENTS} REQUIRED )
include( ${ITK_USE_FILE} )
include_directories(
${TubeTK_SOURCE_DIR}/TubeTKLib
${TubeTK_SOURCE_DIR}/TubeTKLib/Common
${TubeTK_SOURCE_DIR}/TubeTKLib/Filtering
${TubeTK_SOURCE_DIR}/TubeTKLib/IO
${TubeTK_SOURCE_DIR}/TubeTKLib/MetaIO
${TubeTK_SOURCE_DIR}/TubeTKLib/Numerics
${TubeTK_SOURCE_DIR}/TubeTKLib/ObjectDocuments
${TubeTK_SOURCE_DIR}/TubeTKLib/Registration
${TubeTK_SOURCE_DIR}/TubeTKLib/Segmentation )

add_subdirectory( TubeTKLib )

install( TARGETS ${TubeTKLib_LIBRARIES} EXPORT TubeTK-targets
install( TARGETS ${TubeTKLib_LIBRARIES} EXPORT TubeTKLib-targets
ARCHIVE DESTINATION lib )

install( EXPORT TubeTK-targets DESTINATION lib/cmake )
install( EXPORT TubeTKLib-targets DESTINATION lib/cmake )

####
# Build ITK module
####
if( NOT ITK_SOURCE_DIR )
# ITK has already been found (see above), so skip these two lines...
# find_package( ITK COMPONENTS ${TubeTK_ITK_COMPONENTS} REQUIRED )
# include( ${ITK_USE_FILE} )
list( APPEND CMAKE_MODULE_PATH ${ITK_CMAKE_DIR} )
include( ITKModuleExternal )
else()
Expand Down
6 changes: 3 additions & 3 deletions TubeTKLib/Filtering/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ endif()

add_library( TubeTKLibFiltering INTERFACE )
target_include_directories( TubeTKLibFiltering INTERFACE
${ITK_INCLUDE_DIRS}
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
)
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>" )
target_link_libraries( TubeTKLibFiltering INTERFACE
TubeTKLibNumerics )
include_directories(
${ITK_INCLUDE_DIRS} )

if( BUILD_TESTING )
add_subdirectory( Testing )
Expand Down
6 changes: 4 additions & 2 deletions TubeTKLib/Registration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,16 @@ endif()
add_library( TubeTKLibRegistration INTERFACE )

target_include_directories( TubeTKLibRegistration INTERFACE
${ITK_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR} )
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>" )

target_link_libraries( TubeTKLibRegistration INTERFACE
TubeTKLibFiltering
TubeTKLibNumerics
)

include_directories(
${ITK_INCLUDE_DIRS} )

if( BUILD_TESTING )
add_subdirectory( Testing )
endif( BUILD_TESTING )
Expand Down
4 changes: 3 additions & 1 deletion TubeTKLib/Segmentation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ endif()
add_library( TubeTKLibSegmentation INTERFACE )

target_include_directories( TubeTKLibSegmentation INTERFACE
${ITK_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR} )

include_directories(
${ITK_INCLUDE_DIRS} )

target_link_libraries( TubeTKLibSegmentation INTERFACE
TubeTKLibIO
TubeTKLibMetaIO
Expand Down
1 change: 0 additions & 1 deletion apps/AtlasBuilderUsingIntensity/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ SEMMacroBuildCLI(
ADDITIONAL_SRCS tubeAtlasSummation.cxx
LOGO_HEADER ${TubeTK_SOURCE_DIR}/docs/TubeTKLogo.h
TARGET_LIBRARIES
TubeTK
${ITK_LIBRARIES}
TubeTKLibCommon
TubeTKLibObjectDocuments
Expand Down
1 change: 0 additions & 1 deletion apps/ComputeBinaryImageSimilarityMetrics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ SEMMacroBuildCLI(
${TubeTK_SOURCE_DIR}/docs/TubeTKLogo.h
TARGET_LIBRARIES
${ITK_LIBRARIES}
TubeTK
)

if( BUILD_TESTING )
Expand Down
1 change: 0 additions & 1 deletion apps/ComputeImageSimilarityMetrics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ SEMMacroBuildCLI(
${TubeTK_SOURCE_DIR}/docs/TubeTKLogo.h
TARGET_LIBRARIES
${ITK_LIBRARIES}
TubeTK
)

if( BUILD_TESTING )
Expand Down
1 change: 0 additions & 1 deletion apps/ComputeImageStatistics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ SEMMacroBuildCLI(
${TubeTK_SOURCE_DIR}/docs/TubeTKLogo.h
TARGET_LIBRARIES
${ITK_LIBRARIES}
TubeTK
)

if( BUILD_TESTING )
Expand Down
1 change: 0 additions & 1 deletion apps/ComputeImageToTubeRigidMetricImage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ SEMMacroBuildCLI(
${ITK_LIBRARIES}
ITKIOSpatialObjects
ITKIOMeta
TubeTK
TubeTKLibCommon
TubeTKLibNumerics
)
Expand Down
1 change: 0 additions & 1 deletion apps/ComputeRegionSignatures/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,5 @@ SEMMacroBuildCLI(
${TubeTK_SOURCE_DIR}/docs/TubeTKLogo.h
TARGET_LIBRARIES
${ITK_LIBRARIES}
TubeTK
TubeTKCommon
)
3 changes: 2 additions & 1 deletion apps/ComputeSegmentTubesParameters/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ SEMMacroBuildCLI(
LOGO_HEADER
${TubeTK_SOURCE_DIR}/docs/TubeTKLogo.h
TARGET_LIBRARIES
TubeTK
${ITK_LIBRARIES}
ITKIOMeta
ITKIOSpatialObjects
TubeTKLibCommon
TubeTKLibNumerics
TubeTKLibMetaIO
)

if( BUILD_TESTING )
Expand Down
1 change: 0 additions & 1 deletion apps/ComputeTrainingMask/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ SEMMacroBuildCLI(
LOGO_HEADER
${TubeTK_SOURCE_DIR}/docs/TubeTKLogo.h
TARGET_LIBRARIES
TubeTK
${ITK_LIBRARIES}
ITKIOMeta
ITKIOSpatialObjects
Expand Down
1 change: 0 additions & 1 deletion apps/ComputeTubeFlyThroughImage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ SEMMacroBuildCLI(
LOGO_HEADER
${TubeTK_SOURCE_DIR}/docs/TubeTKLogo.h
TARGET_LIBRARIES
TubeTK
${ITK_LIBRARIES}
ITKIOMeta
ITKIOSpatialObjects
Expand Down
1 change: 0 additions & 1 deletion apps/ComputeTubeGraphProbability/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ SEMMacroBuildCLI(
LOGO_HEADER
${TubeTK_SOURCE_DIR}/docs/TubeTKLogo.h
TARGET_LIBRARIES
TubeTK
${ITK_LIBRARIES}
TubeTKLibCommon
)
Expand Down
1 change: 0 additions & 1 deletion apps/ComputeTubeGraphSimilarityKernelMatrix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ SEMMacroBuildCLI(
LOGO_HEADER
${TubeTK_SOURCE_DIR}/docs/TubeTKLogo.h
TARGET_LIBRARIES
TubeTK
${ITK_LIBRARIES}
TubeTKLibCommon
ADDITIONAL_SRCS
Expand Down
1 change: 0 additions & 1 deletion apps/ComputeTubeMeasures/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ SEMMacroBuildCLI(
LOGO_HEADER
${TubeTK_SOURCE_DIR}/docs/TubeTKLogo.h
TARGET_LIBRARIES
TubeTK
${ITK_LIBRARIES}
TubeTKLibCommon
)
Expand Down
1 change: 0 additions & 1 deletion apps/ComputeTubeProbability/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ SEMMacroBuildCLI(
LOGO_HEADER
${TubeTK_SOURCE_DIR}/docs/TubeTKLogo.h
TARGET_LIBRARIES
TubeTK
${ITK_LIBRARIES}
ITKIOMeta
ITKIOSpatialObjects
Expand Down
1 change: 0 additions & 1 deletion apps/ComputeTubeTortuosityMeasures/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ SEMMacroBuildCLI(
LOGO_HEADER
${TubeTK_SOURCE_DIR}/docs/TubeTKLogo.h
TARGET_LIBRARIES
TubeTK
${ITK_LIBRARIES}
${VTK_LIBRARIES}
ITKIOMeta
Expand Down
1 change: 0 additions & 1 deletion apps/Convert4DImageTo3DImages/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ SEMMacroBuildCLI(
LOGO_HEADER
${TubeTK_SOURCE_DIR}/docs/TubeTKLogo.h
TARGET_LIBRARIES
TubeTK
${ITK_LIBRARIES}
TubeTKLibCommon
)
Expand Down
1 change: 0 additions & 1 deletion apps/ConvertCSVToImages/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ SEMMacroBuildCLI(
LOGO_HEADER
${TubeTK_SOURCE_DIR}/docs/TubeTKLogo.h
TARGET_LIBRARIES
TubeTK
${ITK_LIBRARIES}
TubeTKLibCommon
)
Expand Down
1 change: 0 additions & 1 deletion apps/ConvertImagesToCSV/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ SEMMacroBuildCLI(
LOGO_HEADER
${TubeTK_SOURCE_DIR}/docs/TubeTKLogo.h
TARGET_LIBRARIES
TubeTK
${ITK_LIBRARIES}
TubeTKLibCommon
ITKIOSpatialObjects
Expand Down
1 change: 0 additions & 1 deletion apps/ConvertShrunkenSeedImageToList/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ SEMMacroBuildCLI(
LOGO_HEADER
${TubeTK_SOURCE_DIR}/docs/TubeTKLogo.h
TARGET_LIBRARIES
TubeTK
${ITK_LIBRARIES}
)

Expand Down
1 change: 0 additions & 1 deletion apps/ConvertSpatialGraphToImage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ SEMMacroBuildCLI(
${TubeTK_SOURCE_DIR}/docs/TubeTKLogo.h
TARGET_LIBRARIES
${ITK_LIBRARIES}
TubeTK
TubeTKLibCommon
TubeTKLibNumerics
)
Expand Down
1 change: 0 additions & 1 deletion apps/ConvertTRE/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ SEMMacroBuildCLI(
LOGO_HEADER
${TubeTK_SOURCE_DIR}/docs/TubeTKLogo.h
TARGET_LIBRARIES
TubeTK
${ITK_LIBRARIES}
ITKIOMeta
ITKIOSpatialObjects
Expand Down
2 changes: 0 additions & 2 deletions apps/ConvertTubesToDensityImage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ SEMMacroBuildCLI(
LOGO_HEADER
${TubeTK_SOURCE_DIR}/docs/TubeTKLogo.h
TARGET_LIBRARIES
TubeTK
${ITK_LIBRARIES}
ITKIOMeta
ITKIOSpatialObjects
TubeTK
)

if( BUILD_TESTING )
Expand Down
2 changes: 0 additions & 2 deletions apps/ConvertTubesToImage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ SEMMacroBuildCLI(
LOGO_HEADER
${TubeTK_SOURCE_DIR}/docs/TubeTKLogo.h
TARGET_LIBRARIES
TubeTK
${ITK_LIBRARIES}
ITKIOMeta
ITKIOSpatialObjects
TubeTK
TubeTKLibCommon
)

Expand Down
1 change: 0 additions & 1 deletion apps/ConvertTubesToSurface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ SEMMacroBuildCLI(
LOGO_HEADER
${TubeTK_SOURCE_DIR}/docs/TubeTKLogo.h
TARGET_LIBRARIES
TubeTK
${ITK_LIBRARIES}
${VTK_LIBRARIES}
ITKIOMeta
Expand Down
1 change: 0 additions & 1 deletion apps/ConvertTubesToTubeGraph/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ SEMMacroBuildCLI(
LOGO_HEADER
${TubeTK_SOURCE_DIR}/docs/TubeTKLogo.h
TARGET_LIBRARIES
TubeTK
${ITK_LIBRARIES}
ITKIOMeta
ITKIOSpatialObjects
Expand Down
1 change: 0 additions & 1 deletion apps/ConvertTubesToTubeTree/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ SEMMacroBuildCLI(
LOGO_HEADER
${TubeTK_SOURCE_DIR}/docs/TubeTKLogo.h
TARGET_LIBRARIES
TubeTK
${ITK_LIBRARIES}
ITKIOMeta
ITKIOSpatialObjects
Expand Down
1 change: 0 additions & 1 deletion apps/CropImage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ SEMMacroBuildCLI(
LOGO_HEADER ${TubeTK_SOURCE_DIR}/docs/TubeTKLogo.h
TARGET_LIBRARIES
${ITK_LIBRARIES}
TubeTK
TubeTKLibCommon )

if( BUILD_TESTING )
Expand Down
1 change: 0 additions & 1 deletion apps/CropTubes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ SEMMacroBuildCLI(
${ITK_LIBRARIES}
ITKIOMeta
ITKIOSpatialObjects
TubeTK
TubeTKLibCommon
)

Expand Down
1 change: 0 additions & 1 deletion apps/DeblendTomosynthesisSlicesUsingPrior/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ SEMMacroBuildCLI(
${ITK_LIBRARIES}
ITKMetaIO
ITKOptimizers
TubeTK
TubeTKLibCommon
)

Expand Down
1 change: 0 additions & 1 deletion apps/EnhanceCoherenceAndEdgesUsingDiffusion/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ SEMMacroBuildCLI(
LOGO_HEADER ${TubeTK_SOURCE_DIR}/docs/TubeTKLogo.h
TARGET_LIBRARIES
${ITK_LIBRARIES}
TubeTK
TubeTKLibCommon
)

Expand Down
1 change: 0 additions & 1 deletion apps/EnhanceCoherenceUsingDiffusion/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ SEMMacroBuildCLI(
LOGO_HEADER ${TubeTK_SOURCE_DIR}/docs/TubeTKLogo.h
TARGET_LIBRARIES
${ITK_LIBRARIES}
TubeTK
TubeTKLibCommon
)

Expand Down
Loading

0 comments on commit ac4b205

Please sign in to comment.