-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
76 lines (64 loc) · 2.19 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
cmake_minimum_required(VERSION 2.8.12)
if(CMAKE_CONFIGURATION_TYPES)
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "My multi config types" FORCE)
elseif(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RELEASE)
endif()
set(CMAKE_C_FLAGS, "-Wall")
set(CMAKE_CXX_FLAGS, "-Wall")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
project(SerialPortToolGUI)
find_package (PkgConfig REQUIRED)
pkg_check_modules (GTK3 REQUIRED gtk+-3.0)
if(APPLE)
find_library(IOKIT_LIBRARY IOKit)
find_library(FOUNDATION_LIBRARY Foundation)
endif()
## Sources
set(serial_SRCS
serial/src/serial.cc
serial/include/serial/serial.h
serial/include/serial/v8stdint.h
)
if(APPLE)
# If OSX
list(APPEND serial_SRCS serial/src/impl/unix.cc)
list(APPEND serial_SRCS serial/src/impl/list_ports/list_ports_osx.cc)
elseif(UNIX)
# If unix
list(APPEND serial_SRCS serial/src/impl/unix.cc)
list(APPEND serial_SRCS serial/src/impl/list_ports/list_ports_linux.cc)
else()
# If windows
list(APPEND serial_SRCS serial/src/impl/win.cc)
list(APPEND serial_SRCS serial/src/impl/list_ports/list_ports_win.cc)
endif()
## Add serial library
add_library(serial ${serial_SRCS})
if(APPLE)
target_link_libraries(serial ${FOUNDATION_LIBRARY} ${IOKIT_LIBRARY})
elseif(UNIX)
target_link_libraries(serial rt pthread)
else()
target_link_libraries(serial setupapi)
endif()
## Include headers
include_directories(serial/include)
include_directories (${GTK3_INCLUDE_DIRS})
## SerialPortTool
file(GLOB SerialPortTool_SRCS "${CMAKE_SOURCE_DIR}/sptsrc/*.cpp" "${CMAKE_SOURCE_DIR}/sptsrc/*.h")
add_executable(${PROJECT_NAME} ${SerialPortTool_SRCS})
add_dependencies(${PROJECT_NAME} serial)
target_link_libraries(${PROJECT_NAME} serial)
add_definitions (${GTK3_CFLAGS_OTHER})
target_link_libraries(${PROJECT_NAME} ${GTK3_LIBRARIES})
# Install
if(UNIX)
set(CMAKE_INSTALL_PREFIX /usr/local)
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/SerialPortToolGUI.ui DESTINATION bin)
elseif(WIN32)
set(CMAKE_INSTALL_PREFIX "C:/Program Files (x86)/")
install(TARGETS ${PROJECT_NAME} DESTINATION SerialPortTool)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/SerialPortToolGUI.ui DESTINATION SerialPortTool)
endif()