Skip to content

Commit

Permalink
Make a stab at replacing FindASSETIMPORT and using the built-in expor…
Browse files Browse the repository at this point in the history
…t targets instead.
  • Loading branch information
starseeker committed Oct 4, 2024
1 parent 0b3f853 commit 9871128
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 128 deletions.
38 changes: 34 additions & 4 deletions misc/CMake/BRLCAD_Find_Package.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,41 @@ macro(BRLCAD_Find_Package pkg_name)
get_property(cv_new DIRECTORY PROPERTY CACHE_VARIABLES)

# Using the list of variables that were already set before the find_package
# call, trim the new list down to just the newly set variables.
# call, trim the new list down to just the newly set variables. This is
# one possible source of paths, but we also need this to clear the cache
# versions of the results. We want find_package to re-run on each configure
# as a clean test of the current state of the system, and to do that we only
# allow the values from a find_package to persist in the current working
# CMake state. To prevent their being cached (the default CMake behavior)
# we need to manually intervene and clear them.
list(REMOVE_ITEM cv_new ${cv_ctrl})

# If find_package is using an imported target, get the location from
# the target.
set(brlcad_find_package_tloc)
if (TARGET ${pkg_name}::${pkg_name})
# TODO - we may need to check CONFIG versions of this property as well.
get_target_property(brlcad_find_package_tloc ${pkg_name}::${pkg_name} LOCATION)
list(APPEND cv_new brlcad_find_package_tloc)
endif (TARGET ${pkg_name}::${pkg_name})

if (BRLCAD_FIND_DEBUG_MODE)
message("new cache items: ${cv_new}")
endif (BRLCAD_FIND_DEBUG_MODE)

set(is_bundled FALSE)
foreach(nc ${cv_new})
if (BRLCAD_FIND_DEBUG_MODE)
message("Checking ${nc}: ${${nc}}")
endif (BRLCAD_FIND_DEBUG_MODE)

# We don't know what vars were set, but check each one that was set
# for a local path. If we find one, we have a bundled package
is_subpath("${CMAKE_BINARY_DIR}" "${${nc}}" LOCAL_TEST)
if(LOCAL_TEST)
if (BRLCAD_FIND_DEBUG_MODE)
message(" - Local path found")
endif (BRLCAD_FIND_DEBUG_MODE)
set(is_bundled TRUE)
endif(LOCAL_TEST)

Expand Down Expand Up @@ -125,12 +152,15 @@ macro(BRLCAD_Find_Package pkg_name)
if(is_bundled)
set(${pkg_upper}_STATUS "Bundled" CACHE STRING "${pkg_name} bundled status")
else(is_bundled)
if(${pkg_name}_FOUND)
if(${pkg_name}_FOUND OR ${pkg_upper}_FOUND)
set(${pkg_upper}_STATUS "System" CACHE STRING "${pkg_name} bundled status")
else(${pkg_name}_FOUND)
else()
set(${pkg_upper}_STATUS "NotFound" CACHE STRING "${pkg_name} bundled status")
endif(${pkg_name}_FOUND)
endif()
endif(is_bundled)
if (BRLCAD_FIND_DEBUG_MODE)
message("${pkg_upper}_STATUS: ${${pkg_upper}_STATUS}")
endif (BRLCAD_FIND_DEBUG_MODE)
endmacro()

# Local Variables:
Expand Down
2 changes: 1 addition & 1 deletion misc/CMake/BRLCAD_Summary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ function(BRLCAD_Summary)
endif(ER_REQUIRED_VARS)
endfunction(EXT_REPORT blabel bvar)

