Skip to content

Commit

Permalink
Add *.pc file for easier use in non-cmake environments. (#901)
Browse files Browse the repository at this point in the history
pkg-config is the common way how to find cflags and library flags
for projects not using cmake.
  • Loading branch information
hzeller authored Aug 19, 2024
1 parent d4fb82d commit 74e15b1
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,12 @@ install(FILES
${CMAKE_CURRENT_BINARY_DIR}/manifoldConfig.cmake
DESTINATION ${CMAKE_INSTALL_DATADIR}/manifold
)

if(MANIFOLD_CROSS_SECTION)
set(TEMPLATE_OPTIONAL_CLIPPER "Clipper2")
endif()
configure_file(manifold.pc.in ${CMAKE_CURRENT_BINARY_DIR}/manifold.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/manifold.pc
DESTINATION lib/pkgconfig)

endif()
12 changes: 12 additions & 0 deletions manifold.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@

Name: manifold@PCFILE_LIB_SUFFIX@
Description: Geometry library for topological robustness
Version: @MANIFOLD_VERSION@
URL: https://github.com/elalish/manifold
Requires-private: glm tbb @TEMPLATE_OPTIONAL_CLIPPER@
Libs: -L${libdir} -lmanifold@PCFILE_LIB_SUFFIX@
Cflags: -I${includedir}
18 changes: 18 additions & 0 deletions test-pkgconfig.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
mkdir make-consumer
cd make-consumer

cat <<'EOT' >> Makefile
CXXFLAGS=$(shell pkg-config --cflags manifold)
LDFLAGS=$(shell pkg-config --libs manifold)
testing : testing.cpp
EOT

cat <<EOT >> testing.cpp
#include <manifold/manifold.h>
int main() { manifold::Manifold foo; return 0; }
EOT

make
./testing

0 comments on commit 74e15b1

Please sign in to comment.