2019-07-28 10:31:56 +08:00
|
|
|
cmake_minimum_required(VERSION 2.8)
|
2017-02-12 21:39:38 +08:00
|
|
|
#set(CMAKE_BUILD_TYPE Release)
|
|
|
|
#set(CMAKE_BUILD_TYPE Release CACHE STRING "set build type to release")
|
|
|
|
|
|
|
|
if (${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
message(FATAL_ERROR "Please into another dir to build!")
|
|
|
|
endif()
|
|
|
|
|
2017-03-25 23:05:44 +08:00
|
|
|
#string(TOUPPER ${CMAKE_SYSTEM_NAME} CMAKE_SYSTEM_NAME)
|
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "Android")
|
2019-09-19 09:00:59 +08:00
|
|
|
add_definitions("-flto")
|
2017-02-12 21:39:38 +08:00
|
|
|
add_definitions("-DANDROID")
|
2019-09-19 09:00:59 +08:00
|
|
|
add_definitions("-DACL_CLIENT_ONLY")
|
2019-09-24 11:21:36 +08:00
|
|
|
add_definitions("-Wno-unused-command-line-argument")
|
2019-09-19 09:00:59 +08:00
|
|
|
add_definitions("-Wno-invalid-source-encoding")
|
2019-09-24 11:21:36 +08:00
|
|
|
add_definitions("-fvisibility=hidden")
|
|
|
|
add_definitions("-fvisibility-inlines-hidden")
|
2019-09-19 09:00:59 +08:00
|
|
|
string(APPEND CMAKE_CXX_FLAGS " -Qunused-arguments")
|
2017-03-31 23:04:16 +08:00
|
|
|
set(UNIX_OS true)
|
2017-03-25 23:05:44 +08:00
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
2019-09-19 09:00:59 +08:00
|
|
|
add_definitions("-Wno-invalid-source-encoding")
|
2019-09-18 17:10:49 +08:00
|
|
|
add_definitions("-O2")
|
2017-07-11 15:18:41 +08:00
|
|
|
set(UNIX_OS true)
|
2019-09-19 09:00:59 +08:00
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
2019-09-18 17:10:49 +08:00
|
|
|
add_definitions("-O2")
|
2017-03-31 23:04:16 +08:00
|
|
|
set(UNIX_OS true)
|
2019-09-19 09:00:59 +08:00
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
|
|
|
add_definitions("-Wno-invalid-source-encoding")
|
2019-09-18 17:10:49 +08:00
|
|
|
add_definitions("-Os")
|
2019-09-19 09:00:59 +08:00
|
|
|
set(UNIX_OS true)
|
2017-03-31 23:04:16 +08:00
|
|
|
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
|
|
|
|
set(WIN_OS true)
|
2017-02-12 21:39:38 +08:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "unknown CMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
set(acl_path ${CMAKE_CURRENT_SOURCE_DIR}/../lib_acl)
|
|
|
|
set(acl_include ${acl_path}/include)
|
|
|
|
set(proto_path ${CMAKE_CURRENT_SOURCE_DIR}/../lib_protocol)
|
|
|
|
set(proto_include ${proto_path}/include)
|
2017-03-31 23:04:16 +08:00
|
|
|
set(zlib_include ${CMAKE_CURRENT_SOURCE_DIR}/../include/zlib)
|
2017-02-12 21:39:38 +08:00
|
|
|
set(mysql_include ${CMAKE_CURRENT_SOURCE_DIR}/../include/mysql)
|
2017-05-03 11:19:20 +08:00
|
|
|
set(pgsql_include ${CMAKE_CURRENT_SOURCE_DIR}/../include/pgsql)
|
2017-02-12 21:39:38 +08:00
|
|
|
set(sqlite_include ${CMAKE_CURRENT_SOURCE_DIR}/../include/sqlite)
|
2017-12-14 18:35:18 +08:00
|
|
|
set(polarssl_include ${CMAKE_CURRENT_SOURCE_DIR}/../include)
|
2017-02-12 21:39:38 +08:00
|
|
|
|
2019-06-28 16:36:00 +08:00
|
|
|
include_directories(#if !defined(ACL_CLIENT_ONLY) && !defined(ACL_DB_DISABLE)
|
2017-03-31 23:04:16 +08:00
|
|
|
${zlib_include}
|
2017-02-12 21:39:38 +08:00
|
|
|
${mysql_include}
|
2017-04-27 21:46:28 +08:00
|
|
|
${pgsql_include}
|
2017-02-12 21:39:38 +08:00
|
|
|
${sqlite_include}
|
2017-12-14 18:35:18 +08:00
|
|
|
${polarssl_include}
|
2017-02-12 21:39:38 +08:00
|
|
|
${acl_include}
|
|
|
|
${proto_include}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
|
|
|
)
|
|
|
|
|
2017-03-31 23:04:16 +08:00
|
|
|
#if (${WIN_OS})
|
|
|
|
# set(iconv_include ${CMAKE_CURRENT_SOURCE_DIR}/src/stdlib/internal)
|
|
|
|
# include_directories(iconv_include)
|
|
|
|
#endif()
|
|
|
|
|
2017-02-12 21:39:38 +08:00
|
|
|
set(src ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
|
|
|
set(sources
|
|
|
|
${src}
|
|
|
|
${src}/beanstalk
|
|
|
|
${src}/connpool
|
|
|
|
${src}/db
|
|
|
|
${src}/disque
|
|
|
|
${src}/event
|
|
|
|
${src}/hsocket
|
|
|
|
${src}/http
|
|
|
|
${src}/ipc
|
|
|
|
${src}/master
|
|
|
|
${src}/memcache
|
|
|
|
${src}/mime
|
|
|
|
${src}/mime/internal
|
|
|
|
${src}/queue
|
|
|
|
${src}/redis
|
|
|
|
${src}/serialize
|
|
|
|
${src}/session
|
|
|
|
${src}/smtp
|
|
|
|
${src}/stdlib
|
|
|
|
${src}/stream lib_src
|
|
|
|
)
|
|
|
|
|
|
|
|
foreach(iter ${sources})
|
|
|
|
aux_source_directory(${iter} lib_src)
|
|
|
|
endforeach()
|
|
|
|
|
2017-03-31 23:04:16 +08:00
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
if (${UNIX_OS})
|
|
|
|
add_definitions(
|
|
|
|
"-W"
|
|
|
|
"-fPIC"
|
|
|
|
"-Wall"
|
|
|
|
"-Werror"
|
|
|
|
"-Wshadow"
|
|
|
|
"-Wformat"
|
|
|
|
"-Wpointer-arith"
|
|
|
|
"-D_REENTRANT"
|
|
|
|
"-D_USE_FAST_MACRO"
|
|
|
|
"-Wno-long-long"
|
|
|
|
"-Wuninitialized"
|
|
|
|
"-D_POSIX_PTHREAD_SEMANTICS"
|
2019-06-28 10:54:27 +08:00
|
|
|
"-DACL_PREPARE_COMPILE"
|
2017-03-31 23:04:16 +08:00
|
|
|
"-Wno-unused-parameter"
|
|
|
|
"-fexceptions"
|
|
|
|
)
|
|
|
|
|
2017-07-11 15:18:41 +08:00
|
|
|
if (!CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
2019-09-19 09:00:59 +08:00
|
|
|
add_definitions("-Wno-unused-private-field"
|
2017-07-11 15:18:41 +08:00
|
|
|
"-Wno-unused-const-variable"
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2019-09-06 11:27:36 +08:00
|
|
|
# if (CMAKE_BUILD_TYPE STREQUAL "")
|
|
|
|
# set(CMAKE_BUILD_TYPE "DEBUG")
|
|
|
|
# else()
|
|
|
|
# string(TOUPPER CMAKE_BUILD_TYPE CMAKE_BUILD_TYPE)
|
|
|
|
# endif()
|
2017-03-31 23:04:16 +08:00
|
|
|
|
2019-09-18 17:10:49 +08:00
|
|
|
if (!CMAKE_BUILD_TYPE STREQUAL "RELEASE")
|
2017-03-31 23:04:16 +08:00
|
|
|
add_definitions("-g")
|
|
|
|
endif()
|
2019-06-28 10:54:27 +08:00
|
|
|
|
|
|
|
if (DISABLE_DB MATCHES "YES")
|
|
|
|
add_definitions("-DACL_DB_DISABLE")
|
|
|
|
message(STATUS "DB (mysql, pgsql, sqlite) was disabled!")
|
|
|
|
else()
|
|
|
|
if (HAS_MYSQL MATCHES "YES")
|
|
|
|
add_definitions("-DHAS_MYSQL")
|
|
|
|
message(STATUS "HAS_MYSQL been set, mysql enable!")
|
|
|
|
elseif (HAS_MYSQL_DLL MATCHES "YES")
|
|
|
|
add_definitions("-DHAS_MYSQL_DLL")
|
|
|
|
message(STATUS "HAS_MYSQL_DLL been set, mysql enable!")
|
|
|
|
else()
|
|
|
|
message(STATUS "mysql disable!")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (HAS_PGSQL MATCHES "YES")
|
|
|
|
add_definitions("-DHAS_PGSQL")
|
|
|
|
message(STATUS "HAS_PGSQL been set, pgsql enable!")
|
|
|
|
elseif (HAS_PGSQL_DLL MATCHES "YES")
|
|
|
|
add_definitions("-DHAS_PGSQL_DLL")
|
|
|
|
message(STATUS "HAS_PGSQL_DLL been set, pgsql enable!")
|
|
|
|
else()
|
|
|
|
message(STATUS "pgsql disable!")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (HAS_SQLITE MATCHES "YES")
|
|
|
|
add_definitions("-DHAS_SQLITE")
|
|
|
|
message(STATUS "HAS_SQLITE been set, sqlite enable!")
|
|
|
|
elseif (HAS_SQLITE_DLL MATCHES "YES")
|
|
|
|
add_definitions("-DHAS_SQLITE_DLL")
|
|
|
|
message(STATUS "HAS_SQLITE_DLL been set, sqlite enable!")
|
|
|
|
else()
|
|
|
|
message(STATUS "sqlite disable!")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (HAS_POLARSSL MATCHES "YES")
|
|
|
|
add_definitions("-DHAS_POLARSSL")
|
|
|
|
message(STATUS "HAS_POLARSSL been set, polarssl enable!")
|
|
|
|
elseif (HAS_POLARSSL_DLL MATCHES "YES")
|
|
|
|
add_definitions("-DHAS_POLARSSL_DLL")
|
|
|
|
message(STATUS "HAS_POLARSSL_DLL been set, polarssl enable!")
|
|
|
|
else()
|
|
|
|
message(STATUS "polarssl disable!")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
2017-03-31 23:04:16 +08:00
|
|
|
elseif (${WIN_OS})
|
|
|
|
add_definitions(
|
|
|
|
"-Ycacl_stdafx.hpp"
|
|
|
|
"-DACL_WRITEABLE_CHECK"
|
|
|
|
"-DACL_PREPARE_COMPILE"
|
|
|
|
"-DHAS_ZLIB_DLL"
|
2018-03-30 14:35:34 +08:00
|
|
|
"-DHAS_MYSQL_DLL"
|
|
|
|
"-DHAS_SQLITE_DLL"
|
|
|
|
"-DHAS_PGSQL_DLL"
|
|
|
|
"-DHAS_POLARSSL_DLL"
|
2017-03-31 23:04:16 +08:00
|
|
|
"-DUSE_WIN_ICONV")
|
|
|
|
aux_source_directory(${src}/stdlib/internal lib_src)
|
|
|
|
endif()
|
|
|
|
|
2019-06-28 10:54:27 +08:00
|
|
|
if (ACL_CLIENT_ONLY MATCHES "YES")
|
|
|
|
message(STATUS "acl_cpp: ACL_CLIENT_ONLY been set")
|
|
|
|
endif()
|
|
|
|
|
2017-03-25 23:05:44 +08:00
|
|
|
if (CMAKE_SYSTEM_NAME MATCHES "Android")
|
2019-09-19 09:00:59 +08:00
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "-shared -lz -flto")
|
2019-06-28 16:36:00 +08:00
|
|
|
|
2019-08-27 15:18:31 +08:00
|
|
|
set(lib_output_path ${CMAKE_CURRENT_SOURCE_DIR}/../android/lib/${ANDROID_ABI})
|
2019-08-21 10:15:08 +08:00
|
|
|
set(LIBRARY_OUTPUT_PATH ${lib_output_path})
|
2019-06-28 16:36:00 +08:00
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${lib_output_path})
|
2019-08-21 17:35:56 +08:00
|
|
|
|
|
|
|
add_library(acl_cpp_static STATIC ${lib_src})
|
|
|
|
SET_TARGET_PROPERTIES(acl_cpp_static PROPERTIES OUTPUT_NAME "acl_cpp")
|
2019-06-28 16:36:00 +08:00
|
|
|
link_directories(${lib_output_path})
|
2017-03-25 23:05:44 +08:00
|
|
|
else()
|
2017-02-12 21:39:38 +08:00
|
|
|
set(lib_output_path ${PROJECT_BINARY_DIR}/lib)
|
|
|
|
set(LIBRARY_OUTPUT_PATH ${lib_output_path})
|
2019-08-27 15:18:31 +08:00
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${lib_output_path})
|
2017-03-25 23:05:44 +08:00
|
|
|
|
|
|
|
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS
|
|
|
|
"-shared -Wl,-rpath,. -L${lib_output_path} -lprotocol -lacl -liconv -lz -lpthread")
|
2017-03-31 23:04:16 +08:00
|
|
|
elseif (${UNIX_OS})
|
2017-03-25 23:05:44 +08:00
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS
|
|
|
|
"-shared -Wl,-rpath,. -L${lib_output_path} -lprotocol -lacl -lz -lpthread")
|
2017-03-31 23:04:16 +08:00
|
|
|
elseif (${WIN_OS})
|
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "/DYNAMICBASE ws2_32.lib")
|
2017-03-25 23:05:44 +08:00
|
|
|
endif()
|
2017-02-12 21:39:38 +08:00
|
|
|
|
2019-08-27 15:18:31 +08:00
|
|
|
add_library(acl_cpp_static STATIC ${lib_src})
|
|
|
|
SET_TARGET_PROPERTIES(acl_cpp_static PROPERTIES OUTPUT_NAME "acl_cpp")
|
2017-02-12 21:39:38 +08:00
|
|
|
link_directories(${lib_output_path})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
2017-03-25 23:05:44 +08:00
|
|
|
add_library(acl_cpp SHARED ${lib_src})
|
|
|
|
target_link_libraries(acl_cpp protocol acl)
|
2017-02-12 21:39:38 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
##############################################################################
|