CMakeLists.txt 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. cmake_minimum_required(VERSION 2.6)
  2. project(libigl_tutorials)
  3. message("Generated with config types: ${CMAKE_CONFIGURATION_TYPES}")
  4. option(LIBIGL_USE_STATIC_LIBRARY "Use static library" OFF)
  5. option(LIBIGL_VIEWER_WITH_NANOGUI "Enable nanogui " OFF)
  6. if(LIBIGL_USE_STATIC_LIBRARY)
  7. add_definitions(-DIGL_STATIC_LIBRARY)
  8. endif(LIBIGL_USE_STATIC_LIBRARY)
  9. SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
  10. IF(MSVC)
  11. # Enable parallel compilation for Visual Studio
  12. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /bigobj /w")
  13. SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR} )
  14. SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR} )
  15. ELSE(MSVC)
  16. # Libigl requires a modern C++ compiler that supports c++11
  17. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  18. SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "../" )
  19. ENDIF(MSVC)
  20. find_package(CORK QUIET)
  21. find_package(CGAL QUIET)
  22. find_package(EMBREE QUIET)
  23. find_package(LIBCOMISOH QUIET)
  24. find_package(MATLAB QUIET)
  25. find_package(MOSEK QUIET)
  26. find_package(TETGEN QUIET)
  27. find_package(TINYXML2 QUIET)
  28. find_package(TRIANGLE QUIET)
  29. find_package(LIM QUIET)
  30. message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
  31. include("CMakeLists.shared")
  32. #Compile libigl
  33. add_definitions(-DIGL_NO_OPENGL)
  34. if(LIBIGL_USE_STATIC_LIBRARY)
  35. add_subdirectory("../optional" "libigl")
  36. endif(LIBIGL_USE_STATIC_LIBRARY)
  37. include_directories("../include")
  38. #Compile embree
  39. option(ENABLE_ISPC_SUPPORT " " OFF)
  40. option(RTCORE_TASKING_SYSTEM " " INTERNAL)
  41. # embree static build is broken on visual studio
  42. IF(NOT MSVC)
  43. option(ENABLE_STATIC_LIB " " ON)
  44. set(ENABLE_STATIC_LIB ON CACHE BOOL "force static build of embree" FORCE)
  45. ENDIF(NOT MSVC)
  46. IF(MSVC)
  47. option(USE_STATIC_RUNTIME " " OFF)
  48. set(USE_STATIC_RUNTIME OFF CACHE BOOL "disable changes in the runtime for VS" FORCE)
  49. ENDIF(MSVC)
  50. option(ENABLE_TUTORIALS " " OFF)
  51. IF(EMBREE_FOUND)
  52. add_subdirectory("../external/embree/" "embree")
  53. include_directories("../external/embree/include")
  54. list(APPEND SHARED_LIBRARIES "embree")
  55. ENDIF(EMBREE_FOUND)
  56. #Compile nanogui
  57. if(LIBIGL_VIEWER_WITH_NANOGUI)
  58. set(NANOGUI_BUILD_PYTHON OFF CACHE BOOL " " FORCE)
  59. set(NANOGUI_BUILD_EXAMPLE OFF CACHE BOOL " " FORCE)
  60. set(NANOGUI_BUILD_SHARED OFF CACHE BOOL " " FORCE)
  61. add_definitions(-DIGL_VIEWER_WITH_NANOGUI)
  62. add_subdirectory("../external/nanogui/" "nanogui")
  63. include_directories("../external/nanogui/include")
  64. include_directories("../external/nanogui/ext/nanovg/src")
  65. list(APPEND SHARED_LIBRARIES "nanogui")
  66. else()
  67. # still need to build GLFW
  68. set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL " " FORCE)
  69. set(GLFW_BUILD_TESTS OFF CACHE BOOL " " FORCE)
  70. set(GLFW_BUILD_DOCS OFF CACHE BOOL " " FORCE)
  71. set(GLFW_BUILD_INSTALL OFF CACHE BOOL " " FORCE)
  72. add_subdirectory("${GLFW_INCLUDE_DIR}/../" "glfw")
  73. list(APPEND SHARED_LIBRARIES "glfw")
  74. endif()
  75. #Compile CoMISo (if found)
  76. # NOTE: this cmakefile works only with the
  77. # comiso available here: https://github.com/libigl/CoMISo
  78. IF(LIBCOMISO_FOUND)
  79. list(GET LIBCOMISO_INCLUDE_DIRS 0 COMISO_ROOT)
  80. # message( FATAL_ERROR "${COMISO_ROOT}" )
  81. if(APPLE)
  82. find_library(accelerate_library Accelerate)
  83. list(APPEND SHARED_LIBRARIES "CoMISo" ${accelerate_library})
  84. elseif(UNIX)
  85. find_package(BLAS REQUIRED)
  86. list(APPEND SHARED_LIBRARIES "CoMISo" ${BLAS_LIBRARIES})
  87. endif(APPLE)
  88. if(MSVC)
  89. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_SCL_SECURE_NO_DEPRECATE")
  90. #link_directories("${COMISO_ROOT}/CoMISo/ext/OpenBLAS-v0.2.14-Win64-int64/lib/")
  91. list(APPEND SHARED_LIBRARIES "CoMISo" "${COMISO_ROOT}/CoMISo/ext/OpenBLAS-v0.2.14-Win64-int64/lib/libopenblas.dll.a.lib")
  92. endif(MSVC)
  93. include_directories("${COMISO_ROOT}/CoMISo/ext/gmm-4.2/include")
  94. include_directories("${COMISO_ROOT}/")
  95. add_subdirectory("${COMISO_ROOT}/CoMISo/" "CoMISo")
  96. if(MSVC)
  97. # Copy the dll
  98. add_custom_target(Copy-CoMISo-DLL # Adds a post-build event to MyTest
  99. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  100. "${COMISO_ROOT}/CoMISo/ext/OpenBLAS-v0.2.14-Win64-int64/bin/libopenblas.dll"
  101. "${CMAKE_CURRENT_BINARY_DIR}/libopenblas.dll"
  102. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  103. "${COMISO_ROOT}/CoMISo/ext/OpenBLAS-v0.2.14-Win64-int64/bin/libgcc_s_seh-1.dll"
  104. "${CMAKE_CURRENT_BINARY_DIR}/libgcc_s_seh-1.dll"
  105. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  106. "${COMISO_ROOT}/CoMISo/ext/OpenBLAS-v0.2.14-Win64-int64/bin/libgfortran-3.dll"
  107. "${CMAKE_CURRENT_BINARY_DIR}/libgfortran-3.dll"
  108. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  109. "${COMISO_ROOT}/CoMISo/ext/OpenBLAS-v0.2.14-Win64-int64/bin/libquadmath-0.dll"
  110. "${CMAKE_CURRENT_BINARY_DIR}/libquadmath-0.dll")
  111. endif(MSVC)
  112. ENDIF(LIBCOMISO_FOUND)
  113. message(STATUS "Linking with: ${LIBIGL_LIBRARIES}")
  114. list(APPEND SHARED_LIBRARIES ${LIBIGL_LIBRARIES})
  115. # This is necessary to work around the static linking order dependencies on linux
  116. if(UNIX AND NOT APPLE)
  117. set(SHARED_LIBRARIES ${SHARED_LIBRARIES} ${SHARED_LIBRARIES})
  118. endif(UNIX AND NOT APPLE)
  119. #message(FATAL_ERROR ${SHARED_LIBRARIES})
  120. # Store location of tutorial/shared directory
  121. set(TUTORIAL_SHARED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/shared CACHE PATH "location of shared tutorial resources")
  122. add_definitions("-DTUTORIAL_SHARED_PATH=\"${TUTORIAL_SHARED_PATH}\"")
  123. # Chapter 1
  124. add_subdirectory("101_FileIO")
  125. add_subdirectory("102_DrawMesh")
  126. add_subdirectory("103_Events")
  127. add_subdirectory("104_Colors")
  128. add_subdirectory("105_Overlays")
  129. add_subdirectory("106_ViewerMenu")
  130. # Chapter 2
  131. add_subdirectory("201_Normals")
  132. add_subdirectory("202_GaussianCurvature")
  133. add_subdirectory("203_CurvatureDirections")
  134. add_subdirectory("204_Gradient")
  135. add_subdirectory("205_Laplacian")
  136. # Chapter 3
  137. add_subdirectory("301_Slice")
  138. add_subdirectory("302_Sort")
  139. add_subdirectory("303_LaplaceEquation")
  140. add_subdirectory("304_LinearEqualityConstraints")
  141. add_subdirectory("305_QuadraticProgramming")
  142. add_subdirectory("306_EigenDecomposition")
  143. # Chapter 4
  144. add_subdirectory("401_BiharmonicDeformation")
  145. add_subdirectory("402_PolyharmonicDeformation")
  146. add_subdirectory("403_BoundedBiharmonicWeights")
  147. add_subdirectory("404_DualQuaternionSkinning")
  148. add_subdirectory("405_AsRigidAsPossible")
  149. add_subdirectory("406_FastAutomaticSkinningTransformations")
  150. add_subdirectory("407_BiharmonicCoordinates")
  151. # Chapter 5
  152. add_subdirectory("501_HarmonicParam")
  153. add_subdirectory("502_LSCMParam")
  154. add_subdirectory("503_ARAPParam")
  155. if(LIBCOMISO_FOUND)
  156. add_subdirectory("504_NRosyDesign")
  157. add_subdirectory("505_MIQ")
  158. add_subdirectory("506_FrameField")
  159. endif(LIBCOMISO_FOUND)
  160. add_subdirectory("507_PolyVectorField")
  161. add_subdirectory("508_ConjugateField")
  162. add_subdirectory("509_Planarization")
  163. add_subdirectory("510_Integrable")
  164. # Chapter 6
  165. if(TINYXML2_FOUND)
  166. add_subdirectory("601_Serialization")
  167. endif(TINYXML2_FOUND)
  168. if(MATLAB_FOUND)
  169. add_subdirectory("602_Matlab")
  170. endif(MATLAB_FOUND)
  171. add_subdirectory("604_Triangle")
  172. add_subdirectory("605_Tetgen")
  173. if (EMBREE_FOUND)
  174. add_subdirectory("606_AmbientOcclusion")
  175. add_subdirectory("607_Picking")
  176. endif (EMBREE_FOUND)
  177. if(LIM_FOUND)
  178. add_subdirectory("608_LIM")
  179. endif(LIM_FOUND)
  180. if(CGAL_FOUND)
  181. add_subdirectory("609_Boolean")
  182. add_subdirectory("610_CSGTree")
  183. endif()
  184. add_subdirectory("701_Statistics")
  185. add_subdirectory("702_WindingNumber")
  186. add_subdirectory("703_Decimation")
  187. add_subdirectory("704_SignedDistance")
  188. add_subdirectory("705_MarchingCubes")