Skip to content

Commit

Permalink
First working version
Browse files Browse the repository at this point in the history
  • Loading branch information
mwestphal committed Feb 14, 2024
1 parent f6b9e90 commit 77cd7c9
Show file tree
Hide file tree
Showing 95 changed files with 67 additions and 96 deletions.
20 changes: 18 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,22 @@ if(NOT F3D_SANITIZER STREQUAL "none")
set(f3d_sanitizer_link_options -fsanitize=${F3D_SANITIZER})
endif()

# Construct generic build and link options
set(f3d_compile_options_private "")
set(f3d_compile_options_public "")
set(f3d_link_options_public "")

## F3D_STRICT_BUILD
list(APPEND f3d_compile_options_private ${f3d_strict_build_compile_options})

## Coverage
list(APPEND f3d_compile_options_public ${f3d_coverage_compile_options})
list(APPEND f3d_link_options_public ${f3d_coverage_link_options})

## Sanitizer
list(APPEND f3d_compile_options_public ${f3d_sanitizer_compile_options})
list(APPEND f3d_link_options_public ${f3d_sanitizer_link_options})

# Testing
option(BUILD_TESTING "Build the tests" OFF)
cmake_dependent_option(F3D_TESTING_DISABLE_DEFAULT_LIGHTS_TESTS_COMPARISON "Disable image comparison on tests using the default lights" OFF "BUILD_TESTING" OFF)
Expand Down Expand Up @@ -189,8 +205,8 @@ endif()
# F3D Application
cmake_dependent_option(F3D_BUILD_APPLICATION "Build the application" ON "NOT ANDROID AND NOT EMSCRIPTEN" OFF)

# VTKShared module
add_subdirectory(VTKShared)
# Build VTK extension moddules
add_subdirectory(VTKExtensions)

# plugins
option(F3D_PLUGINS_STATIC_BUILD "Make all plugins static (embedded into libf3d) and automatically loaded by F3D" ON)
Expand Down
2 changes: 2 additions & 0 deletions VTKExtensions/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
add_subdirectory(public)
add_subdirectory(private)
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ vtk_module_build(
INSTALL_HEADERS OFF
HEADERS_COMPONENT vtkext
TARGETS_COMPONENT vtkext
PACKAGE "f3d-VTKExtensions")
PACKAGE "f3d-VTKExtensionsPrivate")

# We need non empty cmake vars for these calls for VTK <= 9.1
# See https://gitlab.kitware.com/vtk/vtk/-/merge_requests/9084
foreach (module IN LISTS modules)
if(NOT "${libf3d_compile_options_public}" STREQUAL "")
vtk_module_compile_options(${module} PUBLIC ${libf3d_compile_options_public})
if(NOT "${f3d_compile_options_public}" STREQUAL "")
vtk_module_compile_options(${module} PUBLIC ${f3d_compile_options_public})
endif()
if(NOT "${libf3d_compile_options_private}" STREQUAL "")
vtk_module_compile_options(${module} PRIVATE ${libf3d_compile_options_private})
if(NOT "${f3d_compile_options_private}" STREQUAL "")
vtk_module_compile_options(${module} PRIVATE ${f3d_compile_options_private})
endif()
if (NOT "${libf3d_link_options_public}" STREQUAL "")
vtk_module_link_options(${module} PUBLIC ${libf3d_link_options_public})
if (NOT "${f3d_link_options_public}" STREQUAL "")
vtk_module_link_options(${module} PUBLIC ${f3d_link_options_public})
endif()
vtk_module_set_property(${module} PROPERTY CXX_STANDARD VALUE 17)
if(F3D_STRICT_BUILD AND MSVC)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 12 additions & 9 deletions VTKShared/CMakeLists.txt → VTKExtensions/public/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
vtk_module_find_modules(vtk_module_files "${CMAKE_CURRENT_SOURCE_DIR}")

