-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
70 lines (56 loc) · 2.53 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
# EU-tire-label - CMakeLists.txt
# Copyright (c) 2015-2021 Arkadiusz Bokowy
cmake_minimum_required(VERSION 3.2)
project(EU-tire-label
VERSION 2.0.0
LANGUAGES C)
option(ENABLE_CGI "Enable Common Gateway Interface (CGI) support." OFF)
option(ENABLE_PNG "Enable SVG rasterisation support (PNG output)." OFF)
if(ENABLE_PNG)
find_package(PkgConfig REQUIRED)
pkg_check_modules(rSVG REQUIRED IMPORTED_TARGET librsvg-2.0)
endif()
add_executable(label2array
${CMAKE_CURRENT_SOURCE_DIR}/src/label2array.c)
set(SOURCE_LABEL_EC_1222_2009 ${CMAKE_CURRENT_SOURCE_DIR}/src/label-EC-1222-2009.svg)
set(GENERATED_LABEL_EC_1222_2009 ${CMAKE_CURRENT_BINARY_DIR}/label_EC_1222_2009-template.h)
add_custom_command(
DEPENDS label2array ${SOURCE_LABEL_EC_1222_2009}
COMMAND label2array label_EC_1222_2009_template ${SOURCE_LABEL_EC_1222_2009} > ${GENERATED_LABEL_EC_1222_2009}
OUTPUT ${GENERATED_LABEL_EC_1222_2009})
set(SOURCE_LABEL_EU_2020_740 ${CMAKE_CURRENT_SOURCE_DIR}/src/label-EU-2020-740.svg)
set(GENERATED_LABEL_EU_2020_740 ${CMAKE_CURRENT_BINARY_DIR}/label_EU_2020_740-template.h)
add_custom_command(
DEPENDS label2array ${SOURCE_LABEL_EU_2020_740}
COMMAND label2array label_EU_2020_740_template ${SOURCE_LABEL_EU_2020_740} > ${GENERATED_LABEL_EU_2020_740}
OUTPUT ${GENERATED_LABEL_EU_2020_740})
set(DOWNLOADED_QRCODE_C_PATH ${CMAKE_CURRENT_BINARY_DIR}/qrcode.c)
set(DOWNLOADED_QRCODE_H_PATH ${CMAKE_CURRENT_BINARY_DIR}/qrcode.h)
if (NOT EXISTS ${DOWNLOADED_QRCODE_C_PATH})
message(STATUS "Downloading QRCode library")
file(DOWNLOAD https://github.com/ricmoo/QRCode/raw/master/src/qrcode.c ${DOWNLOADED_QRCODE_C_PATH})
file(DOWNLOAD https://github.com/ricmoo/QRCode/raw/master/src/qrcode.h ${DOWNLOADED_QRCODE_H_PATH})
message(STATUS "Downloading QRCode library - done")
endif()
add_executable(eu-tire-label
${GENERATED_LABEL_EC_1222_2009}
${GENERATED_LABEL_EU_2020_740}
${DOWNLOADED_QRCODE_C_PATH}
${CMAKE_CURRENT_SOURCE_DIR}/src/label.c
${CMAKE_CURRENT_SOURCE_DIR}/src/main.c)
set_target_properties(eu-tire-label
PROPERTIES C_STANDARD 99)
target_include_directories(eu-tire-label
PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_compile_definitions(eu-tire-label
PRIVATE -DVERSION="${PROJECT_VERSION}")
if(ENABLE_CGI)
target_compile_definitions(eu-tire-label PRIVATE -DENABLE_CGI=1)
endif()
if(ENABLE_PNG)
target_compile_definitions(eu-tire-label PRIVATE -DENABLE_PNG=1)
target_sources(eu-tire-label PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/raster.c)
target_link_libraries(eu-tire-label PkgConfig::rSVG)
endif()
install(TARGETS eu-tire-label
RUNTIME DESTINATION bin)