Skip to content

Commit

Permalink
See if we can make bext configure respond to a BRLCAD_COMPONENTS list
Browse files Browse the repository at this point in the history
  • Loading branch information
starseeker committed Mar 25, 2024
1 parent 2f3a221 commit 54bd914
Show file tree
Hide file tree
Showing 36 changed files with 327 additions and 230 deletions.
45 changes: 44 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,49 @@ option(USE_OSPRAY "OSPRay rendering system" OFF)
option(USE_QT "Qt graphical toolkit support" ON)
option(USE_TCL "Tcl/Tk support" ON)

# If we're using BRLCAD_COMPONENTS, the check is more nuanced.
# For bext, the BRLCAD_COMPONENTS list should be the expanded
# list from BRL-CAD's parent logic that fully populates the
# dependencies, not just the components directly specified by
# the user to BRL-CAD's configure.
function(cad_enable pname components)
if (DEFINED BRLCAD_COMPONENTS)
# In case the component list changed, make sure we're
# not using a cached result.
unset(ENABLE_${pname} CACHE)
unset(DISABLE_${pname} CACHE)

set(acomponents ${components})

# Look for a component in the list
foreach(c ${BRLCAD_COMPONENTS})
list(FIND acomponents ${c} LFIND)
if (NOT LFIND EQUAL -1)
if (ENABLE_ALL AND NOT DEFINED ENABLE_${pname})
set(ENABLE_${pname} ON PARENT_SCOPE)
endif (ENABLE_ALL AND NOT DEFINED ENABLE_${pname})
set(DISABLE_${pname} OFF PARENT_SCOPE)
return()
endif (NOT LFIND EQUAL -1)
endforeach(c ${components})

# If we're a component build and this component
# isn't enabled, it's a definite off
set(ENABLE_${pname} OFF)
set(DISABLE_${pname} ON)
endif (DEFINED BRLCAD_COMPONENTS)

# Check for ENABLE_ALL
if (ENABLE_ALL AND NOT DEFINED ENABLE_${pname})
set(ENABLE_${pname} ON)
endif (ENABLE_ALL AND NOT DEFINED ENABLE_${pname})

# Final decision
set(ENABLE_${pname} ${ENABLE_${pname}} PARENT_SCOPE)
set(DISABLE_${pname} ${DISABLE_${pname}} PARENT_SCOPE)
endfunction(cad_enable pname components)


# If configurations change after a build has been performed,
# we don't automatically scrub a pre-existing output directory
# to remove the files from the newly disabled components.
Expand All @@ -300,7 +343,7 @@ function(add_project pname)
endforeach(grp ${A_GROUPS})
if (NOT is_added)
if (ENABLE_${UPNAME})
message("Disabling ${pname} due to disabled USE flags")
message("Disabling ${pname}")
set(STALE_INSTALL_WARN TRUE PARENT_SCOPE)
endif (ENABLE_${UPNAME})
execute_process(COMMAND ${CMAKE_COMMAND} -E rm -rf ${CMAKE_BINARY_DIR}/${pname})
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ git clone --recursive https://github.com/BRL-CAD/bext

This is primarily useful if you want to do all the downloading at once up front or you are preparing to work in an environment without an internet connection.

A word of caution - full cloning of all the repository contents can be time, bandwidth and space intensive. To help alleviate this a bit, you can add -DGIT_SHALLOW_CLONE=ON to the CMake configure, or if you're pre-cloning all repositories ahead of time use --depth=1 option with the above recursive clone. Be aware that shallow clones have some limitations that make them unsuitable for much other than compiling (updating to newer versions of submodules won't work, for example) so use of those options isn't recommended for general use.
A word of caution - full cloning of all the repository contents can be time, bandwidth and space intensive. To help alleviate this a bit, you can add -DGIT_SHALLOW_CLONE=ON to the CMake configure, or if you're pre-cloning all repositories ahead of time use --depth=1 option with the above recursive clone. Be aware that shallow clones have some limitations that make them unsuitable for much other than compiling (updating to newer versions of submodules won't work, for example) so shallow clones aren't recommended for development.

# USE_* Options

Expand All @@ -44,6 +44,8 @@ A complete ENABLE_ALL build of all components in this repository is a *very* lar
* USE_APPLESEED - Physically-based global illumination rendering engine
* USE_OSPRAY - Intel high performance ray tracing engine

(For BRL-CAD components specifically, a more nuanced enable/disable decision can be made if the BRLCAD_COMPONENTS variable is set. If the parent BRL-CAD build is only building a subset of the BRL-CAD target set, no all dependencies will be needed.)

# Using the Build Outputs with BRL-CAD

