Skip to content

Commit

Permalink
Add GeometricTools as a bext module
Browse files Browse the repository at this point in the history
This is preliminary - setting up to replace our copies of "ported" GTE
algorithms with calls to the upstream copies directly.  The key part of
GTE for our use case is header only, so treating it like Eigen and
staging it in noinstall.
  • Loading branch information
starseeker committed Jul 31, 2024
1 parent f39a5b0 commit b12f5a3
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -304,3 +304,6 @@
url = https://github.com/BRL-CAD/geogram.git
branch = RELEASE
ignore = dirty
[submodule "gte/GeometricTools"]
path = gte/GeometricTools
url = https://github.com/BRL-CAD/GeometricTools
40 changes: 40 additions & 0 deletions CMake/FindGTE.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Find GeometricTools Mathematics headers
#
# Once done this will define
#
# GTE_FOUND - system has GTE Mathematics headers
# GTE_INCLUDE_DIR - the GTE include directory
#
# and the following imported target:
#
# GTE::GTE- Provides include dir for GeometricTools Mathematics headers

set(_GTE_SEARCHES)

# Search GTE_ROOT first if it is set.
if(GTE_ROOT)
set(_GTE_SEARCH_ROOT PATHS ${GTE_ROOT} NO_DEFAULT_PATH)
list(APPEND _GTE_SEARCHES _GTE_SEARCH_ROOT)
endif()

# Try each search configuration.
foreach(search ${_GTE_SEARCHES})
find_path(GTE_INCLUDE_DIR NAMES GTE/Mathematics/ConvexHull3.h ${${search}} PATH_SUFFIXES include)
endforeach()

mark_as_advanced(GTE_INCLUDE_DIR)

# handle the QUIETLY and REQUIRED arguments and set ZLIB_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTE REQUIRED_VARS GTE_INCLUDE_DIR)

if(GTE_FOUND)
set(GTE_INCLUDE_DIRS ${GTE_INCLUDE_DIR})

if(NOT TARGET GTE::GTE)
add_library(GTE::GTE UNKNOWN IMPORTED)
set_target_properties(GTE::GTE PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${GTE_INCLUDE_DIRS}")
endif()
endif()
5 changes: 5 additions & 0 deletions dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ add_project(assetimport GROUPS "BRLCAD")
# http://opencv.org
add_project(opencv GROUPS "BRLCAD_EXTRA")

# GeometricTools - a collection of geometry algorithms.
# https://github.com/davideberly/GeometricTools
add_project(gte GROUPS "BRLCAD")


# OpenMesh Library - library for representing and manipulating polygonal meshes
# https://www.graphics.rwth-aachen.de/software/openmesh/
add_project(openmesh GROUPS "BRLCAD_EXTRA")
Expand Down
53 changes: 53 additions & 0 deletions gte/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Decide if we're using GeometricTools
cad_enable(GTE "libbg")

unset(ENGEN_BUNDLED CACHE)

if (NOT ENABLE_GTE AND NOT DISABLE_GTE)

# https://github.com/davideberly/GeometricTools
find_package(GTE)

if (NOT TARGET GTE::GTE)
set(ENABLE_GTE "ON" CACHE BOOL "Enable GeometricTools build")
endif (NOT TARGET GTE::GTE)

endif (NOT ENABLE_GTE AND NOT DISABLE_GTE)

set(ENABLE_GTE "${ENABLE_GTE}" CACHE BOOL "Enable GeometricTools build")

# Decision made

if (ENABLE_GTE)

git_submodule_init(GeometricTools GTE/CMakeLists.txt)

TargetDeps(GTE)

ExternalProject_Add(GTE_BLD
URL "${CMAKE_CURRENT_SOURCE_DIR}/GeometricTools"
BUILD_ALWAYS ${EXT_BUILD_ALWAYS} ${LOG_OPTS}
PATCH_COMMAND ${PATCH_EXECUTABLE};-E;-p1;${PATCH_OPTIONS};-i;${CMAKE_CURRENT_SOURCE_DIR}/gte.patch
CMAKE_ARGS
${BUILD_TYPE_SPECIFIER}
-DCMAKE_INSTALL_PREFIX=${CMAKE_NOBUNDLE_INSTALL_PREFIX}
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(GTE GTE_DEPENDS)

set(GTE_BUNDLED TRUE CACHE BOOL "GeometricTools bundle flag")

endif (ENABLE_GTE)

# Local Variables:
# tab-width: 8
# mode: cmake
# indent-tabs-mode: t
# End:
# ex: shiftwidth=2 tabstop=8

1 change: 1 addition & 0 deletions gte/GeometricTools
Submodule GeometricTools added at 435934
2 changes: 2 additions & 0 deletions gte/gte.deps
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PATCH

23 changes: 23 additions & 0 deletions gte/gte.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
diff -Naur GeometricTools/CMakeLists.txt GTE_BLD/CMakeLists.txt
--- GeometricTools/CMakeLists.txt 1969-12-31 19:00:00.000000000 -0500
+++ GTE_BLD/CMakeLists.txt 2024-07-31 16:48:17.163077007 -0400
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 3.8)
+
+project(GTE)
+
+file(GLOB GTE_MFILES "${CMAKE_SOURCE_DIR}/GTE/Mathematics/*")
+
+if(NOT DEFINED INCLUDE_DIR)
+ set(INCLUDE_DIR include)
+endif(NOT DEFINED INCLUDE_DIR)
+
+install(FILES ${GTE_MFILES} DESTINATION ${INCLUDE_DIR}/GTE/Mathematics)
+
+# Local Variables:
+# tab-width: 8
+# mode: cmake
+# indent-tabs-mode: t
+# End:
+# ex: shiftwidth=2 tabstop=8
+

0 comments on commit b12f5a3

Please sign in to comment.