2026-07-23 05:27:51 +00:00
|
|
|
cmake_minimum_required(VERSION 3.16)
|
2026-07-27 06:24:36 +08:00
|
|
|
project(ViewDesignEngine VERSION 1.0.0 LANGUAGES C CXX)
|
2026-07-27 15:08:21 +08:00
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
2026-07-23 05:27:51 +00:00
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
|
|
2026-07-27 21:54:46 +08:00
|
|
|
# ── 生成构建时间戳 ──────────────────────────────────
|
|
|
|
|
string(TIMESTAMP VDE_BUILD_TIMESTAMP "%Y-%m-%dT%H:%M:%SZ" UTC)
|
|
|
|
|
configure_file(
|
2026-07-27 23:34:18 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cmake/vde_build_config.h.in
|
2026-07-27 21:54:46 +08:00
|
|
|
${CMAKE_BINARY_DIR}/generated/vde_build_config.h
|
|
|
|
|
@ONLY
|
|
|
|
|
)
|
|
|
|
|
|
2026-07-23 09:06:18 +00:00
|
|
|
option(BUILD_TESTS "Build tests" ON)
|
2026-07-23 23:26:46 +00:00
|
|
|
option(BUILD_BENCHMARKS "Build benchmarks" OFF)
|
2026-07-23 09:06:18 +00:00
|
|
|
option(BUILD_EXAMPLES "Build examples" ON)
|
|
|
|
|
option(ENABLE_SANITIZERS "Enable ASan" OFF)
|
2026-07-23 10:32:51 +00:00
|
|
|
option(VDE_USE_GMP "GMP exact arithmetic" OFF)
|
2026-07-23 09:06:18 +00:00
|
|
|
option(VDE_BUILD_PYTHON "Python bindings" OFF)
|
2026-07-27 22:51:03 +08:00
|
|
|
option(VDE_USE_OPENMP "Enable OpenMP" ON)
|
|
|
|
|
|
|
|
|
|
# ── 模块构建开关 ────────────────────────────────────
|
|
|
|
|
option(VDE_BUILD_CURVES "Build curves module" ON)
|
|
|
|
|
option(VDE_BUILD_MESH "Build mesh module" ON)
|
|
|
|
|
option(VDE_BUILD_BREP "Build brep module" ON)
|
|
|
|
|
option(VDE_BUILD_SPATIAL "Build spatial module" ON)
|
|
|
|
|
option(VDE_BUILD_BOOLEAN "Build boolean module" ON)
|
|
|
|
|
option(VDE_BUILD_COLLISION "Build collision module" ON)
|
|
|
|
|
option(VDE_BUILD_SKETCH "Build sketch module" ON)
|
|
|
|
|
option(VDE_BUILD_SDF "Build sdf module" ON)
|
|
|
|
|
option(VDE_BUILD_CAPI "Build C API module" ON)
|
2026-07-23 05:27:51 +00:00
|
|
|
|
2026-07-23 07:51:23 +00:00
|
|
|
add_library(vde_compile_options INTERFACE)
|
2026-07-23 05:27:51 +00:00
|
|
|
include(cmake/CompilerSettings.cmake)
|
2026-07-27 15:08:21 +08:00
|
|
|
target_compile_features(vde_compile_options INTERFACE cxx_std_20)
|
2026-07-23 05:27:51 +00:00
|
|
|
|
|
|
|
|
find_package(Eigen3 3.3 QUIET)
|
|
|
|
|
if(NOT Eigen3_FOUND)
|
|
|
|
|
include(FetchContent)
|
|
|
|
|
FetchContent_Declare(Eigen3
|
2026-07-23 09:06:18 +00:00
|
|
|
URL https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz)
|
2026-07-23 05:27:51 +00:00
|
|
|
FetchContent_MakeAvailable(Eigen3)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
add_subdirectory(src)
|
|
|
|
|
|
2026-07-23 23:26:46 +00:00
|
|
|
if(BUILD_BENCHMARKS)
|
|
|
|
|
add_subdirectory(bench)
|
|
|
|
|
endif()
|
|
|
|
|
|
2026-07-23 05:27:51 +00:00
|
|
|
if(BUILD_TESTS)
|
|
|
|
|
enable_testing()
|
|
|
|
|
find_package(GTest QUIET)
|
|
|
|
|
if(NOT GTest_FOUND)
|
|
|
|
|
include(FetchContent)
|
|
|
|
|
FetchContent_Declare(googletest
|
2026-07-23 09:06:18 +00:00
|
|
|
URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz)
|
2026-07-23 05:27:51 +00:00
|
|
|
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
|
|
|
|
|
FetchContent_MakeAvailable(googletest)
|
|
|
|
|
endif()
|
|
|
|
|
add_subdirectory(tests)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(BUILD_EXAMPLES)
|
|
|
|
|
add_subdirectory(examples)
|
|
|
|
|
endif()
|
|
|
|
|
|
2026-07-23 07:51:23 +00:00
|
|
|
if(VDE_BUILD_PYTHON)
|
|
|
|
|
add_subdirectory(python)
|
|
|
|
|
endif()
|