Commit 57901457 authored by Marcus D. Hanwell's avatar Marcus D. Hanwell
Browse files

Add support for private dependencies in VTK

A simple implementation of private dependencies, with some of the most
obvious private dependencies moved over. This should be used for all
dependencies that are not exposed in the public API of the classes in
the module.

The target_link_libraries call defaults to private due to the way CMake
implements the link logic. The private dependency logic can help reduce
link line and include directory length for private links where the
dependency's API is not exposed in the module. Also added code to ensure
include directories are not duplicated for modules in the build tree.

Change-Id: If4535338e8d5e9957d7bcce7d3ab0eadec21d2c4
parent a3e99a32
# Helper to find and configure MPI for VTK targets. Centralize the logic for
# any necessary compiler definitions, linking etc.
find_package(MPI REQUIRED)
mark_as_advanced(MPI_LIBRARY MPI_EXTRA_LIBRARY)
include_directories(${MPI_C_INCLUDE_PATH})
# Needed for MPICH 2
add_definitions("-DMPICH_IGNORE_CXX_SEEK")
# Function to link a VTK target to the necessary MPI libraries.
function(vtk_mpi_link target)
target_link_libraries(${target} LINK_PRIVATE ${MPI_C_LIBRARIES})
if(MPI_CXX_LIBRARIES)
target_link_libraries(${target} LINK_PRIVATE ${MPI_CXX_LIBRARIES})
endif()
endfunction()
......@@ -21,6 +21,7 @@ macro(vtk_module _name)
set(${vtk-module-test}_DECLARED 1)
set(${vtk-module}_DEPENDS "")
set(${vtk-module}_COMPILE_DEPENDS "")
set(${vtk-module}_PRIVATE_DEPENDS "")
set(${vtk-module-test}_DEPENDS "${vtk-module}")
set(${vtk-module}_IMPLEMENTS "")
set(${vtk-module}_DESCRIPTION "description")
......@@ -30,7 +31,7 @@ macro(vtk_module _name)
set(${vtk-module}_EXCLUDE_FROM_WRAP_HIERARCHY 0)
set(${vtk-module}_TEST_LABELS "")
foreach(arg ${ARGN})
if("${arg}" MATCHES "^((|COMPILE_|TEST_|)DEPENDS|DESCRIPTION|TCL_NAME|IMPLEMENTS|DEFAULT|GROUPS|TEST_LABELS)$")
if("${arg}" MATCHES "^((|COMPILE_|PRIVATE_|TEST_|)DEPENDS|DESCRIPTION|TCL_NAME|IMPLEMENTS|DEFAULT|GROUPS|TEST_LABELS)$")
set(_doing "${arg}")
elseif("${arg}" MATCHES "^EXCLUDE_FROM_ALL$")
set(_doing "")
......@@ -53,6 +54,8 @@ macro(vtk_module _name)
list(APPEND ${vtk-module-test}_DEPENDS "${arg}")
elseif("${_doing}" MATCHES "^COMPILE_DEPENDS$")
list(APPEND ${vtk-module}_COMPILE_DEPENDS "${arg}")
elseif("${_doing}" MATCHES "^PRIVATE_DEPENDS$")
list(APPEND ${vtk-module}_PRIVATE_DEPENDS "${arg}")
elseif("${_doing}" MATCHES "^DESCRIPTION$")
set(_doing "")
set(${vtk-module}_DESCRIPTION "${arg}")
......@@ -77,7 +80,9 @@ macro(vtk_module _name)
endforeach()
list(SORT ${vtk-module}_DEPENDS) # Deterministic order.
set(${vtk-module}_LINK_DEPENDS "${${vtk-module}_DEPENDS}")
list(APPEND ${vtk-module}_DEPENDS ${${vtk-module}_COMPILE_DEPENDS})
list(APPEND ${vtk-module}_DEPENDS
${${vtk-module}_COMPILE_DEPENDS}
${${vtk-module}_PRIVATE_DEPENDS})
unset(${vtk-module}_COMPILE_DEPENDS)
list(SORT ${vtk-module}_DEPENDS) # Deterministic order.
list(SORT ${vtk-module-test}_DEPENDS) # Deterministic order.
......@@ -110,7 +115,6 @@ macro(vtk_module_impl)
endif()
if(NOT DEFINED ${vtk-module}_LIBRARIES)
set(${vtk-module}_LIBRARIES "")
foreach(dep IN LISTS ${vtk-module}_LINK_DEPENDS)
list(APPEND ${vtk-module}_LIBRARIES "${${dep}_LIBRARIES}")
endforeach()
......@@ -121,8 +125,8 @@ macro(vtk_module_impl)
list(APPEND ${vtk-module}_INCLUDE_DIRS
${${vtk-module}_BINARY_DIR}
${${vtk-module}_SOURCE_DIR}
)
${${vtk-module}_SOURCE_DIR})
list(REMOVE_DUPLICATES ${vtk-module}_INCLUDE_DIRS)
if(${vtk-module}_INCLUDE_DIRS)
include_directories(${${vtk-module}_INCLUDE_DIRS})
......@@ -476,7 +480,21 @@ function(vtk_module_library name)
vtk_add_library(${vtk-module} ${ARGN} ${_hdrs} ${_instantiator_SRCS} ${_hierarchy})
foreach(dep IN LISTS ${vtk-module}_LINK_DEPENDS)
target_link_libraries(${vtk-module} ${${dep}_LIBRARIES})
target_link_libraries(${vtk-module} LINK_PUBLIC ${${dep}_LIBRARIES})
if(_help_vs7 AND ${dep}_LIBRARIES)
add_dependencies(${vtk-module} ${${dep}_LIBRARIES})
endif()
endforeach()
# Handle the private dependencies, setting up link/include directories.
foreach(dep IN LISTS ${vtk-module}_PRIVATE_DEPENDS)
if(${dep}_INCLUDE_DIRS)
include_directories(${${dep}_INCLUDE_DIRS})
endif()
if(${dep}_LIBRARY_DIRS)
link_directories(${${dep}_LIBRARY_DIRS})
endif()
target_link_libraries(${vtk-module} LINK_PRIVATE ${${dep}_LIBRARIES})
if(_help_vs7 AND ${dep}_LIBRARIES)
add_dependencies(${vtk-module} ${${dep}_LIBRARIES})
endif()
......
cmake_minimum_required(VERSION 2.8.5 FATAL_ERROR)
cmake_minimum_required(VERSION 2.8.7 FATAL_ERROR)
project(VTK)
......
vtk_module(vtkCommonCore
GROUPS
StandAlone
DEPENDS
PRIVATE_DEPENDS
vtksys
TEST_DEPENDS
vtkTestingCore
......
......@@ -4,6 +4,8 @@ vtk_module(vtkCommonDataModel
vtkCommonMath
vtkCommonMisc
vtkCommonTransforms
PRIVATE_DEPENDS
vtksys
TEST_DEPENDS
vtkTestingCore
vtkTestingRendering
......
......@@ -3,6 +3,7 @@ vtk_module(vtkCommonSystem
StandAlone
DEPENDS
vtkCommonCore
PRIVATE_DEPENDS
vtksys
TEST_DEPENDS
vtkTestingCore
......
include(vtkMPI)
vtk_add_test_mpi(DistributedData.cxx TESTING_DATA)
vtk_add_test_mpi(DistributedDataRenderPass.cxx TESTING_DATA)
vtk_add_test_mpi(TransmitImageData.cxx TESTING_DATA)
vtk_add_test_mpi(TransmitImageDataRenderPass.cxx TESTING_DATA)
vtk_add_test_mpi(TransmitRectilinearGrid.cxx TESTING_DATA)
vtk_add_test_mpi(TransmitStructuredGrid.cxx TESTING_DATA)
vtk_mpi_link(TransmitImageData)
vtk_mpi_link(TransmitImageDataRenderPass)
vtk_mpi_link(TransmitRectilinearGrid)
vtk_mpi_link(TransmitStructuredGrid)
include(vtkMPI)
vtk_add_test_mpi(TestPStructuredGridConnectivity.cxx)
vtk_add_test_mpi(TestPStructuredGridGhostDataGenerator.cxx)
vtk_add_test_mpi(TestPUniformGridGhostDataGenerator.cxx)
vtk_mpi_link(TestPStructuredGridConnectivity)
include(vtkMPI)
vtk_add_test_mpi(TestRandomPContingencyStatisticsMPI.cxx)
vtk_add_test_mpi(TestRandomPKMeansStatisticsMPI.cxx)
vtk_add_test_mpi(TestRandomPMomentStatisticsMPI.cxx)
vtk_add_test_mpi(TestRandomPOrderStatisticsMPI.cxx)
vtk_mpi_link(TestRandomPContingencyStatisticsMPI)
vtk_mpi_link(TestRandomPKMeansStatisticsMPI)
vtk_mpi_link(TestRandomPMomentStatisticsMPI)
vtk_mpi_link(TestRandomPOrderStatisticsMPI)
# # -----------------------------------------------------------------------------
# # The following file was being compiled but never added as a testin older
# # vtk. Why is that so?
......
......@@ -88,7 +88,7 @@ vtk_module_library(${vtk-module}
${QVTKNonMocHeaders} ${QVTKMocHeaders}
)
target_link_libraries(${vtk-module} ${QT_LIBRARIES})
target_link_libraries(${vtk-module} LINK_PUBLIC ${QT_LIBRARIES})
if(VTK_USE_X)
target_link_libraries(${vtk-module} ${X11_LIBRARIES})
......
......@@ -3,6 +3,8 @@ vtk_module(vtkGUISupportQtSQL
Qt
DEPENDS
vtkIOSQL
PRIVATE_DEPENDS
vtksys
TEST_DEPENDS
vtkTestingCore
EXCLUDE_FROM_WRAPPING
......
......@@ -3,10 +3,12 @@ vtk_module(vtkIOAMR
StandAlone
DEPENDS
vtkParallelCore
vtkhdf5
vtkFiltersAMR
PRIVATE_DEPENDS
vtkhdf5
vtksys
TEST_DEPENDS
vtkIOXML
vtkTestingCore
vtkTestingRendering
)
\ No newline at end of file
)
......@@ -5,6 +5,7 @@ vtk_module(vtkIOCore
vtkCommonDataModel
vtkCommonExecutionModel
vtkCommonMisc
PRIVATE_DEPENDS
vtkzlib
vtksys
TEST_DEPENDS
......
......@@ -4,7 +4,9 @@ vtk_module(vtkIOExodus
DEPENDS
vtkFiltersGeneral
vtkIOXML
PRIVATE_DEPENDS
vtkexodusII
vtksys
TEST_DEPENDS
vtkTestingRendering
vtkInteractionStyle
......
......@@ -170,7 +170,7 @@ int vtkFFMPEGWriterInternal::Start()
//Set up the codec.
AVCodecContext *c = this->avStream->codec;
c->codec_id = (CodecID)this->avOutputFormat->video_codec;
c->codec_id = (AVCodecID)this->avOutputFormat->video_codec;
#ifdef VTK_FFMPEG_HAS_OLD_HEADER
c->codec_type = CODEC_TYPE_VIDEO;
#else
......
......@@ -6,8 +6,10 @@ vtk_module(vtkIOGeometry
vtkCommonSystem
vtkCommonMisc
vtkIOCore
PRIVATE_DEPENDS
vtkzlib
vtkjsoncpp
vtksys
TEST_DEPENDS
vtkIOAMR
vtkIOLegacy
......
......@@ -9,11 +9,13 @@ vtk_module(vtkIOImage
vtkCommonMisc
vtkCommonTransforms
vtkIOCore
PRIVATE_DEPENDS
vtkjpeg
vtkpng
vtktiff
vtkMetaIO
vtkDICOMParser
vtksys
TEST_DEPENDS
vtkTestingCore
vtkImagingSources
......
......@@ -8,7 +8,9 @@ vtk_module(vtkIOInfovis
vtkIOCore
vtkIOLegacy
vtkInfovisCore
PRIVATE_DEPENDS
vtklibxml2
vtksys
TEST_DEPENDS
vtkInfovisLayout
vtkRenderingCore
......
......@@ -4,6 +4,8 @@ vtk_module(vtkIOLSDyna
DEPENDS
vtkCommonExecutionModel
vtkIOXML
PRIVATE_DEPENDS
vtksys
TEST_DEPENDS
vtkRenderingOpenGL
vtkTestingRendering
......
......@@ -6,6 +6,8 @@ vtk_module(vtkIOLegacy
vtkCommonSystem
vtkCommonMisc
vtkIOCore
PRIVATE_DEPENDS
vtksys
TEST_DEPENDS
vtkFiltersAMR
vtkInteractionStyle
......
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