-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
99 lines (73 loc) · 2.4 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
87
88
89
90
91
92
93
94
95
96
97
98
#****************************************************************************
#* CMakeLists.txt
#*
#* project: tblink-rpc-core
#****************************************************************************
cmake_minimum_required(VERSION 3.11)
project(tblink-rpc-core)
include (ExternalProject)
if(NOT WIN32)
add_compile_options(-fPIC)
# list(APPEND CMAKE_C_FLAGS -fPIC)
# list(APPEND CMAKE_CXX_FLAGS -fPIC)
else()
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
add_compile_options(-Wno-deprecated-declarations)
add_compile_options(-Wno-format)
endif()
set(CMAKE_CXX_STANDARD 11)
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
string(REPLACE "/MDd" "/MTd" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
file(GLOB tblink_rpc_core_SRC
cpp/*.cpp
cpp/*.h)
if (NOT PACKAGES_DIR)
set(PACKAGES_DIR ${CMAKE_SOURCE_DIR}/packages)
# TODO: this should only be if tblink-rpc-core is a toplevel project
# enable_testing()
# add_subdirectory(tests)
endif()
execute_process(
COMMAND python3-config --includes
OUTPUT_VARIABLE PYTHON_PATH
)
#message("PYTHON_PATH: ${PYTHON_PATH}")
#string(REPLACE "-I" "" PYTHON_PATH ${PYTHON_PATH})
#string(REPLACE " " ";" PYTHON_INCDIRS ${PYTHON_PATH})
#list(GET PYTHON_INCDIRS 0 PYTHON_INCDIR)
#message("PYTHON_INCDIRS: ${PYTHON_INCDIRS}")
#********************************************************************
#* Static Library
#********************************************************************
add_library(tblink_rpc_core_static ${tblink_rpc_core_SRC})
target_include_directories(tblink_rpc_core_static PRIVATE
${PACKAGES_DIR}/json/include
${PYTHON_INCDIR}
${CMAKE_CURRENT_SOURCE_DIR}/cpp/include
)
install(TARGETS tblink_rpc_core_static
DESTINATION lib
EXPORT tblink_rpc_core-targets)
#********************************************************************
#* Shared Library
#********************************************************************
add_library(tblink_rpc_core SHARED ${tblink_rpc_core_SRC})
target_include_directories(tblink_rpc_core PRIVATE
${PACKAGES_DIR}/json/include
${PYTHON_INCDIR}
${CMAKE_CURRENT_SOURCE_DIR}/cpp/include
)
if (WIN32)
target_link_libraries(tblink_rpc_core ws2_32)
endif()
#target_link_directories(
# tblink_rpc_core
# PRIVATE
# ${CMAKE_BINARY_DIR}/glog/lib64
# )
#target_link_libraries(
# tblink_rpc_core
# )
message("tlink-rpc-core: PACKAGES_DIR=${PACKAGES_DIR}")