ext_report("Asset Import Library" ASSETIMPORT_STATUS REQUIRED_VARS "BRLCAD_ENABLE_ASSETIMPORT")
ext_report("Asset Import Library" ASSIMP_STATUS REQUIRED_VARS "BRLCAD_ENABLE_ASSETIMPORT")
ext_report("Eigen" EIGEN3_INCLUDE_DIR)
ext_report("Geogram" GEOGRAM_STATUS)
ext_report("Geospatial Data Abstraction Library" GDAL_STATUS REQUIRED_VARS "BRLCAD_ENABLE_GDAL")
Expand Down
1 change: 0 additions & 1 deletion misc/CMake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ set(
FindADAPTAGRAMS.cmake
FindASTYLE.cmake
FindAppleseed.cmake
FindASSETIMPORT.cmake
FindBlosc.cmake
FindBSON.cmake
FindFontconfig.cmake
Expand Down
92 changes: 0 additions & 92 deletions misc/CMake/FindASSETIMPORT.cmake

This file was deleted.

37 changes: 19 additions & 18 deletions src/libgcv/plugins/assetimport/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
set(ASSETIMPORT_SRCS assetimport_read.cpp assetimport_write.cpp)

brlcad_find_package(ASSETIMPORT)
brlcad_find_package(assimp)

if(BRLCAD_ENABLE_ASSETIMPORT AND ASSETIMPORT_LIBRARY AND ASSETIMPORT_INCLUDE_DIR)
message("assetimport plugin FOUND and ENABLED")
include_directories(SYSTEM ${ASSETIMPORT_INCLUDE_DIR})

gcv_plugin_library(gcv-assetimport SHARED ${ASSETIMPORT_SRCS})
target_link_libraries(
gcv-assetimport
libgcv
libwdb
librt
libbu
${ASSETIMPORT_LIBRARY}
)
set_property(TARGET gcv-assetimport APPEND PROPERTY COMPILE_DEFINITIONS BRLCADBUILD HAVE_CONFIG_H)
validate_style(gcv-assetimport "${ASSETIMPORT_SRCS}")
plugin_setup(gcv-assetimport gcv)
endif(BRLCAD_ENABLE_ASSETIMPORT AND ASSETIMPORT_LIBRARY AND ASSETIMPORT_INCLUDE_DIR)
if(BRLCAD_ENABLE_ASSETIMPORT)
if(TARGET assimp::assimp)
gcv_plugin_library(gcv-assetimport SHARED ${ASSETIMPORT_SRCS})
target_link_libraries(
gcv-assetimport
libgcv
libwdb
librt
libbu
assimp::assimp
)
set_property(TARGET gcv-assetimport APPEND PROPERTY COMPILE_DEFINITIONS BRLCADBUILD HAVE_CONFIG_H)
validate_style(gcv-assetimport "${ASSETIMPORT_SRCS}")
plugin_setup(gcv-assetimport gcv)
else()
message("Warning - Asset Import support enabled, but Asset Import Library not found - disabling GCV plugin\n")
endif()
endif(BRLCAD_ENABLE_ASSETIMPORT)

cmakefiles(
${ASSETIMPORT_SRCS}
Expand Down
8 changes: 5 additions & 3 deletions src/libged/facetize/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
brlcad_find_package(MANIFOLD REQUIRED)
brlcad_find_package(ASSETIMPORT)
message("starting")
brlcad_find_package(assimp)
message("done")

set(FACETIZE_LOCAL_INCLUDE_DIRS)

if(MANIFOLD_LIBRARIES)
list(APPEND FACETIZE_LOCAL_INCLUDE_DIRS ${MANIFOLD_INCLUDE_DIRS})
add_definitions(-DUSE_MANIFOLD)

if(ASSETIMPORT_LIBRARY)
list(APPEND FACETIZE_LOCAL_INCLUDE_DIRS ${ASSETIMPORT_INCLUDE_DIR})
if(TARGET assimp::assimp)
set(ASSETIMPORT_LIBRARIES assimp::assimp)
add_definitions(-DUSE_ASSETIMPORT)
endif(ASSETIMPORT_LIBRARY)
endif(MANIFOLD_LIBRARIES)
Expand Down
7 changes: 4 additions & 3 deletions src/libged/facetize/subprocess/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ set(

brlcad_find_package(MANIFOLD REQUIRED)

brlcad_find_package(ASSETIMPORT)
if(ASSETIMPORT_LIBRARIES)
brlcad_find_package(assimp)
if(TARGET assimp::assimp)
add_definitions(-DUSE_ASSETIMPORT)
set(ASSETIMPORT_LIBRARIES assimp::assimp)
endif(ASSETIMPORT_LIBRARIES)

brlcad_find_package(GEOGRAM REQUIRED SYSPATTERN geogram)
add_definitions(-DUSE_GEOGRAM)

set(INCLUDE_DIRS ${GEOGRAM_INCLUDE_DIR} ${MANIFOLD_INCLUDE_DIRS} ${ASSETIMPORT_INCLUDE_DIR})
set(INCLUDE_DIRS ${GEOGRAM_INCLUDE_DIR} ${MANIFOLD_INCLUDE_DIRS})

ged_subprocess_library(facetize_process SHARED ${GED_TESS_SRCS})
target_include_directories(facetize_process SYSTEM PRIVATE ${INCLUDE_DIRS})
Expand Down
14 changes: 8 additions & 6 deletions src/librt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ brlcad_find_package(MANIFOLD REQUIRED)
brlcad_find_package(OPENNURBS REQUIRED SYSPATTERN openNURBS)
brlcad_find_package(REGEX REQUIRED)
if(BRLCAD_ENABLE_ASSETIMPORT)
brlcad_find_package(ASSETIMPORT)
# TODO - see if we can use tinygltf to write out the glb file ourselves -
# Manifold's assimp integration is convenient for producing glb files, which
# are needed if we're going to submit problem cases upstream, but using it
# introduces an additional large dependency just for a debugging output...
brlcad_find_package(assimp)
endif(BRLCAD_ENABLE_ASSETIMPORT)
brlcad_find_package(GEOGRAM REQUIRED SYSPATTERN geogram)
add_definitions(-DUSE_GEOGRAM)

if(ASSETIMPORT_LIBRARIES)
if(TARGET assimp::assimp)
add_definitions(-DUSE_ASSETIMPORT)
endif(ASSETIMPORT_LIBRARIES)
set(ASSETIMPORT_LIBRARIES assimp::assimp)
endif(TARGET assimp::assimp)

if(NOT BRLCAD_ENABLE_GCT)
brlcad_find_package(MMESH REQUIRED)
Expand Down Expand Up @@ -388,9 +393,6 @@ set(
${GEOGRAM_INCLUDE_DIR}
${MANIFOLD_INCLUDE_DIRS}
${MMESH_INCLUDE_DIR}
${ASSETIMPORT_INCLUDE_DIR}
${MANIFOLD_INCLUDE_DIRS}
${ASSETIMPORT_INCLUDE_DIR}
)
# FIXME: needs materialX
# ${CMAKE_CURRENT_SOURCE_DIR}/../../../MaterialXSource/source
Expand Down

0 comments on commit 9871128

Please sign in to comment.