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")
|
|
|
|
|
|
|
|
#message(${PROJECT_SOURCE_DIR})
|
|
|
|
|
|
|
|
if (${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
message(FATAL_ERROR "Please into another dir to build!")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_definitions(
|
|
|
|
"-W"
|
2017-12-20 23:30:33 +08:00
|
|
|
"-std=gnu99"
|
2017-03-25 23:05:44 +08:00
|
|
|
"-fPIC"
|
2017-02-12 21:39:38 +08:00
|
|
|
"-Wall"
|
2018-10-27 22:21:29 +08:00
|
|
|
# "-Werror"
|
2017-02-12 21:39:38 +08:00
|
|
|
"-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"
|
2018-10-27 22:21:29 +08:00
|
|
|
# "-Wno-invalid-source-encoding"
|
2017-02-12 21:39:38 +08:00
|
|
|
"-Wstrict-prototypes"
|
|
|
|
)
|
|
|
|
|
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL "")
|
|
|
|
set(CMAKE_BUILD_TYPE "DEBUG")
|
|
|
|
else()
|
|
|
|
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL "RELEASE")
|
|
|
|
add_definitions("-O3")
|
|
|
|
else()
|
|
|
|
add_definitions("-g")
|
|
|
|
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-25 23:05:44 +08:00
|
|
|
add_definitions("-Wno-incompatible-pointer-types-discards-qualifiers")
|
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
2017-02-12 21:39:38 +08:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "unknown CMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
set(src ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
|
|
|
|
|
|
|
include_directories(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
|
|
|
)
|
|
|
|
|
|
|
|
set(sources
|
|
|
|
${src}
|
2017-12-20 23:30:33 +08:00
|
|
|
${src}/common
|
|
|
|
${src}/event
|
|
|
|
${src}/hook
|
|
|
|
${src}/dns
|
2017-02-12 21:39:38 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
foreach(iter ${sources})
|
|
|
|
aux_source_directory(${iter} lib_src)
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
if(NOT CMAKE_SYSTEM_NAME MATCHES "ANDROID")
|
|
|
|
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(fiber_static STATIC ${lib_src})
|
|
|
|
SET_TARGET_PROPERTIES(fiber_static PROPERTIES OUTPUT_NAME "fiber")
|
2017-02-12 21:39:38 +08:00
|
|
|
|
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${lib_output_path})
|
|
|
|
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(fiber SHARED ${lib_src})
|
2017-12-21 22:23:07 +08:00
|
|
|
# target_link_libraries(fiber acl)
|
2017-02-12 21:39:38 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
##############################################################################
|