CMakeLists.txt 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. cmake_minimum_required(VERSION 2.8.12)
  2. project(libigl_tutorials)
  3. ### libIGL options: choose between header only and compiled static library
  4. option(LIBIGL_USE_STATIC_LIBRARY "Use LibIGL as static library" ON)
  5. option(LIBIGL_WITH_VIEWER "Use OpenGL viewer" ON)
  6. option(LIBIGL_WITH_NANOGUI "Use Nanogui menu" OFF)
  7. ### libIGL options: choose your dependencies (by default everything is OFF, in this example we need the viewer) ###
  8. option(LIBIGL_WITH_CGAL "Use CGAL" OFF) # This option is not supported yet
  9. option(LIBIGL_WITH_BOOLEAN "Use Cork boolean" OFF) # This option is not supported yet
  10. option(LIBIGL_WITH_COMISO "Use CoMiso" ON)
  11. option(LIBIGL_WITH_EMBREE "Use Embree" ON)
  12. option(LIBIGL_WITH_LIM "Use LIM" ON)
  13. option(LIBIGL_WITH_MATLAB "Use Matlab" OFF) # This option is not supported yet
  14. option(LIBIGL_WITH_MOSEK "Use MOSEK" OFF) # This option is not supported yet
  15. option(LIBIGL_WITH_BBW "Use BBW" ON)
  16. option(LIBIGL_WITH_OPENGL_AND_PNG "Use OpenGL" ON)
  17. option(LIBIGL_WITH_TETGEN "Use Tetgen" ON)
  18. option(LIBIGL_WITH_TRIANGLE "Use Triangle" ON)
  19. option(LIBIGL_WITH_XML "Use XML" ON)
  20. ### End to be tested ----
  21. ### Output directories
  22. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
  23. set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
  24. set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
  25. ### libIGL options: decide if you want to use the functionalities that depends on cgal
  26. if(LIBIGL_WITH_CGAL) # Do not remove or move this block, cgal strange build system fails without it
  27. find_package(CGAL REQUIRED)
  28. set(CGAL_DONT_OVERRIDE_CMAKE_FLAGS TRUE CACHE BOOL "CGAL's CMAKE Setup is super annoying ")
  29. include(${CGAL_USE_FILE})
  30. endif()
  31. ### Adding libIGL: choose the path to your local copy libIGL ###
  32. ### This is going to compile everything you requested ###
  33. add_subdirectory("${PROJECT_SOURCE_DIR}/../shared/cmake" "libigl")
  34. ### Compilation flags: adapt to your needs ###
  35. if(MSVC)
  36. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /bigobj /w") ### Enable parallel compilation
  37. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR} )
  38. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR} )
  39. else()
  40. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") #### Libigl requires a modern C++ compiler that supports c++11
  41. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "../" )
  42. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations -Wno-unused-parameter -Wno-deprecated-register -Wno-return-type-c-linkage")
  43. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations -Wno-unused-parameter -Wno-deprecated-register -Wno-return-type-c-linkage")
  44. endif()
  45. # Enable openMP if possible
  46. find_package(OpenMP)
  47. if (OPENMP_FOUND AND NOT WIN32)
  48. set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
  49. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
  50. endif()
  51. ### Prepare the build environment
  52. include_directories(${LIBIGL_INCLUDE_DIRS})
  53. add_definitions(${LIBIGL_DEFINITIONS})
  54. ### Choose which chapters to compile ###
  55. option(TUTORIALS_CHAPTER1 "Compile chapter 1" ON)
  56. option(TUTORIALS_CHAPTER2 "Compile chapter 2" ON)
  57. option(TUTORIALS_CHAPTER3 "Compile chapter 3" ON)
  58. option(TUTORIALS_CHAPTER4 "Compile chapter 4" ON)
  59. option(TUTORIALS_CHAPTER5 "Compile chapter 5" ON)
  60. option(TUTORIALS_CHAPTER6 "Compile chapter 6" ON)
  61. option(TUTORIALS_CHAPTER7 "Compile chapter 7" ON)
  62. # Store location of tutorial/shared directory
  63. set(TUTORIAL_SHARED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/shared CACHE PATH "location of shared tutorial resources")
  64. add_definitions("-DTUTORIAL_SHARED_PATH=\"${TUTORIAL_SHARED_PATH}\"")
  65. include_directories(${CMAKE_CURRENT_SOURCE_DIR})
  66. # Chapter 1
  67. if(TUTORIALS_CHAPTER1)
  68. add_subdirectory("101_FileIO")
  69. add_subdirectory("102_DrawMesh")
  70. add_subdirectory("103_Events")
  71. add_subdirectory("104_Colors")
  72. add_subdirectory("105_Overlays")
  73. add_subdirectory("106_ViewerMenu")
  74. endif()
  75. # Chapter 2
  76. if(TUTORIALS_CHAPTER2)
  77. add_subdirectory("201_Normals")
  78. add_subdirectory("202_GaussianCurvature")
  79. add_subdirectory("203_CurvatureDirections")
  80. add_subdirectory("204_Gradient")
  81. add_subdirectory("205_Laplacian")
  82. endif()
  83. # Chapter 3
  84. if(TUTORIALS_CHAPTER3)
  85. add_subdirectory("301_Slice")
  86. add_subdirectory("302_Sort")
  87. add_subdirectory("303_LaplaceEquation")
  88. add_subdirectory("304_LinearEqualityConstraints")
  89. add_subdirectory("305_QuadraticProgramming")
  90. add_subdirectory("306_EigenDecomposition")
  91. endif()
  92. # Chapter 4
  93. if(TUTORIALS_CHAPTER4)
  94. add_subdirectory("401_BiharmonicDeformation")
  95. add_subdirectory("402_PolyharmonicDeformation")
  96. add_subdirectory("403_BoundedBiharmonicWeights")
  97. add_subdirectory("404_DualQuaternionSkinning")
  98. add_subdirectory("405_AsRigidAsPossible")
  99. add_subdirectory("406_FastAutomaticSkinningTransformations")
  100. add_subdirectory("407_BiharmonicCoordinates")
  101. endif()
  102. # Chapter 5
  103. if(TUTORIALS_CHAPTER5)
  104. add_subdirectory("501_HarmonicParam")
  105. add_subdirectory("502_LSCMParam")
  106. add_subdirectory("503_ARAPParam")
  107. if(LIBIGL_WITH_COMISO)
  108. add_subdirectory("504_NRosyDesign")
  109. add_subdirectory("505_MIQ")
  110. add_subdirectory("506_FrameField")
  111. endif()
  112. add_subdirectory("507_PolyVectorField")
  113. add_subdirectory("508_ConjugateField")
  114. add_subdirectory("509_Planarization")
  115. add_subdirectory("510_Integrable")
  116. endif()
  117. # Chapter 6
  118. if(TUTORIALS_CHAPTER6)
  119. if(LIBIGL_WITH_XML)
  120. add_subdirectory("601_Serialization")
  121. endif()
  122. if(LIBIGL_WITH_MATLAB)
  123. add_subdirectory("602_Matlab")
  124. endif()
  125. if(LIBIGL_WITH_TRIANGLE)
  126. add_subdirectory("604_Triangle")
  127. endif()
  128. if(LIBIGL_WITH_TETGEN)
  129. add_subdirectory("605_Tetgen")
  130. endif()
  131. if(LIBIGL_WITH_EMBREE)
  132. add_subdirectory("606_AmbientOcclusion")
  133. add_subdirectory("607_Picking")
  134. endif()
  135. if(LIBIGL_WITH_LIM)
  136. add_subdirectory("608_LIM")
  137. endif()
  138. if(LIBIGL_WITH_CGAL)
  139. add_subdirectory("609_Boolean")
  140. add_subdirectory("610_CSGTree")
  141. endif()
  142. endif()
  143. # Chapter 7
  144. if(TUTORIALS_CHAPTER7)
  145. add_subdirectory("701_Statistics")
  146. add_subdirectory("702_WindingNumber")
  147. add_subdirectory("703_Decimation")
  148. add_subdirectory("704_SignedDistance")
  149. add_subdirectory("705_MarchingCubes")
  150. endif()