|
@@ -3,19 +3,14 @@ cmake_minimum_required(VERSION 3.1)
|
|
|
### Find packages to populate default options ###
|
|
|
#
|
|
|
# COMPONENTS should match subsequent calls
|
|
|
-find_package(CGAL COMPONENTS Core) # --> CGAL_FOUND
|
|
|
-find_package(Boost 1.48 COMPONENTS thread system) # --> BOOST_FOUND
|
|
|
-if(CGAL_FOUND AND BOOST_FOUND)
|
|
|
- set(CGAL_AND_BOOST_FOUND TRUE)
|
|
|
-endif()
|
|
|
find_package(Matlab COMPONENTS MEX_COMPILER MX_LIBRARY ENG_LIBRARY) # --> Matlab_FOUND
|
|
|
find_package(MOSEK) # --> MOSEK_FOUND
|
|
|
find_package(OpenGL) # --> OPENGL_FOUND
|
|
|
|
|
|
### Available options ###
|
|
|
-option(LIBIGL_USE_STATIC_LIBRARY "Use libigl as static library" OFF)
|
|
|
+option(LIBIGL_USE_STATIC_LIBRARY "Use libigl as static library" ON)
|
|
|
option(LIBIGL_WITH_ANTTWEAKBAR "Use AntTweakBar" OFF)
|
|
|
-option(LIBIGL_WITH_CGAL "Use CGAL" "${CGAL_AND_BOOST_FOUND}")
|
|
|
+option(LIBIGL_WITH_CGAL "Use CGAL" ON)
|
|
|
option(LIBIGL_WITH_COMISO "Use CoMiso" ON)
|
|
|
option(LIBIGL_WITH_CORK "Use Cork" OFF)
|
|
|
option(LIBIGL_WITH_EMBREE "Use Embree" OFF)
|
|
@@ -68,9 +63,6 @@ target_compile_features(igl_common INTERFACE ${CXX11_FEATURES})
|
|
|
if(MSVC)
|
|
|
# Enable parallel compilation for Visual Studio
|
|
|
target_compile_options(igl_common INTERFACE /MP /bigobj)
|
|
|
- if(LIBIGL_WITH_CGAL)
|
|
|
- target_compile_options(igl_common INTERFACE "/MD$<$<CONFIG:Debug>:d>")
|
|
|
- endif()
|
|
|
endif()
|
|
|
|
|
|
if(BUILD_SHARED_LIBS)
|
|
@@ -92,6 +84,38 @@ target_link_libraries(igl_common INTERFACE ${CMAKE_THREAD_LIBS_INIT})
|
|
|
|
|
|
################################################################################
|
|
|
|
|
|
+include(DownloadProject)
|
|
|
+
|
|
|
+# Shortcut function
|
|
|
+function(igl_download_project name)
|
|
|
+ download_project(
|
|
|
+ PROJ ${name}
|
|
|
+ SOURCE_DIR ${LIBIGL_EXTERNAL}/${name}
|
|
|
+ DOWNLOAD_DIR ${LIBIGL_EXTERNAL}/.cache/${name}
|
|
|
+ ${ARGN}
|
|
|
+ )
|
|
|
+endfunction()
|
|
|
+
|
|
|
+################################################################################
|
|
|
+
|
|
|
+## CGAL dependencies on Windows: GMP & MPFR
|
|
|
+function(igl_download_cgal_deps)
|
|
|
+ if(WIN32)
|
|
|
+ igl_download_project(gmp
|
|
|
+ URL https://cgal.geometryfactory.com/CGAL/precompiled_libs/auxiliary/x64/GMP/5.0.1/gmp-all-CGAL-3.9.zip
|
|
|
+ URL_MD5 508c1292319c832609329116a8234c9f
|
|
|
+ )
|
|
|
+ igl_download_project(mpfr
|
|
|
+ URL https://cgal.geometryfactory.com/CGAL/precompiled_libs/auxiliary/x64/MPFR/3.0.0/mpfr-all-CGAL-3.9.zip
|
|
|
+ URL_MD5 48840454eef0ff18730050c05028734b
|
|
|
+ )
|
|
|
+ set(ENV{GMP_DIR} "${LIBIGL_EXTERNAL}/gmp")
|
|
|
+ set(ENV{MPFR_DIR} "${LIBIGL_EXTERNAL}/mpfr")
|
|
|
+ endif()
|
|
|
+endfunction()
|
|
|
+
|
|
|
+################################################################################
|
|
|
+
|
|
|
function(compile_igl_module module_dir)
|
|
|
string(REPLACE "/" "_" module_name "${module_dir}")
|
|
|
if(LIBIGL_USE_STATIC_LIBRARY)
|
|
@@ -141,23 +165,23 @@ if(LIBIGL_WITH_ANTTWEAKBAR)
|
|
|
endif()
|
|
|
|
|
|
################################################################################
|
|
|
-### Compile the cgal parts ###
|
|
|
+### Compile the CGAL part ###
|
|
|
if(LIBIGL_WITH_CGAL)
|
|
|
- # CGAL Core is needed for
|
|
|
- # `Exact_predicates_exact_constructions_kernel_with_sqrt`
|
|
|
- if(EXISTS ${LIBIGL_EXTERNAL}/boost)
|
|
|
- set(BOOST_ROOT "${LIBIGL_EXTERNAL}/boost")
|
|
|
+ # Try to find the CGAL library
|
|
|
+ if(NOT TARGET CGAL::CGAL)
|
|
|
+ set(CGAL_DIR "${LIBIGL_EXTERNAL}/cgal")
|
|
|
+ igl_download_cgal_deps()
|
|
|
+ if(EXISTS ${LIBIGL_EXTERNAL}/boost)
|
|
|
+ set(BOOST_ROOT "${LIBIGL_EXTERNAL}/boost")
|
|
|
+ endif()
|
|
|
+ set(CGAL_Boost_USE_STATIC_LIBS ON CACHE BOOL "" FORCE)
|
|
|
+ find_package(CGAL CONFIG COMPONENTS PATHS ${CGAL_DIR} NO_DEFAULT_PATH)
|
|
|
endif()
|
|
|
- find_package(CGAL COMPONENTS Core)
|
|
|
- if(CGAL_FOUND)
|
|
|
+
|
|
|
+ # If CGAL has been found, then build the libigl module
|
|
|
+ if(TARGET CGAL::CGAL)
|
|
|
compile_igl_module("cgal")
|
|
|
- if(WIN32)
|
|
|
- set(Boost_USE_STATIC_LIBS ON) # Favor static Boost libs on Windows
|
|
|
- endif()
|
|
|
- target_include_directories(igl_cgal ${IGL_SCOPE} "${GMP_INCLUDE_DIR}" "${MPFR_INCLUDE_DIR}")
|
|
|
- find_package(Boost 1.48 REQUIRED thread system)
|
|
|
- target_include_directories(igl_cgal ${IGL_SCOPE} ${CGAL_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
|
|
|
- target_link_libraries(igl_cgal ${IGL_SCOPE} CGAL::CGAL CGAL::CGAL_Core ${Boost_LIBRARIES})
|
|
|
+ target_link_libraries(igl_cgal ${IGL_SCOPE} CGAL::CGAL)
|
|
|
else()
|
|
|
set(LIBIGL_WITH_CGAL OFF CACHE BOOL "" FORCE)
|
|
|
endif()
|
|
@@ -165,19 +189,15 @@ endif()
|
|
|
|
|
|
# Helper function for `igl_copy_cgal_dll()`
|
|
|
function(igl_copy_imported_dll src_target dst_target)
|
|
|
- get_target_property(configurations ${src_target} IMPORTED_CONFIGURATIONS)
|
|
|
- foreach(config ${configurations})
|
|
|
- get_target_property(main_lib ${src_target} IMPORTED_LOCATION_${config})
|
|
|
- get_target_property(other_libs ${src_target} IMPORTED_LINK_INTERFACE_LIBRARIES_${config})
|
|
|
- set(locations)
|
|
|
- list(APPEND locations ${main_lib} ${other_libs})
|
|
|
- foreach(location ${locations})
|
|
|
- string(REGEX MATCH "^(.*)\\.[^.]*$" dummy ${location})
|
|
|
- set(location "${CMAKE_MATCH_1}.dll")
|
|
|
- if(EXISTS "${location}" AND location MATCHES "^.*\\.dll$")
|
|
|
- add_custom_command(TARGET ${dst_target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${location}" $<TARGET_FILE_DIR:${dst_target}>)
|
|
|
- endif()
|
|
|
- endforeach()
|
|
|
+ get_target_property(other_libs ${src_target} INTERFACE_LINK_LIBRARIES)
|
|
|
+ set(locations)
|
|
|
+ list(APPEND locations ${main_lib} ${other_libs})
|
|
|
+ foreach(location ${locations})
|
|
|
+ string(REGEX MATCH "^(.*)\\.[^.]*$" dummy ${location})
|
|
|
+ set(location "${CMAKE_MATCH_1}.dll")
|
|
|
+ if(EXISTS "${location}" AND location MATCHES "^.*\\.dll$")
|
|
|
+ add_custom_command(TARGET ${dst_target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${location}" $<TARGET_FILE_DIR:${dst_target}>)
|
|
|
+ endif()
|
|
|
endforeach()
|
|
|
endfunction()
|
|
|
|
|
@@ -185,12 +205,11 @@ endfunction()
|
|
|
function(igl_copy_cgal_dll target)
|
|
|
if(WIN32 AND LIBIGL_WITH_CGAL)
|
|
|
igl_copy_imported_dll(CGAL::CGAL ${target})
|
|
|
- igl_copy_imported_dll(CGAL::CGAL_Core ${target})
|
|
|
endif()
|
|
|
endfunction()
|
|
|
|
|
|
################################################################################
|
|
|
-# Compile CoMISo
|
|
|
+### Compile the CoMISo part ###
|
|
|
# NOTE: this cmakefile works only with the
|
|
|
# comiso available here: https://github.com/libigl/CoMISo
|
|
|
if(LIBIGL_WITH_COMISO)
|
|
@@ -202,7 +221,7 @@ if(LIBIGL_WITH_COMISO)
|
|
|
endif()
|
|
|
|
|
|
################################################################################
|
|
|
-### Compile the cork parts ###
|
|
|
+### Compile the cork part ###
|
|
|
if(LIBIGL_WITH_CORK)
|
|
|
set(CORK_DIR "${LIBIGL_EXTERNAL}/cork")
|
|
|
if(NOT TARGET cork)
|
|
@@ -224,6 +243,7 @@ if(LIBIGL_WITH_EMBREE)
|
|
|
set(EMBREE_TASKING_SYSTEM "INTERNAL" CACHE BOOL " " FORCE)
|
|
|
set(EMBREE_TUTORIALS OFF CACHE BOOL " " FORCE)
|
|
|
set(EMBREE_MAX_ISA NONE CACHE STRINGS " " FORCE)
|
|
|
+ set(BUILD_TESTING OFF CACHE BOOL " " FORCE)
|
|
|
|
|
|
# set(ENABLE_INSTALLER OFF CACHE BOOL " " FORCE)
|
|
|
if(MSVC)
|
|
@@ -285,8 +305,7 @@ if(LIBIGL_WITH_MOSEK)
|
|
|
endif()
|
|
|
|
|
|
################################################################################
|
|
|
-### Compile the opengl parts ###
|
|
|
-
|
|
|
+### Compile the opengl part ###
|
|
|
if(LIBIGL_WITH_OPENGL)
|
|
|
# OpenGL module
|
|
|
find_package(OpenGL REQUIRED)
|
|
@@ -303,7 +322,6 @@ endif()
|
|
|
|
|
|
################################################################################
|
|
|
### Compile the GLFW part ###
|
|
|
-
|
|
|
if(LIBIGL_WITH_OPENGL_GLFW)
|
|
|
if(TARGET igl::opengl)
|
|
|
# GLFW module
|
|
@@ -321,7 +339,6 @@ endif()
|
|
|
|
|
|
################################################################################
|
|
|
### Compile the ImGui part ###
|
|
|
-
|
|
|
if(LIBIGL_WITH_OPENGL_GLFW_IMGUI)
|
|
|
if(TARGET igl::opengl_glfw)
|
|
|
# ImGui module
|