cmake: add WITH_CGAL / WITH_VIEWER modes, remove unused Boost

Restructures the CMake build into three clearly separated modes:

  (default)        tests only – Eigen + GTest, no heavy deps
  -DWITH_VIEWER=ON builds viewer lib (libigl / GLFW / GLAD)
  -DWITH_CGAL=ON   builds conformallab_core CLI app;
                   implies WITH_VIEWER automatically

Changes:
- code/CMakeLists.txt: viewer and core targets are now guarded by
  option() flags; GTest / tests target is always built
- code/deps/Cmakelists.txt: CGAL, libigl, glfw, glad are only
  extracted when the corresponding mode is enabled; Eigen always
- Remove Boost (211 MB tarball, 0 usages in the codebase – CGAL 6.x
  does not require Boost for Simple_cartesian / Surface_mesh / basic IO)
- Remove code/src/main.cpp (dead file, not referenced in CMake)

All 16 C++ tests pass in tests-only mode (verified locally).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Tarik Moussa
2026-05-09 21:42:43 +02:00
parent 5337a9e5a7
commit cd7b7a8fd8
4 changed files with 99 additions and 98 deletions

View File

@@ -1,5 +1,16 @@
# deps/CMakeLists.txt
function(setup_dependency NAME SUBDIR)
#
# Lazy tarball extraction a dependency is only extracted when its directory
# does not yet exist. Extraction happens at cmake configure time.
#
# Which deps are extracted depends on the active build mode:
#
# (default) Eigen only → tests-only build
# WITH_VIEWER=ON + Eigen, libigl, libigl-glad, glfw
# WITH_CGAL=ON + Eigen, CGAL (WITH_VIEWER is implied by WITH_CGAL)
#
function(setup_dependency NAME SUBDIR)
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${NAME}")
file(MAKE_DIRECTORY "${NAME}")
file(GLOB TARBALL "${CMAKE_CURRENT_SOURCE_DIR}/tarballs/${NAME}.tar.*")
@@ -7,20 +18,21 @@ function(setup_dependency NAME SUBDIR)
if(NOT TARBALL)
message(FATAL_ERROR "❌ No '${NAME}*.tar.*' in deps/tarballs/")
else()
message(STATUS "${CMAKE_COMMAND} ${TARBALL}" )
message(STATUS "${CMAKE_COMMAND} ${TARBALL}")
if(SUBDIR STREQUAL "")
execute_process(COMMAND "${CMAKE_COMMAND}" -E tar xf "${TARBALL}" RESULT_VARIABLE TAR_STATUS WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" )
message(STATUS "Extracting ${NAME}... Output: ${TAR_OUTPUT} Status: ${TAR_STATUS}")
if(NOT TAR_STATUS EQUAL 0)
message(FATAL_ERROR "❌ Extract failed: ${NAME}")
endif()
execute_process(
COMMAND "${CMAKE_COMMAND}" -E tar xf "${TARBALL}"
RESULT_VARIABLE TAR_STATUS
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
else()
execute_process(COMMAND "${CMAKE_COMMAND}" -E tar xf "${TARBALL}" "${NAME}/${SUBDIR}" RESULT_VARIABLE TAR_STATUS WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" )
message(STATUS "Extracting ${NAME}... Output: ${TAR_OUTPUT} Status: ${TAR_STATUS}")
if(NOT TAR_STATUS EQUAL 0)
message(FATAL_ERROR "❌ Extract failed: ${NAME}")
endif()
execute_process(
COMMAND "${CMAKE_COMMAND}" -E tar xf "${TARBALL}" "${NAME}/${SUBDIR}"
RESULT_VARIABLE TAR_STATUS
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
endif()
message(STATUS "Extracting ${NAME}... Status: ${TAR_STATUS}")
if(NOT TAR_STATUS EQUAL 0)
message(FATAL_ERROR "❌ Extract failed: ${NAME}")
endif()
endif()
else()
@@ -28,10 +40,17 @@ function(setup_dependency NAME SUBDIR)
endif()
endfunction()
setup_dependency("CGAL-6.1.1" "include" )
setup_dependency("eigen-3.4.0" "Eigen" )
setup_dependency("boost_1_90_0" "boost" )
setup_dependency("libigl-2.6.0" "include" )
setup_dependency("libigl-glad" "" )
setup_dependency("glfw-3.4" "" )
# ── Always required ────────────────────────────────────────────────────────────
setup_dependency("eigen-3.4.0" "Eigen")
# ── Viewer mode ────────────────────────────────────────────────────────────────
if(WITH_VIEWER)
setup_dependency("libigl-2.6.0" "include")
setup_dependency("libigl-glad" "")
setup_dependency("glfw-3.4" "")
endif()
# ── CGAL mode ─────────────────────────────────────────────────────────────────
if(WITH_CGAL)
setup_dependency("CGAL-6.1.1" "include")
endif()