CMakeLists.txt 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. cmake_minimum_required(VERSION 2.6)
  2. project(shape-up)
  3. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
  4. find_package(LIBIGL QUIET)
  5. find_package(LIBHEDRA QUIET)
  6. if (NOT LIBIGL_FOUND)
  7. message(FATAL_ERROR "libigl not found --- You can download it using: \n git clone --recursive https://github.com/libigl/libigl.git ${PROJECT_SOURCE_DIR}/../libigl")
  8. endif()
  9. if (NOT LIBHEDRA_FOUND)
  10. message(FATAL_ERROR "libhedra not found --- You can download it in https://github.com/avaxman/libhedra.git")
  11. endif()
  12. # Compilation flags: adapt to your needs
  13. if(MSVC)
  14. # Enable parallel compilation
  15. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /bigobj")
  16. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR} )
  17. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR} )
  18. else()
  19. # Libigl requires a modern C++ compiler that supports c++11
  20. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  21. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "." )
  22. endif()
  23. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
  24. # libigl options: choose between header only and compiled static library
  25. # Header-only is preferred for small projects. For larger projects the static build
  26. # considerably reduces the compilation times
  27. option(LIBIGL_USE_STATIC_LIBRARY "Use LibIGL as static library" OFF)
  28. # add a customizable menu bar
  29. option(LIBIGL_WITH_NANOGUI "Use Nanogui menu" OFF)
  30. # libigl options: choose your dependencies (by default everything is OFF except opengl)
  31. option(LIBIGL_WITH_VIEWER "Use OpenGL viewer" ON)
  32. option(LIBIGL_WITH_OPENGL "Use OpenGL" ON)
  33. option(LIBIGL_WITH_GLFW "Use GLFW" ON)
  34. option(LIBIGL_WITH_BBW "Use BBW" OFF)
  35. option(LIBIGL_WITH_EMBREE "Use Embree" OFF)
  36. option(LIBIGL_WITH_PNG "Use PNG" OFF)
  37. option(LIBIGL_WITH_TETGEN "Use Tetgen" OFF)
  38. option(LIBIGL_WITH_TRIANGLE "Use Triangle" OFF)
  39. option(LIBIGL_WITH_XML "Use XML" OFF)
  40. option(LIBIGL_WITH_LIM "Use LIM" OFF)
  41. option(LIBIGL_WITH_COMISO "Use CoMiso" OFF)
  42. option(LIBIGL_WITH_MATLAB "Use Matlab" OFF) # This option is not supported yet
  43. option(LIBIGL_WITH_MOSEK "Use MOSEK" OFF) # This option is not supported yet
  44. option(LIBIGL_WITH_CGAL "Use CGAL" OFF)
  45. if(LIBIGL_WITH_CGAL) # Do not remove or move this block, the cgal build system fails without it
  46. find_package(CGAL REQUIRED)
  47. set(CGAL_DONT_OVERRIDE_CMAKE_FLAGS TRUE CACHE BOOL "CGAL's CMAKE Setup is super annoying ")
  48. include(${CGAL_USE_FILE})
  49. endif()
  50. # Adding libigl: choose the path to your local copy libigl
  51. # This is going to compile everything you requested
  52. #message(FATAL_ERROR "${PROJECT_SOURCE_DIR}/../libigl/cmake")
  53. add_subdirectory("${LIBIGL_INCLUDE_DIR}/../shared/cmake" "libigl")
  54. # libigl information
  55. message("libigl includes: ${LIBIGL_INCLUDE_DIRS}")
  56. message("libigl libraries: ${LIBIGL_LIBRARIES}")
  57. message("libigl extra sources: ${LIBIGL_EXTRA_SOURCES}")
  58. message("libigl extra libraries: ${LIBIGL_EXTRA_LIBRARIES}")
  59. message("libigl definitions: ${LIBIGL_DEFINITIONS}")
  60. message("libhedra includes: ${LIBHEDRA_INCLUDE_DIRS}")
  61. # Prepare the build environment
  62. include_directories(${LIBIGL_INCLUDE_DIRS})
  63. add_definitions(${LIBIGL_DEFINITIONS})
  64. include_directories(${LIBHEDRA_INCLUDE_DIRS})
  65. # Store location of data directory
  66. set(DATA_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../data CACHE PATH "location of mesh data")
  67. add_definitions("-DDATA_PATH=\"${DATA_PATH}\"")
  68. include_directories(${CMAKE_CURRENT_SOURCE_DIR})
  69. # Add your project files
  70. FILE(GLOB SRCFILES *.cpp)
  71. add_executable(${PROJECT_NAME}_bin ${SRCFILES} ${LIBIGL_EXTRA_SOURCES})
  72. target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_EXTRA_LIBRARIES})