# Although we have a single module
# we need to follow the full VTK module logic here
vtk_module_scan(
MODULE_FILES ${vtk_module_files}
PROVIDES_MODULES modules
Expand All @@ -11,22 +13,23 @@ vtk_module_scan(
vtk_module_build(
MODULES ${modules}
INSTALL_EXPORT "f3dTargets"
INSTALL_HEADERS OFF
HEADERS_COMPONENT vtkext
INSTALL_HEADERS ON
HEADERS_COMPONENT plugin_sdk
HEADERS_EXCLUDE_FROM_ALL ON
TARGETS_COMPONENT vtkext
PACKAGE "f3d-VTKShared")
PACKAGE "f3d-VTKExtensions-public")

# We need non empty cmake vars for these calls for VTK <= 9.1
# See https://gitlab.kitware.com/vtk/vtk/-/merge_requests/9084
foreach (module IN LISTS modules)
if(NOT "${libf3d_compile_options_public}" STREQUAL "")
vtk_module_compile_options(${module} PUBLIC ${libf3d_compile_options_public})
if(NOT "${f3d_compile_options_public}" STREQUAL "")
vtk_module_compile_options(${module} PUBLIC ${f3d_compile_options_public})
endif()
if(NOT "${libf3d_compile_options_private}" STREQUAL "")
vtk_module_compile_options(${module} PRIVATE ${libf3d_compile_options_private})
if(NOT "${f3d_compile_options_private}" STREQUAL "")
vtk_module_compile_options(${module} PRIVATE ${f3d_compile_options_private})
endif()
if (NOT "${libf3d_link_options_public}" STREQUAL "")
vtk_module_link_options(${module} PUBLIC ${libf3d_link_options_public})
if (NOT "${f3d_link_options_public}" STREQUAL "")
vtk_module_link_options(${module} PUBLIC ${f3d_link_options_public})
endif()
vtk_module_set_property(${module} PROPERTY CXX_STANDARD VALUE 17)
if(F3D_STRICT_BUILD AND MSVC)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ set(classes
vtkF3DFaceVaryingPointDispatcher
)

vtk_module_add_module(f3d::VTKShared
vtk_module_add_module(f3d::VTKExtensionsPublic
CLASSES ${classes})
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
NAME
f3d::VTKShared
f3d::VTKExtensionsPublic
DESCRIPTION
A VTK module that is shared and usable by plugins
A VTK module that is shared and usable by both libf3d and plugins
DEPENDS
VTK::CommonExecutionModel
PRIVATE_DEPENDS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
#define vtkF3DFaceVaryingPointDispatcher_h

#include "vtkPolyDataAlgorithm.h"
#include "VTKSharedModule.h"
#include "VTKExtensionsPublicModule.h"

class VTKSHARED_EXPORT vtkF3DFaceVaryingPointDispatcher : public vtkPolyDataAlgorithm
class VTKEXTENSIONSPUBLIC_EXPORT vtkF3DFaceVaryingPointDispatcher : public vtkPolyDataAlgorithm
{
public:
static vtkF3DFaceVaryingPointDispatcher* New();
Expand Down
9 changes: 6 additions & 3 deletions cmake/f3dPlugin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,14 @@ macro(f3d_plugin_build)
EXPORT_FILE_NAME plugin_export.h
EXPORT_MACRO_NAME F3D_PLUGIN_EXPORT)

if(UNIX)
# Add rpath origin so the VTKExtensionsShared can be found
if (APPLE)
set_target_properties(f3d PROPERTIES INSTALL_RPATH @loader_path)
elseif (UNIX)
# On Unix, add the RPATH to VTK install folder
get_target_property(target_type VTK::CommonCore TYPE)
if (target_type STREQUAL SHARED_LIBRARY)
list(APPEND F3D_PLUGIN_ADDITIONAL_RPATHS "$<TARGET_FILE_DIR:VTK::CommonCore>")
list(APPEND F3D_PLUGIN_ADDITIONAL_RPATHS "$ORIGIN:$<TARGET_FILE_DIR:VTK::CommonCore>")
endif ()
set_target_properties(f3d-plugin-${F3D_PLUGIN_NAME} PROPERTIES
INSTALL_RPATH "${F3D_PLUGIN_ADDITIONAL_RPATHS}")
Expand Down Expand Up @@ -289,7 +292,7 @@ macro(f3d_plugin_build)
list(TRANSFORM F3D_PLUGIN_VTK_MODULES PREPEND "VTK::")

target_link_libraries(f3d-plugin-${F3D_PLUGIN_NAME} PRIVATE
VTK::CommonCore VTK::CommonExecutionModel VTK::IOImport f3d::VTKShared
VTK::CommonCore VTK::CommonExecutionModel VTK::IOImport f3d::VTKExtensionsPublic
${F3D_PLUGIN_VTK_MODULES}
${modules})

Expand Down
33 changes: 12 additions & 21 deletions library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set(F3D_VTK_MODULES
f3d::VTKExtensionsCore
f3d::VTKExtensionsReaders
f3d::VTKExtensionsRendering
f3d::VTKShared
f3d::VTKExtensionsPublic
)

# Check modules
Expand All @@ -31,23 +31,6 @@ if(F3D_MODULE_EXTERNAL_RENDERING)
endif()
endif()

set(libf3d_compile_options_private "")
set(libf3d_compile_options_public "")
set(libf3d_link_options_public "")

# F3D_STRICT_BUILD
list(APPEND libf3d_compile_options_private ${f3d_strict_build_compile_options})

# Coverage
list(APPEND libf3d_compile_options_public ${f3d_coverage_compile_options})
list(APPEND libf3d_link_options_public ${f3d_coverage_link_options})

# Sanitizer
list(APPEND libf3d_compile_options_public ${f3d_sanitizer_compile_options})
list(APPEND libf3d_link_options_public ${f3d_sanitizer_link_options})

add_subdirectory(VTKExtensions)

configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/src/config.cxx.in"
"${CMAKE_CURRENT_BINARY_DIR}/src/config.cxx"
Expand Down Expand Up @@ -174,8 +157,8 @@ configure_file(
list(TRANSFORM F3D_STATIC_PLUGIN_TARGETS PREPEND "f3d-plugin-")

target_link_libraries(libf3d PRIVATE ${F3D_VTK_MODULES} ${F3D_STATIC_PLUGIN_TARGETS})
target_compile_options(libf3d PUBLIC ${libf3d_compile_options_public} PRIVATE ${libf3d_compile_options_private})
target_link_options(libf3d PUBLIC ${libf3d_link_options_public})
target_compile_options(libf3d PUBLIC ${f3d_compile_options_public} PRIVATE ${f3d_compile_options_private})
target_link_options(libf3d PUBLIC ${f3d_link_options_public})

if(F3D_STRICT_BUILD AND MSVC)
# There are warnings in VTK related to deprecated features in C++17
Expand Down Expand Up @@ -252,13 +235,21 @@ if(BUILD_SHARED_LIBS)
"${CMAKE_BINARY_DIR}/cmake/f3dConfig.cmake"
"${CMAKE_BINARY_DIR}/cmake/f3dConfigVersion.cmake"
"${F3D_SOURCE_DIR}/cmake/f3dEmbed.cmake"
DESTINATION
"${CMAKE_INSTALL_LIBDIR}/cmake/f3d"
COMPONENT sdk
EXCLUDE_FROM_ALL)

install(
FILES
"${F3D_SOURCE_DIR}/cmake/f3dPlugin.cmake"
"${F3D_SOURCE_DIR}/cmake/plugin.cxx.in"
"${F3D_SOURCE_DIR}/cmake/plugin.desktop.in"
"${F3D_SOURCE_DIR}/cmake/plugin.thumbnailer.in"
"${F3D_SOURCE_DIR}/cmake/readerBoilerPlate.h.in"
DESTINATION
"${CMAKE_INSTALL_LIBDIR}/cmake/f3d"
COMPONENT sdk
COMPONENT plugin_sdk
EXCLUDE_FROM_ALL)

endif()
47 changes: 0 additions & 47 deletions library/VTKExtensions/Core/Testing/TestF3DLog.cxx

This file was deleted.

4 changes: 4 additions & 0 deletions library/src/engine.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ void engine::loadPlugin(const std::string& pathOrName, const std::vector<std::st
pluginOrigin = tryPath;
break;
}
else
{
log::debug("Could not load \"", tryPath, "\" because: ", vtksys::DynamicLoader::LastError());
}
}
}

Expand Down
1 change: 0 additions & 1 deletion plugins/native/module/vtk.module
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ DESCRIPTION
DEPENDS
VTK::CommonCore
VTK::CommonExecutionModel
f3d::VTKShared
TEST_DEPENDS
VTK::TestingCore
VTK::CommonDataModel
2 changes: 1 addition & 1 deletion plugins/usd/module/vtk.module
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ DEPENDS
VTK::FiltersSources
VTK::IOImport
VTK::IOImage
f3d::VTKShared
f3d::VTKExtensionsPublic
TEST_DEPENDS
VTK::TestingCore

0 comments on commit 77cd7c9

Please sign in to comment.