Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 19, 2025

Fixes #26884

Description

Adds proper CMake installation infrastructure to enable vcpkg packaging. The repository previously only exported targets to the build tree, preventing vcpkg from creating a functional port.

Changes:

  • CMakeLists.txt: Added install commands for library, headers, and CMake config files using GNUInstallDirs and CMakePackageConfigHelpers
  • casbin/CMakeLists.txt: Changed include directories and dependencies from PRIVATE to PUBLIC with generator expressions for build/install interface separation
  • cmake/casbinConfig.cmake.in: Created package config template that handles dependency resolution for nlohmann_json

Result:

Consumers can now use standard CMake discovery:

find_package(casbin REQUIRED)
target_link_libraries(myapp PRIVATE casbin::casbin)

The library installs to:

  • ${CMAKE_INSTALL_LIBDIR}/casbin.a
  • ${CMAKE_INSTALL_INCLUDEDIR}/casbin/
  • ${CMAKE_INSTALL_LIBDIR}/cmake/casbin/

All 74 tests pass. vcpkg port can now be created using standard CMake build/install workflow.

Screenshots/Testimonials

N/A

Original prompt

This section details on the original issue you should resolve

<issue_title>Add casbin-cpp to vcpkg</issue_title>
<issue_description>### Description
I issued in vcpkg,but closed by someone.
Have a expert to reopen or Pull requests about casbin-cpp.</issue_description>

Comments on the Issue (you are @copilot in this section)

@nomeguy see: https://github.com/microsoft/vcpkg/pull/29027

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@nomeguy nomeguy marked this pull request as ready for review November 19, 2025 10:53
- Add proper install(TARGETS) command for the casbin library
- Add install(EXPORT) to generate and install CMake config files
- Create casbinConfig.cmake.in for proper package discovery
- Use GNUInstallDirs for standard installation paths
- Change include directories and link libraries from PRIVATE to PUBLIC
- Add generator expressions for BUILD_INTERFACE and INSTALL_INTERFACE
- Create casbinConfigVersion.cmake with version compatibility checking
- All tests pass successfully

Co-authored-by: nomeguy <85475922+nomeguy@users.noreply.github.com>
Copilot AI changed the title [WIP] Add casbin-cpp to vcpkg feat: add vcpkg support with proper CMake package config Nov 19, 2025
Copilot AI requested a review from nomeguy November 19, 2025 11:07
Copilot finished work on behalf of nomeguy November 19, 2025 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add casbin-cpp to vcpkg

3 participants