2024-08-31 21:19:48 +08:00
|
|
|
cmake_minimum_required(VERSION 3.2.0)
|
2024-08-31 21:10:21 +08:00
|
|
|
#cmake_minimum_required(VERSION 2.8.0)
|
|
|
|
project(acl)
|
2023-03-27 20:48:27 +08:00
|
|
|
|
2017-03-25 23:05:44 +08:00
|
|
|
#message(${CMAKE_SYSTEM_NAME})
|
2017-02-12 21:39:38 +08:00
|
|
|
|
2018-10-27 22:04:58 +08:00
|
|
|
#if(COMMAND CMAKE_POLICY)
|
|
|
|
# message(STATUS "Set CMake Policy")
|
|
|
|
# if(CMAKE_VERSION GREATER "2.8")
|
|
|
|
# CMAKE_POLICY(set CMP0015 OLD)
|
|
|
|
# CMAKE_POLICY(set CMP0010 OLD)
|
|
|
|
# CMAKE_POLICY(set CMP0011 OLD)
|
|
|
|
# endif(CMAKE_VERSION GREATER "2.8")
|
|
|
|
#endif(COMMAND CMAKE_POLICY)
|
2018-07-01 22:09:12 +08:00
|
|
|
|
|
|
|
enable_testing()
|
|
|
|
|
2018-10-27 22:04:58 +08:00
|
|
|
#include(CheckCCompilerFlag)
|
|
|
|
#check_c_compiler_flag("-std=c99" COMPILER_SUPPORTS_C99)
|
|
|
|
#check_c_compiler_flag("-std=c89" COMPILER_SUPPORTS_C89)
|
|
|
|
#if(COMPILER_SUPPORTS_C99)
|
|
|
|
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
|
|
|
|
#elseif(COMPILER_SUPPORTS_C89)
|
|
|
|
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c89")
|
|
|
|
#else()
|
|
|
|
# message(STATUS "The cc compiler ${CMAKE_C_COMPILER} has no C99 or C89 support. Please use a different cc compiler.")
|
|
|
|
#endif()
|
2018-07-01 22:09:12 +08:00
|
|
|
|
2018-10-27 22:04:58 +08:00
|
|
|
#include(CheckCXXCompilerFlag)
|
|
|
|
#check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11)
|
|
|
|
#check_cxx_compiler_flag("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
|
|
|
|
#if(COMPILER_SUPPORTS_CXX11)
|
|
|
|
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
|
|
|
#elseif(COMPILER_SUPPORTS_CXX0X)
|
|
|
|
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
|
|
|
#else()
|
|
|
|
# message(STATUS "The c++ compiler ${CMAKE_CXX_COMPILER} has no C++11 or C++0x support. Please use a different c++ compiler.")
|
|
|
|
#endif()
|
2018-07-01 22:09:12 +08:00
|
|
|
|
2017-01-23 16:59:58 +08:00
|
|
|
#set(CMAKE_BUILD_TYPE Release)
|
2017-02-12 21:39:38 +08:00
|
|
|
#set(CMAKE_BUILD_TYPE Release CACHE STRING "set build type to release")
|
|
|
|
|
|
|
|
if (${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
|
|
|
|
message(FATAL_ERROR "Please into another dir to build!")
|
|
|
|
endif()
|
|
|
|
|
2018-07-01 22:09:12 +08:00
|
|
|
#string(TOUPPER ${CMAKE_SYSTEM_NAME} CMAKE_SYSTEM_NAME)
|
|
|
|
if (CMAKE_SYSTEM_NAME MATCHES "Android")
|
|
|
|
message(STATUS "current platform: Android")
|
2020-12-10 16:57:31 +08:00
|
|
|
message(STATUS "current ndk path: ${CMAKE_ANDROID_NDK}")
|
2018-07-01 22:09:12 +08:00
|
|
|
elseif (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
|
|
|
message(STATUS "current platform: Linux")
|
|
|
|
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
|
|
|
message(STATUS "current platform: Darwin")
|
|
|
|
set(CMAKE_MACOSX_RPATH build)
|
|
|
|
elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
|
|
|
message(STATUS "current platform: FreeBSD")
|
|
|
|
include_directories(
|
|
|
|
#/usr/include/c++/4.2
|
|
|
|
#/usr/include/c++/4.2/backward
|
|
|
|
/usr/local/include
|
|
|
|
/usr/include
|
|
|
|
)
|
|
|
|
|
|
|
|
link_directories(
|
|
|
|
/usr/lib
|
|
|
|
/usr/local/lib
|
|
|
|
)
|
|
|
|
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--export-dynamic")
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,./:./lib:../:../lib")
|
|
|
|
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
|
|
|
|
message(STATUS "current platform: Windows")
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "unknown CMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
2017-03-25 23:05:44 +08:00
|
|
|
set(CMAKE_MACOSX_RPATH build)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_subdirectory(lib_acl acl)
|
|
|
|
add_subdirectory(lib_protocol protocol)
|
|
|
|
add_subdirectory(lib_acl_cpp acl_cpp)
|
2024-04-04 15:28:22 +08:00
|
|
|
add_subdirectory(lib_fiber/c fiber)
|
|
|
|
add_subdirectory(lib_fiber/cpp fiber_cpp)
|
2024-04-02 17:40:52 +08:00
|
|
|
|
2024-04-04 15:28:22 +08:00
|
|
|
if (ACL_BUILD_SHARED MATCHES "YES")
|
2024-04-16 10:12:29 +08:00
|
|
|
add_dependencies(protocol_shared acl_shared)
|
|
|
|
add_dependencies(acl_cpp_shared protocol_shared acl_shared)
|
2024-04-06 21:48:42 +08:00
|
|
|
add_dependencies(fiber_cpp_shared acl_cpp_shared protocol_shared acl_shared fiber_shared)
|
2024-04-04 15:28:22 +08:00
|
|
|
endif()
|