2015-10-16 108 views
1

我已經編寫了一個用於評估科學數據(3D表面網格)的小程序。我使用vtk庫提供的函數進行所有幾何計算。 vtkBooleanOperationPolyDataFilter不健壯,隨機崩潰。所以我決定用cgal庫的函數來執行布爾操作(用一些示例數據進行測試 - >沒有穩定性問題)。如何爲包含CGAL和VTK庫的項目創建CMakeLists.txt

現在我想合併這兩個項目。

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版) 如果(」 $ {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(版本2.6)ENDIF()ENDIF()

find_package(CGAL QUIET零部件核心)

如果(CGAL_FOUND)

包括($ {CGAL_USE_FILE})

包括(CGAL_CreateSingleSourceCGALProgram)

include_directories(BEFORE 「../../include」)

include_directories(BEFORE 「包括」)

create_single_source_cgal_program( 「cgaltest.cpp」)其他()

消息(STATUS 「這個程序需要CGAL庫,並且不會被編譯。」)
endif()

我試圖合併到文件,但我失敗了。有人能給我一個提示如何爲一個利用兩個庫的項目創建一個合適的CMakeLists.txt。

在此先感謝和問候!

P.S:我在Windows plattform工作

回答

2

基本上需要採取什麼是你需要提供包括來自你的依賴的目錄和鏈接庫到你的可執行文件。

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

非常感謝。奇蹟般有效! – monchi

相關問題