-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
97 lines (77 loc) · 2.72 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
cmake_minimum_required(VERSION 2.8.12)
project(ccorutine)
set(VERSION_MAJOR 1)
set(VERSION_MINOR 0)
set(VERSION_BUGOR 0)
set(BasicLibSrcPath ${PROJECT_SOURCE_DIR})
macro(source_group_by_dir source_files)
if(MSVC)
set(sgbd_cur_dir ${PROJECT_SOURCE_DIR})
foreach(sgbd_file ${${source_files}})
set(samefilename FALSE)
while (NOT samefilename)
string(REGEX REPLACE "/[^/\\.]*/\\.\\./" "/" sgbd_fpath ${sgbd_file})
string(COMPARE EQUAL ${sgbd_fpath} ${sgbd_file} samefilename)
set(sgbd_file ${sgbd_fpath})
endwhile()
string(REGEX REPLACE "${sgbd_cur_dir}/" "" sgbd_fpath ${sgbd_file})
string(REGEX REPLACE "(.*)/" "" sgbd_group_name ${sgbd_fpath})
string(COMPARE EQUAL ${sgbd_fpath} ${sgbd_group_name} sgbd_nogroup)
if(sgbd_nogroup)
set(sgbd_real_group_name "\\")
else()
string(REGEX REPLACE "/${sgbd_group_name}" "" sgbd_real_group_name ${sgbd_fpath})
string(REPLACE "/" "\\" sgbd_real_group_name ${sgbd_real_group_name})
endif()
source_group(${sgbd_real_group_name} FILES ${sgbd_file})
endforeach(sgbd_file)
endif(MSVC)
endmacro(source_group_by_dir)
#fourth self build
#extra src
set(BasicLibExtra_Src)
#flags
set(BasicLibCMakeCXX_FLAGS ${CMAKE_CXX_FLAGS})
set(BasicLibCMakeC_FLAGS ${CMAKE_C_FLAGS})
#define
set(BasicLibDefinitions)
#link add event
set(BasicLibLinks)
if(MSVC)
enable_language(ASM_MASM)
set(BasicLibExtra_Src ${BasicLibExtra_Src}
${BasicLibSrcPath}/coctx_swap_win.asm)
set(BasicLibCMakeCXX_FLAGS "${BasicLibCMakeCXX_FLAGS} /MP")
set(BasicLibCMakeC_FLAGS "${BasicLibCMakeC_FLAGS} /MP")
set(BasicLibDefinitions ${BasicLibDefinitions} -DUNICODE -D_UNICODE)
else()
enable_language(ASM)
set(BasicLibExtra_Src ${BasicLibExtra_Src} ${BasicLibSrcPath}/coctx_swap.S)
set(BasicLibCMakeCXX_FLAGS "${BasicLibCMakeCXX_FLAGS} --std=c++11 -frtti -fexceptions")
set(BasicLibLinks ${BasicLibLinks} pthread)
endif()
#define
add_definitions(${BasicLibDefinitions})
#flags
set(CMAKE_CXX_FLAGS ${BasicLibCMakeCXX_FLAGS})
set(CMAKE_C_FLAGS ${BasicLibCMakeC_FLAGS})
#src
set(basiclib_SOURCES
${BasicLibSrcPath}/ccoroutine.cpp
${BasicLibSrcPath}/ccoroutine.h
${BasicLibSrcPath}/ccoroutinepool.cpp
${BasicLibSrcPath}/ccoroutinepool.h
${BasicLibSrcPath}/main.cpp
${BasicLibSrcPath}/headdefine.h
${BasicLibSrcPath}/ccoroutinedef.h
${BasicLibSrcPath}/debug.cpp
${BasicLibSrcPath}/debug.h
${BasicLibSrcPath}/ccorutinetemplate.h
)
set(TotalSourceData ${basiclib_SOURCES} ${BasicLibExtra_Src})
source_group_by_dir(TotalSourceData)
add_executable(ccorutine ${basiclib_SOURCES} ${BasicLibExtra_Src})
target_link_libraries(ccorutine ${BasicLibLinks})
if(MSVC)
set_target_properties(ccorutine PROPERTIES LINK_FLAGS "/SAFESEH:NO")
endif()