Skip to content

Commit d543655

Browse files
committed
fix: Added -fPIC link flag
Signed-off-by: Yash Pandey (YP) <[email protected]>
1 parent 4d750ac commit d543655

File tree

4 files changed

+38
-18
lines changed

4 files changed

+38
-18
lines changed

bindings/python/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ if(UNIX)
4242

4343
# If supported for the target machine, emit position-independent code
4444
# suitable for dynamic linking.
45-
set_property(TARGET pycasbin PROPERTY POSITION_INDEPENDENT_CODE ON)
45+
set_target_properties(pycasbin PROPERTIES
46+
POSITION_INDEPENDENT_CODE ON
47+
)
4648
endif()
4749

4850
# macOS demands that the linker resolve all symbols at build time

casbin/CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,17 @@ target_precompile_headers(casbin PUBLIC "pch.h")
2424

2525
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR})
2626

27-
set_target_properties(casbin PROPERTIES PREFIX "")
27+
set_target_properties(casbin PROPERTIES
28+
PREFIX ""
29+
)
30+
2831
if(WIN32 OR MSVC)
2932
set_target_properties(casbin PROPERTIES SUFFIX ".lib")
3033
elseif(UNIX)
31-
set_target_properties(casbin PROPERTIES SUFFIX ".a")
34+
set_target_properties(casbin PROPERTIES
35+
SUFFIX ".a"
36+
POSITION_INDEPENDENT_CODE ON
37+
)
3238
endif()
3339

3440
install(

tests/CMakeLists.txt

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,27 @@
1515
if(CASBIN_BUILD_TEST)
1616
set(CMAKE_CXX_STANDARD 17)
1717

18-
add_executable(
19-
casbintest
20-
built_in_functions_test.cpp
21-
config_test.cpp
22-
enforcer_test.cpp
23-
enforcer_cached_test.cpp
24-
enforcer_synced_test.cpp
25-
management_api_test.cpp
26-
model_enforcer_test.cpp
27-
model_test.cpp
28-
rbac_api_with_domains_test.cpp
29-
rbac_api_test.cpp
30-
role_manager_test.cpp
31-
util_test.cpp
32-
)
18+
add_executable(
19+
casbintest
20+
built_in_functions_test.cpp
21+
config_test.cpp
22+
enforcer_test.cpp
23+
enforcer_cached_test.cpp
24+
enforcer_synced_test.cpp
25+
management_api_test.cpp
26+
model_enforcer_test.cpp
27+
model_test.cpp
28+
rbac_api_with_domains_test.cpp
29+
rbac_api_test.cpp
30+
role_manager_test.cpp
31+
util_test.cpp
32+
)
33+
34+
if(UNIX)
35+
set_target_properties(casbintest PROPERTIES
36+
POSITION_INDEPENDENT_CODE ON
37+
)
38+
endif()
3339

3440
target_include_directories(casbintest PUBLIC ${CMAKE_SOURCE_DIR})
3541

tests/benchmarks/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ add_executable(casbin_benchmark
2323

2424
target_include_directories(casbin_benchmark PUBLIC ${CMAKE_SOURCE_DIR})
2525

26+
if(UNIX)
27+
set_target_properties(casbin_benchmark PROPERTIES
28+
POSITION_INDEPENDENT_CODE ON
29+
)
30+
endif()
31+
2632
target_link_libraries(
2733
casbin_benchmark
2834
benchmark

0 commit comments

Comments
 (0)