我编写了一个用于评估科学数据(3D表面网格)的小程序。我使用vtk库提供的函数进行所有几何计算。 vtkBooleanOperationPolyDataFilter不健壮并随机崩溃。所以我决定使用cgal库的函数来执行布尔运算(使用一些示例数据进行测试 - >没有稳定性问题)。
现在我想将这两个项目合并在一起。
vtk项目CMakeLists.txt:
cmake_minimum_required(VERSION 2.8)
PROJECT(calcporosity)
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
add_executable(calcporosity MACOSX_BUNDLE calcporosity)
if(VTK_LIBRARIES)
target_link_libraries(calcporosity ${VTK_LIBRARIES})
else()
target_link_libraries(calcporosity vtkHybrid vtkWidgets)
endif()
cgal项目CMakeLists.txt:
项目(cgal_test)
cmake_minimum_required(VERSION 2.6.2) if(" $ {CMAKE_MAJOR_VERSION}。$ {CMAKE_MINOR_VERSION}" VERSION_GREATER 2.6)if(" $ {CMAKE_MAJOR_VERSION}。$ {CMAKE_MINOR_VERSION}。$ {CMAKE_PATCH_VERSION}" VERSION_GREATER 2.8.3) cmake_policy(VERSION 2.8.4)else() cmake_policy(VERSION 2.6)endif()endif()
find_package(CGAL QUIET COMPONENTS Core)
if(CGAL_FOUND)
include($ {CGAL_USE_FILE})
include(CGAL_CreateSingleSourceCGALProgram)
include_directories(BEFORE" ../../ include")
include_directories(BEFORE" include")
create_single_source_cgal_program(" cgaltest.cpp")else()
消息(状态"此程序需要CGAL库,不会被编译。")
ENDIF()
我尝试将其合并到文件中但我失败了。有些人可以给我一个提示,告诉我如何为一个利用两个库的项目创建一个合适的CMakeLists.txt。
提前致谢和最诚挚的问候!
P.s。:我正在使用Windows平台
答案 0 :(得分:3)
基本上需要发生的是,您需要提供从两个依赖项到可执行文件的包含目录和链接库。
cmake_minimum_required(VERSION 2.8.4)
project( cgal_vtk_test )
# Find CGAL
find_package(CGAL REQUIRED COMPONENTS Core) # If the dependency is required, use REQUIRED option - if it's not found CMake will issue an error
include( ${CGAL_USE_FILE} )
# Find VTK
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
# Setup your executable
include_directories (BEFORE "../../include")
include_directories (BEFORE "include")
include( CGAL_CreateSingleSourceCGALProgram )
create_single_source_cgal_program( "cgal_vtk_test.cpp" ) # This will create an executable target with name 'cgal_vtk_test'
# Add VTK link libraries to your executable target
target_link_libraries(cgal_vtk_test ${VTK_LIBRARIES})