56 lines
1.7 KiB
CMake
56 lines
1.7 KiB
CMake
cmake_minimum_required(VERSION 2.8)
|
|
project(libco)
|
|
|
|
# This for mac osx only
|
|
set(CMAKE_MACOSX_RPATH 0)
|
|
|
|
# Set lib version
|
|
set(LIBCO_VERSION 0.5)
|
|
|
|
# Set cflags
|
|
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -g -fno-strict-aliasing -O2 -Wall -export-dynamic -Wall -pipe -D_GNU_SOURCE -D_REENTRANT -fPIC -Wno-deprecated -m64)
|
|
|
|
# Use c and asm
|
|
enable_language(C ASM)
|
|
|
|
# Add source files
|
|
set(SOURCE_FILES
|
|
co_epoll.cpp
|
|
co_hook_sys_call.cpp
|
|
co_routine.cpp
|
|
coctx.cpp
|
|
coctx_swap.S)
|
|
|
|
# Add static and shared library target
|
|
add_library(colib_static STATIC ${SOURCE_FILES})
|
|
add_library(colib_shared SHARED ${SOURCE_FILES})
|
|
|
|
# Set library output name
|
|
set_target_properties(colib_static PROPERTIES OUTPUT_NAME colib)
|
|
set_target_properties(colib_shared PROPERTIES OUTPUT_NAME colib)
|
|
|
|
set_target_properties(colib_static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
|
|
set_target_properties(colib_shared PROPERTIES CLEAN_DIRECT_OUTPUT 1)
|
|
|
|
# Set shared library version, will generate libcolib.${LIBCO_VERSION}.so and a symbol link named libcolib.so
|
|
# For mac osx, the extension name will be .dylib
|
|
set_target_properties(colib_shared PROPERTIES VERSION ${LIBCO_VERSION} SOVERSION ${LIBCO_VERSION})
|
|
|
|
|
|
|
|
# Macro for add example target
|
|
macro(add_example_target EXAMPLE_TARGET)
|
|
add_executable("example_${EXAMPLE_TARGET}" "example_${EXAMPLE_TARGET}.cpp")
|
|
target_link_libraries("example_${EXAMPLE_TARGET}" colib_static pthread dl)
|
|
endmacro(add_example_target)
|
|
|
|
add_example_target(closure)
|
|
add_example_target(cond)
|
|
add_example_target(copystack)
|
|
add_example_target(echocli)
|
|
add_example_target(echosvr)
|
|
add_example_target(poll)
|
|
add_example_target(setenv)
|
|
add_example_target(specific)
|
|
add_example_target(thread)
|