| 1 | From 283d6a4bae95f42aaccd9ddd06d16c2e33ed4abf Mon Sep 17 00:00:00 2001
|
| 2 | From: Vitaly Zaitsev <[email protected]>
|
| 3 | Date: Thu, 21 Apr 2022 15:36:23 +0200
|
| 4 | Subject: [PATCH 1/2] Implemented CMake build support.
|
| 5 |
|
| 6 | Co-authored-by: leha-bot <[email protected]>
|
| 7 | Signed-off-by: Vitaly Zaitsev <[email protected]>
|
| 8 | ---
|
| 9 | CMakeLists.txt | 235 +++++++++++++++++++++++++++++
|
| 10 | c/Makefile | 88 -----------
|
| 11 | cmake/qrcodegen-config.cmake.in | 4 +
|
| 12 | cmake/qrcodegen.pc.in | 11 ++
|
| 13 | cmake/qrcodegencpp-config.cmake.in | 4 +
|
| 14 | cmake/qrcodegencpp.pc.in | 11 ++
|
| 15 | cpp/Makefile | 84 -----------
|
| 16 | 7 files changed, 265 insertions(+), 172 deletions(-)
|
| 17 | create mode 100644 CMakeLists.txt
|
| 18 | delete mode 100644 c/Makefile
|
| 19 | create mode 100644 cmake/qrcodegen-config.cmake.in
|
| 20 | create mode 100644 cmake/qrcodegen.pc.in
|
| 21 | create mode 100644 cmake/qrcodegencpp-config.cmake.in
|
| 22 | create mode 100644 cmake/qrcodegencpp.pc.in
|
| 23 | delete mode 100644 cpp/Makefile
|
| 24 |
|
| 25 | diff --git a/CMakeLists.txt b/CMakeLists.txt
|
| 26 | new file mode 100644
|
| 27 | index 0000000..b07197f
|
| 28 | |
| 29 | |
| 30 | @@ -0,0 +1,235 @@
|
| 31 | +# ==============================
|
| 32 | +# === Project initialization ===
|
| 33 | +# ==============================
|
| 34 | +
|
| 35 | +cmake_minimum_required(VERSION 3.12)
|
| 36 | +
|
| 37 | +project(QR-Code-generator
|
| 38 | + VERSION 1.8.0
|
| 39 | + DESCRIPTION "High-quality QR Code generator library in Java, TypeScript/JavaScript, Python, C++, C, Rust"
|
| 40 | + HOMEPAGE_URL "https://www.nayuki.io/page/qr-code-generator-library"
|
| 41 | + LANGUAGES C CXX
|
| 42 | +)
|
| 43 | +
|
| 44 | +set(CMAKE_CXX_STANDARD 11)
|
| 45 | +set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
| 46 | +
|
| 47 | +# =======================
|
| 48 | +# === Project options ===
|
| 49 | +# =======================
|
| 50 | +
|
| 51 | +option(BUILD_EXAMPLES "Build examples and demos" OFF)
|
| 52 | +option(BUILD_TESTS "Build and run unit tests" OFF)
|
| 53 | +
|
| 54 | +# =======================
|
| 55 | +# === Paths detection ===
|
| 56 | +# =======================
|
| 57 | +
|
| 58 | +include(GNUInstallDirs)
|
| 59 | +
|
| 60 | +# ============================
|
| 61 | +# === CMake config helpers ===
|
| 62 | +# ============================
|
| 63 | +
|
| 64 | +include(CMakePackageConfigHelpers)
|
| 65 | +
|
| 66 | +# ========================
|
| 67 | +# === C library target ===
|
| 68 | +# ========================
|
| 69 | +
|
| 70 | +set(QRCODEGEN_NAME "qrcodegen")
|
| 71 | +
|
| 72 | +set(QRCODEGEN_SOURCES
|
| 73 | + c/qrcodegen.c
|
| 74 | +)
|
| 75 | +
|
| 76 | +set(QRCODEGEN_HEADERS
|
| 77 | + c/qrcodegen.h
|
| 78 | +)
|
| 79 | +
|
| 80 | +add_library(${QRCODEGEN_NAME}
|
| 81 | + ${QRCODEGEN_SOURCES}
|
| 82 | + ${QRCODEGEN_HEADERS}
|
| 83 | +)
|
| 84 | +
|
| 85 | +target_include_directories(${QRCODEGEN_NAME} PUBLIC
|
| 86 | + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/c>
|
| 87 | + $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${QRCODEGEN_NAME}>
|
| 88 | +)
|
| 89 | +
|
| 90 | +set_property(TARGET ${QRCODEGEN_NAME} PROPERTY PUBLIC_HEADER ${QRCODEGEN_HEADERS})
|
| 91 | +set_property(TARGET ${QRCODEGEN_NAME} PROPERTY VERSION ${CMAKE_PROJECT_VERSION})
|
| 92 | +set_property(TARGET ${QRCODEGEN_NAME} PROPERTY SOVERSION 1)
|
| 93 | +
|
| 94 | +install(TARGETS ${QRCODEGEN_NAME}
|
| 95 | + EXPORT ${QRCODEGEN_NAME}-targets
|
| 96 | + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
| 97 | + BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}
|
| 98 | + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${QRCODEGEN_NAME}
|
| 99 | +)
|
| 100 | +
|
| 101 | +configure_package_config_file(cmake/${QRCODEGEN_NAME}-config.cmake.in
|
| 102 | + ${QRCODEGEN_NAME}-config.cmake
|
| 103 | + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${QRCODEGEN_NAME}
|
| 104 | +)
|
| 105 | +write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${QRCODEGEN_NAME}-config-version.cmake
|
| 106 | + COMPATIBILITY ExactVersion
|
| 107 | +)
|
| 108 | +
|
| 109 | +install(FILES
|
| 110 | + ${CMAKE_CURRENT_BINARY_DIR}/${QRCODEGEN_NAME}-config.cmake
|
| 111 | + ${CMAKE_CURRENT_BINARY_DIR}/${QRCODEGEN_NAME}-config-version.cmake
|
| 112 | + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${QRCODEGEN_NAME}
|
| 113 | +)
|
| 114 | +
|
| 115 | +install(EXPORT ${QRCODEGEN_NAME}-targets
|
| 116 | + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${QRCODEGEN_NAME}
|
| 117 | + NAMESPACE ${QRCODEGEN_NAME}::
|
| 118 | +)
|
| 119 | +
|
| 120 | +configure_file(cmake/${QRCODEGEN_NAME}.pc.in
|
| 121 | + ${CMAKE_CURRENT_BINARY_DIR}/${QRCODEGEN_NAME}.pc
|
| 122 | + @ONLY
|
| 123 | +)
|
| 124 | +
|
| 125 | +install(FILES
|
| 126 | + ${CMAKE_CURRENT_BINARY_DIR}/${QRCODEGEN_NAME}.pc
|
| 127 | + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
|
| 128 | +)
|
| 129 | +
|
| 130 | +# =========================
|
| 131 | +# === C examples target ===
|
| 132 | +# =========================
|
| 133 | +
|
| 134 | +if(BUILD_EXAMPLES)
|
| 135 | + set(QRCODEGENDEMO_SOURCES
|
| 136 | + c/qrcodegen-demo.c
|
| 137 | + )
|
| 138 | +
|
| 139 | + add_executable(${QRCODEGEN_NAME}-demo
|
| 140 | + ${QRCODEGENDEMO_SOURCES}
|
| 141 | + )
|
| 142 | +
|
| 143 | + target_link_libraries(${QRCODEGEN_NAME}-demo PRIVATE
|
| 144 | + ${QRCODEGEN_NAME}
|
| 145 | + )
|
| 146 | +endif()
|
| 147 | +
|
| 148 | +# ======================
|
| 149 | +# === C tests target ===
|
| 150 | +# ======================
|
| 151 | +
|
| 152 | +if (BUILD_TESTS)
|
| 153 | + set(QRCODEGENTEST_SOURCES
|
| 154 | + c/qrcodegen-test.c
|
| 155 | + )
|
| 156 | +
|
| 157 | + add_library(${QRCODEGEN_NAME}-testable OBJECT
|
| 158 | + ${QRCODEGEN_SOURCES}
|
| 159 | + ${QRCODEGEN_HEADERS}
|
| 160 | + )
|
| 161 | +
|
| 162 | + target_compile_options(${QRCODEGEN_NAME}-testable PUBLIC
|
| 163 | + -DQRCODEGEN_TEST
|
| 164 | + )
|
| 165 | +
|
| 166 | + add_executable(${QRCODEGEN_NAME}-test
|
| 167 | + ${QRCODEGENTEST_SOURCES}
|
| 168 | + )
|
| 169 | +
|
| 170 | + target_link_libraries(${QRCODEGEN_NAME}-test PRIVATE
|
| 171 | + ${QRCODEGEN_NAME}-testable
|
| 172 | + )
|
| 173 | +
|
| 174 | + add_test(NAME ${QRCODEGEN_NAME}-test COMMAND ${QRCODEGEN_NAME}-test)
|
| 175 | +endif()
|
| 176 | +
|
| 177 | +# ==========================
|
| 178 | +# === C++ library target ===
|
| 179 | +# ==========================
|
| 180 | +
|
| 181 | +set(QRCODEGENCPP_NAME "qrcodegencpp")
|
| 182 | +
|
| 183 | +set(QRCODEGENCPP_SOURCES
|
| 184 | + cpp/qrcodegen.cpp
|
| 185 | +)
|
| 186 | +
|
| 187 | +set(QRCODEGENCPP_HEADERS
|
| 188 | + cpp/qrcodegen.hpp
|
| 189 | +)
|
| 190 | +
|
| 191 | +add_library(${QRCODEGENCPP_NAME}
|
| 192 | + ${QRCODEGENCPP_SOURCES}
|
| 193 | + ${QRCODEGENCPP_HEADERS}
|
| 194 | +)
|
| 195 | +
|
| 196 | +target_include_directories(${QRCODEGENCPP_NAME} PUBLIC
|
| 197 | + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cpp>
|
| 198 | + $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${QRCODEGENCPP_NAME}>
|
| 199 | +)
|
| 200 | +
|
| 201 | +set_property(TARGET ${QRCODEGENCPP_NAME} PROPERTY PUBLIC_HEADER ${QRCODEGENCPP_HEADERS})
|
| 202 | +set_property(TARGET ${QRCODEGENCPP_NAME} PROPERTY VERSION ${CMAKE_PROJECT_VERSION})
|
| 203 | +set_property(TARGET ${QRCODEGENCPP_NAME} PROPERTY SOVERSION 1)
|
| 204 | +
|
| 205 | +install(TARGETS ${QRCODEGENCPP_NAME}
|
| 206 | + EXPORT ${QRCODEGENCPP_NAME}-targets
|
| 207 | + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
| 208 | + BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}
|
| 209 | + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${QRCODEGENCPP_NAME}
|
| 210 | +)
|
| 211 | +
|
| 212 | +configure_package_config_file(cmake/${QRCODEGENCPP_NAME}-config.cmake.in
|
| 213 | + ${QRCODEGENCPP_NAME}-config.cmake
|
| 214 | + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${QRCODEGENCPP_NAME}
|
| 215 | +)
|
| 216 | +write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${QRCODEGENCPP_NAME}-config-version.cmake
|
| 217 | + COMPATIBILITY ExactVersion
|
| 218 | +)
|
| 219 | +
|
| 220 | +install(FILES
|
| 221 | + ${CMAKE_CURRENT_BINARY_DIR}/${QRCODEGENCPP_NAME}-config.cmake
|
| 222 | + ${CMAKE_CURRENT_BINARY_DIR}/${QRCODEGENCPP_NAME}-config-version.cmake
|
| 223 | + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${QRCODEGENCPP_NAME}
|
| 224 | +)
|
| 225 | +
|
| 226 | +install(EXPORT ${QRCODEGENCPP_NAME}-targets
|
| 227 | + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${QRCODEGENCPP_NAME}
|
| 228 | + NAMESPACE ${QRCODEGENCPP_NAME}::
|
| 229 | +)
|
| 230 | +
|
| 231 | +configure_file(cmake/${QRCODEGENCPP_NAME}.pc.in
|
| 232 | + ${CMAKE_CURRENT_BINARY_DIR}/${QRCODEGENCPP_NAME}.pc
|
| 233 | + @ONLY
|
| 234 | +)
|
| 235 | +
|
| 236 | +install(FILES
|
| 237 | + ${CMAKE_CURRENT_BINARY_DIR}/${QRCODEGENCPP_NAME}.pc
|
| 238 | + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
|
| 239 | +)
|
| 240 | +
|
| 241 | +# ===========================
|
| 242 | +# === C++ examples target ===
|
| 243 | +# ===========================
|
| 244 | +
|
| 245 | +if(BUILD_EXAMPLES)
|
| 246 | + set(QRCODEGENCPPDEMO_SOURCES
|
| 247 | + cpp/QrCodeGeneratorDemo.cpp
|
| 248 | + )
|
| 249 | +
|
| 250 | + add_executable(${QRCODEGENCPP_NAME}-demo
|
| 251 | + ${QRCODEGENCPPDEMO_SOURCES}
|
| 252 | + )
|
| 253 | +
|
| 254 | + target_link_libraries(${QRCODEGENCPP_NAME}-demo PRIVATE
|
| 255 | + ${QRCODEGENCPP_NAME}
|
| 256 | + )
|
| 257 | +endif()
|
| 258 | +
|
| 259 | +# ====================
|
| 260 | +# === Tests export ===
|
| 261 | +# ====================
|
| 262 | +
|
| 263 | +if (BUILD_TESTS)
|
| 264 | + enable_testing()
|
| 265 | +endif()
|
| 266 | diff --git a/c/Makefile b/c/Makefile
|
| 267 | deleted file mode 100644
|
| 268 | index 661b1f7..0000000
|
| 269 | |
| 270 | |
| 271 | @@ -1,88 +0,0 @@
|
| 272 | -#
|
| 273 | -# Makefile for QR Code generator (C)
|
| 274 | -#
|
| 275 | -# Copyright (c) Project Nayuki. (MIT License)
|
| 276 | -# https://www.nayuki.io/page/qr-code-generator-library
|
| 277 | -#
|
| 278 | -# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
| 279 | -# this software and associated documentation files (the "Software"), to deal in
|
| 280 | -# the Software without restriction, including without limitation the rights to
|
| 281 | -# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
| 282 | -# the Software, and to permit persons to whom the Software is furnished to do so,
|
| 283 | -# subject to the following conditions:
|
| 284 | -# - The above copyright notice and this permission notice shall be included in
|
| 285 | -# all copies or substantial portions of the Software.
|
| 286 | -# - The Software is provided "as is", without warranty of any kind, express or
|
| 287 | -# implied, including but not limited to the warranties of merchantability,
|
| 288 | -# fitness for a particular purpose and noninfringement. In no event shall the
|
| 289 | -# authors or copyright holders be liable for any claim, damages or other
|
| 290 | -# liability, whether in an action of contract, tort or otherwise, arising from,
|
| 291 | -# out of or in connection with the Software or the use or other dealings in the
|
| 292 | -# Software.
|
| 293 | -#
|
| 294 | -
|
| 295 | -
|
| 296 | -# ---- Configuration options ----
|
| 297 | -
|
| 298 | -# External/implicit variables:
|
| 299 | -# - CC: The C compiler, such as gcc or clang.
|
| 300 | -# - CFLAGS: Any extra user-specified compiler flags (can be blank).
|
| 301 | -
|
| 302 | -# Recommended compiler flags:
|
| 303 | -CFLAGS += -std=c99 -O
|
| 304 | -
|
| 305 | -# Extra flags for diagnostics:
|
| 306 | -# CFLAGS += -g -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -fsanitize=undefined,address
|
| 307 | -
|
| 308 | -
|
| 309 | -# ---- Controlling make ----
|
| 310 | -
|
| 311 | -# Clear default suffix rules
|
| 312 | -.SUFFIXES:
|
| 313 | -
|
| 314 | -# Don't delete object files
|
| 315 | -.SECONDARY:
|
| 316 | -
|
| 317 | -# Stuff concerning goals
|
| 318 | -.DEFAULT_GOAL = all
|
| 319 | -.PHONY: all clean
|
| 320 | -
|
| 321 | -
|
| 322 | -# ---- Targets to build ----
|
| 323 | -
|
| 324 | -LIB = qrcodegen
|
| 325 | -LIBFILE = lib$(LIB).a
|
| 326 | -LIBOBJ = qrcodegen.o
|
| 327 | -MAINS = qrcodegen-demo qrcodegen-test
|
| 328 | -
|
| 329 | -# Build all binaries
|
| 330 | -all: $(LIBFILE) $(MAINS)
|
| 331 | -
|
| 332 | -# Delete build output
|
| 333 | -clean:
|
| 334 | - rm -f -- $(LIBOBJ) $(LIBFILE) $(MAINS:=.o) $(MAINS)
|
| 335 | - rm -rf .deps
|
| 336 | -
|
| 337 | -# Executable files
|
| 338 | -%: %.o $(LIBFILE)
|
| 339 | - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -L . -l $(LIB)
|
| 340 | -
|
| 341 | -# Special executable
|
| 342 | -qrcodegen-test: qrcodegen-test.c $(LIBOBJ:%.o=%.c)
|
| 343 | - $(CC) $(CFLAGS) $(LDFLAGS) -DQRCODEGEN_TEST -o $@ $^
|
| 344 | -
|
| 345 | -# The library
|
| 346 | -$(LIBFILE): $(LIBOBJ)
|
| 347 | - $(AR) -crs $@ -- $^
|
| 348 | -
|
| 349 | -# Object files
|
| 350 | -%.o: %.c .deps/timestamp
|
| 351 | - $(CC) $(CFLAGS) -c -o $@ -MMD -MF .deps/$*.d $<
|
| 352 | -
|
| 353 | -# Have a place to store header dependencies automatically generated by compiler
|
| 354 | -.deps/timestamp:
|
| 355 | - mkdir -p .deps
|
| 356 | - touch .deps/timestamp
|
| 357 | -
|
| 358 | -# Make use of said dependencies if available
|
| 359 | --include .deps/*.d
|
| 360 | diff --git a/cmake/qrcodegen-config.cmake.in b/cmake/qrcodegen-config.cmake.in
|
| 361 | new file mode 100644
|
| 362 | index 0000000..0b82c63
|
| 363 | |
| 364 | |
| 365 | @@ -0,0 +1,4 @@
|
| 366 | +@PACKAGE_INIT@
|
| 367 | +
|
| 368 | +include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
|
| 369 | +check_required_components(@QRCODEGEN_NAME@)
|
| 370 | diff --git a/cmake/qrcodegen.pc.in b/cmake/qrcodegen.pc.in
|
| 371 | new file mode 100644
|
| 372 | index 0000000..c68955b
|
| 373 | |
| 374 | |
| 375 | @@ -0,0 +1,11 @@
|
| 376 | +prefix=@CMAKE_INSTALL_PREFIX@
|
| 377 | +exec_prefix=${prefix}
|
| 378 | +libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
|
| 379 | +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@/@QRCODEGEN_NAME@
|
| 380 | +
|
| 381 | +Name: @QRCODEGEN_NAME@
|
| 382 | +Description: @CMAKE_PROJECT_DESCRIPTION@
|
| 383 | +Version: @CMAKE_PROJECT_VERSION@
|
| 384 | +
|
| 385 | +Libs: -L${libdir} -l@QRCODEGEN_NAME@
|
| 386 | +Cflags: -I${includedir}
|
| 387 | diff --git a/cmake/qrcodegencpp-config.cmake.in b/cmake/qrcodegencpp-config.cmake.in
|
| 388 | new file mode 100644
|
| 389 | index 0000000..3d18f99
|
| 390 | |
| 391 | |
| 392 | @@ -0,0 +1,4 @@
|
| 393 | +@PACKAGE_INIT@
|
| 394 | +
|
| 395 | +include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
|
| 396 | +check_required_components(@QRCODEGENCPP_NAME@)
|
| 397 | diff --git a/cmake/qrcodegencpp.pc.in b/cmake/qrcodegencpp.pc.in
|
| 398 | new file mode 100644
|
| 399 | index 0000000..89db084
|
| 400 | |
| 401 | |
| 402 | @@ -0,0 +1,11 @@
|
| 403 | +prefix=@CMAKE_INSTALL_PREFIX@
|
| 404 | +exec_prefix=${prefix}
|
| 405 | +libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
|
| 406 | +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@/@QRCODEGENCPP_NAME@
|
| 407 | +
|
| 408 | +Name: @QRCODEGENCPP_NAME@
|
| 409 | +Description: @CMAKE_PROJECT_DESCRIPTION@
|
| 410 | +Version: @CMAKE_PROJECT_VERSION@
|
| 411 | +
|
| 412 | +Libs: -L${libdir} -l@QRCODEGENCPP_NAME@
|
| 413 | +Cflags: -I${includedir}
|
| 414 | diff --git a/cpp/Makefile b/cpp/Makefile
|
| 415 | deleted file mode 100644
|
| 416 | index 57dc0bf..0000000
|
| 417 | |
| 418 | |
| 419 | @@ -1,84 +0,0 @@
|
| 420 | -#
|
| 421 | -# Makefile for QR Code generator (C++)
|
| 422 | -#
|
| 423 | -# Copyright (c) Project Nayuki. (MIT License)
|
| 424 | -# https://www.nayuki.io/page/qr-code-generator-library
|
| 425 | -#
|
| 426 | -# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
| 427 | -# this software and associated documentation files (the "Software"), to deal in
|
| 428 | -# the Software without restriction, including without limitation the rights to
|
| 429 | -# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
| 430 | -# the Software, and to permit persons to whom the Software is furnished to do so,
|
| 431 | -# subject to the following conditions:
|
| 432 | -# - The above copyright notice and this permission notice shall be included in
|
| 433 | -# all copies or substantial portions of the Software.
|
| 434 | -# - The Software is provided "as is", without warranty of any kind, express or
|
| 435 | -# implied, including but not limited to the warranties of merchantability,
|
| 436 | -# fitness for a particular purpose and noninfringement. In no event shall the
|
| 437 | -# authors or copyright holders be liable for any claim, damages or other
|
| 438 | -# liability, whether in an action of contract, tort or otherwise, arising from,
|
| 439 | -# out of or in connection with the Software or the use or other dealings in the
|
| 440 | -# Software.
|
| 441 | -#
|
| 442 | -
|
| 443 | -
|
| 444 | -# ---- Configuration options ----
|
| 445 | -
|
| 446 | -# External/implicit variables:
|
| 447 | -# - CXX: The C++ compiler, such as g++ or clang++.
|
| 448 | -# - CXXFLAGS: Any extra user-specified compiler flags (can be blank).
|
| 449 | -
|
| 450 | -# Recommended compiler flags:
|
| 451 | -CXXFLAGS += -std=c++11 -O
|
| 452 | -
|
| 453 | -# Extra flags for diagnostics:
|
| 454 | -# CXXFLAGS += -g -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -fsanitize=undefined,address
|
| 455 | -
|
| 456 | -
|
| 457 | -# ---- Controlling make ----
|
| 458 | -
|
| 459 | -# Clear default suffix rules
|
| 460 | -.SUFFIXES:
|
| 461 | -
|
| 462 | -# Don't delete object files
|
| 463 | -.SECONDARY:
|
| 464 | -
|
| 465 | -# Stuff concerning goals
|
| 466 | -.DEFAULT_GOAL = all
|
| 467 | -.PHONY: all clean
|
| 468 | -
|
| 469 | -
|
| 470 | -# ---- Targets to build ----
|
| 471 | -
|
| 472 | -LIB = qrcodegencpp
|
| 473 | -LIBFILE = lib$(LIB).a
|
| 474 | -LIBOBJ = qrcodegen.o
|
| 475 | -MAINS = QrCodeGeneratorDemo
|
| 476 | -
|
| 477 | -# Build all binaries
|
| 478 | -all: $(LIBFILE) $(MAINS)
|
| 479 | -
|
| 480 | -# Delete build output
|
| 481 | -clean:
|
| 482 | - rm -f -- $(LIBOBJ) $(LIBFILE) $(MAINS:=.o) $(MAINS)
|
| 483 | - rm -rf .deps
|
| 484 | -
|
| 485 | -# Executable files
|
| 486 | -%: %.o $(LIBFILE)
|
| 487 | - $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $< -L . -l $(LIB)
|
| 488 | -
|
| 489 | -# The library
|
| 490 | -$(LIBFILE): $(LIBOBJ)
|
| 491 | - $(AR) -crs $@ -- $^
|
| 492 | -
|
| 493 | -# Object files
|
| 494 | -%.o: %.cpp .deps/timestamp
|
| 495 | - $(CXX) $(CXXFLAGS) -c -o $@ -MMD -MF .deps/$*.d $<
|
| 496 | -
|
| 497 | -# Have a place to store header dependencies automatically generated by compiler
|
| 498 | -.deps/timestamp:
|
| 499 | - mkdir -p .deps
|
| 500 | - touch .deps/timestamp
|
| 501 | -
|
| 502 | -# Make use of said dependencies if available
|
| 503 | --include .deps/*.d
|
| 504 | --
|
| 505 | 2.41.0
|
| 506 |
|