CMakeLists.txt 6.9 KB

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