2017-02-12 21:39:38 +08:00
|
|
|
cmake_minimum_required(VERSION 2.8)
|
|
|
|
|
|
|
|
#set(CMAKE_BUILD_TYPE Release)
|
|
|
|
#set(CMAKE_BUILD_TYPE Release CACHE STRING "set build type to release")
|
|
|
|
|
|
|
|
#message(project_dir=${PROJECT_SOURCE_DIR})
|
|
|
|
|
|
|
|
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")
|
2017-02-12 21:39:38 +08:00
|
|
|
add_definitions("-DANDROID")
|
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")
|
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 "Darwin")
|
2017-03-31 23:04:16 +08:00
|
|
|
set(UNIX_OS true)
|
2017-07-11 15:18:41 +08:00
|
|
|
elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
|
|
|
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()
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
include_directories(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
|
|
|
)
|
|
|
|
|
2017-03-31 23:04:16 +08:00
|
|
|
set(src ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
2017-02-12 21:39:38 +08:00
|
|
|
set(sources
|
2017-03-31 23:04:16 +08:00
|
|
|
${src}
|
2017-02-12 21:39:38 +08:00
|
|
|
${src}/stdlib
|
|
|
|
${src}/stdlib/debug
|
|
|
|
${src}/stdlib/memory
|
|
|
|
${src}/stdlib/filedir
|
|
|
|
${src}/stdlib/string
|
|
|
|
${src}/stdlib/common
|
|
|
|
${src}/stdlib/sys
|
|
|
|
${src}/stdlib/sys/unix
|
|
|
|
${src}/stdlib/configure
|
|
|
|
${src}/stdlib/iostuff
|
|
|
|
${src}/aio
|
|
|
|
${src}/code
|
|
|
|
${src}/db
|
|
|
|
${src}/db/memdb
|
|
|
|
${src}/db/mysql
|
|
|
|
${src}/db/null
|
|
|
|
${src}/db/zdb
|
|
|
|
${src}/event
|
|
|
|
${src}/init
|
|
|
|
${src}/ioctl
|
|
|
|
${src}/json
|
|
|
|
${src}/master
|
|
|
|
${src}/master/template
|
|
|
|
${src}/msg
|
|
|
|
${src}/net
|
|
|
|
${src}/net/dns
|
|
|
|
${src}/net/connect
|
|
|
|
${src}/net/listen
|
|
|
|
${src}/private
|
|
|
|
${src}/thread
|
|
|
|
${src}/unit_test
|
|
|
|
${src}/xml
|
|
|
|
)
|
|
|
|
|
|
|
|
foreach(iter ${sources})
|
|
|
|
aux_source_directory(${iter} lib_src)
|
|
|
|
endforeach()
|
|
|
|
|
2017-03-31 23:04:16 +08:00
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL "")
|
|
|
|
set(CMAKE_BUILD_TYPE "DEBUG")
|
|
|
|
else()
|
|
|
|
string(TOUPPER CMAKE_BUILD_TYPE CMAKE_BUILD_TYPE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (${UNIX_OS})
|
|
|
|
add_definitions(
|
|
|
|
"-W"
|
2017-07-11 15:18:41 +08:00
|
|
|
"-O2"
|
2017-03-31 23:04:16 +08:00
|
|
|
"-fPIC"
|
|
|
|
"-Wall"
|
|
|
|
"-Werror"
|
|
|
|
"-Wshadow"
|
|
|
|
"-Wpointer-arith"
|
|
|
|
"-Waggregate-return"
|
|
|
|
"-Wmissing-prototypes"
|
|
|
|
"-D_REENTRANT"
|
|
|
|
"-D_USE_FAST_MACRO"
|
|
|
|
"-DACL_WRITEABLE_CHECK"
|
|
|
|
"-Wno-long-long"
|
|
|
|
"-Wuninitialized"
|
|
|
|
"-D_POSIX_PTHREAD_SEMANTICS"
|
|
|
|
"-DACL_PREPARE_COMPILE"
|
|
|
|
"-Wstrict-prototypes"
|
|
|
|
)
|
|
|
|
|
2017-07-11 15:18:41 +08:00
|
|
|
if (!CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
|
|
|
add_definitions("-Wno-invalid-source-encoding")
|
|
|
|
endif()
|
|
|
|
|
2017-03-31 23:04:16 +08:00
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL "RELEASE")
|
|
|
|
add_definitions("-O3")
|
|
|
|
else()
|
|
|
|
add_definitions("-g")
|
|
|
|
endif()
|
|
|
|
elseif (${WIN_OS})
|
|
|
|
add_definitions(
|
|
|
|
"-Yc"
|
|
|
|
"-DACL_WRITEABLE_CHECK"
|
|
|
|
"-DACL_PREPARE_COMPILE")
|
|
|
|
endif()
|
|
|
|
|
2017-03-25 23:05:44 +08:00
|
|
|
if (CMAKE_SYSTEM_NAME MATCHES "Android")
|
2017-07-21 16:05:45 +08:00
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "-shared")
|
2017-07-11 15:18:41 +08:00
|
|
|
add_definitions("-Wno-invalid-source-encoding")
|
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})
|
2017-03-25 23:05:44 +08:00
|
|
|
add_library(acl_static STATIC ${lib_src})
|
|
|
|
SET_TARGET_PROPERTIES(acl_static PROPERTIES OUTPUT_NAME "acl")
|
2017-02-12 21:39:38 +08:00
|
|
|
|
2017-03-31 23:04:16 +08:00
|
|
|
if (${WIN_OS})
|
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "/DYNAMICBASE ws2_32.lib IPHlpApi.lib")
|
|
|
|
endif()
|
|
|
|
|
2017-02-12 21:39:38 +08:00
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${lib_output_path})
|
|
|
|
endif()
|
|
|
|
|
2017-03-25 23:05:44 +08:00
|
|
|
add_library(acl SHARED ${lib_src})
|
2017-02-12 21:39:38 +08:00
|
|
|
|
|
|
|
##############################################################################
|