Skip to content

Commit

Permalink
Link just against required VTK modules on Linux.
Browse files Browse the repository at this point in the history
Note:
If VTK is installed below /opt or anywhere else just add a path to GLOB_RECURSE.
  • Loading branch information
jobermayr authored and wwmayer committed Nov 20, 2016
1 parent cf22852 commit af62262
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 36 deletions.
29 changes: 18 additions & 11 deletions CMakeLists.txt
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions src/3rdParty/salomesmesh/CMakeLists.txt
Expand Up @@ -20,7 +20,6 @@ if (VTK_OPTIONS)
add_definitions(${VTK_OPTIONS})
endif()

include(${VTK_USE_FILE})
include_directories(
src/SMDS
src/Driver
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 1 addition & 9 deletions src/Mod/Fem/App/CMakeLists.txt
Expand Up @@ -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})
Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions src/Mod/Fem/CMakeLists.txt
Expand Up @@ -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)
Expand Down
13 changes: 2 additions & 11 deletions src/Mod/Fem/Gui/CMakeLists.txt
Expand Up @@ -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}
Expand All @@ -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})
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/MeshPart/App/CMakeLists.txt
Expand Up @@ -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)
Expand All @@ -21,6 +20,7 @@ include_directories(
${PYTHON_INCLUDE_DIRS}
${XercesC_INCLUDE_DIRS}
${SMESH_INCLUDE_DIR}
${VTK_INCLUDE_DIRS}
)


Expand Down

0 comments on commit af62262

Please sign in to comment.