At the moment this repository and BRL-CAD's support of it are still experimental.
Expand Down
15 changes: 8 additions & 7 deletions assetimport/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
# Unless we have ENABLE_ALL set, base the building of png on
# the system detection results
if (ENABLE_ALL AND NOT DEFINED ENABLE_ASSETIMPORT)
set(ENABLE_ASSETIMPORT ON)
endif (ENABLE_ALL AND NOT DEFINED ENABLE_ASSETIMPORT)
# Decide if we're using assetimport - used by Manifold which is used by librt.
# Also, assetimport is used directly by a libgcv plugin
cad_enable(ASSETIMPORT "librt;libgcv")

if (NOT ENABLE_ASSETIMPORT)
if (NOT ENABLE_ASSETIMPORT AND NOT DISABLE_ASSETIMPORT)

find_package(ASSETIMPORT)

if (NOT ASSETIMPORT_FOUND AND NOT DEFINED ENABLE_ASSETIMPORT)
set(ENABLE_ASSETIMPORT "ON" CACHE BOOL "Enable assetimport build")
endif (NOT ASSETIMPORT_FOUND AND NOT DEFINED ENABLE_ASSETIMPORT)

endif (NOT ENABLE_ASSETIMPORT)
endif (NOT ENABLE_ASSETIMPORT AND NOT DISABLE_ASSETIMPORT)

set(ENABLE_ASSETIMPORT "${ENABLE_ASSETIMPORT}" CACHE BOOL "Enable assetimport build")

# Decision made

if (ENABLE_ASSETIMPORT)

git_submodule_init(assimp CMakeLists.txt)
Expand Down
14 changes: 7 additions & 7 deletions eigen/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# Eigen is not bundled with BRL-CAD - it is a header only library
# and is only required at compile time,
if (ENABLE_ALL AND NOT DEFINED ENABLE_EIGEN)
set(ENABLE_EIGEN ON)
endif (ENABLE_ALL AND NOT DEFINED ENABLE_EIGEN)
# Decide if we're using Eigen
cad_enable(EIGEN "libbg;libbn;librt")

if (NOT ENABLE_EIGEN)
if (NOT ENABLE_EIGEN AND NOT DISABLE_EIGEN)

# https://eigen.tuxfamily.org/dox/TopicCMakeGuide.html
find_package(Eigen3 NO_MODULE)
Expand All @@ -13,9 +10,12 @@ if (NOT ENABLE_EIGEN)
set(ENABLE_EIGEN "ON" CACHE BOOL "Enable Eigen build")
endif (NOT TARGET Eigen3::Eigen)

endif (NOT ENABLE_EIGEN)
endif (NOT ENABLE_EIGEN AND NOT DISABLE_EIGEN)

set(ENABLE_EIGEN "${ENABLE_EIGEN}" CACHE BOOL "Enable Eigen build")

# Decision made

if (ENABLE_EIGEN)

git_submodule_init(eigen CMakeLists.txt)
Expand Down
18 changes: 9 additions & 9 deletions gdal/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Unless we have ENABLE_ALL set, base the building of png on
# the system detection results
if (ENABLE_ALL AND NOT DEFINED ENABLE_GDAL)
set(ENABLE_GDAL ON)
endif (ENABLE_ALL AND NOT DEFINED ENABLE_GDAL)
# Decide if we're using GDAL
cad_enable(GDAL "libgcv")

if (NOT ENABLE_GDAL)
if (NOT ENABLE_GDAL AND NOT DISABLE_GDAL)

find_package(GDAL)

if (NOT GDAL_FOUND AND NOT DEFINED ENABLE_GDAL)
set(ENABLE_GDAL "ON" CACHE BOOL "Enable gdal build")
set(ENABLE_GDAL "ON" CACHE BOOL "Enable GDAL build")
endif (NOT GDAL_FOUND AND NOT DEFINED ENABLE_GDAL)

endif (NOT ENABLE_GDAL)
set(ENABLE_GDAL "${ENABLE_GDAL}" CACHE BOOL "Enable gdal build")
endif (NOT ENABLE_GDAL AND NOT DISABLE_GDAL)

set(ENABLE_GDAL "${ENABLE_GDAL}" CACHE BOOL "Enable GDAL build")

# Decision made

if (ENABLE_GDAL)

Expand Down
14 changes: 7 additions & 7 deletions geogram/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# 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)
# Decide if we're using Geogram
cad_enable(GEOGRAM "librt")

if (NOT ENABLE_GEOGRAM)
if (NOT ENABLE_GEOGRAM AND NOT DISABLE_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)
endif (NOT ENABLE_GEOGRAM AND NOT DISABLE_GEOGRAM)

