From 07d979f758676b9f49172dcc51d4020191baddce Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Thu, 25 Jan 2024 15:52:38 -0500 Subject: [PATCH] Add geogram geometry library to bext --- .gitmodules | 6 ++ CMake/FindGeogram.cmake | 145 ++++++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 4 ++ geogram/CMakeLists.txt | 69 +++++++++++++++++++ geogram/geogram | 1 + geogram/geogram.deps | 2 + 6 files changed, 227 insertions(+) create mode 100644 CMake/FindGeogram.cmake create mode 100644 geogram/CMakeLists.txt create mode 160000 geogram/geogram create mode 100644 geogram/geogram.deps diff --git a/.gitmodules b/.gitmodules index 25b4fff3..9c9124f9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -369,3 +369,9 @@ url = https://github.com/BRL-CAD/appleseed shallow = true ignore = dirty +[submodule "geogram/geogram"] + path = geogram/geogram + url = https://github.com/BRL-CAD/geogram.git + branch = RELEASE + shallow = true + ignore = dirty diff --git a/CMake/FindGeogram.cmake b/CMake/FindGeogram.cmake new file mode 100644 index 00000000..d4f3dd3f --- /dev/null +++ b/CMake/FindGeogram.cmake @@ -0,0 +1,145 @@ +# Find Geogram +# ------------ +# +# Find Geogram include dirs and libraries +# +# This module defines the following variables: +# +# Geogram_FOUND - True if geogram has been found. +# Geogram::geogram - Imported target for the main Geogram library. +# Geogram::geogram_gfx - Imported target for Geogram graphics library. +# +# This module reads hints about the Geogram location from the following +# environment variables: +# +# GEOGRAM_INSTALL_PREFIX - Directory where Geogram is installed. +# +# Authors: Jeremie Dumas +# Pierre Moulon +# Bruno Levy + +set (GEOGRAM_SEARCH_PATHS + "${GEOGRAM_ROOT}" + ${GEOGRAM_INSTALL_PREFIX} + "$ENV{GEOGRAM_INSTALL_PREFIX}" + "/usr/local/" + "$ENV{PROGRAMFILES}/Geogram" + "$ENV{PROGRAMW6432}/Geogram" +) + +set (GEOGRAM_SEARCH_PATHS_SYSTEM + "/usr/lib" + "/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}" +) + +find_path (GEOGRAM_INCLUDE_DIR + geogram/basic/common.h + PATHS ${GEOGRAM_SEARCH_PATHS} + PATH_SUFFIXES include/geogram1 +) + +find_library (GEOGRAM_LIBRARY + NAMES geogram + PATHS ${GEOGRAM_SEARCH_PATHS} + PATH_SUFFIXES lib +) + +find_library (GEOGRAM_GFX_LIBRARY + NAMES geogram_gfx + PATHS ${GEOGRAM_SEARCH_PATHS} + PATH_SUFFIXES lib +) + +# This one we search in both Geogram search path and +# system search path since it may be already installed +# in the system +find_library (GEOGRAM_GLFW3_LIBRARY + NAMES glfw3 glfw geogram_glfw3 glfw3dll glfwdll + PATHS ${GEOGRAM_SEARCH_PATHS} ${GEOGRAM_SEARCH_PATHS_SYSTEM} + PATH_SUFFIXES lib +) + +include (FindPackageHandleStandardArgs) +find_package_handle_standard_args( + GEOGRAM DEFAULT_MSG GEOGRAM_LIBRARY GEOGRAM_INCLUDE_DIR +) + +# Create an imported target for Geogram +If (GEOGRAM_FOUND) + + set(GEOGRAM_INSTALL_PREFIX ${GEOGRAM_INCLUDE_DIR}/../..) + + if (NOT TARGET Geogram::geogram) + add_library (Geogram::geogram UNKNOWN IMPORTED) + + # Interface include directory + set_target_Properties(Geogram::geogram PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${GEOGRAM_INCLUDE_DIR}" + ) + + # Link to library file + Set_Target_Properties(Geogram::geogram PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${GEOGRAM_LIBRARY}" + ) + endif () + + if (NOT TARGET Geogram::geogram_gfx) + add_library (Geogram::geogram_gfx UNKNOWN IMPORTED) + + set_target_properties(Geogram::geogram_gfx PROPERTIES + INTERFACE_LINK_LIBRARIES ${GEOGRAM_GLFW3_LIBRARY} + ) + + # Interface include directory + set_target_properties(Geogram::geogram_gfx PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${GEOGRAM_INCLUDE_DIR}" + ) + + # Link to library file + set_target_properties(Geogram::geogram_gfx PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${GEOGRAM_GFX_LIBRARY}" + ) + + endif () + + +endif () + +# Hide variables from the default CMake-Gui options +mark_as_advanced (GEOGRAM_LIBRARY GEOGRAM_GFX_LIBRARY GEOGRAM_INCLUDE_DIR) + +# Some specific settings for Windows + +if(WIN32) + + # Default mode for Windows uses static libraries. Use this variable to + # link with geogram compiled as DLLs. + set(VORPALINE_BUILD_DYNAMIC FALSE CACHE BOOL "Installed Geogram uses DLLs") + + # remove warning for multiply defined symbols (caused by multiple + # instanciations of STL templates) + add_definitions(/wd4251) + + # remove all unused stuff from windows.h + add_definitions(-DWIN32_LEAN_AND_MEAN) + add_definitions(-DVC_EXTRALEAN) + + # do not define a min() and a max() macro, breaks + # std::min() and std::max() !! + add_definitions(-DNOMINMAX ) + + # we want M_PI etc... + add_definitions(-D_USE_MATH_DEFINES) + + if(NOT VORPALINE_BUILD_DYNAMIC) + # If we use static library, we link with the static C++ runtime. + foreach(config ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER ${config} config) + string(REPLACE /MD /MT CMAKE_C_FLAGS_${config} "${CMAKE_C_FLAGS_${config}}") + string(REPLACE /MD /MT CMAKE_CXX_FLAGS_${config} "${CMAKE_CXX_FLAGS_${config}}") + endforeach() + endif() + +endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index bab76fdc..2d8b71ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -560,6 +560,10 @@ add_project(osmesa GROUPS "BRLCAD") # https://github.com/jhasse/poly2tri add_project(poly2tri GROUPS "BRLCAD") +# Geogram - a programming library with geometric algorithms +# https://github.com/BrunoLevy/geogram +add_project(geogram GROUPS "BRLCAD_EXTRA") + # Open Shading Language (OSL) - language for programmable shading # https://github.com/AcademySoftwareFoundation/OpenShadingLanguage # diff --git a/geogram/CMakeLists.txt b/geogram/CMakeLists.txt new file mode 100644 index 00000000..353a6029 --- /dev/null +++ b/geogram/CMakeLists.txt @@ -0,0 +1,69 @@ +# Unless we have ENABLE_ALL set, base the building of geogram on +# the system detection results +if (ENABLE_ALL AND NOT DEFINED ENABLE_GEOGRAM) + set(ENABLE_GEOGRAM ON) +endif (ENABLE_ALL AND NOT DEFINED ENABLE_GEOGRAM) + +if (NOT ENABLE_GEOGRAM) + + find_package(Geogram) + + if (NOT Geogram_FOUND AND NOT DEFINED ENABLE_GEOGRAM) + set(ENABLE_GEOGRAM "ON" CACHE BOOL "Enable Geogram build") + endif (NOT Geogram_FOUND AND NOT DEFINED ENABLE_GEOGRAM) + +endif (NOT ENABLE_GEOGRAM) +set(ENABLE_GEOGRAM "${ENABLE_GEOGRAM}" CACHE BOOL "Enable Geogram build") + +if (ENABLE_GEOGRAM) + + git_submodule_init(geogram CMakeLists.txt) + + TargetDeps(GEOGRAM) + + ExternalProject_Add(GEOGRAM_BLD + URL "${CMAKE_CURRENT_SOURCE_DIR}/geogram" + BUILD_ALWAYS ${EXT_BUILD_ALWAYS} ${LOG_OPTS} + #PATCH_COMMAND ${PATCH_EXECUTABLE};-E;-p1;${PATCH_OPTIONS};-i;${CMAKE_CURRENT_SOURCE_DIR}/geogram.patch + CMAKE_ARGS + ${BUILD_TYPE_SPECIFIER} + -DBIN_DIR=${BIN_DIR} + -DLIB_DIR=${LIB_DIR} + -DBUILD_STATIC_LIBS=${BUILD_STATIC_LIBS} + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} + -DCMAKE_INSTALL_PREFIX=${CMAKE_BUNDLE_INSTALL_PREFIX} + -DCMAKE_INSTALL_LIBDIR:PATH=${LIB_DIR} + -DCMAKE_INSTALL_RPATH=${CMAKE_BUNDLE_INSTALL_PREFIX}/${LIB_DIR} + -DGEOGRAM_LIB_ONLY=ON + -DGEOGRAM_WITH_GRAPHICS=OFF + -DGEOGRAM_WITH_LUA=OFF + -DGEOGRAM_WITH_HLBFGS=OFF + -DGEOGRAM_WITH_TETGEN=OFF + -DGEOGRAM_WITH_TRIANGLE=OFF + LOG_CONFIGURE ${EXT_BUILD_QUIET} + LOG_BUILD ${EXT_BUILD_QUIET} + LOG_INSTALL ${EXT_BUILD_QUIET} + LOG_OUTPUT_ON_FAILURE ${EXT_BUILD_QUIET} + STEP_TARGETS install + ) + + TargetInstallDeps(GEOGRAM GEOGRAM_DEPENDS) + + # Copy the license into position in CMAKE_BUNDLE_INSTALL_PREFIX + file(MAKE_DIRECTORY ${CMAKE_BUNDLE_INSTALL_PREFIX}/doc/legal/other) + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/geogram/LICENSE + ${CMAKE_BUNDLE_INSTALL_PREFIX}/doc/legal/other/geogram.txt + COPYONLY + ) + +endif (ENABLE_GEOGRAM) + +# Local Variables: +# tab-width: 8 +# mode: cmake +# indent-tabs-mode: t +# End: +# ex: shiftwidth=2 tabstop=8 + diff --git a/geogram/geogram b/geogram/geogram new file mode 160000 index 00000000..296fdc24 --- /dev/null +++ b/geogram/geogram @@ -0,0 +1 @@ +Subproject commit 296fdc24467cd5d47d6baecec95210287201d456 diff --git a/geogram/geogram.deps b/geogram/geogram.deps new file mode 100644 index 00000000..ecdeab5f --- /dev/null +++ b/geogram/geogram.deps @@ -0,0 +1,2 @@ +PATCH +