forked from stlink-org/stlink
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
75 lines (58 loc) · 2.15 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
cmake_minimum_required(VERSION 2.8.11)
project(stlink)
find_package(PkgConfig)
pkg_check_modules(libusb REQUIRED libusb-1.0)
pkg_check_modules(gtk gtk+-3.0)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -Wextra")
set(HFILES src/stlink-common.h
src/stlink-usb.h
src/stlink-sg.h
src/uglylogging.h
src/mmap.h)
set(CFILES src/stlink-common.c
src/stlink-usb.c
src/stlink-sg.c
src/uglylogging.c
src/st-info.c)
include_directories(${libusb_INCLUDE_DIRS})
include_directories(src)
include_directories(mingw)
add_library(stlink STATIC
${HFILES} # header files for ide projects generated by cmake
${CFILES})
target_link_libraries(stlink ${libusb_LDFLAGS})
add_executable(st-flash flash/main.c)
target_link_libraries(st-flash stlink)
add_executable(st-util gdbserver/gdb-remote.c
gdbserver/gdb-remote.h
gdbserver/gdb-server.c
gdbserver/gdb-server.h)
target_link_libraries(st-util stlink)
install(TARGETS stlink st-flash st-util
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib)
if(NOT MINGW)
list(APPEND CFILES src/st-term.c)
add_executable(st-term src/st-term.c)
target_link_libraries(st-term stlink)
install(TARGETS st-term
RUNTIME DESTINATION bin)
endif()
if(gtk_FOUND)
include_directories(${gtk_INCLUDE_DIRS})
set(GUI_SOURCES gui/stlink-gui.c
gui/stlink-gui.h)
add_executable(stlink-gui-local ${GUI_SOURCES})
set_target_properties(stlink-gui-local PROPERTIES
COMPILE_FLAGS -DSTLINK_UI_DIR=\\"${CMAKE_CURRENT_SOURCE_DIR}/gui\\")
target_link_libraries(stlink-gui-local stlink ${gtk_LDFLAGS})
set(INSTALLED_UI_DIR ${CMAKE_INSTALL_PREFIX}/share)
add_executable(stlink-gui ${GUI_SOURCES})
set_target_properties(stlink-gui PROPERTIES
COMPILE_FLAGS -DSTLINK_UI_DIR=\\"${INSTALLED_UI_DIR}\\")
target_link_libraries(stlink-gui stlink ${gtk_LDFLAGS})
install(TARGETS stlink-gui
RUNTIME DESTINATION bin)
install(FILES gui/stlink-gui.ui
DESTINATION ${INSTALLED_UI_DIR})
endif()