forked from Tencent/libco
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Tencent#33 from xiaozhuai/master
add cmake build support and something in example_echosvr
- Loading branch information
Showing
3 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
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) | ||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters