Skip to content

Commit

Permalink
chore: tweak cmakelists and fetch clipper2
Browse files Browse the repository at this point in the history
  • Loading branch information
lvjonok committed Mar 15, 2023
1 parent 5e2c332 commit 799756e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ project(clipper2c LANGUAGES CXX)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# turn off unused parts of Clipper2
set(CLIPPER2_TESTS OFF)
set(CLIPPER2_EXAMPLES OFF)
set(CLIPPER2_UTILS OFF)

option(BUILD_SHARED_LIBS ON)

add_compile_options(-fPIC)
Expand All @@ -13,6 +18,8 @@ add_subdirectory(vendor/Clipper2/CPP)
file(GLOB_RECURSE SOURCE_FILES src/*.cpp)
file(GLOB_RECURSE INCLUDE_FILES include/*.h)

set(PCFILE "${CMAKE_CURRENT_BINARY_DIR}/clipper2c.pc")

add_library(clipper2c SHARED ${INCLUDE_FILES} ${SOURCE_FILES})

target_link_libraries(
Expand All @@ -29,8 +36,13 @@ set_target_properties(clipper2c PROPERTIES FOLDER Libraries
PUBLIC_HEADER "${INCLUDE_FILES}"
)


CONFIGURE_FILE(clipper2c.pc.cmakein "${PCFILE}" @ONLY)

install(TARGETS clipper2c
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/clipper2c
)

install(FILES ${PCFILE} DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)

target_compile_features(clipper2c PUBLIC cxx_std_17)
12 changes: 12 additions & 0 deletions clipper2c.pc.cmakein
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@

Name: clipper2c@PCFILE_LIB_SUFFIX@
Description: C warpper of a Polygon Clipping and Offsetting library in C++
Version: @PROJECT_VERSION@
URL: https://github.com/epit3d/clipper2c
Requires:
Libs: -L${libdir} -lclipper2c@PCFILE_LIB_SUFFIX@
Cflags: -I${includedir}
2 changes: 1 addition & 1 deletion vendor/Clipper2

0 comments on commit 799756e

Please sign in to comment.