set(ENABLE_GEOGRAM "${ENABLE_GEOGRAM}" CACHE BOOL "Enable Geogram build")

# Decision made, start processing if we are enabled

if (ENABLE_GEOGRAM)

git_submodule_init(geogram CMakeLists.txt)
Expand Down
19 changes: 14 additions & 5 deletions itcl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
if (ENABLE_TCL AND NOT DEFINED ENABLE_ITCL)
set(ENABLE_ITCL ON)
endif (ENABLE_TCL AND NOT DEFINED ENABLE_ITCL)
if (USE_BRLCAD)

if (NOT ENABLE_ITCL)
# Decide if we're using ITcl
cad_enable(ITCL "archer;mged;bwish;rtwizard;brlman")

else (USE_BRLCAD)

if (ENABLE_TCL AND NOT DEFINED ENABLE_ITCL)
set(ENABLE_ITCL ON)
endif (ENABLE_TCL AND NOT DEFINED ENABLE_ITCL)

endif (USE_BRLCAD)

if (NOT ENABLE_ITCL AND NOT DEFINED DISABLE_ITCL)

find_package(ITCL)

if (NOT ITCL_FOUND AND NOT DEFINED ENABLE_ITCL)
set(ENABLE_ITCL "ON" CACHE BOOL "Enable itcl build")
endif (NOT ITCL_FOUND AND NOT DEFINED ENABLE_ITCL)

endif (NOT ENABLE_ITCL)
endif (NOT ENABLE_ITCL AND NOT DEFINED DISABLE_ITCL)
set(ENABLE_ITCL "${ENABLE_ITCL}" CACHE BOOL "Enable itcl build")

if (ENABLE_ITCL)
Expand Down
8 changes: 4 additions & 4 deletions itk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@
# enough that it won't be a significant issue, since there appears to be
# only so much we can do to sort it out...

if (ENABLE_ITCL AND NOT DEFINED ENABLE_ITK)
if (ENABLE_ITCL AND NOT DEFINED ENABLE_ITK AND NOT DEFINED DISABLE_TCL)
set(ENABLE_ITK ON)
endif (ENABLE_ITCL AND NOT DEFINED ENABLE_ITK)
endif (ENABLE_ITCL AND NOT DEFINED ENABLE_ITK AND NOT DEFINED DISABLE_TCL)

if (NOT ENABLE_ITK)
if (NOT ENABLE_ITK AND NOT DEFINED DISABLE_ITCL AND NOT DEFINED DISABLE_TCL)
find_library(ITK_SYS_LIBRARY NAMES itk3)

if (NOT ITK_SYS_LIBRARY AND NOT DEFINED ENABLE_ITK)
set(ENABLE_ITK "ON" CACHE BOOL "Enable itk build")
endif (NOT ITK_SYS_LIBRARY AND NOT DEFINED ENABLE_ITK)

endif (NOT ENABLE_ITK)
endif (NOT ENABLE_ITK AND NOT DEFINED DISABLE_ITCL AND NOT DEFINED DISABLE_TCL)
set(ENABLE_ITK "${ENABLE_ITK}" CACHE BOOL "Enable itk build")

if (ENABLE_ITK)
Expand Down
11 changes: 9 additions & 2 deletions iwidgets/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
if (USE_BRLCAD)

# Decide if we're using Tcl
cad_enable(IWIDGETS "archer;mged")

endif (USE_BRLCAD)

# Unfortunately, there does not appear to be a reliable way to test for the
# presence of the IWidgets package on a system Tcl/Tk. As far as I can tell
# the "package require Iwidgets" test (which is what is required to properly
Expand All @@ -9,9 +16,9 @@
# Unless we have been specifically instructed not to, provide the bundled
# version of IWidgets.

if (NOT DEFINED ENABLE_IWIDGETS)
if (NOT DEFINED ENABLE_IWIDGETS AND NOT DISABLE_IWIDGETS)
set(ENABLE_IWIDGETS ON)
endif (NOT DEFINED ENABLE_IWIDGETS)
endif (NOT DEFINED ENABLE_IWIDGETS AND NOT DISABLE_IWIDGETS)

if (ENABLE_IWIDGETS)

Expand Down
15 changes: 8 additions & 7 deletions jpeg/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
# Unless we have ENABLE_ALL set, based the building of jpeg on
# the system detection results
if (ENABLE_ALL AND NOT DEFINED ENABLE_JPEG)
set(ENABLE_JPEG ON)
endif (ENABLE_ALL AND NOT DEFINED ENABLE_JPEG)
# jpeg is needed by GDAL, which is used by libgcv. TODO: Probably ought to
# wire this into libicv as well if we're going to have it along for the ride...
cad_enable(JPEG "libgcv;libicv")

