-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
92 lines (70 loc) · 2.43 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
cmake_minimum_required (VERSION 3.10.0)
project (pavr2)
set(ENABLE_GUI TRUE CACHE BOOL
"True if you want to build the GUI, which depends on Qt 5.")
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 (CLI_NAME "pavr2cmd")
set (GUI_NAME "pavr2gui")
set (DOCUMENTATION_URL "https://www.pololu.com/docs/0J67")
set (SOFTWARE_VERSION_MAJOR 1)
set (SOFTWARE_VERSION_MINOR 1)
set (SOFTWARE_VERSION_PATCH 1)
set (SOFTWARE_VERSION ${SOFTWARE_VERSION_MAJOR}.${SOFTWARE_VERSION_MINOR}.${SOFTWARE_VERSION_PATCH})
string(TIMESTAMP YEAR "%Y")
find_package(PkgConfig)
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE "Release" CACHE STRING
"Options are Debug Release RelWithDebInfo MinSizeRel" FORCE)
endif ()
# 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})
# Warn about everything.
set (CMAKE_C_FLAGS "-Wall -Wextra ${CMAKE_C_FLAGS}")
set (CMAKE_CXX_FLAGS "-Wall -Wextra ${CMAKE_CXX_FLAGS}")
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 1)
endif ()
# Find libusbp and use it.
pkg_check_modules(LIBUSBP REQUIRED libusbp-1)
string (REPLACE ";" " " LIBUSBP_CFLAGS "${LIBUSBP_CFLAGS}")
string (REPLACE ";" " " LIBUSBP_LDFLAGS "${LIBUSBP_LDFLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBUSBP_CFLAGS}")
include_directories (
"${CMAKE_SOURCE_DIR}/include"
"${CMAKE_BINARY_DIR}/include"
)
configure_file (
"include/pavrpgm_config.h.in"
"include/pavrpgm_config.h"
)
file(WRITE "${CMAKE_BINARY_DIR}/version.txt" "${SOFTWARE_VERSION}")
add_subdirectory (lib)
add_subdirectory (cli)
if (ENABLE_GUI)
add_subdirectory (gui)
endif ()