Skip to content

Commit

Permalink
verb instead of noun, rename TargetDeps to RegisterDeps.
Browse files Browse the repository at this point in the history
make it a smidge more clear what this macro is doing in the call sites.  document it also and detangle the side effect from its core purpose.
  • Loading branch information
brlcad committed Aug 6, 2024
1 parent 7bebe2a commit 21b72aa
Show file tree
Hide file tree
Showing 65 changed files with 93 additions and 72 deletions.
31 changes: 23 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -248,23 +248,29 @@ macro(TargetVars roots)
endforeach(root ${${roots}})
endmacro(TargetVars root)

macro(TargetDeps proot)

###
# Loads dependencies from an in-src file named same as containing
# directory with .deps suffix. Dependencies are added to the
# corresponding ${proot}_DEPENDS variable.
#
# FIXME: Dependencies are also added here to a .dot file dependency
# graph file, but that shouldn't be intertwined here as side effect.
###
macro(RegisterDeps proot)
get_filename_component(dirname ${CMAKE_CURRENT_SOURCE_DIR} NAME)
if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${dirname}.deps")
message(FATAL_ERROR "No ${dirname}.deps file found in ${CMAKE_CURRENT_SOURCE_DIR}/")
endif (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${dirname}.deps")
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/${dirname}.deps" DEP_LINES)
string(TOLOWER "${proot}" lr)

# Add each dependency to this directory's _DEPENDS list
foreach(dl ${DEP_LINES})
set(${proot}_DEPENDS ${${proot}_DEPENDS} ${dl})
string(TOLOWER "${dl}" ldl)
# Add the dependency to the dot file
if (NOT "${ldl}" STREQUAL "patch")
file(APPEND "${CMAKE_BINARY_DIR}/bext.dot" "\t${lr} -> ${ldl};\n")
endif (NOT "${ldl}" STREQUAL "patch")
endforeach(dl ${DEP_LINES})

# Add these dependencies to the global list
# Add all dependencies to the global ALL_DEPENDENCIES list
get_property(ALL_DEPS GLOBAL PROPERTY ALL_DEPENDENCIES)
set(ALL_DEPS ${ALL_DEPS} ${${proot}_DEPENDS})
list(SORT ALL_DEPS)
Expand All @@ -273,7 +279,16 @@ macro(TargetDeps proot)

# Set the TARGET variables for CMake generator expression "if" tests
TargetVars(${proot}_DEPENDS)
endmacro(TargetDeps)

# Add each dependency to a global .dot file
foreach(dl ${DEP_LINES})
string(TOLOWER "${dl}" ldl)
if (NOT "${ldl}" STREQUAL "patch")
file(APPEND "${CMAKE_BINARY_DIR}/bext.dot" "\t${lr} -> ${ldl};\n")
endif (NOT "${ldl}" STREQUAL "patch")
endforeach(dl ${DEP_LINES})

endmacro(RegisterDeps)

macro(TargetInstallDeps croot roots)
foreach(root ${${roots}})
Expand Down
2 changes: 1 addition & 1 deletion NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ if (ENABLE_GEOGRAM)
git_submodule_init(geogram CMakeLists.txt)
TargetDeps(GEOGRAM)
RegisterDeps(GEOGRAM)
ExternalProject_Add(GEOGRAM_BLD
URL "${CMAKE_CURRENT_SOURCE_DIR}/geogram"
Expand Down
2 changes: 1 addition & 1 deletion appleseed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if (ENABLE_APPLESEED)

git_submodule_init(appleseed CMakeLists.txt)

TargetDeps(APPLESEED)
RegisterDeps(APPLESEED)
if (TARGET ZLIB_BLD)
set(Z_PREFIX_STR "brl_")
endif (TARGET ZLIB_BLD)
Expand Down
2 changes: 1 addition & 1 deletion assetimport/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if (ENABLE_ASSETIMPORT)

git_submodule_init(assimp CMakeLists.txt)

TargetDeps(ASSETIMPORT)
RegisterDeps(ASSETIMPORT)
if (TARGET ZLIB_BLD)
set(ZLIB_TARGET ZLIB_BLD)
endif (TARGET ZLIB_BLD)
Expand Down
2 changes: 1 addition & 1 deletion astyle/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if (ENABLE_ASTYLE)

git_submodule_init(astyle CMakeLists.txt)

TargetDeps(ASTYLE)
RegisterDeps(ASTYLE)

ExternalProject_Add(ASTYLE_BLD
URL "${CMAKE_CURRENT_SOURCE_DIR}/astyle"
Expand Down
2 changes: 1 addition & 1 deletion boost/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if (ENABLE_BOOST)

git_submodule_init(boost CMakeLists.txt)

TargetDeps(BOOST)
RegisterDeps(BOOST)

if (TARGET ZLIB_BLD)
set(Z_PREFIX_STR "brl_")
Expand Down
2 changes: 1 addition & 1 deletion deflate/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if (ENABLE_DEFLATE)

git_submodule_init(libdeflate CMakeLists.txt)

TargetDeps(DEFLATE)
RegisterDeps(DEFLATE)

ExternalProject_Add(DEFLATE_BLD
URL "${CMAKE_CURRENT_SOURCE_DIR}/libdeflate"
Expand Down
2 changes: 1 addition & 1 deletion eigen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if (ENABLE_EIGEN)

git_submodule_init(eigen CMakeLists.txt)

TargetDeps(EIGEN)
RegisterDeps(EIGEN)

ExternalProject_Add(EIGEN_BLD
URL "${CMAKE_CURRENT_SOURCE_DIR}/eigen"
Expand Down
2 changes: 1 addition & 1 deletion embree/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if (ENABLE_EMBREE)

git_submodule_init(embree CMakeLists.txt)

TargetDeps(EMBREE)
RegisterDeps(EMBREE)
if (TARGET ZLIB_BLD)
set(Z_PREFIX_STR "brl_")
endif (TARGET ZLIB_BLD)
Expand Down
2 changes: 1 addition & 1 deletion expat/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if (ENABLE_EXPAT)

git_submodule_init(libexpat CMakeLists.txt)

TargetDeps(EXPAT)
RegisterDeps(EXPAT)

ExternalProject_Add(EXPAT_BLD
URL "${CMAKE_CURRENT_SOURCE_DIR}/libexpat"
Expand Down
2 changes: 1 addition & 1 deletion fmt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if (ENABLE_FMT)

git_submodule_init(fmt CMakeLists.txt)

TargetDeps(FMT)
RegisterDeps(FMT)

ExternalProject_Add(FMT_BLD
URL "${CMAKE_CURRENT_SOURCE_DIR}/fmt"
Expand Down
2 changes: 1 addition & 1 deletion gdal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if (ENABLE_GDAL)

git_submodule_init(gdal CMakeLists.txt)

TargetDeps(GDAL)
RegisterDeps(GDAL)
if (TARGET ZLIB_BLD)
set(Z_PREFIX_STR "brl_")
endif (TARGET ZLIB_BLD)
Expand Down
2 changes: 1 addition & 1 deletion geogram/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if (ENABLE_GEOGRAM)

git_submodule_init(geogram CMakeLists.txt)

TargetDeps(GEOGRAM)
RegisterDeps(GEOGRAM)

ExternalProject_Add(GEOGRAM_BLD
URL "${CMAKE_CURRENT_SOURCE_DIR}/geogram"
Expand Down
2 changes: 1 addition & 1 deletion gte/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if (ENABLE_GTE)

git_submodule_init(GeometricTools GTE/CMakeLists.txt)

TargetDeps(GTE)
RegisterDeps(GTE)

ExternalProject_Add(GTE_BLD
URL "${CMAKE_CURRENT_SOURCE_DIR}/GeometricTools"
Expand Down
2 changes: 1 addition & 1 deletion icu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if (NOT WIN32 AND NOT APPLE)

git_submodule_init(icu icu4c/source/configure)

TargetDeps(ICU)
RegisterDeps(ICU)

ExternalProject_Add(ICU_BLD
URL "${CMAKE_CURRENT_SOURCE_DIR}/icu"
Expand Down
2 changes: 1 addition & 1 deletion ispc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if (ENABLE_ISPC)

git_submodule_init(ispc CMakeLists.txt)

TargetDeps(ISPC)
RegisterDeps(ISPC)
if (TARGET ZLIB_BLD)
set(Z_PREFIX_STR "brl_")
endif (TARGET ZLIB_BLD)
Expand Down
8 changes: 7 additions & 1 deletion itcl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if (ENABLE_ITCL)

git_submodule_init(itcl configure.in)

TargetDeps(ITCL)
RegisterDeps(ITCL)

# Itcl3 has a problem in that it requires internal Tcl headers.
# Occasionally (but not always) we can get these headers from
Expand All @@ -41,6 +41,8 @@ if (ENABLE_ITCL)
endif(NOT WIN32)
endif (EXISTS ${HDRS_CANDIDATE_DIR})

# message("TCL HEADERS1: ${TCL_PRIVATE_HDRS}")

# If we can't find them from the system, see if we have a local
# clone of Tcl to use
if (NOT TCL_PRIVATE_HDRS AND EXISTS ${CMAKE_SOURCE_DIR}/tcl/tcl)
Expand All @@ -52,6 +54,8 @@ if (ENABLE_ITCL)
endif(NOT WIN32)
endif (NOT TCL_PRIVATE_HDRS AND EXISTS ${CMAKE_SOURCE_DIR}/tcl/tcl)

# message("TCL HEADERS2: ${TCL_PRIVATE_HDRS}")

# If we STILL don't have anything, patch the Itcl sources to add
# the headers in question
set(TCL_HDRS_PATCH_CMD)
Expand All @@ -65,6 +69,8 @@ if (ENABLE_ITCL)
endif(NOT WIN32)
endif (NOT TCL_PRIVATE_HDRS)

# message("TCL HEADERS3: ${TCL_PRIVATE_HDRS}")

# When building ITCL, its path setup must take into account the subdirectory
# in which we are storing the library.
set(RPATH_SUFFIX itcl3.4)
Expand Down
2 changes: 1 addition & 1 deletion itk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ if (ENABLE_ITK)

git_submodule_init(itk configure.in)

TargetDeps(ITK)
RegisterDeps(ITK)

# If we're building ITK, it's path setup must take into account the
# subdirectory in which we are storing the library.
Expand Down
2 changes: 1 addition & 1 deletion iwidgets/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if (ENABLE_IWIDGETS)

git_submodule_init(iwidgets CMakeLists.txt)

TargetDeps(IWIDGETS)
RegisterDeps(IWIDGETS)

ExternalProject_Add(IWIDGETS_BLD
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/iwidgets"
Expand Down
2 changes: 1 addition & 1 deletion jpeg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if (ENABLE_JPEG)

git_submodule_init(libjpeg-turbo CMakeLists.txt)

TargetDeps(JPEG)
RegisterDeps(JPEG)

ExternalProject_Add(JPEG_BLD
URL "${CMAKE_CURRENT_SOURCE_DIR}/libjpeg-turbo"
Expand Down
2 changes: 1 addition & 1 deletion lemon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if (ENABLE_LEMON)

git_submodule_init(lemon lemon.c)

TargetDeps(LEMON)
RegisterDeps(LEMON)

ExternalProject_Add(LEMON_BLD
URL "${CMAKE_CURRENT_SOURCE_DIR}/lemon"
Expand Down
2 changes: 1 addition & 1 deletion lief/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if (NOT MSVC AND NOT APPLE)

git_submodule_init(LIEF CMakeLists.txt)

TargetDeps(LIEF)
RegisterDeps(LIEF)

ExternalProject_Add(LIEF_BLD
URL "${CMAKE_CURRENT_SOURCE_DIR}/LIEF"
Expand Down
2 changes: 1 addition & 1 deletion linenoise/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if (ENABLE_LINENOISE)

git_submodule_init(linenoise linenoise.c)

TargetDeps(LINENOISE)
RegisterDeps(LINENOISE)

ExternalProject_Add(LINENOISE_BLD
URL "${CMAKE_CURRENT_SOURCE_DIR}/linenoise"
Expand Down
2 changes: 1 addition & 1 deletion llvm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if (ENABLE_LLVM)

git_submodule_init(llvm-project llvm/CMakeLists.txt)

TargetDeps(LLVM)
RegisterDeps(LLVM)

# We may need one or more patches, depending on settings. ExternalProject_Add
# expects the first command to be "PATCH_COMMAND", with subsequent patch commands
Expand Down
2 changes: 1 addition & 1 deletion lmdb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if (ENABLE_LMDB)

git_submodule_init(lmdb libraries/liblmdb/mdb.c)

TargetDeps(LMDB)
RegisterDeps(LMDB)

ExternalProject_Add(LMDB_BLD
URL "${CMAKE_CURRENT_SOURCE_DIR}/lmdb"
Expand Down
2 changes: 1 addition & 1 deletion lz4/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if (ENABLE_LZ4)

git_submodule_init(lz4 CMakeLists.txt)

TargetDeps(LZ4)
RegisterDeps(LZ4)

ExternalProject_Add(LZ4_BLD
URL "${CMAKE_CURRENT_SOURCE_DIR}/lz4"
Expand Down
2 changes: 1 addition & 1 deletion manifold/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if (ENABLE_MANIFOLD)

git_submodule_init(manifold src/manifold/include/manifold.h)

TargetDeps(MANIFOLD)
RegisterDeps(MANIFOLD)

ExternalProject_Add(MANIFOLD_BLD
URL "${CMAKE_CURRENT_SOURCE_DIR}/manifold"
Expand Down
2 changes: 1 addition & 1 deletion minizip-ng/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if (ENABLE_MINIZIP_NG)

git_submodule_init(minizip-ng CMakeLists.txt)

TargetDeps(MINIZIP_NG)
RegisterDeps(MINIZIP_NG)
if (TARGET ZLIB_BLD)
set(Z_PREFIX_STR "brl_")
endif (TARGET ZLIB_BLD)
Expand Down
2 changes: 1 addition & 1 deletion ncurses/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if (NOT WIN32)

git_submodule_init(ncurses README)

TargetDeps(NCURSES)
RegisterDeps(NCURSES)

set(NCURSES_SRC_DIR "${CMAKE_CURRENT_BINARY_DIR}/NCURSES_BLD-prefix/src/NCURSES_BLD")

Expand Down
2 changes: 1 addition & 1 deletion netpbm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if (ENABLE_NETPBM)

git_submodule_init(netpbm CMakeLists.txt)

TargetDeps(NETPBM)
RegisterDeps(NETPBM)

ExternalProject_Add(NETPBM_BLD
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/netpbm"
Expand Down
2 changes: 1 addition & 1 deletion onetbb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (ENABLE_ONETBB)

git_submodule_init(oneTBB CMakeLists.txt)

TargetDeps(ONETBB)
RegisterDeps(ONETBB)

ExternalProject_Add(ONETBB_BLD
URL "${CMAKE_CURRENT_SOURCE_DIR}/oneTBB"
Expand Down
2 changes: 1 addition & 1 deletion opencolorio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if (ENABLE_OPENCOLORIO)

git_submodule_init(OpenColorIO CMakeLists.txt)

TargetDeps(OPENCOLORIO)
RegisterDeps(OPENCOLORIO)
if (TARGET ZLIB_BLD)
set(Z_PREFIX_STR "brl_")
endif (TARGET ZLIB_BLD)
Expand Down
2 changes: 1 addition & 1 deletion opencv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if (ENABLE_OPENCV)

git_submodule_init(opencv CMakeLists.txt)

TargetDeps(OPENCV)
RegisterDeps(OPENCV)
if (TARGET ZLIB_BLD)
set(Z_PREFIX_STR "brl_")
endif (TARGET ZLIB_BLD)
Expand Down
2 changes: 1 addition & 1 deletion openexr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if (ENABLE_OPENEXR)

git_submodule_init(openexr CMakeLists.txt)

TargetDeps(OPENEXR)
RegisterDeps(OPENEXR)

ExternalProject_Add(OPENEXR_BLD
URL "${CMAKE_CURRENT_SOURCE_DIR}/openexr"
Expand Down
2 changes: 1 addition & 1 deletion openimageio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if (ENABLE_OPENIMAGEIO)

git_submodule_init(oiio CMakeLists.txt)

TargetDeps(OPENIMAGEIO)
RegisterDeps(OPENIMAGEIO)
if (TARGET ZLIB_BLD)
set(Z_PREFIX_STR "brl_")
endif (TARGET ZLIB_BLD)
Expand Down
2 changes: 1 addition & 1 deletion openmesh/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if (ENABLE_OPENMESH)

git_submodule_init(OpenMesh CMakeLists.txt)

TargetDeps(OPENMESH)
RegisterDeps(OPENMESH)

ExternalProject_Add(OPENMESH_BLD
URL "${CMAKE_CURRENT_SOURCE_DIR}/OpenMesh"
Expand Down
Loading

0 comments on commit 21b72aa

Please sign in to comment.