blob: bba1a01ef3aef62c2b3106bea996d7cc4d22c524 (
plain)
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
|
cmake_minimum_required(VERSION 3.16)
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
# This needs to come before project() to skip the compiler config process
if ("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
message(FATAL_ERROR "In-source builds are disabled.
Please create a subfolder and use `cmake ..` inside it.
NOTE: cmake will now create CMakeCache.txt and CMakeFiles/*.
You must delete them, or cmake will refuse to work.")
endif() # yes, end-markers and even else() need empty parentheses
project(lan7800-led-ctl LANGUAGES C)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
set(CMAKE_INSTALL_PREFIX /usr)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_VERBOSE_MAKEFILE ON)
find_package(PkgConfig REQUIRED)
pkg_check_modules(libusb REQUIRED libusb-1.0)
set(HEADERS
include/lan7800-led-ctl.h
)
add_executable(${PROJECT_NAME}
${HEADERS}
)
target_include_directories(${PROJECT_NAME} PUBLIC
${CMAKE_BINARY_DIR} # HB9HEI - location of generated version.h
${CMAKE_SOURCE_DIR}/include
)
target_link_libraries(${PROJECT_NAME} PRIVATE
usb-1.0
)
target_sources(${PROJECT_NAME} PRIVATE
src/lan7800-led-ctl.c
)
add_dependencies(${PROJECT_NAME}
git-version
)
target_compile_options(${PROJECT_NAME} PUBLIC
-g
-Os
-std=c11
-fstack-protector-strong
-Wall
-Wextra
-Werror
-Wstrict-prototypes
-Wconversion
-Wmissing-prototypes
-Wshadow
-Wunused
)
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
# HB9HEI - custom target that produces version.h (req. cmake 3.0)
add_custom_target(git-version ALL
${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/gitversion.cmake
)
|