【问题标题】:How to create a CMakeLists.txt for a project containing CGAL and VTK libraries如何为包含 CGAL 和 VTK 库的项目创建 CMakeLists.txt
【发布时间】:2016-01-15 07:14:37
【问题描述】:

我编写了一个小程序来评估 sientific 数据(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(版本 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(版本 2.8.4)否则() cmake_policy(VERSION 2.6) endif() endif()

find_package(CGAL QUIET COMPONENTS Core)

如果 (CGAL_FOUND)

包括(${CGAL_USE_FILE})

包括(CGAL_CreateSingleSourceCGALProgram)

include_directories(在“../../include”之前)

include_directories(在“包含”之前)

create_single_source_cgal_program("cgaltest.cpp") else()

message(STATUS "这个程序需要 CGAL 库,不会被编译。")
endif()

我尝试将其合并到文件中,但失败了。有人可以给我一个提示,如何为使用这两个库的项目创建适当的 CMakeLists.txt。

提前致谢并致以最诚挚的问候!

P.s.:我正在开发一个 Windows 平台

【问题讨论】:

    标签: c++ cmake vtk cgal


    【解决方案1】:

    基本上需要做的是,您需要提供包含目录和链接库,从您的两个依赖项到您的可执行文件。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-06
      • 1970-01-01
      • 1970-01-01
      • 2011-04-11
      • 2017-07-03
      • 1970-01-01
      相关资源
      最近更新 更多