Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/actions/generic-ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,21 @@ runs:
working-directory: ${{github.workspace}}
run: ctest --test-dir build_examples --no-tests=error -C Release -VV

# These use pkg-config directly instead of find_package(f3d), so they are built
# separately from the other examples with a plain Makefile instead of CMake.
- name: Build and run pkg-config examples
if: runner.os == 'Linux' && inputs.static_label == 'no-static'
shell: bash
working-directory: ${{github.workspace}}
run: |
F3D_PKGCONFIG_DIR=$(dirname "$(find $(pwd)/install -name 'f3d.pc')")
VTK_LIB_DIR=$(dirname "$(find $(pwd)/dependencies/install -name 'libvtkCommonCore.so*' | head -1)")
Comment thread
mwestphal marked this conversation as resolved.
Outdated
export PKG_CONFIG_PATH=$F3D_PKGCONFIG_DIR
Comment thread
mwestphal marked this conversation as resolved.
Outdated
for lang in c cpp; do
make -C source/examples/libf3d/$lang/pkgconfig LDFLAGS="-Wl,-rpath-link,$VTK_LIB_DIR"
LD_LIBRARY_PATH=$VTK_LIB_DIR source/examples/libf3d/$lang/pkgconfig/check-engine-pkgconfig
done

- name: Install optional component f3d plugins
shell: bash
working-directory: ${{github.workspace}}/build
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ _wasm_build

# testing related
.cache

# pkg-config examples build in-tree
examples/libf3d/c/pkgconfig/check-engine-pkgconfig
examples/libf3d/cpp/pkgconfig/check-engine-pkgconfig
9 changes: 9 additions & 0 deletions c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,13 @@ if (BUILD_SHARED_LIBS)
DESTINATION
"${CMAKE_INSTALL_LIBDIR}/cmake/f3d"
COMPONENT sdk EXCLUDE_FROM_ALL)

# pkg-config
configure_file(
"${F3D_SOURCE_DIR}/cmake/f3d_c_api.pc.in"
"${CMAKE_BINARY_DIR}/cmake/f3d_c_api.pc"
@ONLY)
install(FILES "${CMAKE_BINARY_DIR}/cmake/f3d_c_api.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
COMPONENT sdk EXCLUDE_FROM_ALL)
endif ()
10 changes: 10 additions & 0 deletions cmake/f3d.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
prefix=@CMAKE_INSTALL_PREFIX@
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@

Name: f3d
Description: @F3D_DESCRIPTION@
URL: https://f3d.app
Version: @F3D_VERSION@
Libs: -L${libdir} -lf3d
Cflags: -I${includedir}
11 changes: 11 additions & 0 deletions cmake/f3d_c_api.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
prefix=@CMAKE_INSTALL_PREFIX@
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@

Name: f3d_c_api
Description: C bindings for @F3D_DESCRIPTION@
URL: https://f3d.app
Version: @F3D_VERSION@
Requires.private: f3d
Libs: -L${libdir} -lf3d_c_api
Cflags: -I${includedir}
2 changes: 1 addition & 1 deletion doc/dev/05-BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ Here is the list of all the components:
| `library` | YES | ALL | libf3d library binaries. |
| `plugin` | YES | ALL | libf3d plugins. |
| `dependencies` | NO | ALL | libf3d runtime dependencies. Can be used to create a self-contained and relocatable package. System libraries are excluded. |
| `sdk` | NO | ALL | libf3d SDK (headers and CMake config files) for `library` and `application` find_package components. |
| `sdk` | NO | ALL | libf3d SDK (headers, CMake config files and pkg-config files) for `library` and `application` find_package components. |
| `plugin_sdk` | NO | ALL | libf3d plugin SDK (headers and CMake config files including macros) for `pluginsdk` find_package components. |
| `licenses` | YES | ALL | F3D and third party licenses. |
| `documentation` | YES | Linux | `man` documentation. |
Expand Down
13 changes: 13 additions & 0 deletions examples/libf3d/c/pkgconfig/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Build against libf3d_c_api using pkg-config, without CMake.
# If VTK isn't in a standard system location, pass e.g.
# LDFLAGS="-Wl,-rpath-link,/path/to/vtk/lib" and LD_LIBRARY_PATH=/path/to/vtk/lib at runtime.
Comment thread
AnikethTS marked this conversation as resolved.
Outdated
CC ?= cc
CFLAGS += $(shell pkg-config --cflags f3d_c_api)
LDLIBS += $(shell pkg-config --libs f3d_c_api) -Wl,-rpath,$(shell pkg-config --variable=libdir f3d_c_api)

check-engine-pkgconfig: main.c
$(CC) $(CFLAGS) $< $(LDFLAGS) $(LDLIBS) -o $@

.PHONY: clean
clean:
rm -f check-engine-pkgconfig
15 changes: 15 additions & 0 deletions examples/libf3d/c/pkgconfig/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <f3d/engine_c_api.h>
#include <f3d/log_c_api.h>

int main(void)
{
f3d_engine_autoload_plugins();

f3d_engine_t* engine = f3d_engine_create_none();

f3d_log_info("F3D engine is loaded");

f3d_engine_delete(engine);

return 0;
}
13 changes: 13 additions & 0 deletions examples/libf3d/cpp/pkgconfig/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Build against libf3d using pkg-config, without CMake.
# If VTK isn't in a standard system location, pass e.g.
# LDFLAGS="-Wl,-rpath-link,/path/to/vtk/lib" and LD_LIBRARY_PATH=/path/to/vtk/lib at runtime.
Comment thread
AnikethTS marked this conversation as resolved.
Outdated
CXX ?= c++
CXXFLAGS += -std=c++20 $(shell pkg-config --cflags f3d)
LDLIBS += $(shell pkg-config --libs f3d) -Wl,-rpath,$(shell pkg-config --variable=libdir f3d)

check-engine-pkgconfig: main.cxx
$(CXX) $(CXXFLAGS) $< $(LDFLAGS) $(LDLIBS) -o $@

.PHONY: clean
clean:
rm -f check-engine-pkgconfig
13 changes: 13 additions & 0 deletions examples/libf3d/cpp/pkgconfig/main.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <f3d/engine.h>
#include <f3d/log.h>

int main()
{
f3d::engine::autoloadPlugins();

f3d::engine eng = f3d::engine::createNone();

f3d::log::info("F3D engine is loaded");

return 0;
}
10 changes: 10 additions & 0 deletions library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,16 @@ if(BUILD_SHARED_LIBS)
COMPONENT sdk
EXCLUDE_FROM_ALL)

# Install a pkg-config file for libf3d
configure_file(
"${F3D_SOURCE_DIR}/cmake/f3d.pc.in"
"${CMAKE_BINARY_DIR}/cmake/f3d.pc"
@ONLY)
install(FILES "${CMAKE_BINARY_DIR}/cmake/f3d.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
COMPONENT sdk
EXCLUDE_FROM_ALL)

# Install plugin headers
install(FILES ${F3D_PLUGIN_HEADERS}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/f3d"
Expand Down
Loading