Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Exported targets for easy access #138

Merged
merged 5 commits into from
Aug 11, 2021

Conversation

EmperorYP7
Copy link
Member

@EmperorYP7 EmperorYP7 commented Aug 8, 2021

Fixes #99 completely

Signed-off-by: Yash Pandey (YP) [email protected]


Description

This code:

  • Refactors the headers in the source code into their respective directories

  • Exports the casbin::casbin and casbin::pycasbin(optionally) targets for the library to be used directly by the client's build system likewise :

find_package(casbin 1.35.0 REQUIRED)
  • Cleans up the build configurations and installation paths

  • Adds an include directory to package the library in a compact bundle for the client.

    • This contains a few headers which have all the definitions required for the casbin library.

Usage

The client may include casbin directly into their CMake build system through find_package() as demonstrated above.
Suppose we have a directory structure as follows:

.
└── project-root/
    ├── cmake/
    │   └── modules/
    │       ├── FindExtPackages.cmake
    │       └── Findcasbin.cmake
    ├── CMakeLists.txt
    └── src/
        ├── main.cpp
        └── app.h
# FindExtPackages.cmake

find_package(casbin 1.36.0 REQUIRED)
# Findcasbin.cmake

include(FetchContent)

FetchContent_Declare(
  casbin
  URL https://github.com/casbin/casbin-cpp/archive/refs/tags/v1.36.0.zip
)

FetchContent_MakeAvailable(casbin)

set(CASBIN_BUILD_TEST OFF)
set(CASBIN_BUILD_BENCHMARK OFF)
set(CASBIN_BUILD_BINDINGS OFF)       # If you don't need language bindings provided by casbin-cpp
# CMakeLists.txt

cmake_minimum_required(VERSION 3.19)

set(CMAKE_MODULE_PATH
    ${CMAKE_MODULE_PATH}
    ${CMAKE_SOURCE_DIR}/cmake/modules
)

project(Example)

include(FindExtPackages)

add_executable(example src/main.cpp src/app.h)

target_link_libraries(example PRIVATE casbin::casbin)

Note

The large LOC is due to duktape files being copied over to the include directory.

@hsluoyz hsluoyz requested a review from divy9881 August 8, 2021 12:38
Signed-off-by: Yash Pandey (YP) <[email protected]>
Signed-off-by: Yash Pandey (YP) <[email protected]>
Signed-off-by: Yash Pandey (YP) <[email protected]>
Signed-off-by: Yash Pandey (YP) <[email protected]>
Signed-off-by: Yash Pandey (YP) <[email protected]>
@hsluoyz hsluoyz merged commit 673bc01 into casbin:master Aug 11, 2021
@github-actions
Copy link

🎉 This PR is included in version 1.36.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Configure CMake build system 🏗️
2 participants