如何为包含CGAL和VTK库的项目创建CMakeLists.txt [英] How to create a CMakeLists.txt for a project containing CGAL and VTK libraries

查看:345
本文介绍了如何为包含CGAL和VTK库的项目创建CMakeLists.txt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个小程序来评估定向数据(3D表面网格)。我使用vtk库提供的函数进行所有几何计算。 vtkBooleanOperationPolyDataFilter不够鲁棒,并且会随机崩溃。因此,我决定使用cgal库的功能执行布尔操作(已通过一些示例数据进行了测试->没有稳定性问题)。

I've written a small programm for evaluating sientific data (3D surface mesh). I do all the geometric calculations with functions provided by the vtk library. The vtkBooleanOperationPolyDataFilter is no robust and crashes randomly. So i decided to performe the boolean operations with functions of the cgal library (tested with some sample data -> no stability problems).

现在我想合并这两个项目一起。

Now I want to merge this two projects together.

vtk项目CMakeLists.txt:

The vtk project 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:

The cgal project CMakeLists.txt:


project(cgal_test)

project( 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( 2.6版)endif()endif()

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)

find_package(CGAL QUIET COMPONENTS Core )

如果(CGAL_FOUND)

if ( CGAL_FOUND )

include($ {CGAL_USE_FILE})

include( ${CGAL_USE_FILE} )

include(CGAL_CreateSingleSourceCGALProgram)

include( CGAL_CreateSingleSourceCGALProgram )

include_directories( ../../include之前)

include_directories (BEFORE "../../include")

include_directories(在 include之前)

include_directories (BEFORE "include")

create_single_source_cgal_program( cgaltest.cpp)else()

create_single_source_cgal_program( "cgaltest.cpp" ) else()

消息(状态此程序需要CGAL库,不会被编译。)

endif()

message(STATUS "This program requires the CGAL library, and will not be compiled.")
endif()

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

I tried to merge this to files but I've failed. Could some give me a hint how to create a proper CMakeLists.txt for a project which utilizes both libraries.

在此先感谢您!

Ps:我正在Windows平台上工作

P.s.: I'm working on a Windows plattform

推荐答案

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

Basically what needs to happen is that you need to provide include directories and link libraries from both of your dependencies to your executable.

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

这篇关于如何为包含CGAL和VTK库的项目创建CMakeLists.txt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