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.
This commit is contained in:
Johannes Obermayr 2016-10-04 20:19:38 +02:00 committed by wmayer
parent cf22852ee3
commit af62262021
6 changed files with 23 additions and 36 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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}
)