@@ -13,22 +13,69 @@ set(CMAKE_C_STANDARD 11)
13
13
set (CMAKE_C_STANDARD_REQUIRED ON )
14
14
set (CMAKE_C_EXTENSIONS ON )
15
15
16
+ ###
17
+ #
18
+ # Default cmake directories:
19
+ #
20
+ # | Target Type | GNUInstallDirs Variable | Built-In Default |
21
+ # | --- | --- | --- |
22
+ # | RUNTIME | ${CMAKE_INSTALL_BINDIR} | bin |
23
+ # | LIBRARY | ${CMAKE_INSTALL_LIBDIR} | lib |
24
+ # | ARCHIVE | ${CMAKE_INSTALL_LIBDIR} | lib |
25
+ # | PRIVATE_HEADER | ${CMAKE_INSTALL_INCLUDEDIR} | include |
26
+ # | PUBLIC_HEADER | ${CMAKE_INSTALL_INCLUDEDIR} | include |
27
+ # | FILE_SET (type HEADERS) | ${CMAKE_INSTALL_INCLUDEDIR} | include |
28
+ #
29
+ # | TYPE Argument | GNUInstallDirs Variable | Built-In Default |
30
+ # | --- | --- | --- |
31
+ # | BIN | ${CMAKE_INSTALL_BINDIR} | bin |
32
+ # | SBIN | ${CMAKE_INSTALL_SBINDIR} | sbin |
33
+ # | LIB | ${CMAKE_INSTALL_LIBDIR} | lib |
34
+ # | INCLUDE | ${CMAKE_INSTALL_INCLUDEDIR} | include |
35
+ # | SYSCONF | ${CMAKE_INSTALL_SYSCONFDIR} | etc |
36
+ # | SHAREDSTATE | ${CMAKE_INSTALL_SHARESTATEDIR} | com |
37
+ # | LOCALSTATE | ${CMAKE_INSTALL_LOCALSTATEDIR} | var |
38
+ # | RUNSTATE | ${CMAKE_INSTALL_RUNSTATEDIR} | <LOCALSTATE dir>/run |
39
+ # | DATA | ${CMAKE_INSTALL_DATADIR} | <DATAROOT dir> |
40
+ # | INFO | ${CMAKE_INSTALL_INFODIR} | <DATAROOT dir>/info |
41
+ # | LOCALE | ${CMAKE_INSTALL_LOCALEDIR} | <DATAROOT dir>/locale |
42
+ # | MAN | ${CMAKE_INSTALL_MANDIR} | <DATAROOT dir>/man |
43
+ # | DOC | ${CMAKE_INSTALL_DOCDIR} | <DATAROOT dir>/doc |
44
+ #
45
+ # ${CMAKE_BINARY_DIR}
46
+ # This is the full path to the top level of the current CMake build tree.
47
+ # For an in-source build, this would be the same as CMAKE_SOURCE_DIR.
48
+ #
49
+ # ${CMAKE_SOURCE_DIR}
50
+ # This is the full path to the top level of the current CMake source tree.
51
+ # For an in-source build, this would be the same as CMAKE_BINARY_DIR.
52
+ #
53
+ # ${CMAKE_CURRENT_BINARY_DIR}
54
+ # The path to the binary directory currently being processed.
55
+ # This is the full path to the build directory that is currently being processed by cmake.
56
+ # Each directory added by add_subdirectory() will create a binary directory in the build tree,
57
+ # and as it is being processed this variable will be set.
58
+ # For in-source builds this is the current source directory being processed.
59
+ #
60
+ # ${CMAKE_CURRENT_SOURCE_DIR}
61
+ # The path to the source directory currently being processed.
62
+ # This is the full path to the source directory that is currently being processed by cmake.
63
+ #
64
+ ###
65
+
16
66
17
67
###
18
- # General project settings
68
+ # General Project Settings
19
69
###
20
70
21
71
project (stlink C)
22
72
set (PROJECT_DESCRIPTION "Open source version of the STMicroelectronics ST-LINK Tools" )
23
- include (GNUInstallDirs ) # Define GNU standard installation directories
73
+ include (${CMAKE_MODULE_PATH} /get_version.cmake ) # Determine project version
24
74
25
- ## MCU configuration files
26
- set (CMAKE_CHIPS_SUBDIR stlink/chips)
27
- set (CMAKE_CHIPS_DIR ${CMAKE_INSTALL_PREFIX} /${CMAKE_CHIPS_SUBDIR} )
28
- add_definitions ( -DETC_STLINK_DIR="${CMAKE_CHIPS_DIR} " )
75
+ include (GNUInstallDirs) # Define GNU standard installation directories
29
76
30
- ## Determine project version
31
- include ( ${CMAKE_MODULE_PATH} /get_version.cmake )
77
+ # Define install directory /usr/share
78
+ set (CMAKE_INSTALL_SHAREDIR /usr/share/ )
32
79
33
80
## Set C build flags
34
81
if (NOT MSVC )
@@ -178,8 +225,6 @@ endif ()
178
225
# Libraries
179
226
###
180
227
181
- set (STLINK_LIBRARY_PATH ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Main library install directory" )
182
-
183
228
# Set the environment variable LD_LIBRARY_PATH to point to /usr/local/lib (per default).
184
229
execute_process (COMMAND bash -c "export LD_LIBRARY_PATH=${CMAKE_INSTALL_LIBDIR} " )
185
230
@@ -205,21 +250,15 @@ set_target_properties(${STLINK_LIB_SHARED} PROPERTIES
205
250
)
206
251
207
252
# Link shared library
208
- if (APPLE ) # ... with Apple macOS libraries
209
- find_library (ObjC objc)
210
- find_library (CoreFoundation CoreFoundation)
211
- find_library (IOKit IOKit)
212
- find_library (Security Security)
213
- target_link_libraries (${STLINK_LIB_SHARED} ${LIBUSB_LIBRARY} ${SSP_LIB} ${ObjC} ${CoreFoundation} ${IOKit} ${Security} )
214
- elseif (WIN32 ) # ... with Windows libraries
253
+ if (WIN32 ) # ... with Windows libraries
215
254
target_link_libraries (${STLINK_LIB_SHARED} ${LIBUSB_LIBRARY} ${SSP_LIB} wsock32 ws2_32)
216
255
else ()
217
256
target_link_libraries (${STLINK_LIB_SHARED} ${LIBUSB_LIBRARY} ${SSP_LIB} )
218
257
endif ()
219
258
220
259
install (TARGETS ${STLINK_LIB_SHARED}
221
- ARCHIVE DESTINATION ${STLINK_LIBRARY_PATH }
222
- LIBRARY DESTINATION ${STLINK_LIBRARY_PATH }
260
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR }
261
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR }
223
262
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
224
263
)
225
264
@@ -248,19 +287,13 @@ set_target_properties(${STLINK_LIB_STATIC} PROPERTIES
248
287
)
249
288
250
289
# Link static library
251
- if (APPLE ) # ... with Apple macOS libraries
252
- find_library (ObjC objc)
253
- find_library (CoreFoundation CoreFoundation)
254
- find_library (IOKit IOKit)
255
- find_library (Security Security)
256
- target_link_libraries (${STLINK_LIB_STATIC} ${LIBUSB_LIBRARY} ${SSP_LIB} ${ObjC} ${CoreFoundation} ${IOKit} ${Security} )
257
- elseif (WIN32 ) # ... with Windows libraries
290
+ if (WIN32 ) # ... with Windows libraries
258
291
target_link_libraries (${STLINK_LIB_STATIC} ${LIBUSB_LIBRARY} ${SSP_LIB} wsock32 ws2_32)
259
292
else ()
260
293
target_link_libraries (${STLINK_LIB_STATIC} ${LIBUSB_LIBRARY} ${SSP_LIB} )
261
294
endif ()
262
295
263
- install (TARGETS ${STLINK_LIB_STATIC} ARCHIVE DESTINATION ${STLINK_LIBRARY_PATH } )
296
+ install (TARGETS ${STLINK_LIB_STATIC} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR } )
264
297
265
298
266
299
###
@@ -284,7 +317,7 @@ add_executable(st-info ${ST-INFO_SOURCES})
284
317
add_executable (st-util ${ST-UTIL_SOURCES})
285
318
add_executable (st-trace ${ST-TRACE_SOURCES})
286
319
287
- if (WIN32 OR APPLE )
320
+ if (WIN32 )
288
321
target_link_libraries (st-flash ${STLINK_LIB_STATIC} ${SSP_LIB} )
289
322
target_link_libraries (st-info ${STLINK_LIB_STATIC} ${SSP_LIB} )
290
323
target_link_libraries (st-util ${STLINK_LIB_STATIC} ${SSP_LIB} )
@@ -301,10 +334,6 @@ install(TARGETS st-info DESTINATION ${CMAKE_INSTALL_BINDIR})
301
334
install (TARGETS st-util DESTINATION ${CMAKE_INSTALL_BINDIR} )
302
335
install (TARGETS st-trace DESTINATION ${CMAKE_INSTALL_BINDIR} )
303
336
304
- # Install MCU configuration files
305
- file (GLOB CHIP_FILES ${CMAKE_SOURCE_DIR} /config/chips/*.chip)
306
- install (FILES ${CHIP_FILES} DESTINATION ${CMAKE_CHIPS_DIR} )
307
-
308
337
309
338
###
310
339
# Device configuration (Linux only)
@@ -326,13 +355,19 @@ endif ()
326
355
# Additional build tasks
327
356
###
328
357
329
- add_subdirectory (src/stlink-gui) # contains subordinate CMakeLists to build GUI
330
- add_subdirectory (tests) # contains subordinate CMakeLists to build test executables
331
- add_subdirectory (cmake/packaging) # contains subordinate CMakeLists to build packages
358
+ # MCU configuration files
359
+ set (CMAKE_CHIPS_DIR ${CMAKE_INSTALL_SHAREDIR} /${PROJECT_NAME} /chips)
360
+ add_definitions ( -DSTLINK_CHIPS_DIR="${CMAKE_CHIPS_DIR} " )
361
+ file (GLOB CHIP_FILES ${CMAKE_SOURCE_DIR} /config/chips/*.chip)
362
+ install (FILES ${CHIP_FILES} DESTINATION ${CMAKE_CHIPS_DIR} )
332
363
364
+ # Documentation / manpages
333
365
option (STLINK_GENERATE_MANPAGES "Generate manpages with pandoc" OFF )
334
366
add_subdirectory (doc /man) # contains subordinate CMakeLists to generate manpages
335
367
368
+ add_subdirectory (src/stlink-gui) # contains subordinate CMakeLists to build GUI
369
+ add_subdirectory (tests) # contains subordinate CMakeLists to build test executables
370
+ add_subdirectory (cmake/packaging) # contains subordinate CMakeLists to build packages
336
371
337
372
###
338
373
# Uninstall target
0 commit comments