Skip to content

Commit

Permalink
Add geogram geometry library to bext
Browse files Browse the repository at this point in the history
  • Loading branch information
starseeker committed Jan 25, 2024
1 parent 4358334 commit 07d979f
Show file tree
Hide file tree
Showing 6 changed files with 227 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
145 changes: 145 additions & 0 deletions CMake/FindGeogram.cmake
Original file line number Diff line number Diff line change
@@ -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()
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down
69 changes: 69 additions & 0 deletions geogram/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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

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

0 comments on commit 07d979f

Please sign in to comment.