Skip to content

Commit

Permalink
Improve plugin SDK (#543)
Browse files Browse the repository at this point in the history
  • Loading branch information
Meakk committed Jan 10, 2023
1 parent aeb51ea commit 579c614
Show file tree
Hide file tree
Showing 21 changed files with 54 additions and 46 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ jobs:
-DF3D_INSTALL_DEFAULT_CONFIGURATION_FILE=ON
${{ matrix.os == 'windows-latest' && '-Ax64 -DF3D_WINDOWS_GUI=ON -DF3D_INSTALL_LOGOS_FOR_NSIS_PACKAGING=ON -DOpenCASCADE_DIR:PATH=$(pwd)/../dependencies/occt_install/cmake/ -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded' || null }}
${{ matrix.os == 'macos-latest' && '-DF3D_BINDINGS_PYTHON=ON -DF3D_MACOS_BUNDLE=ON -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DOpenCASCADE_DIR:PATH=$(pwd)/../dependencies/occt_install/lib/cmake/opencascade' || null }}
${{ matrix.os == 'ubuntu-latest' && '-DF3D_BINDINGS_PYTHON=ON -DOpenCASCADE_DIR:PATH=$(pwd)/../dependencies/occt_install/lib/cmake/opencascade -DF3D_INSTALL_DEFAULT_CONFIGURATION_FILE_IN_PREFIX=ON -DF3D_GENERATE_MAN=ON -DF3D_INSTALL_MIME_TYPES_FILES=ON -DF3D_INSTALL_THUMBNAILER_FILES=ON -DF3D_TESTING_ENABLE_LONG_TIMEOUT_TESTS=ON' || null }}
${{ matrix.os == 'ubuntu-latest' && '-DF3D_BINDINGS_PYTHON=ON -DOpenCASCADE_DIR:PATH=$(pwd)/../dependencies/occt_install/lib/cmake/opencascade -DF3D_INSTALL_DEFAULT_CONFIGURATION_FILE_IN_PREFIX=ON -DF3D_GENERATE_MAN=ON -DF3D_INSTALL_THUMBNAILER_FILES=ON -DF3D_TESTING_ENABLE_LONG_TIMEOUT_TESTS=ON' || null }}
${{ matrix.vtk_version == 'commit' && '-DF3D_TESTING_ENABLE_HDRI_TESTS=ON' || '-DF3D_TESTING_ENABLE_HDRI_TESTS=OFF' }}
${{ matrix.vtk_version == 'v9.0.0' && '-DF3D_TESTING_DISABLE_DEFAULT_LIGHTS_TESTS_COMPARISON=ON' || '-DF3D_TESTING_DISABLE_DEFAULT_LIGHTS_TESTS_COMPARISON=OFF' }}
Expand Down Expand Up @@ -150,10 +150,15 @@ jobs:
path: ./build/Testing/Temporary
name: f3d-tests-artifact-${{matrix.os}}-${{matrix.vtk_version}}

- name: Install
- name: Install (ALL)
working-directory: ${{github.workspace}}/build
run: cmake --install .

- name: Install (mimetypes on Linux)
if: matrix.os == 'ubuntu-latest'
working-directory: ${{github.workspace}}/build
run: cmake --install . --component mimetypes

- name: Check Install ubuntu
if: matrix.os == 'ubuntu-latest'
working-directory: ${{github.workspace}}/install
Expand Down
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,6 @@ endif()
if(UNIX AND NOT APPLE)
option(F3D_INSTALL_THUMBNAILER_FILES "Install thumbnailer files" OFF)
mark_as_advanced(F3D_INSTALL_THUMBNAILER_FILES)

option(F3D_INSTALL_MIME_TYPES_FILES "Install mime types files" OFF)
mark_as_advanced(F3D_INSTALL_MIME_TYPES_FILES)
endif()

include(cmake/installing.cmake)
Expand Down
16 changes: 13 additions & 3 deletions cmake/f3dPlugin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ f3d_plugin_build(
[VERSION <string>]
[VTK_MODULES <string>...]
[ADDITIONAL_RPATHS <path>...]
[MIMETYPE_XML_FILES <path>...]
[FORCE_STATIC])
~~~

Expand All @@ -123,11 +124,12 @@ The `NAME` argument is required. The arguments are as follows:
* `VERSION`: The version of the plugin.
* `VTK_MODULES`: The list of VTK modules used by the plugin to link with.
* `ADDITIONAL_RPATHS`: The list of additional RPATH for the installed binaries on Unix. VTK path is added automatically.
* `MIMETYPE_XML_FILES`: The list of mimetype files to install. It's useful for file association on OS using Freedesktop specifications.
* `FORCE_STATIC`: If specified, the plugin is built as a static library and embedded into libf3d.
#]==]

macro(f3d_plugin_build)
cmake_parse_arguments(F3D_PLUGIN "FORCE_STATIC" "NAME;DESCRIPTION;VERSION" "VTK_MODULES;ADDITIONAL_RPATHS" ${ARGN})
cmake_parse_arguments(F3D_PLUGIN "FORCE_STATIC" "NAME;DESCRIPTION;VERSION" "VTK_MODULES;ADDITIONAL_RPATHS;MIMETYPE_XML_FILES" ${ARGN})

find_package(VTK 9.0 REQUIRED COMPONENTS ${F3D_PLUGIN_VTK_MODULES})

Expand Down Expand Up @@ -228,7 +230,7 @@ macro(f3d_plugin_build)
set(_f3d_include_path "${f3d_INCLUDE_DIR}/f3d")
else()
# In-source plugin path
set(_f3d_include_path "${CMAKE_SOURCE_DIR}/library/public")
set(_f3d_include_path "${CMAKE_SOURCE_DIR}/library/plugin")
endif()

target_include_directories(f3d-plugin-${F3D_PLUGIN_NAME}
Expand All @@ -245,11 +247,19 @@ macro(f3d_plugin_build)
${F3D_PLUGIN_VTK_MODULES}
${modules})

if (NOT F3D_PLUGIN_IS_STATIC OR NOT BUILD_SHARED_LIBS)
if(NOT F3D_PLUGIN_IS_STATIC OR NOT BUILD_SHARED_LIBS)
install(TARGETS f3d-plugin-${F3D_PLUGIN_NAME}
EXPORT ${export_name}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT plugin
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT plugin
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT plugin)
endif()

foreach(mimetype_xml ${F3D_PLUGIN_MIMETYPE_XML_FILES})
install(FILES "${mimetype_xml}"
DESTINATION "share/mime/packages"
COMPONENT mimetypes
EXCLUDE_FROM_ALL)
endforeach()

endmacro()
36 changes: 0 additions & 36 deletions cmake/installing.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -115,42 +115,6 @@ if(UNIX AND NOT APPLE AND NOT ANDROID)
install(FILES "${CMAKE_BINARY_DIR}/resources/f3d.thumbnailer"
DESTINATION "share/thumbnailers/" COMPONENT shellext)
endif()
if (F3D_INSTALL_MIME_TYPES_FILES)
install(FILES "${CMAKE_SOURCE_DIR}/resources/mime-types-3d-formats.xml"
DESTINATION "share/mime/packages" COMPONENT mimetypes
RENAME "f3d-3d-formats.xml")
install(FILES "${CMAKE_SOURCE_DIR}/resources/mime-types-3d-image-formats.xml"
DESTINATION "share/mime/packages" COMPONENT mimetypes
RENAME "f3d-3d-image-formats.xml")
install(FILES "${CMAKE_SOURCE_DIR}/resources/mime-types-vtk-formats.xml"
DESTINATION "share/mime/packages" COMPONENT mimetypes
RENAME "f3d-vtk-formats.xml")
if (F3D_PLUGIN_BUILD_ALEMBIC)
install(FILES "${CMAKE_SOURCE_DIR}/resources/mime-types-alembic-formats.xml"
DESTINATION "share/mime/packages" COMPONENT mimetypes
RENAME "f3d-alembic-formats.xml")
endif()
if (F3D_PLUGIN_BUILD_ASSIMP)
install(FILES "${CMAKE_SOURCE_DIR}/resources/mime-types-assimp-formats.xml"
DESTINATION "share/mime/packages" COMPONENT mimetypes
RENAME "f3d-assimp-formats.xml")
endif()
if (F3D_PLUGIN_BUILD_DRACO)
install(FILES "${CMAKE_SOURCE_DIR}/resources/mime-types-draco-formats.xml"
DESTINATION "share/mime/packages" COMPONENT mimetypes
RENAME "f3d-draco-formats.xml")
endif()
if (F3D_PLUGIN_BUILD_EXODUS)
install(FILES "${CMAKE_SOURCE_DIR}/resources/mime-types-exodus-formats.xml"
DESTINATION "share/mime/packages" COMPONENT mimetypes
RENAME "f3d-3d-exodus-formats.xml")
endif()
if (F3D_PLUGIN_BUILD_OCCT)
install(FILES "${CMAKE_SOURCE_DIR}/resources/mime-types-occt-formats.xml"
DESTINATION "share/mime/packages" COMPONENT mimetypes
RENAME "f3d-occt-formats.xml")
endif()
endif()
elseif(WIN32)
if (F3D_INSTALL_LOGOS_FOR_NSIS_PACKAGING)
install(FILES "${CMAKE_SOURCE_DIR}/resources/logo.ico"
Expand Down
18 changes: 18 additions & 0 deletions doc/dev/BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,21 @@ Some modules, plugins and bindings depending on external libraries can be option
* `F3D_PLUGIN_BUILD_DRACO`: Support for DRC file format. Requires `Draco`. Disabled by default.
* `F3D_BINDINGS_PYTHON`: Generate python bindings (requires `Python` and `pybind11`). Disabled by default.
* `F3D_BINDINGS_JAVA`: Generate java bindings (requires `Java` and `JNI`). Disabled by default.

## Installing

Installation can be done through CMake, by running the following command:

```
cmake --install ${your_build_dir}
```

Optional components can be installed by specifying the component name:

```
cmake --install ${your_build_dir} --component ${component_name}
```

Here is the list of the optional components you can install:

* `mimetypes`: Install plugins mimetype XML files for integration with Freedesktop (Linux only)
10 changes: 8 additions & 2 deletions library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,16 @@ set(F3D_PUBLIC_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/public/loader.h
${CMAKE_CURRENT_SOURCE_DIR}/public/log.h
${CMAKE_CURRENT_SOURCE_DIR}/public/options.h
${CMAKE_CURRENT_SOURCE_DIR}/public/reader.h
${CMAKE_CURRENT_SOURCE_DIR}/public/plugin.h
${CMAKE_CURRENT_SOURCE_DIR}/public/types.h
${CMAKE_CURRENT_SOURCE_DIR}/public/window.h
)

if (F3D_INSTALL_SDK_PLUGIN)
list(APPEND F3D_PUBLIC_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/plugin/reader.h
${CMAKE_CURRENT_SOURCE_DIR}/plugin/plugin.h)
endif ()

add_library(libf3d
${F3D_SOURCE_FILES}
)
Expand All @@ -98,6 +102,8 @@ target_include_directories(libf3d
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/private>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/private>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/plugin>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/plugin>
)

set_target_properties(libf3d PROPERTIES
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions plugins/alembic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ f3d_plugin_build(
DESCRIPTION "Alembic support (version ${Alembic_VERSION})"
VTK_MODULES CommonCore CommonExecutionModel IOImport
ADDITIONAL_RPATHS ${rpaths}
MIMETYPE_XML_FILES "${CMAKE_CURRENT_SOURCE_DIR}/f3d-alembic-formats.xml"
)
File renamed without changes.
1 change: 1 addition & 0 deletions plugins/assimp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ f3d_plugin_build(
DESCRIPTION "Assimp support (version ${assimp_VERSION})"
VTK_MODULES CommonCore CommonExecutionModel IOImport
ADDITIONAL_RPATHS ${rpaths}
MIMETYPE_XML_FILES "${CMAKE_CURRENT_SOURCE_DIR}/f3d-assimp-formats.xml"
)
File renamed without changes.
1 change: 1 addition & 0 deletions plugins/draco/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ f3d_plugin_build(
DESCRIPTION "Draco support (version ${draco_VERSION})"
VTK_MODULES CommonCore CommonExecutionModel
ADDITIONAL_RPATHS ${rpaths}
MIMETYPE_XML_FILES "${CMAKE_CURRENT_SOURCE_DIR}/f3d-draco-formats.xml"
)
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions plugins/native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,9 @@ f3d_plugin_build(
VERSION 1.0
DESCRIPTION "Native VTK I/O support"
VTK_MODULES CommonCore CommonExecutionModel IOImport IOXML IOParallel IOCityGML IOImage IOGeometry IOPLY
MIMETYPE_XML_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/f3d-3d-formats.xml"
"${CMAKE_CURRENT_SOURCE_DIR}/f3d-3d-image-formats.xml"
"${CMAKE_CURRENT_SOURCE_DIR}/f3d-vtk-formats.xml"
FORCE_STATIC
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions plugins/occt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ f3d_plugin_build(
DESCRIPTION "OpenCASCADE support (version ${OpenCASCADE_VERSION})"
VTK_MODULES CommonCore CommonExecutionModel IOImport
ADDITIONAL_RPATHS ${rpaths}
MIMETYPE_XML_FILES "${CMAKE_CURRENT_SOURCE_DIR}/f3d-occt-formats.xml"
)
File renamed without changes.

0 comments on commit 579c614

Please sign in to comment.