-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
164 lines (155 loc) · 5.69 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
cmake_minimum_required(VERSION 3.0)
# to bypass -rdynamic linker error on CMake test, you need to declare this _before_ project declaration
set( CMAKE_C_COMPILER_WORKS 1 )
set( CMAKE_CXX_COMPILER_WORKS 1 )
project (SerialChronometer)
#include folder
find_package(LibXml2 REQUIRED)
include_directories(include)
include_directories(libserialport/include)
# source files
#libcsoap includes libsoap and libnanohttp. libsoap is not used
file(GLOB SOURCES "src/*.c")
file(GLOB INCLUDES "include/*.h")
include_directories( libserialport/include/ libcsoap-1.1.0/include/ ${LIBXML2_INCLUDE_DIR})
#executable declaration
add_executable(SerialChronometer ${SOURCES} ${INCLUDES})
# target_compile_options(SerialChronometer PRIVATE -static)
# target_link_options(SerialChronometer PRIVATE -static)
# module libraries definition for "generic" module
add_library(generic SHARED src/modules/generic.c src/debug.c)
target_compile_options(generic PRIVATE -DADD_EXPORTS)
set_target_properties(generic PROPERTIES PREFIX "")
# module libraries definition for OitoInnova's "digican" module
add_library(digican SHARED src/modules/digican.c src/debug.c)
target_compile_options(digican PRIVATE -DADD_EXPORTS)
set_target_properties(digican PROPERTIES PREFIX "")
# module libraries definition for "null" (dummy )serial module
add_library(dummy SHARED src/modules/dummy.c src/debug.c)
target_compile_options(dummy PRIVATE -DADD_EXPORTS)
set_target_properties(dummy PROPERTIES PREFIX "")
# module libraries definition for Galican's canometer web interface module
add_library(canometroweb SHARED src/modules/canometroweb.c src/debug.c src/sc_tools.c)
target_compile_options(canometroweb PRIVATE -DADD_EXPORTS)
set_target_properties(canometroweb PROPERTIES PREFIX "")
# add libcsoap library
if (${CMAKE_MAKE_PROGRAM} STREQUAL "/usr/bin/mingw32-make")
set(dlfcn-win32_DIR /usr/i686-w64-mingw32/sys-root/mingw/share/dlfcn-win32)
find_package(dlfcn-win32 REQUIRED)
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_CROSSCOMPILING 1)
set( CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-static" )
set( CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "-static")
# target_link_options(SerialChronometer PRIVATE -static)
target_compile_options(SerialChronometer PRIVATE -static -DCURL_STATICLIB)
target_link_libraries(
SerialChronometer
${CMAKE_SOURCE_DIR}/libserialport/lib/mingw32/libserialport.a
${CMAKE_SOURCE_DIR}/libcsoap-1.1.0/lib/mingw32/libnanohttp.a
${CMAKE_SOURCE_DIR}/libcsoap-1.1.0/lib/mingw32/libcsoap.a
dlfcn-win32::dl
curl
idn2
ssh2
ssl
crypto
gdi32
z
wldap32
setupapi
ws2_32
pthread
ssp
)
target_link_libraries(
generic
${CMAKE_SOURCE_DIR}/libserialport/lib/mingw32/libserialport.a
dlfcn-win32::dl
setupapi
)
target_link_libraries(
digican
${CMAKE_SOURCE_DIR}/libserialport/lib/mingw32/libserialport.a
dlfcn-win32::dl
setupapi
)
target_link_libraries(
dummy
dlfcn-win32::dl
setupapi
)
target_link_libraries(
canometroweb
${CMAKE_SOURCE_DIR}/libcsoap-1.1.0/lib/mingw32/libcsoap.a
${CMAKE_SOURCE_DIR}/libcsoap-1.1.0/lib/mingw32/libnanohttp.a
dlfcn-win32::dl
curl
xml2
ws2_32
setupapi
)
elseif(APPLE)
find_package (Threads REQUIRED)
target_compile_options(SerialChronometer PRIVATE -I/usr/local/opt/[email protected]/include)
target_link_options(SerialChronometer PRIVATE -L/usr/local/opt/[email protected]/lib)
target_link_libraries(
SerialChronometer
"-framework IOKit"
"-framework CoreFoundation"
${CMAKE_SOURCE_DIR}/libserialport/lib/osx/libserialport.a
${CMAKE_SOURCE_DIR}/libcsoap-1.1.0/lib/osx/libnanohttp.a
${CMAKE_SOURCE_DIR}/libcsoap-1.1.0/lib/osx/libcsoap.a
pthread
crypto
ssl
curl
dl
)
target_link_libraries(
generic
${CMAKE_SOURCE_DIR}/libserialport/lib/osx/libserialport.a
"-framework IOKit"
"-framework CoreFoundation"
)
target_link_libraries(
digican
${CMAKE_SOURCE_DIR}/libserialport/lib/osx/libserialport.a
"-framework IOKit"
"-framework CoreFoundation"
)
target_link_libraries(
dummy
"-framework IOKit"
"-framework CoreFoundation"
)
target_link_libraries(
# libnanohttp and csoap needs to be compiled with -fpic option to be included in DLL's
canometroweb
"-framework IOKit"
"-framework CoreFoundation"
${CMAKE_SOURCE_DIR}/libcsoap-1.1.0/lib/osx/libcsoap.a
${CMAKE_SOURCE_DIR}/libcsoap-1.1.0/lib/osx/libnanohttp.a
curl
xml2
)
else()
find_package (Threads REQUIRED)
target_link_libraries(
SerialChronometer
${CMAKE_SOURCE_DIR}/libserialport/lib/linux/libserialport.a
${CMAKE_SOURCE_DIR}/libcsoap-1.1.0/lib/linux/libnanohttp.a
${CMAKE_SOURCE_DIR}/libcsoap-1.1.0/lib/linux/libcsoap.a
pthread
crypto
curl
dl
)
target_link_libraries(
# libnanohttp and csoap needs to be compiled with -fpic option to be included in DLL's
canometroweb
${CMAKE_SOURCE_DIR}/libcsoap-1.1.0/lib/linux/libcsoap.a
${CMAKE_SOURCE_DIR}/libcsoap-1.1.0/lib/linux/libnanohttp.a
curl
xml2
)
endif()