-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
151 lines (125 loc) · 4.66 KB
/
CMakeLists.txt
File metadata and controls
151 lines (125 loc) · 4.66 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
cmake_minimum_required(VERSION 3.2)
project(QRencode VERSION 4.1.1 LANGUAGES C)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE PATH "" FORCE)
endif()
add_definitions(
-DSTATIC_IN_RELEASE=
-DQR_MAJOR_VERSION=4
-DQR_MINOR_VERSION=4
-DQR_MICRO_VERSION=1
-DQR_VERSION=4.4.1
-DHAVE_CONFIG_H=0)
option(WITH_TOOLS "Build utility tools" YES )
option(WITH_TESTS "Build tests" NO )
option(WITHOUT_PNG "Disable PNG support" NO)
option(GPROF "Generate extra code to write profile information" OFF)
option(COVERAGE "Generate extra code to write coverage information" OFF)
option(ASAN "Use AddressSanitizer" OFF)
option(BUILD_SHARED_LIBS "Enable build of shared libraries" NO)
if(BUILD_TESTING)
set(WITH_TESTS ON)
message(DEPRECATION "use WITH_TESTS option instead BUILD_TESTING")
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(CMAKE_THREAD_PREFER_PTHREAD ON)
find_package(Threads)
find_package(PNG)
find_package(Iconv)
if(CMAKE_USE_PTHREADS_INIT)
add_definitions(-DHAVE_LIBPTHREAD=1)
# for libqrencode.pc
set(LIBPTHREAD ${CMAKE_THREAD_LIBS_INIT})
endif()
## Check for system include files
include(CheckIncludeFile)
include(CheckFunctionExists)
check_include_file(dlfcn.h HAVE_DLFCN_H )
check_include_file(inttypes.h HAVE_INTTYPES_H)
check_include_file(memory.h HAVE_MEMORY_H )
check_include_file(stdint.h HAVE_STDINT_H )
check_include_file(stdlib.h HAVE_STDLIB_H )
check_include_file(strings.h HAVE_STRINGS_H )
check_include_file(string.h HAVE_STRING_H )
check_include_file(getopt.h HAVE_GETOPT_H )
check_include_file(sys/time.h HAVE_SYS_TIME_H)
check_include_file(time.h HAVE_TIME_H )
check_include_file(pthread.h HAVE_PTHREAD_H )
if(MSVC)
add_definitions(-DSTRDUP=_strdup)
else()
add_definitions(-DSTRDUP=strdup)
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
endif()
if(GPROF)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg")
endif()
if(COVERAGE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
endif()
if(ASAN)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls")
endif()
add_definitions(-DMAJOR_VERSION=${PROJECT_VERSION_MAJOR})
add_definitions(-DMINOR_VERSION=${PROJECT_VERSION_MINOR})
add_definitions(-DMICRO_VERSION=${PROJECT_VERSION_PATCH})
add_definitions(-DVERSION="${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
add_definitions(-DHAVE_SDL=0)
if(MSVC)
set(CMAKE_DEBUG_POSTFIX "d")
add_definitions(-Dstrcasecmp=_stricmp)
add_definitions(-Dstrncasecmp=_strnicmp)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
if(WITH_TOOLS)
find_path(GETOPT_INCLUDE_DIR getopt.h PATH_SUFFIXES include)
find_library(GETOPT_LIBRARIES getopt PATH_SUFFIXES lib)
include_directories(${GETOPT_INCLUDE_DIR})
endif(WITH_TOOLS)
endif(MSVC)
set(QRENCODE_SRCS qrencode.c
qrinput.c
bitstream.c
qrspec.c
rsecc.c
split.c
mask.c
mqrspec.c
mmask.c
qrprint.c)
set(QRENCODE_HDRS qrencode_inner.h
qrinput.h
bitstream.h
qrspec.h
rsecc.h
split.h
mask.h
mqrspec.h
mmask.h
qrprint.h)
if(BUILD_SHARED_LIBS)
if(MSVC)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif()
add_library(qrencode SHARED ${QRENCODE_SRCS} ${QRENCODE_HDRS})
set_target_properties(qrencode PROPERTIES VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} SOVERSION ${PROJECT_VERSION_MAJOR})
else()
add_library(qrencode ${QRENCODE_SRCS} ${QRENCODE_HDRS})
endif()
if(CMAKE_USE_PTHREADS_INIT)
target_link_libraries(qrencode Threads::Threads)
endif()
include(GNUInstallDirs)
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "${CMAKE_INSTALL_FULL_BINDIR}")
set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}")
set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
set(VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
configure_file(qrencode.1.in qrencode.1 @ONLY)
configure_file(libqrencode.pc.in libqrencode.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qrencode.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libqrencode.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install(FILES qrencode.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(TARGETS qrencode DESTINATION ${CMAKE_INSTALL_LIBDIR})