From 475f23b21887c1ba35c14fd053637131405a7cfb Mon Sep 17 00:00:00 2001 From: "Yash Pandey (YP)" Date: Wed, 19 May 2021 11:34:14 +0530 Subject: [PATCH] feat: Initiate CMake config Signed-off-by: Yash Pandey (YP) --- CMakeLists.txt | 46 +++++++++++++++++++++++++++++++++++++------ casbin/CMakeLists.txt | 5 +++++ 2 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 casbin/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 92643c94..1f0210bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,44 @@ -project(casbin) - cmake_minimum_required(VERSION 3.16) -set(CMAKE_CXX_STANDARD 11) -set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib) +set(CMAKE_WARN_DEPRECATED ON) + +if(APPLE AND NOT DEFINED CMAKE_OSX_DEPLOYMENT_TARGET) + # The value of this variable should be set prior to the first project() command invocation + # because it may influence configuration of the toolchain and flags. + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "Minimum OS X deployment version") +endif() + +############################################################################### +# Project definition. + +project(Casbin-CPP + VERSION 1.0.0 + DESCRIPTION "An authorization library that supports access control models like ACL, RBAC, ABAC in C/C++" + HOMEPAGE_URL https://github.com/casbin/casbin-cpp + LANGUAGES CXX C) + -FILE(GLOB_RECURSE SC_FILES "casbin/*.cpp" "casbin/*.h") +############################################################################### +# Forbid in-source build. + +if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) + message(FATAL_ERROR + "In-source build not allowed. Please make a new sub-directory and run CMake from there.") +endif() + +############################################################################### +# Global CMake options. + +# Do not output install messages. +if(NOT DEFINED CMAKE_INSTALL_MESSAGE) + set(CMAKE_INSTALL_MESSAGE "NEVER") +endif() + +# Change the path max size to avoid problem on Windows. +if(NOT DEFINED CMAKE_OBJECT_PATH_MAX) + set(CMAKE_OBJECT_PATH_MAX 300) +endif() + +set(CMAKE_CXX_STANDARD 11) -add_library(casbin ${SC_FILES}) +add_subdirectory(casbin) diff --git a/casbin/CMakeLists.txt b/casbin/CMakeLists.txt new file mode 100644 index 00000000..59c622b2 --- /dev/null +++ b/casbin/CMakeLists.txt @@ -0,0 +1,5 @@ +set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib) + +FILE(GLOB_RECURSE SC_FILES "*.cpp" "*.h") + +add_library(casbin ${SC_FILES})