-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCMakeLists.txt
103 lines (81 loc) · 2.66 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
cmake_minimum_required (VERSION 3.10.0)
project (jrk2)
set (CLI_NAME "jrk2cmd")
set (GUI_NAME "jrk2gui")
set (LIB_NAME "pololu-jrk2")
set (DOCUMENTATION_URL "https://www.pololu.com/docs/0J73")
set (SOFTWARE_VERSION_MAJOR 1)
set (SOFTWARE_VERSION_MINOR 4)
set (SOFTWARE_VERSION_PATCH 1)
option (BUILD_SHARED_LIBS "Build a shared library" TRUE)
if (NOT BUILD_SHARED_LIBS)
add_definitions (-DJRK_STATIC)
endif ()
set(ENABLE_GUI TRUE CACHE BOOL
"True if you want to build the GUI, which depends on Qt 5.")
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE "Release" CACHE STRING
"Options are Debug Release RelWithDebInfo MinSizeRel" FORCE)
endif ()
if (EXISTS "${CMAKE_SOURCE_DIR}/images/app.icns")
set (POLOLU_BUILD TRUE)
endif ()
if (EXISTS "${CMAKE_SOURCE_DIR}/images/app.ico")
set (POLOLU_BUILD TRUE)
endif ()
set (SOFTWARE_VERSION ${SOFTWARE_VERSION_MAJOR}.${SOFTWARE_VERSION_MINOR}.${SOFTWARE_VERSION_PATCH})
string(TIMESTAMP YEAR "%Y")
find_package(PkgConfig)
# Our C code uses features from the C99 standard.
macro(use_c99)
if (CMAKE_VERSION VERSION_LESS "3.1")
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
set (CMAKE_C_FLAGS "--std=gnu99 ${CMAKE_C_FLAGS}")
endif ()
else ()
set (CMAKE_C_STANDARD 99)
endif ()
endmacro(use_c99)
# Our C++ code uses features from the C++11 standard.
macro(use_cxx11)
if (CMAKE_VERSION VERSION_LESS "3.1")
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
set (CMAKE_CXX_FLAGS "--std=gnu++11 ${CMAKE_CXX_FLAGS}")
endif ()
else ()
set (CMAKE_CXX_STANDARD 11)
endif ()
endmacro(use_cxx11)
# Put libraries and executables in the top level of the build directory
# so that the executables can find the libraries and it is easy to run
# everything.
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
if (WIN32)
# Enable correct behavior for the return value of vsnprintf.
add_definitions (-D__USE_MINGW_ANSI_STDIO=1)
# Enable functions only available in Windows Vista and later.
add_definitions (-D_WIN32_WINNT=0x0600 -DNTDDI_VERSION=0x06000000)
endif ()
# Detect Linux.
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
set (LINUX TRUE)
endif ()
include_directories (
"${CMAKE_SOURCE_DIR}/include"
"${CMAKE_BINARY_DIR}/include"
)
configure_file (
"include/config.h.in"
"include/config.h"
)
file(WRITE "${CMAKE_BINARY_DIR}/version.txt" "${SOFTWARE_VERSION}")
add_subdirectory (lib)
add_subdirectory (cli)
add_subdirectory (bootloader)
if (ENABLE_GUI)
add_subdirectory (gui)
endif ()
# Install the header files into include/
install(FILES include/jrk.h include/jrk.hpp include/jrk_protocol.h
DESTINATION "include/lib${LIB_NAME}-${SOFTWARE_VERSION_MAJOR}")