您的位置:首页 > 编程语言 > Qt开发

config libigl in qt through cmake under ubuntu

2016-05-17 21:51 1236 查看
1. download libigl

open terminal, turn to the directory where you want libigl download, then type:

git clone --recursive https://github.com/libigl/libigl.git  

2. open qtcreator, File->Open File or Project..., choose the CMakeList.txt in tutorial directory. 

3. After that, we get into CMake Wizard step, click Run CMake



then click Finsh

4. some stuff about CMakeList.txt

here I would like go into the CMakeList.txt file. If you just want to build this project as soon as possible, you just skip over this step.

Note: the comments marked in red are written by me.

cmake_minimum_required(VERSION 2.8.12)

#project name

project(libigl_tutorials)


#some options, just skip over


### libIGL options: choose between header only and compiled static library

option(LIBIGL_USE_STATIC_LIBRARY "Use LibIGL as static library" ON)

option(LIBIGL_WITH_VIEWER      "Use OpenGL viewer"  ON)

option(LIBIGL_WITH_NANOGUI     "Use Nanogui menu"   OFF)


### libIGL options: choose your dependencies (by default everything is OFF, in this example we need the viewer) ###

option(LIBIGL_WITH_BBW              "Use BBW"            ON)

#try to find CGAL

find_package(CGAL QUIET)

option(LIBIGL_WITH_CGAL             "Use CGAL"           "${CGAL_FOUND}")

option(LIBIGL_WITH_COMISO           "Use CoMiso"         ON)

option(LIBIGL_WITH_CORK             "Use CORK"           OFF)

option(LIBIGL_WITH_EMBREE           "Use Embree"         ON)

option(LIBIGL_WITH_LIM              "Use LIM"            ON)

find_package(MATLAB QUIET)

option(LIBIGL_WITH_MATLAB           "Use Matlab"         "${MATLAB_FOUND}")

option(LIBIGL_WITH_MOSEK            "Use MOSEK"          "${MOSEK_FOUND}")

option(LIBIGL_WITH_OPENGL           "Use OpenGL"         ON)

option(LIBIGL_WITH_PNG              "Use PNG"            ON)

option(LIBIGL_WITH_TETGEN           "Use Tetgen"         ON)

option(LIBIGL_WITH_TRIANGLE         "Use Triangle"       ON)

option(LIBIGL_WITH_XML              "Use XML"            ON)

### End   to be tested ----


### libIGL options: decide if you want to use the functionalities that depends on cgal

if(LIBIGL_WITH_CGAL) # Do not remove or move this block, cgal strange build system fails without it

find_package(CGAL REQUIRED)

set(CGAL_DONT_OVERRIDE_CMAKE_FLAGS TRUE CACHE BOOL "CGAL's CMAKE Setup is super annoying ")

include(${CGAL_USE_FILE})

endif()


### Adding libIGL: choose the path to your local copy libIGL ###

### This is going to compile everything you requested ###

#this sentence is quite important, that subdirectory also has a CMakeList.txt which will set environments like ${LIBIGL_INCLUDE_DIRS}

add_subdirectory("${PROJECT_SOURCE_DIR}/../shared/cmake" "libigl")



### Output directories

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")


### Compilation flags: adapt to your needs ###

if(MSVC)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /bigobj") ### Enable parallel compilation

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR} )

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR} )

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /w") # disable all warnings (not ideal but...)

else()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") #### Libigl requires a modern C++ compiler that supports c++11

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "../" )

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w") # disable all warnings (not ideal but...)

endif()


# Enable openMP if possible

#find_package(OpenMP)

#if (OPENMP_FOUND AND NOT WIN32)

#  set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")

#  set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")

#endif()



### Prepare the build environment

#set including path


include_directories(${LIBIGL_INCLUDE_DIRS})

MESSAGE( STATUS "LIBIGL_INCLUDE_DIRS:         " ${LIBIGL_INCLUDE_DIRS} )



add_definitions(${LIBIGL_DEFINITIONS})

### Choose which chapters to compile ###


#here you can off ones you don't want to compile

option(TUTORIALS_CHAPTER1 "Compile chapter 1" ON)

option(TUTORIALS_CHAPTER2 "Compile chapter 2" ON)

