forked from qiniu/c-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
78 lines (52 loc) · 2.9 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
cmake_minimum_required (VERSION 3.3.1)
project (libqiniu)
set (BUILD_SHARED_LIBS ON CACHE BOOL "Set to ON to build shared or dll libraries (default: ON)")
set (BUILD_STATIC_LIBS OFF CACHE BOOL "Set to ON to build static libraries (default: OFF)")
set (BUILD_X86_PLATFORM OFF CACHE BOOL "Set to ON to build for x86 platform (default: OFF)")
set (FUNCTION_LEVEL_LINKING OFF CACHE BOOL "Set to ON to place every function in its own section to garbadge-collect unreferenced ones")
file (GLOB_RECURSE MY_SOURCE_FILES qiniu/*.c b64/*.c cJSON/*.c)
include_directories (qiniu b64 cJSON)
### test
### Platform Settings
set (MY_COMPILE_DEFINITIONS "")
set (MY_COMPILE_FLAGS "")
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
## Append platform-dependent source files
file (GLOB_RECURSE MY_WINDOWS_SOURCE_FILES windows/*.c)
list (APPEND MY_SOURCE_FILES ${MY_WINDOWS_SOURCE_FILES})
include_directories (windows)
set (LOCAL_PACKAGE_PATH "C:/packages" CACHE PATH "Set to the path where dependent libraries (openssl / curl, etc) reside")
include_directories (${LOCAL_PACKAGE_PATH}/include SYSTEM)
link_directories (${LOCAL_PACKAGE_PATH}/lib)
if (DEFINED BUILD_SHARED_LIBS AND ${BUILD_SHARED_LIBS})
list (APPEND MY_COMPILE_DEFINITIONS COMPILING_QINIU_LIBRARY_DLL)
endif (DEFINED BUILD_SHARED_LIBS AND ${BUILD_SHARED_LIBS})
else ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
include_directories (/usr/include /usr/local/include SYSTEM)
link_directories (/usr/lib /usr/local/lib)
set (MY_LINKING_LIBRARIES curl crypto)
list (APPEND MY_COMPILE_FLAGS -Wall)
if (DEFINED FUNCTION_LEVEL_LINKING AND ${FUNCTION_LEVEL_LINKING})
list (APPEND MY_COMPILE_FLAGS -ffunction-sections)
endif (DEFINED FUNCTION_LEVEL_LINKING AND ${FUNCTION_LEVEL_LINKING})
endif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
if (DEFINED BUILD_X86_PLATFORM AND ${BUILD_X86_PLATFORM})
list (APPEND CMAKE_C_FLAGS "-m32")
endif (DEFINED BUILD_X86_PLATFORM AND ${BUILD_X86_PLATFORM})
### Target Settings
if (DEFINED BUILD_SHARED_LIBS AND ${BUILD_SHARED_LIBS})
add_library (qiniu SHARED ${MY_SOURCE_FILES})
if (NOT ("X${MY_LINKING_LIBRARIES}" STREQUAL "X"))
target_link_libraries (qiniu ${MY_LINKING_LIBRARIES})
endif (NOT ("X${MY_LINKING_LIBRARIES}" STREQUAL "X"))
endif (DEFINED BUILD_SHARED_LIBS AND ${BUILD_SHARED_LIBS})
if (DEFINED BUILD_STATIC_LIBS AND ${BUILD_STATIC_LIBS})
add_library (qiniu_a STATIC ${MY_SOURCE_FILES})
endif (DEFINED BUILD_STATIC_LIBS AND ${BUILD_STATIC_LIBS})
if (NOT ("X${MY_COMPILE_FLAGS}" STREQUAL "X"))
set_target_properties (qiniu PROPERTIES COMPILE_FLAGS "${MY_COMPILE_FLAGS}")
endif (NOT ("X${MY_COMPILE_FLAGS}" STREQUAL "X"))
if (NOT ("X${MY_COMPILE_DEFINITIONS}" STREQUAL "X"))
set_target_properties (qiniu PROPERTIES COMPILE_DEFINITIONS ${MY_COMPILE_DEFINITIONS})
endif (NOT ("X${MY_COMPILE_DEFINITIONS}" STREQUAL "X"))
add_subdirectory (demo)