Skip to content

Commit 0c42d80

Browse files
authored
chore: Updated project config (casbin#141)
* chore: Updated project config Signed-off-by: Yash Pandey (YP) <[email protected]> * fix: Error on windows Signed-off-by: Yash Pandey (YP) <[email protected]>
1 parent df36075 commit 0c42d80

File tree

8 files changed

+46
-40
lines changed

8 files changed

+46
-40
lines changed

.github/workflows/ci.yml

-4
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ jobs:
6565
run: |
6666
cd build
6767
ctest -j10 -C Debug -T test --output-on-failure -T test --output-on-failure
68-
- name: Cleanup
69-
id: clean-up
70-
run: |
71-
rm -r build
7268
7369
macos:
7470
name: "macOS Catalina 10.15 (AppleClang 12.0)"

CMakeLists.txt

+5-16
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ endif()
3131
###############################################################################
3232
# Project definition.
3333

34-
project(CasbinCPP
35-
VERSION 1.38.2
34+
project(
35+
casbin
36+
VERSION 1.38.0
3637
DESCRIPTION "An authorization library that supports access control models like ACL, RBAC, ABAC in C/C++"
3738
HOMEPAGE_URL https://github.com/casbin/casbin-cpp
3839
LANGUAGES CXX C
@@ -55,6 +56,7 @@ option(CASBIN_BUILD_BENCHMARK "State whether to build benchmarks" ON)
5556
option(CASBIN_BUILD_BINDINGS "State whether to build language bindings" ON)
5657
option(CASBIN_BUILD_PYTHON_BINDINGS "State whether to build python bindings" ON)
5758

59+
5860
# Do not output install messages.
5961
if(NOT DEFINED CMAKE_INSTALL_MESSAGE)
6062
set(CMAKE_INSTALL_MESSAGE "NEVER")
@@ -78,24 +80,11 @@ endif()
7880
set(CMAKE_CXX_STANDARD 17)
7981

8082
###############################################################################
81-
# Find or install external dependencies
83+
# Install external dependencies
8284
# Some required targets may be created by third-party CMake configs, which
8385
# don't generally produce global targets. To guarantee all imported targets are
8486
# global, this module is included at the project root level.
8587

8688
include(FindExtPackages)
8789

8890
add_subdirectory(casbin)
89-
90-
export(TARGETS
91-
casbin
92-
NAMESPACE casbin::
93-
FILE "${CMAKE_CURRENT_BINARY_DIR}/CasbinConfig.cmake"
94-
)
95-
96-
if(CASBIN_BUILD_PYTHON_BINDINGS)
97-
export(TARGETS pycasbin
98-
NAMESPACE casbin::
99-
FILE "${CMAKE_CURRENT_BINARY_DIR}/PyCasbinConfig.cmake"
100-
)
101-
endif()

bindings/python/CMakeLists.txt

+8-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
find_package(Python REQUIRED COMPONENTS Interpreter Development)
16+
1517
set(SOURCES
1618
main.cpp
1719
py_cached_enforcer.cpp
@@ -26,7 +28,7 @@ set(HEADERS
2628
py_casbin.h
2729
)
2830

29-
add_library(pycasbin MODULE ${SOURCES} ${HEADERS})
31+
Python_add_library(pycasbin MODULE ${SOURCES} ${HEADERS})
3032

3133
target_include_directories(pycasbin PUBLIC ${CMAKE_SOURCE_DIR}/include)
3234

@@ -35,6 +37,7 @@ set_target_properties(pycasbin PROPERTIES
3537
CXX_STANDARD 17
3638
)
3739

40+
# For in-source versioning macro
3841
add_definitions(-DPY_CASBIN_VERSION=${PY_CASBIN_VERSION})
3942

4043
if(WIN32)
@@ -70,11 +73,13 @@ target_link_libraries(pycasbin
7073
)
7174

7275
if(WIN32)
73-
set(Python_VARIANT_PATH "lib${LIB_SUFFIX}/site-packages")
76+
set(Python_VARIANT_PATH lib${LIB_SUFFIX}/site-packages)
7477
else()
75-
set(Python_VARIANT_PATH "lib${LIB_SUFFIX}/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages")
78+
set(Python_VARIANT_PATH lib${LIB_SUFFIX}/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages)
7679
endif()
7780

81+
message("${Python_VARIANT_PATH}")
82+
7883
# For testing
7984
install(
8085
TARGETS pycasbin

casbin/CMakeLists.txt

+3-15
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,13 @@ set(CASBIN_SOURCE
7272
set(CMAKE_CXX_STANDARD 17)
7373

7474
add_library(casbin STATIC ${CASBIN_SOURCE})
75-
target_include_directories(casbin PUBLIC ${CMAKE_SOURCE_DIR}/casbin)
7675

77-
target_precompile_headers(casbin PUBLIC "pch.h")
76+
target_precompile_headers(casbin PUBLIC pch.h)
77+
target_include_directories(casbin PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
7878

7979
set_target_properties(casbin PROPERTIES
8080
PREFIX ""
81+
VERSION ${CMAKE_PROJECT_VERSION}
8182
)
8283

8384
if(WIN32 OR MSVC)
@@ -88,16 +89,3 @@ elseif(UNIX)
8889
POSITION_INDEPENDENT_CODE ON
8990
)
9091
endif()
91-
92-
install(
93-
TARGETS casbin EXPORT CasbinTargets
94-
LIBRARY DESTINATION lib
95-
ARCHIVE DESTINATION lib
96-
RUNTIME DESTINATION bin
97-
INCLUDES DESTINATION include
98-
)
99-
100-
install(
101-
DIRECTORY ${CMAKE_SOURCE_DIR}/include/casbin
102-
DESTINATION include
103-
)

cmake/modules/FindExtPackages.cmake

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ endif()
3838

3939
if(CASBIN_BUILD_BINDINGS)
4040
if(CASBIN_BUILD_PYTHON_BINDINGS)
41+
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
4142
# pybind11
4243
# https://github.com/pybind/pybind11
4344
find_package(pybind11 2.7.0 REQUIRED)

cmake/modules/Findbenchmark.cmake

+7
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,10 @@ FetchContent_Declare(
2121

2222
set(BENCHMARK_ENABLE_TESTING OFF)
2323
FetchContent_MakeAvailable(benchmark)
24+
25+
FetchContent_GetProperties(benchmark)
26+
27+
if(NOT benchmark_POPULATED)
28+
FetchContent_Populate(benchmark)
29+
add_subdirectory(${benchmark_SOURCE_DIR} ${benchmark_BINARY_DIR})
30+
endif()

cmake/modules/Findgoogletest.cmake

+12-1
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,21 @@
1313
# limitations under the License.
1414

1515
include(FetchContent)
16+
1617
FetchContent_Declare(
1718
googletest
18-
URL https://github.com/google/googletest/archive/refs/tags/release-1.11.0.zip
19+
GIT_REPOSITORY https://github.com/google/googletest.git
20+
GIT_TAG release-1.11.0
1921
)
22+
2023
# For Windows: Prevent overriding the parent project's compiler/linker settings
2124
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
25+
2226
FetchContent_MakeAvailable(googletest)
27+
FetchContent_GetProperties(googletest)
28+
29+
# Populating manually, if not done automatically
30+
if(NOT googletest_POPULATED)
31+
FetchContent_Populate(googletest)
32+
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR})
33+
endif()

cmake/modules/Findpybind11.cmake

+10-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,16 @@ include(FetchContent)
1616

1717
FetchContent_Declare(
1818
pybind11
19-
URL https://github.com/pybind/pybind11/archive/refs/tags/v2.7.0.zip
19+
GIT_REPOSITORY https://github.com/pybind/pybind11.git
20+
GIT_TAG v2.7.1
2021
)
2122

2223
FetchContent_MakeAvailable(pybind11)
24+
25+
FetchContent_GetProperties(pybind11)
26+
27+
# Populating manually, if not done automatically
28+
if(NOT pybind11_POPULATED)
29+
FetchContent_Populate(pybind11)
30+
add_subdirectory(${pybind11_SOURCE_DIR} ${pybind11_BINARY_DIR})
31+
endif()

0 commit comments

Comments
 (0)