cf13496ff6
新增功能: - core: 2D Voronoi 图(Delaunay 对偶图) - mesh: Marching Cubes(完整256项三角表 + SDF 辅助函数) - mesh: 离散曲率(Gaussian/Mean, Cotan 公式) - foundation: 二进制序列化(版本化格式,Little-Endian) - python: pybind11 绑定(30+ API 暴露) - marching_cubes.h: SDF 基本体(球/盒)+ 光滑布尔
74 lines
3.3 KiB
CMake
74 lines
3.3 KiB
CMake
cmake_minimum_required(VERSION 3.16)
|
|
project(ViewDesignEngine VERSION 0.1.0 LANGUAGES CXX)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
# ── 选项 ──────────────────────────────────────────
|
|
option(BUILD_TESTS "Build unit tests" ON)
|
|
option(BUILD_EXAMPLES "Build examples" ON)
|
|
option(BUILD_BENCHMARKS "Build benchmarks" OFF)
|
|
option(BUILD_SHARED_LIBS "Build shared library" OFF)
|
|
option(ENABLE_SANITIZERS "Enable ASan/UBSan" OFF)
|
|
option(ENABLE_LTO "Enable LTO" ON)
|
|
|
|
# ── 编译设置 ──────────────────────────────────────
|
|
include(cmake/CompilerSettings.cmake)
|
|
|
|
# ── 依赖 ──────────────────────────────────────────
|
|
find_package(Eigen3 3.3 QUIET)
|
|
if(NOT Eigen3_FOUND)
|
|
message(STATUS "Eigen3 not found — using FetchContent")
|
|
include(FetchContent)
|
|
FetchContent_Declare(Eigen3
|
|
URL https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz
|
|
)
|
|
FetchContent_MakeAvailable(Eigen3)
|
|
endif()
|
|
|
|
# ── 子目录 ────────────────────────────────────────
|
|
add_subdirectory(src)
|
|
|
|
# ── 测试 ──────────────────────────────────────────
|
|
if(BUILD_TESTS)
|
|
enable_testing()
|
|
find_package(GTest QUIET)
|
|
if(NOT GTest_FOUND)
|
|
include(FetchContent)
|
|
FetchContent_Declare(googletest
|
|
URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz
|
|
)
|
|
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
|
|
FetchContent_MakeAvailable(googletest)
|
|
endif()
|
|
add_subdirectory(tests)
|
|
endif()
|
|
|
|
# ── 示例 ──────────────────────────────────────────
|
|
# ── Python 绑定 ────────────────────────────────────option(VDE_BUILD_PYTHON "Build Python bindings (pybind11)" OFF)if(VDE_BUILD_PYTHON) add_subdirectory(python)endif()
|
|
if(BUILD_EXAMPLES)
|
|
add_subdirectory(examples)
|
|
endif()
|
|
|
|
# ── 性能测试 ──────────────────────────────────────
|
|
if(BUILD_BENCHMARKS)
|
|
find_package(benchmark QUIET)
|
|
if(NOT benchmark_FOUND)
|
|
include(FetchContent)
|
|
FetchContent_Declare(googlebenchmark
|
|
URL https://github.com/google/benchmark/archive/refs/tags/v1.8.0.tar.gz
|
|
)
|
|
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "" FORCE)
|
|
FetchContent_MakeAvailable(googlebenchmark)
|
|
endif()
|
|
add_subdirectory(benchmarks)
|
|
endif()
|
|
|
|
# ── 安装 ──────────────────────────────────────────
|
|
include(GNUInstallDirs)
|
|
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
|
install(TARGETS vde EXPORT ViewDesignEngine-targets)
|
|
install(EXPORT ViewDesignEngine-targets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ViewDesignEngine)
|