if (NOT ENABLE_JPEG)
if (NOT ENABLE_JPEG AND NOT DISABLE_JPEG)

find_package(JPEG)

if (NOT JPEG_FOUND AND NOT DEFINED ENABLE_JPEG)
set(ENABLE_JPEG "ON" CACHE BOOL "Enable jpeg build")
endif (NOT JPEG_FOUND AND NOT DEFINED ENABLE_JPEG)

endif (NOT ENABLE_JPEG)
endif (NOT ENABLE_JPEG AND NOT DISABLE_JPEG)

set(ENABLE_JPEG "${ENABLE_JPEG}" CACHE BOOL "Enable jpeg build")

# Decision made

if (ENABLE_JPEG)

git_submodule_init(libjpeg-turbo CMakeLists.txt)
Expand Down
14 changes: 7 additions & 7 deletions lemon/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Unless we have ENABLE_ALL set, base the building of lemon on
# the system detection results
if (ENABLE_ALL AND NOT DEFINED ENABLE_LEMON)
set(ENABLE_LEMON ON)
endif (ENABLE_ALL AND NOT DEFINED ENABLE_LEMON)
# Decide if we're using lemon
cad_enable(LEMON "libgcv;libged")

if (NOT ENABLE_LEMON)
if (NOT ENABLE_LEMON AND NOT DISABLE_LEMON)

find_package(LEMON)

if (NOT LEMON_FOUND AND NOT DEFINED ENABLE_LEMON)
set(ENABLE_LEMON "ON" CACHE BOOL "Enable lemon build")
endif (NOT LEMON_FOUND AND NOT DEFINED ENABLE_LEMON)

endif (NOT ENABLE_LEMON)
endif (NOT ENABLE_LEMON AND NOT DISABLE_LEMON)

set(ENABLE_LEMON "${ENABLE_LEMON}" CACHE BOOL "Enable lemon build")

# Decision made

if (ENABLE_LEMON)

git_submodule_init(lemon lemon.c)
Expand Down
14 changes: 7 additions & 7 deletions linenoise/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Unless we have ENABLE_ALL set, base the building of linenoise on
# the system detection results
if (ENABLE_ALL AND NOT DEFINED ENABLE_LINENOISE)
set(ENABLE_LINENOISE ON)
endif (ENABLE_ALL AND NOT DEFINED ENABLE_LINENOISE)
# Decide if we're using linenoise
cad_enable(LINENOISE "gtools;nirt")

if (NOT ENABLE_LINENOISE)
if (NOT ENABLE_LINENOISE AND NOT DISABLE_LINENOISE)

find_package(LINENOISE)

if (NOT LINENOISE_FOUND AND NOT DEFINED ENABLE_LINENOISE)
set(ENABLE_LINENOISE "ON" CACHE BOOL "Enable linenoise build")
endif (NOT LINENOISE_FOUND AND NOT DEFINED ENABLE_LINENOISE)

endif (NOT ENABLE_LINENOISE)
endif (NOT ENABLE_LINENOISE AND NOT DISABLE_LINENOISE)

set(ENABLE_LINENOISE "${ENABLE_LINENOISE}" CACHE BOOL "Enable linenoise build")

# Decision made

if (ENABLE_LINENOISE)

git_submodule_init(linenoise linenoise.c)
Expand Down
14 changes: 7 additions & 7 deletions lmdb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Unless we have ENABLE_ALL set, base the building of lmdb on
# the system detection results
if (ENABLE_ALL AND NOT DEFINED ENABLE_LMDB)
set(ENABLE_LMDB ON)
endif (ENABLE_ALL AND NOT DEFINED ENABLE_LMDB)
# Decide if we're using lmdb
cad_enable(LMDB "libbu")

if (NOT ENABLE_LMDB)
if (NOT ENABLE_LMDB AND NOT DISABLE_LMDB)

find_package(LMDB)

if (NOT LMDB_FOUND AND NOT DEFINED ENABLE_LMDB)
set(ENABLE_LMDB "ON" CACHE BOOL "Enable lmdb build")
endif (NOT LMDB_FOUND AND NOT DEFINED ENABLE_LMDB)

endif (NOT ENABLE_LMDB)
endif (NOT ENABLE_LMDB AND NOT DISABLE_LMDB)

set(ENABLE_LMDB "${ENABLE_LMDB}" CACHE BOOL "Enable lmdb build")

# Decision made

if (ENABLE_LMDB)

git_submodule_init(lmdb libraries/liblmdb/mdb.c)
Expand Down
Loading

0 comments on commit 54bd914

Please sign in to comment.