forked from zxing-cpp/zxing-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
128 lines (105 loc) · 3.67 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
cmake_minimum_required (VERSION 3.10)
project (ZXing VERSION "1.1.1" LANGUAGES CXX)
option (BUILD_WRITERS "Build with writer support (encoders)" ON)
option (BUILD_READERS "Build with reader support (decoders)" ON)
option (BUILD_EXAMPLES "Build the example barcode reader/writer applicatons" ON)
option (BUILD_BLACKBOX_TESTS "Build the black box reader/writer tests" ON)
option (BUILD_UNIT_TESTS "Build the unit tests (don't enable for production builds)" OFF)
option (BUILD_PYTHON_MODULE "Build the python module" OFF)
if (WIN32)
option (BUILD_SHARED_LIBS "Build and link as shared library" OFF)
else()
option (BUILD_SHARED_LIBS "Build and link as shared library" ON)
endif()
if (MSVC)
option (LINK_CPP_STATICALLY "MSVC only, link standard library statically (/MT and /MTd)" OFF)
add_definitions (-DUNICODE -D_UNICODE)
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Oi /GS-")
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GS-")
if (LINK_CPP_STATICALLY)
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
endif()
endif()
if (NOT CMAKE_BUILD_TYPE)
set (DEFAULT_BUILD_TYPE "Release")
message (STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.")
set (CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE)
set_property (CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
if (BUILD_SHARED_LIBS)
set (CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif()
set (CMAKE_CXX_STANDARD 17)
set (CMAKE_CXX_EXTENSIONS OFF)
if (BUILD_UNIT_TESTS)
add_definitions (-DZXING_BUILD_FOR_TEST)
if (NOT BUILD_WRITERS OR NOT BUILD_READERS)
message("Note: To build with unit tests, the library will be build with READERS and WRITERS.")
set (BUILD_WRITERS ON)
set (BUILD_READERS ON)
endif()
endif()
add_subdirectory (core)
enable_testing()
if (BUILD_EXAMPLES)
add_subdirectory (example)
endif()
if (BUILD_BLACKBOX_TESTS)
add_subdirectory (test/blackbox)
endif()
if (BUILD_UNIT_TESTS)
add_subdirectory (test/unit)
endif()
if (BUILD_PYTHON_MODULE)
add_subdirectory (wrappers/python)
endif()
if (WIN32)
add_subdirectory (wrappers/gdiplus)
endif()
set (CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/ZXing")
install (
EXPORT ZXingTargets
DESTINATION ${CMAKECONFIG_INSTALL_DIR} NAMESPACE ZXing::
)
install (
DIRECTORY core/src/
DESTINATION include/ZXing
FILES_MATCHING PATTERN "*.h"
)
configure_file (
core/ZXVersion.h.in
ZXVersion.h
)
install (
FILES "${CMAKE_CURRENT_BINARY_DIR}/ZXVersion.h"
DESTINATION include/ZXing
)
# PC file generation.
if (NOT DEFINED INSTALLDIR)
set (INSTALLDIR ${CMAKE_INSTALL_PREFIX})
get_filename_component(INSTALLDIR ${INSTALLDIR} ABSOLUTE)
endif()
IF (NOT WIN32)
configure_file(zxing.pc.in zxing.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/zxing.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
ENDIF()
include (CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/ZXingConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
configure_package_config_file (
core/ZXingConfig.cmake.in
ZXingConfig.cmake
INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}
)
install (
FILES
"${CMAKE_CURRENT_BINARY_DIR}/ZXingConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/ZXingConfigVersion.cmake"
DESTINATION ${CMAKECONFIG_INSTALL_DIR}
)