From af62262021cc4ade42f232d86e8b96b553307691 Mon Sep 17 00:00:00 2001 From: Johannes Obermayr Date: Tue, 4 Oct 2016 20:19:38 +0200 Subject: [PATCH] Link just against required VTK modules on Linux. Note: If VTK is installed below /opt or anywhere else just add a path to GLOB_RECURSE. --- CMakeLists.txt | 29 +++++++++++++++---------- src/3rdParty/salomesmesh/CMakeLists.txt | 3 +-- src/Mod/Fem/App/CMakeLists.txt | 10 +-------- src/Mod/Fem/CMakeLists.txt | 2 -- src/Mod/Fem/Gui/CMakeLists.txt | 13 ++--------- src/Mod/MeshPart/App/CMakeLists.txt | 2 +- 6 files changed, 23 insertions(+), 36 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dc065bea2c16..64c2e6e7dfd2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -585,19 +585,26 @@ endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") vtkFiltersSources vtkFiltersGeometry ) - # On Linux vtkParallelMPI package is required - if (UNIX AND NOT APPLE) - set (VTK_COMPONENTS - ${VTK_COMPONENTS} - vtkIOMPIParallel - vtkParallelMPI) + # check which modules are available + if(UNIX AND NOT APPLE) + list(APPEND VTK_COMPONENTS vtkIOMPIParallel vtkParallelMPI) + foreach(_module ${VTK_COMPONENTS}) + file(GLOB_RECURSE _module_exists /usr/lib*/cmake/*${_module}.cmake + ${CMAKE_ROOT}/*${_module}.cmake) + if(_module_exists) + list(APPEND AVAILABLE_VTK_COMPONENTS ${_module}) + endif() + endforeach() endif() - # For Debian testing you may have to only allow a certain list of components: - # http://forum.freecadweb.org/viewtopic.php?f=4&t=15646&start=10#p141693 - # - #find_package(VTK COMPONENTS ${VTK_COMPONENTS} REQUIRED NO_MODULE) #don't check VERSION 6 as this would exclude version 7 - find_package(VTK REQUIRED NO_MODULE) #don't check VERSION 6 as this would exclude version 7 + # don't check VERSION 6 as this would exlude VERSION 7 + if(AVAILABLE_VTK_COMPONENTS) + message(STATUS "VTK components: ${AVAILABLE_VTK_COMPONENTS}") + find_package(VTK COMPONENTS ${AVAILABLE_VTK_COMPONENTS} REQUIRED NO_MODULE) + else() + message(STATUS "VTK components: not found or used") + find_package(VTK REQUIRED NO_MODULE) + endif() set(BUILD_FEM_VTK ON) if(${VTK_MAJOR_VERSION} LESS 6) diff --git a/src/3rdParty/salomesmesh/CMakeLists.txt b/src/3rdParty/salomesmesh/CMakeLists.txt index bee55100f546..c8528186f81d 100644 --- a/src/3rdParty/salomesmesh/CMakeLists.txt +++ b/src/3rdParty/salomesmesh/CMakeLists.txt @@ -20,7 +20,6 @@ if (VTK_OPTIONS) add_definitions(${VTK_OPTIONS}) endif() -include(${VTK_USE_FILE}) include_directories( src/SMDS src/Driver @@ -265,7 +264,7 @@ SET_BIN_DIR(SMESHDS SMESHDS) ######### FILE(GLOB SMESH_source_files src/SMESH/*.c src/SMESH/*.cpp src/Controls/*.cpp inc/SMESH_*.h*) ADD_LIBRARY(SMESH SHARED ${SMESH_source_files}) -TARGET_LINK_LIBRARIES(SMESH SMDS SMESHDS Driver DriverSTL DriverDAT DriverUNV ${SMESH_LIBS} ${OPENCASCADE_LIBRARIES} ${OCC_LIBRARIES} ${OCC_DEBUG_LIBRARIES} ${OCC_OCAF_DEBUG_LIBRARIES} ${OCC_OCAF_LIBRARIES} ${MEDFILE_LIBRARIES}) +TARGET_LINK_LIBRARIES(SMESH SMDS SMESHDS Driver DriverSTL DriverDAT DriverUNV ${SMESH_LIBS} ${OPENCASCADE_LIBRARIES} ${OCC_LIBRARIES} ${OCC_DEBUG_LIBRARIES} ${OCC_OCAF_DEBUG_LIBRARIES} ${OCC_OCAF_LIBRARIES} ${MEDFILE_LIBRARIES} ${VTK_LIBRARIES}) SET_BIN_DIR(SMESH SMESH) if(WIN32) diff --git a/src/Mod/Fem/App/CMakeLists.txt b/src/Mod/Fem/App/CMakeLists.txt index 7afb6fd1a39b..2c69918e83fa 100755 --- a/src/Mod/Fem/App/CMakeLists.txt +++ b/src/Mod/Fem/App/CMakeLists.txt @@ -22,7 +22,7 @@ include_directories( ${XercesC_INCLUDE_DIRS} ${SMESH_INCLUDE_DIR} ${NETGEN_INCLUDE_DIRS} - ${VTK_INCLUDE_DIR} + ${VTK_INCLUDE_DIRS} ) link_directories(${OCC_LIBRARY_DIR}) @@ -43,16 +43,8 @@ if(BUILD_FEM_NETGEN) ) endif(BUILD_FEM_NETGEN) -if(BUILD_FEM_VTK) - set(Fem_LIBS - ${Fem_LIBS} - ${VTK_LIBRARIES} - ) -endif(BUILD_FEM_VTK) - generate_from_xml(FemMeshPy) - SET(Python_SRCS FemMeshPy.xml FemMeshPyImp.cpp diff --git a/src/Mod/Fem/CMakeLists.txt b/src/Mod/Fem/CMakeLists.txt index ac036bd1e4ae..250388674447 100755 --- a/src/Mod/Fem/CMakeLists.txt +++ b/src/Mod/Fem/CMakeLists.txt @@ -3,8 +3,6 @@ if(BUILD_FEM_VTK) add_definitions(-DFC_USE_VTK) endif(BUILD_FEM_VTK) -include(${VTK_USE_FILE}) - add_subdirectory(App) if(BUILD_GUI) diff --git a/src/Mod/Fem/Gui/CMakeLists.txt b/src/Mod/Fem/Gui/CMakeLists.txt index b30490ac6b36..661b7835b231 100755 --- a/src/Mod/Fem/Gui/CMakeLists.txt +++ b/src/Mod/Fem/Gui/CMakeLists.txt @@ -7,8 +7,6 @@ endif(MSVC) if(BUILD_FEM_NETGEN) add_definitions(-DFCWithNetgen) endif(BUILD_FEM_NETGEN) -find_package(VTK REQUIRED) -include(${VTK_USE_FILE}) include_directories( ${CMAKE_BINARY_DIR} @@ -22,7 +20,7 @@ include_directories( ${PYTHON_INCLUDE_DIRS} ${XercesC_INCLUDE_DIRS} ${SMESH_INCLUDE_DIR} - ${VTK_INCLUDE_DIR} + ${VTK_INCLUDE_DIRS} ) link_directories(${OCC_LIBRARY_DIR}) @@ -34,13 +32,6 @@ set(FemGui_LIBS FreeCADGui ) -if(BUILD_FEM_VTK) - set(FemGui_LIBS - ${FemGui_LIBS} - ${VTK_LIBRARIES} - ) -endif(BUILD_FEM_VTK) - generate_from_xml(ViewProviderFemMeshPy) SET(Python_SRCS @@ -331,7 +322,7 @@ SET(FemGui_SRCS add_library(FemGui SHARED ${FemGui_SRCS}) -target_link_libraries(FemGui ${FemGui_LIBS}) +target_link_libraries(FemGui ${FemGui_LIBS} ${VTK_LIBRARIES}) fc_target_copy_resource(FemGui diff --git a/src/Mod/MeshPart/App/CMakeLists.txt b/src/Mod/MeshPart/App/CMakeLists.txt index 2f3e95083274..d3efec98f8a3 100644 --- a/src/Mod/MeshPart/App/CMakeLists.txt +++ b/src/Mod/MeshPart/App/CMakeLists.txt @@ -6,7 +6,6 @@ endif(MSVC) if (BUILD_SMESH) add_definitions(-DHAVE_SMESH -DHAVE_MEFISTO) - include(${VTK_USE_FILE}) endif(BUILD_SMESH) if(BUILD_FEM_NETGEN) @@ -21,6 +20,7 @@ include_directories( ${PYTHON_INCLUDE_DIRS} ${XercesC_INCLUDE_DIRS} ${SMESH_INCLUDE_DIR} + ${VTK_INCLUDE_DIRS} )