Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 10 additions & 36 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
set(CMAKE_POLICY_VERSION_MINIMUM 3.5)

# Detects whether this is a top-level project
get_directory_property(HAS_PARENT PARENT_DIRECTORY)
if(HAS_PARENT)
Expand Down Expand Up @@ -41,7 +43,7 @@ option(RIGID_IPC_WITH_DERIVATIVE_CHECK "Check derivatives using finite diff

# Set default minimum C++ standard
if(RIGID_IPC_TOPLEVEL_PROJECT)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
endif()
Expand All @@ -57,30 +59,10 @@ include(rigid_ipc_use_colors)

include(rigid_ipc_autogen)

mark_as_advanced(CLEAR CMAKE_BUILD_TYPE)

################################################################################
# External project settings
################################################################################

# libigl options
option(LIBIGL_USE_STATIC_LIBRARY "Use libigl as static library" OFF)
option(LIBIGL_WITH_PREDICATES "Use exact predicates" ON)
set(LIBIGL_WITH_OPENGL_GLFW_IMGUI ${RIGID_IPC_WITH_OPENGL} CACHE BOOL "Use OpenGL" FORCE)
set(LIBIGL_WITH_OPENGL_GLFW ${RIGID_IPC_WITH_OPENGL} CACHE BOOL "Use GLFW" FORCE)
set(LIBIGL_WITH_OPENGL ${RIGID_IPC_WITH_OPENGL} CACHE BOOL "Use IMGUI" FORCE)
set(LIBIGL_WITH_PNG ${RIGID_IPC_WITH_OPENGL} CACHE BOOL "Use PNG" FORCE)

# PolySolve settings
option(POLYSOLVE_WITH_CHOLMOD "Enable Cholmod library" ON)
option(POLYSOLVE_WITH_UMFPACK "Enable UmfPack library" OFF)
option(POLYSOLVE_WITH_SUPERLU "Enable SuperLU library" OFF)
option(POLYSOLVE_WITH_MKL "Enable MKL library" OFF)
option(POLYSOLVE_WITH_PARDISO "Enable Pardiso library" OFF)
option(POLYSOLVE_WITH_HYPRE "Enable hypre" OFF)
option(POLYSOLVE_WITH_AMGCL "Use AMGCL" OFF)
option(POLYSOLVE_WITH_SPECTRA "Enable computing spectrum" OFF)

set(TIGHT_INCLUSION_WITH_NO_ZERO_TOI OFF CACHE BOOL "Enable refinement if CCD produces a zero ToI" FORCE)

################################################################################
Expand Down Expand Up @@ -201,7 +183,7 @@ target_link_libraries(ipc_rigid PUBLIC

# JSON Parser
include(json)
target_link_libraries(ipc_rigid PUBLIC nlohmann::json)
target_link_libraries(ipc_rigid PUBLIC nlohmann_json::nlohmann_json)

# Logger
include(spdlog)
Expand All @@ -216,17 +198,13 @@ include(boost)
target_link_libraries(ipc_rigid PUBLIC Boost::boost)

# TBB
include(tbb)
include(onetbb)
target_link_libraries(ipc_rigid PUBLIC TBB::tbb)

# MSCCD
include(tight_inclusion)
target_link_libraries(ipc_rigid PUBLIC tight_inclusion::tight_inclusion)

# PolySolve for wrapping linear solvers
include(polysolve)
target_link_libraries(ipc_rigid PUBLIC PolyFEM::polysolve)

# IPC Toolkit
include(ipc_toolkit)
target_link_libraries(ipc_rigid PUBLIC ipc::toolkit)
Expand All @@ -243,10 +221,6 @@ target_link_libraries(ipc_rigid PUBLIC simple_bvh::simple_bvh)
include(tinygltf)
target_link_libraries(ipc_rigid PUBLIC tinygltf::tinygltf)

# Filesystem
include(filesystem)
target_link_libraries(ipc_rigid PUBLIC ghc::filesystem)

################################################################################
# Compiler options
################################################################################
Expand Down Expand Up @@ -284,7 +258,7 @@ add_executable(rigid_ipc_sim src/main.cpp)
if(RIGID_IPC_WITH_OPENGL)
target_sources(rigid_ipc_sim PUBLIC
src/viewer/imgui_ext.cpp
src/viewer/igl_viewer_ext.cpp
src/viewer/viewer_data.cpp
src/viewer/UISimState.cpp
src/viewer/UIMenu.cpp
)
Expand All @@ -298,13 +272,13 @@ target_link_libraries(rigid_ipc_sim PUBLIC CLI11::CLI11)
if(RIGID_IPC_WITH_OPENGL)
target_compile_definitions(rigid_ipc_sim PUBLIC RIGID_IPC_WITH_OPENGL)

include(libigl)
target_link_libraries(rigid_ipc_sim PUBLIC
igl::opengl igl::opengl_glfw igl::opengl_glfw_imgui igl::png)

# Charlie Tangora's gif-h library
include(gif_h)
target_link_libraries(rigid_ipc_sim PRIVATE gif_h::gif_h)

# Polyscope visualization library
include(polyscope)
target_link_libraries(rigid_ipc_sim PUBLIC polyscope::polyscope)
endif()

################################################################################
Expand Down
81 changes: 44 additions & 37 deletions cmake/recipes/eigen.cmake
Original file line number Diff line number Diff line change
@@ -1,53 +1,39 @@
#
# Copyright 2020 Adobe. All rights reserved.
# This file is licensed to you under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. You may obtain a copy
# of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
# OF ANY KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.
#
# Eigen (https://gitlab.com/libeigen/eigen)
# License: MPL 2.0
if(TARGET Eigen3::Eigen)
return()
endif()

option(EIGEN_WITH_MKL "Use Eigen with MKL" OFF)
option(EIGEN_DONT_VECTORIZE "Disable Eigen vectorization" OFF)
option(EIGEN_MPL2_ONLY "Enable Eigen MPL2 license only" OFF)

if(EIGEN_ROOT)
message(STATUS "Third-party: creating target 'Eigen3::Eigen' for external path: ${EIGEN_ROOT}")
set(EIGEN_INCLUDE_DIRS ${EIGEN_ROOT})
else()
message(STATUS "Third-party: creating target 'Eigen3::Eigen'")
message(STATUS "Third-party: creating target 'Eigen3::Eigen'")

include(FetchContent)
FetchContent_Declare(
eigen
GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
GIT_TAG tags/3.3.7
GIT_SHALLOW TRUE
)
FetchContent_GetProperties(eigen)
if(NOT eigen_POPULATED)
FetchContent_Populate(eigen)
endif()
set(EIGEN_INCLUDE_DIRS ${eigen_SOURCE_DIR})

install(DIRECTORY ${EIGEN_INCLUDE_DIRS}/Eigen
DESTINATION include
)
endif()
include(CPM)
CPMAddPackage(
NAME eigen
GITLAB_REPOSITORY libeigen/eigen
GIT_TAG 3.3.7
DOWNLOAD_ONLY YES
)

add_library(Eigen3_Eigen INTERFACE)
add_library(Eigen3::Eigen ALIAS Eigen3_Eigen)

include(GNUInstallDirs)
target_include_directories(Eigen3_Eigen SYSTEM INTERFACE
$<BUILD_INTERFACE:${EIGEN_INCLUDE_DIRS}>
$<BUILD_INTERFACE:${eigen_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
# target_compile_definitions(Eigen3_Eigen INTERFACE EIGEN_MPL2_ONLY)

if(EIGEN_MPL2_ONLY)
target_compile_definitions(Eigen3_Eigen INTERFACE EIGEN_MPL2_ONLY)
endif()

if(EIGEN_DONT_VECTORIZE)
target_compile_definitions(Eigen3_Eigen INTERFACE EIGEN_DONT_VECTORIZE)
endif()

if(EIGEN_WITH_MKL)
# TODO: Checks that, on 64bits systems, `mkl::mkl` is using the LP64 interface
Expand All @@ -58,6 +44,27 @@ if(EIGEN_WITH_MKL)
EIGEN_USE_MKL_ALL
EIGEN_USE_LAPACKE_STRICT
)
elseif(APPLE)
find_package(BLAS REQUIRED)
find_library(LAPACKE lapacke PATHS
"/opt/local/lib/lapack"
"/opt/homebrew/opt/lapack/lib"
)
if (NOT LAPACKE)
# BLAS should be available on macOS, but LAPACKE might not be
message(WARNING "LAPACKE library not found (required for EIGEN_USE_LAPACKE on macOS)! "
"Perhaps you need to install it (e.g., brew install lapack). "
"Eigen will be built without LAPACKE support.")
else()
message(STATUS "Found BLAS and LAPACKE. Enabling Eigen LAPACKE support.")
target_link_libraries(Eigen3_Eigen INTERFACE
${BLAS_LIBRARIES} ${LAPACKE}
)
target_compile_definitions(Eigen3_Eigen INTERFACE
EIGEN_USE_BLAS
EIGEN_USE_LAPACKE_STRICT
)
endif()
endif()

# On Windows, enable natvis files to improve debugging experience
Expand All @@ -68,6 +75,6 @@ endif()
# Install rules
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME eigen)
set_target_properties(Eigen3_Eigen PROPERTIES EXPORT_NAME Eigen)
install(DIRECTORY ${EIGEN_INCLUDE_DIRS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(DIRECTORY ${eigen_SOURCE_DIR} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(TARGETS Eigen3_Eigen EXPORT Eigen_Targets)
install(EXPORT Eigen_Targets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/eigen NAMESPACE Eigen3::)
install(EXPORT Eigen_Targets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/eigen NAMESPACE Eigen3::)
63 changes: 0 additions & 63 deletions cmake/recipes/filesystem.cmake

This file was deleted.

8 changes: 5 additions & 3 deletions cmake/recipes/json.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
# OF ANY KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.
#
if(TARGET nlohmann::json)

# JSON MIT
if(TARGET nlohmann_json::nlohmann_json)
return()
endif()

message(STATUS "Third-party: creating target 'nlohmann::json'")
message(STATUS "Third-party: creating target 'nlohmann_json::nlohmann_json'")

# nlohmann_json is a big repo for a single header, so we just download the release archive
set(NLOHMANNJSON_VERSION "v3.10.2")
Expand All @@ -27,7 +29,7 @@ FetchContent_Declare(
FetchContent_MakeAvailable(nlohmann_json)

add_library(nlohmann_json INTERFACE)
add_library(nlohmann::json ALIAS nlohmann_json)
add_library(nlohmann_json::nlohmann_json ALIAS nlohmann_json)

include(GNUInstallDirs)
target_include_directories(nlohmann_json INTERFACE
Expand Down
42 changes: 9 additions & 33 deletions cmake/recipes/libigl.cmake
Original file line number Diff line number Diff line change
@@ -1,43 +1,19 @@
#
# Copyright 2020 Adobe. All rights reserved.
# This file is licensed to you under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. You may obtain a copy
# of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
# OF ANY KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.
#
# libigl (https://github.com/libigl/libigl)
# License: MPL-2.0
if(TARGET igl::core)
return()
endif()

message(STATUS "Third-party: creating target 'igl::core'")

include(FetchContent)
FetchContent_Declare(
libigl
GIT_REPOSITORY https://github.com/libigl/libigl.git
GIT_TAG v2.3.0
GIT_SHALLOW TRUE
)
FetchContent_GetProperties(libigl)
if(libigl_POPULATED)
return()
endif()
FetchContent_Populate(libigl)
set(LIBIGL_PREDICATES ON CACHE BOOL "Use exact predicates" FORCE)

include(eigen)

set(LIBIGL_WITH_PREDICATES ON CACHE BOOL "Use exact predicates" FORCE)

list(APPEND CMAKE_MODULE_PATH ${libigl_SOURCE_DIR}/cmake)
include(${libigl_SOURCE_DIR}/cmake/libigl.cmake ${libigl_BINARY_DIR})
include(CPM)
CPMAddPackage("gh:libigl/[email protected]")

# Install rules
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME libigl)
set_target_properties(igl PROPERTIES EXPORT_NAME core)
install(DIRECTORY ${libigl_SOURCE_DIR}/include/igl DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(TARGETS igl igl_common EXPORT Libigl_Targets)
install(EXPORT Libigl_Targets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/igl NAMESPACE igl::)
# Folder name for IDE
foreach(target_name IN ITEMS core predicates)
set_target_properties(igl_${target_name} PROPERTIES FOLDER "ThirdParty/libigl")
endforeach()
Loading