option(TUTORIALS_CHAPTER3 "Compile chapter 3" ON)

option(TUTORIALS_CHAPTER4 "Compile chapter 4" ON)

option(TUTORIALS_CHAPTER5 "Compile chapter 5" ON)

option(TUTORIALS_CHAPTER6 "Compile chapter 6" ON)

option(TUTORIALS_CHAPTER7 "Compile chapter 7" ON)


# Store location of tutorial/shared directory

set(TUTORIAL_SHARED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/shared CACHE PATH "location of shared tutorial resources")

add_definitions("-DTUTORIAL_SHARED_PATH=\"${TUTORIAL_SHARED_PATH}\"")


include_directories(${CMAKE_CURRENT_SOURCE_DIR})


# Chapter 1

if(TUTORIALS_CHAPTER1)

add_subdirectory("101_FileIO")

add_subdirectory("102_DrawMesh")

add_subdirectory("103_Events")

add_subdirectory("104_Colors")

add_subdirectory("105_Overlays")

add_subdirectory("106_ViewerMenu")

endif()


# Chapter 2

if(TUTORIALS_CHAPTER2)

add_subdirectory("201_Normals")

add_subdirectory("202_GaussianCurvature")

add_subdirectory("203_CurvatureDirections")

add_subdirectory("204_Gradient")

add_subdirectory("205_Laplacian")

endif()


# Chapter 3

if(TUTORIALS_CHAPTER3)

add_subdirectory("301_Slice")

add_subdirectory("302_Sort")

add_subdirectory("303_LaplaceEquation")

add_subdirectory("304_LinearEqualityConstraints")

add_subdirectory("305_QuadraticProgramming")

add_subdirectory("306_EigenDecomposition")

endif()


# Chapter 4

if(TUTORIALS_CHAPTER4)

add_subdirectory("401_BiharmonicDeformation")

add_subdirectory("402_PolyharmonicDeformation")

if(LIBIGL_WITH_BBW)

add_subdirectory("403_BoundedBiharmonicWeights")

endif()

add_subdirectory("404_DualQuaternionSkinning")

add_subdirectory("405_AsRigidAsPossible")

add_subdirectory("406_FastAutomaticSkinningTransformations")

add_subdirectory("407_BiharmonicCoordinates")

endif()


# Chapter 5

if(TUTORIALS_CHAPTER5)

add_subdirectory("501_HarmonicParam")

add_subdirectory("502_LSCMParam")

add_subdirectory("503_ARAPParam")

if(LIBIGL_WITH_COMISO)

add_subdirectory("504_NRosyDesign")

add_subdirectory("505_MIQ")

add_subdirectory("506_FrameField")

endif()

add_subdirectory("507_PolyVectorField")

add_subdirectory("508_ConjugateField")

add_subdirectory("509_Planarization")

add_subdirectory("510_Integrable")

endif()


# Chapter 6

if(TUTORIALS_CHAPTER6)

if(LIBIGL_WITH_XML)

add_subdirectory("601_Serialization")

endif()

if(LIBIGL_WITH_MATLAB)

add_subdirectory("602_Matlab")

endif()

if(LIBIGL_WITH_TRIANGLE)

add_subdirectory("604_Triangle")

endif()

if(LIBIGL_WITH_TETGEN)

add_subdirectory("605_Tetgen")

endif()

if(LIBIGL_WITH_EMBREE)

add_subdirectory("606_AmbientOcclusion")

add_subdirectory("607_Picking")

add_subdirectory("706_FacetOrientation")

endif()

if(LIBIGL_WITH_LIM)

add_subdirectory("608_LIM")

endif()

if(LIBIGL_WITH_CGAL)

add_subdirectory("609_Boolean")

add_subdirectory("610_CSGTree")

endif()

endif()


# Chapter 7

if(TUTORIALS_CHAPTER7)

add_subdirectory("701_Statistics")

add_subdirectory("702_WindingNumber")

add_subdirectory("703_Decimation")

add_subdirectory("704_SignedDistance")

add_subdirectory("705_MarchingCubes")

endif()



5. up to now, there should be a 'Makefile' file in /home/tjiang/Workspace/libigl/build-tutorial-5_5_1-Default. This file will guide the compiler how to generate execute file.

6.after all this set, we can build the project

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: