4 # cmake .. (see below for options)
5 # make (VERBOSE=1 if needed)
9 # cmake -G"MSYS Makefiles" ..
10 # On Proxspace 3.3 or less, you need to install cmake:
11 # pacman -S mingw-w64-x86_64-cmake
12 # /mingw64/bin/cmake -G"MSYS Makefiles" ..
14 # Android cross-compilation: (ANDROID_ABI=arm64-v8a for a 64b version)
16 # -DCMAKE_TOOLCHAIN_FILE=<path-to-your-android-ndk>/build/cmake/android.toolchain.cmake \
17 # -DANDROID_ABI=armeabi-v7a \
18 # -DANDROID_NATIVE_API_LEVEL=android-19 \
19 # -DSKIPBT=1 -DSKIPPYTHON=1 -DSKIPPTHREAD=1 ..
21 message(STATUS "CMake ${CMAKE_VERSION}")
22 cmake_minimum_required(VERSION 3.10)
24 SET (PM3_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..)
26 if(CMAKE_VERSION VERSION_LESS "3.7.0")
27 set(CMAKE_INCLUDE_CURRENT_DIR ON)
30 find_package(PkgConfig)
32 if (NOT SKIPQT EQUAL 1)
33 if(APPLE AND EXISTS /usr/local/opt/qt5)
34 # Homebrew installs Qt5 (up to at least 5.11.0) in
35 # /usr/local/opt/qt5. Ensure that it can be found by CMake
36 # since it is not in the default /usr/local prefix.
37 # Add it to PATHS so that it doesn't override the
38 # CMAKE_PREFIX_PATH environment variable.
39 # QT_FIND_PACKAGE_OPTIONS should be passed to find_package,
40 # e.g. find_package(Qt5Core ${QT_FIND_PACKAGE_OPTIONS})
41 list(APPEND QT_FIND_PACKAGE_OPTIONS PATHS /usr/local/opt/qt5)
42 endif(APPLE AND EXISTS /usr/local/opt/qt5)
43 if(APPLE AND EXISTS /opt/homebrew/opt/qt5)
44 # Homebrew on Apple Silicon installs Qt5 in
45 # /opt/homebrew/opt/qt5. Ensure that it can be found by CMake
46 # since it is not in the default /usr/local prefix.
47 # Add it to PATHS so that it doesn't override the
48 # CMAKE_PREFIX_PATH environment variable.
49 # QT_FIND_PACKAGE_OPTIONS should be passed to find_package,
50 # e.g. find_package(Qt5Core ${QT_FIND_PACKAGE_OPTIONS})
51 list(APPEND QT_FIND_PACKAGE_OPTIONS PATHS /opt/homebrew/opt/qt5)
52 endif(APPLE AND EXISTS /opt/homebrew/opt/qt5)
59 foreach(_qt_package IN LISTS QT_PACKAGELIST)
60 find_package(${_qt_package} QUIET ${QT_FIND_PACKAGE_OPTIONS})
61 set(Qt5_LIBRARIES ${${_qt_package}_LIBRARIES} ${Qt5_LIBRARIES})
62 if(NOT ${_qt_package}_FOUND)
64 endif(NOT ${_qt_package}_FOUND)
66 endif (NOT SKIPQT EQUAL 1)
68 if (NOT SKIPBT EQUAL 1)
69 pkg_search_module(BLUEZ QUIET bluez)
70 endif (NOT SKIPBT EQUAL 1)
72 if (NOT SKIPPYTHON EQUAL 1)
73 pkg_search_module(PYTHON3 QUIET python3)
74 pkg_search_module(PYTHON3EMBED QUIET python3-embed)
75 endif (NOT SKIPPYTHON EQUAL 1)
77 # If cross-compiled, we need to init source and build.
78 if (CMAKE_TOOLCHAIN_FILE)
79 set(CFLAGS_EXTERNAL_LIB "CFLAGS=--target=${CMAKE_C_COMPILER_TARGET} -w")
80 set(EMBED_READLINE ON)
82 endif (CMAKE_TOOLCHAIN_FILE)
84 if (EMBED_READLINE OR EMBED_BZIP2)
85 include(ExternalProject)
86 endif (EMBED_READLINE OR EMBED_BZIP2)
88 if (NOT SKIPREADLINE EQUAL 1)
90 find_path(READLINE_INCLUDE_DIRS readline/readline.h /usr/local/opt/readline/include /opt/local/include /opt/include /usr/local/include /usr/include /opt/homebrew/opt/readline/include NO_DEFAULT_PATH)
91 find_library(READLINE_LIBRARIES readline /usr/local/opt/readline/lib /opt/local/lib /opt/lib /usr/local/lib /usr/lib /opt/homebrew/opt/readline/lib NO_DEFAULT_PATH)
94 ExternalProject_Add(ncurses
95 URL http://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.1.tar.gz
97 DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/ncurses
98 CONFIGURE_COMMAND ./configure CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} LD=${CMAKE_C_COMPILER} AR=${CMAKE_AR} RANLIB=${CMAKE_RANLIB} ${CFLAGS_EXTERNAL_LIB} --host=arm --disable-database --with-fallbacks=ansi-generic,ansi-mini,color_xterm,dtterm,dumb,Eterm,Eterm-256color,Eterm-88color,eterm-color,gnome,gnome-256color,guru,hurd,iTerm.app,konsole,konsole-16color,konsole-256color,konsole-base,konsole-linux,konsole-solaris,konsole-vt100,kterm,kterm-color,linux,linux-16color,linux-basic,mac,mlterm,mlterm-256color,mrxvt,mrxvt-256color,mterm,mterm-ansi,mvterm,nsterm,nsterm-16color,nsterm-256color,pty,putty,putty-256color,putty-vt100,rxvt,rxvt-16color,rxvt-256color,rxvt-88color,rxvt-basic,rxvt-color,screen,screen-16color,screen-256color,simpleterm,st-16color,st-256color,st52,st52-color,stv52,tt,tt52,unknown,vt100,vt102,vte,vte-256color,xterm,xterm-16color,xterm-256color,xterm-88color,xterm-basic,xterm-bold,xterm-color,xterm-utf8,xterm-vt220,xterm-vt52,xterm1,xtermc,xtermm --enable-termcap --without-ada --without-debug --without-dlsym --without-gpm --without-develop --without-tests --without-cxx-binding --with-termlib
100 BUILD_COMMAND make libs
104 ExternalProject_Add_StepTargets(ncurses configure build install)
106 ExternalProject_Add(readline
107 URL ftp://ftp.gnu.org/gnu/readline/readline-8.1.tar.gz
109 DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/readline
110 CONFIGURE_COMMAND ./configure CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} LD=${CMAKE_C_COMPILER} AR=${CMAKE_AR} RANLIB=${CMAKE_RANLIB} ${CFLAGS_EXTERNAL_LIB} --host=arm --enable-static
116 ExternalProject_Add_StepTargets(readline configure build install)
117 set(READLINE_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/deps/readline/src/)
118 set(READLINE_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/deps/readline/src/readline/libreadline.a ${CMAKE_CURRENT_BINARY_DIR}/deps/ncurses/src/ncurses/lib/libtinfo.a)
119 else (EMBED_READLINE)
120 find_path(READLINE_INCLUDE_DIRS readline/readline.h)
121 find_library(READLINE_LIBRARIES readline)
122 endif (EMBED_READLINE)
123 if (READLINE_INCLUDE_DIRS AND READLINE_LIBRARIES)
124 set(READLINE_FOUND ON)
125 endif (READLINE_INCLUDE_DIRS AND READLINE_LIBRARIES)
126 endif (NOT SKIPREADLINE EQUAL 1)
128 if (NOT SKIPJANSSONSYSTEM EQUAL 1)
129 pkg_check_modules(PC_JANSSON QUIET jansson)
130 find_path(JANSSON_INCLUDE_DIRS
132 HINTS ${PC_JANSSON_INCLUDEDIR} ${PC_JANSSON_INCLUDE_DIRS})
133 find_library(JANSSON_LIBRARIES
134 NAMES jansson libjansson
135 HINTS ${PC_JANSSON_LIBDIR} ${PC_JANSSON_LIBRARY_DIRS})
136 if (JANSSON_INCLUDE_DIRS AND JANSSON_LIBRARIES)
137 set(JANSSON_FOUND ON)
138 endif (JANSSON_INCLUDE_DIRS AND JANSSON_LIBRARIES)
139 endif (NOT SKIPJANSSONSYSTEM EQUAL 1)
142 set(BZIP2_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/deps/bzip2/src/bzip2)
143 ExternalProject_Add(bzip2
144 GIT_REPOSITORY https://android.googlesource.com/platform/external/bzip2
145 GIT_TAG platform-tools-30.0.2
147 SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/bzip2
148 CONFIGURE_COMMAND mkdir -p ${BZIP2_BUILD_DIR} && git archive --format tar HEAD | tar -C ${BZIP2_BUILD_DIR} -x
150 BUILD_COMMAND make -C ${BZIP2_BUILD_DIR} -j4 CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} LD=${CMAKE_C_COMPILER} AR=${CMAKE_AR} RANLIB=${CMAKE_RANLIB} ${CFLAGS_EXTERNAL_LIB} libbz2.a
154 ExternalProject_Add_StepTargets(bzip2 configure build install)
155 set(BZIP2_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/deps/bzip2/src/bzip2)
156 set(BZIP2_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/deps/bzip2/src/bzip2/libbz2.a)
159 find_package (BZip2 REQUIRED)
162 if (NOT SKIPWHEREAMISYSTEM EQUAL 1)
163 find_path(WHEREAMI_INCLUDE_DIRS whereami.h)
164 find_library(WHEREAMI_LIBRARIES whereami)
165 if (WHEREAMI_INCLUDE_DIRS AND WHEREAMI_LIBRARIES)
166 set(WHEREAMI_FOUND ON)
167 endif (WHEREAMI_INCLUDE_DIRS AND WHEREAMI_LIBRARIES)
168 endif (NOT SKIPWHEREAMISYSTEM EQUAL 1)
170 add_subdirectory(${PM3_ROOT}/client/deps deps)
173 ${PM3_ROOT}/common/commonutil.c
174 ${PM3_ROOT}/common/util_posix.c
175 ${PM3_ROOT}/common/parity.c
176 ${PM3_ROOT}/common/bucketsort.c
177 ${PM3_ROOT}/common/crapto1/crapto1.c
178 ${PM3_ROOT}/common/crapto1/crypto1.c
179 ${PM3_ROOT}/common/crc.c
180 ${PM3_ROOT}/common/crc16.c
181 ${PM3_ROOT}/common/crc32.c
182 ${PM3_ROOT}/common/crc64.c
183 ${PM3_ROOT}/common/lfdemod.c
184 ${PM3_ROOT}/common/legic_prng.c
185 ${PM3_ROOT}/common/iso15693tools.c
186 ${PM3_ROOT}/common/cardhelper.c
187 ${PM3_ROOT}/common/generator.c
188 ${PM3_ROOT}/client/src/crypto/asn1dump.c
189 ${PM3_ROOT}/client/src/crypto/asn1utils.c
190 ${PM3_ROOT}/client/src/crypto/libpcrypto.c
191 ${PM3_ROOT}/client/src/emv/test/cda_test.c
192 ${PM3_ROOT}/client/src/emv/test/crypto_test.c
193 ${PM3_ROOT}/client/src/emv/test/cryptotest.c
194 ${PM3_ROOT}/client/src/emv/test/dda_test.c
195 ${PM3_ROOT}/client/src/emv/test/sda_test.c
196 ${PM3_ROOT}/client/src/emv/cmdemv.c
197 ${PM3_ROOT}/client/src/emv/crypto.c
198 ${PM3_ROOT}/client/src/emv/crypto_polarssl.c
199 ${PM3_ROOT}/client/src/emv/dol.c
200 ${PM3_ROOT}/client/src/emv/emv_pk.c
201 ${PM3_ROOT}/client/src/emv/emv_pki.c
202 ${PM3_ROOT}/client/src/emv/emv_pki_priv.c
203 ${PM3_ROOT}/client/src/emv/emv_roca.c
204 ${PM3_ROOT}/client/src/emv/emv_tags.c
205 ${PM3_ROOT}/client/src/emv/emvcore.c
206 ${PM3_ROOT}/client/src/emv/emvjson.c
207 ${PM3_ROOT}/client/src/emv/tlv.c
208 ${PM3_ROOT}/client/src/fido/additional_ca.c
209 ${PM3_ROOT}/client/src/fido/cbortools.c
210 ${PM3_ROOT}/client/src/fido/cose.c
211 ${PM3_ROOT}/client/src/fido/fidocore.c
212 ${PM3_ROOT}/client/src/iso7816/apduinfo.c
213 ${PM3_ROOT}/client/src/iso7816/iso7816core.c
214 ${PM3_ROOT}/client/src/loclass/cipher.c
215 ${PM3_ROOT}/client/src/loclass/cipherutils.c
216 ${PM3_ROOT}/client/src/loclass/elite_crack.c
217 ${PM3_ROOT}/client/src/loclass/hash1_brute.c
218 ${PM3_ROOT}/client/src/loclass/ikeys.c
219 ${PM3_ROOT}/client/src/mifare/mad.c
220 ${PM3_ROOT}/client/src/mifare/mfkey.c
221 ${PM3_ROOT}/client/src/mifare/mifare4.c
222 ${PM3_ROOT}/client/src/mifare/mifaredefault.c
223 ${PM3_ROOT}/client/src/mifare/mifarehost.c
224 ${PM3_ROOT}/client/src/nfc/ndef.c
225 ${PM3_ROOT}/client/src/mifare/desfire_crypto.c
226 ${PM3_ROOT}/client/src/uart/uart_posix.c
227 ${PM3_ROOT}/client/src/uart/uart_win32.c
228 ${PM3_ROOT}/client/src/ui/overlays.ui
229 ${PM3_ROOT}/client/src/aiddesfire.c
230 ${PM3_ROOT}/client/src/aidsearch.c
231 ${PM3_ROOT}/client/src/cmdanalyse.c
232 ${PM3_ROOT}/client/src/cmdcrc.c
233 ${PM3_ROOT}/client/src/cmddata.c
234 ${PM3_ROOT}/client/src/cmdflashmem.c
235 ${PM3_ROOT}/client/src/cmdflashmemspiffs.c
236 ${PM3_ROOT}/client/src/cmdhf.c
237 ${PM3_ROOT}/client/src/cmdhf14a.c
238 ${PM3_ROOT}/client/src/cmdhf14b.c
239 ${PM3_ROOT}/client/src/cmdhf15.c
240 ${PM3_ROOT}/client/src/cmdhfcryptorf.c
241 ${PM3_ROOT}/client/src/cmdhfemrtd.c
242 ${PM3_ROOT}/client/src/cmdhfepa.c
243 ${PM3_ROOT}/client/src/cmdhffelica.c
244 ${PM3_ROOT}/client/src/cmdhffido.c
245 ${PM3_ROOT}/client/src/cmdhficlass.c
246 ${PM3_ROOT}/client/src/cmdhfjooki.c
247 ${PM3_ROOT}/client/src/cmdhflegic.c
248 ${PM3_ROOT}/client/src/cmdhflist.c
249 ${PM3_ROOT}/client/src/cmdhflto.c
250 ${PM3_ROOT}/client/src/cmdhfmf.c
251 ${PM3_ROOT}/client/src/cmdhfmfdes.c
252 ${PM3_ROOT}/client/src/cmdhfmfhard.c
253 ${PM3_ROOT}/client/src/cmdhfmfp.c
254 ${PM3_ROOT}/client/src/cmdhfmfu.c
255 ${PM3_ROOT}/client/src/cmdhfst.c
256 ${PM3_ROOT}/client/src/cmdhfst25ta.c
257 ${PM3_ROOT}/client/src/cmdhfthinfilm.c
258 ${PM3_ROOT}/client/src/cmdhftopaz.c
259 ${PM3_ROOT}/client/src/cmdhfwaveshare.c
260 ${PM3_ROOT}/client/src/cmdhw.c
261 ${PM3_ROOT}/client/src/cmdlf.c
262 ${PM3_ROOT}/client/src/cmdlfawid.c
263 ${PM3_ROOT}/client/src/cmdlfcotag.c
264 ${PM3_ROOT}/client/src/cmdlfdestron.c
265 ${PM3_ROOT}/client/src/cmdlfem.c
266 ${PM3_ROOT}/client/src/cmdlfem410x.c
267 ${PM3_ROOT}/client/src/cmdlfem4x05.c
268 ${PM3_ROOT}/client/src/cmdlfem4x50.c
269 ${PM3_ROOT}/client/src/cmdlfem4x70.c
270 ${PM3_ROOT}/client/src/cmdlffdxb.c
271 ${PM3_ROOT}/client/src/cmdlfgallagher.c
272 ${PM3_ROOT}/client/src/cmdlfguard.c
273 ${PM3_ROOT}/client/src/cmdlfhid.c
274 ${PM3_ROOT}/client/src/cmdlfhitag.c
275 ${PM3_ROOT}/client/src/cmdlfidteck.c
276 ${PM3_ROOT}/client/src/cmdlfindala.c
277 ${PM3_ROOT}/client/src/cmdlfio.c
278 ${PM3_ROOT}/client/src/cmdlfjablotron.c
279 ${PM3_ROOT}/client/src/cmdlfkeri.c
280 ${PM3_ROOT}/client/src/cmdlfmotorola.c
281 ${PM3_ROOT}/client/src/cmdlfnedap.c
282 ${PM3_ROOT}/client/src/cmdlfnexwatch.c
283 ${PM3_ROOT}/client/src/cmdlfnoralsy.c
284 ${PM3_ROOT}/client/src/cmdlfpac.c
285 ${PM3_ROOT}/client/src/cmdlfparadox.c
286 ${PM3_ROOT}/client/src/cmdlfpcf7931.c
287 ${PM3_ROOT}/client/src/cmdlfpresco.c
288 ${PM3_ROOT}/client/src/cmdlfpyramid.c
289 ${PM3_ROOT}/client/src/cmdlfsecurakey.c
290 ${PM3_ROOT}/client/src/cmdlft55xx.c
291 ${PM3_ROOT}/client/src/cmdlfti.c
292 ${PM3_ROOT}/client/src/cmdlfviking.c
293 ${PM3_ROOT}/client/src/cmdlfvisa2000.c
294 ${PM3_ROOT}/client/src/cmdmain.c
295 ${PM3_ROOT}/client/src/cmdnfc.c
296 ${PM3_ROOT}/client/src/cmdparser.c
297 ${PM3_ROOT}/client/src/cmdscript.c
298 ${PM3_ROOT}/client/src/cmdsmartcard.c
299 ${PM3_ROOT}/client/src/cmdtrace.c
300 ${PM3_ROOT}/client/src/cmdusart.c
301 ${PM3_ROOT}/client/src/cmdwiegand.c
302 ${PM3_ROOT}/client/src/comms.c
303 ${PM3_ROOT}/client/src/fileutils.c
304 ${PM3_ROOT}/client/src/flash.c
305 ${PM3_ROOT}/client/src/graph.c
306 ${PM3_ROOT}/client/src/jansson_path.c
307 ${PM3_ROOT}/client/src/preferences.c
308 ${PM3_ROOT}/client/src/pm3.c
309 ${PM3_ROOT}/client/src/pm3_binlib.c
310 ${PM3_ROOT}/client/src/pm3_bitlib.c
311 ${PM3_ROOT}/client/src/prng.c
312 ${PM3_ROOT}/client/src/scandir.c
313 ${PM3_ROOT}/client/src/scripting.c
314 ${PM3_ROOT}/client/src/tea.c
315 ${PM3_ROOT}/client/src/ui.c
316 ${PM3_ROOT}/client/src/util.c
317 ${PM3_ROOT}/client/src/wiegand_formats.c
318 ${PM3_ROOT}/client/src/wiegand_formatutils.c
319 ${CMAKE_BINARY_DIR}/version_pm3.c
323 OUTPUT ${CMAKE_BINARY_DIR}/version_pm3.c
324 COMMAND sh ${PM3_ROOT}/tools/mkversion.sh > ${CMAKE_BINARY_DIR}/version_pm3.c || perl ${PM3_ROOT}/tools/mkversion.pl > ${CMAKE_BINARY_DIR}/version_pm3.c || ${CMAKE_COMMAND} -E copy ${PM3_ROOT}/common/default_version_pm3.c ${CMAKE_BINARY_DIR}/version_pm3.c
325 DEPENDS ${PM3_ROOT}/common/default_version_pm3.c
328 set(ADDITIONAL_SRC "")
329 set(ADDITIONAL_LNK "")
330 set(ADDITIONAL_DIRS "")
331 set(ADDITIONAL_LNKDIRS "")
332 set(X86_CPUS x86 x86_64 i686)
334 message(STATUS "CMAKE_SYSTEM_PROCESSOR := ${CMAKE_SYSTEM_PROCESSOR}")
337 message(STATUS "Apple device detected.")
338 set(ADDITIONAL_SRC ${PM3_ROOT}/client/src/util_darwin.h ${PM3_ROOT}/client/src/util_darwin.m ${ADDITIONAL_SRC})
339 set(ADDITIONAL_LNK "-framework Foundation" "-framework AppKit")
342 if ((NOT SKIPQT EQUAL 1) AND (Qt5_FOUND))
343 set(CMAKE_AUTOMOC ON)
344 set(CMAKE_AUTORCC ON)
345 set(CMAKE_AUTOUIC ON)
347 ${PM3_ROOT}/client/src/proxgui.cpp
348 ${PM3_ROOT}/client/src/proxguiqt.cpp
351 add_definitions("-DHAVE_GUI")
352 set(ADDITIONAL_LNK ${Qt5_LIBRARIES} ${ADDITIONAL_LNK})
353 else ((NOT SKIPQT EQUAL 1) AND (Qt5_FOUND))
355 ${PM3_ROOT}/client/src/guidummy.cpp
357 endif ((NOT SKIPQT EQUAL 1) AND (Qt5_FOUND))
359 if (NOT SKIPBT EQUAL 1)
361 add_definitions("-DHAVE_BLUEZ")
362 set(ADDITIONAL_LNK ${BLUEZ_LIBRARIES} ${ADDITIONAL_LNK})
364 endif(NOT SKIPBT EQUAL 1)
367 set(ADDITIONAL_DIRS ${JANSSON_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
368 set(ADDITIONAL_LNK ${JANSSON_LIBRARIES} ${ADDITIONAL_LNK})
369 endif (JANSSON_FOUND)
371 if (NOT SKIPPYTHON EQUAL 1)
372 if (PYTHON3EMBED_FOUND)
373 add_definitions(-DHAVE_PYTHON)
374 set(ADDITIONAL_DIRS ${PYTHON3EMBED_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
375 set(ADDITIONAL_LNK ${PYTHON3EMBED_LIBRARIES} ${ADDITIONAL_LNK})
376 set(ADDITIONAL_LNKDIRS ${PYTHON3EMBED_LIBRARY_DIRS} ${ADDITIONAL_LNKDIRS})
377 elseif (PYTHON3_FOUND)
378 add_definitions(-DHAVE_PYTHON)
379 set(ADDITIONAL_DIRS ${PYTHON3_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
380 set(ADDITIONAL_LNK ${PYTHON3_LIBRARIES} ${ADDITIONAL_LNK})
381 set(ADDITIONAL_LNKDIRS ${PYTHON3_LIBRARY_DIRS} ${ADDITIONAL_LNKDIRS})
382 endif (PYTHON3EMBED_FOUND)
383 endif (NOT SKIPPYTHON EQUAL 1)
385 if (NOT SKIPREADLINE EQUAL 1)
387 add_definitions("-DHAVE_READLINE")
388 set(ADDITIONAL_DIRS ${READLINE_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
389 set(ADDITIONAL_LNK ${READLINE_LIBRARIES} ${ADDITIONAL_LNK})
390 endif (READLINE_FOUND)
391 endif(NOT SKIPREADLINE EQUAL 1)
394 set(ADDITIONAL_DIRS ${BZIP2_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
395 set(ADDITIONAL_LNK ${BZIP2_LIBRARIES} ${ADDITIONAL_LNK})
399 set(ADDITIONAL_DIRS ${WHEREAMI_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
400 set(ADDITIONAL_LNK ${WHEREAMI_LIBRARIES} ${ADDITIONAL_LNK})
401 endif (WHEREAMI_FOUND)
403 message(STATUS "===================================================================")
405 message(STATUS "GUI support: skipped")
406 else (SKIPQT EQUAL 1)
408 message(STATUS "GUI support: QT5 found, enabled")
410 message(STATUS "GUI support: QT5 not found, disabled")
412 endif (SKIPQT EQUAL 1)
415 message(STATUS "native BT support: skipped")
416 else (SKIPBT EQUAL 1)
418 message(STATUS "native BT support: Bluez found, enabled")
420 message(STATUS "native BT support: Bluez not found, disabled")
422 endif(SKIPBT EQUAL 1)
425 message(STATUS "Bzip2 library: embedded")
427 message(STATUS "Bzip2 library: system library found")
430 if (SKIPJANSSONSYSTEM EQUAL 1)
431 message(STATUS "Jansson library: local library forced")
432 else (SKIPJANSSONSYSTEM EQUAL 1)
434 message(STATUS "Jansson library: system library found")
436 message(STATUS "Jansson library: system library not found, using local library")
437 endif (JANSSON_FOUND)
438 endif (SKIPJANSSONSYSTEM EQUAL 1)
440 if (SKIPPYTHON EQUAL 1)
441 message(STATUS "Python3 library: skipped")
442 else (SKIPPYTHON EQUAL 1)
443 if (PYTHON3EMBED_FOUND)
444 message(STATUS "Python3 library: Python3 embed found, enabled")
445 elseif (PYTHON3_FOUND)
446 message(STATUS "Python3 library: Python3 found, enabled")
447 else (PYTHON3EMBED_FOUND)
448 message(STATUS "Python3 library: Python3 not found, disabled")
449 endif (PYTHON3EMBED_FOUND)
450 endif(SKIPPYTHON EQUAL 1)
452 if (SKIPREADLINE EQUAL 1)
453 message(STATUS "Readline library: skipped")
454 else (SKIPREADLINE EQUAL 1)
457 message(STATUS "Readline library: embedded")
458 else (EMBED_READLINE)
459 message(STATUS "Readline library: system library found")
460 endif (EMBED_READLINE)
461 else (READLINE_FOUND)
462 message(STATUS "Readline library: Readline not found, disabled")
463 endif (READLINE_FOUND)
464 endif(SKIPREADLINE EQUAL 1)
466 if (SKIPWHEREAMISYSTEM EQUAL 1)
467 message(STATUS "Whereami library: local library forced")
468 else (SKIPWHEREAMISYSTEM EQUAL 1)
470 message(STATUS "Whereami library: system library found")
471 else (WHEREAMI_FOUND)
472 message(STATUS "Whereami library: system library not found, using local library")
473 endif (WHEREAMI_FOUND)
474 endif (SKIPWHEREAMISYSTEM EQUAL 1)
477 if (EXISTS ${PM3_ROOT}/client/src/pm3_luawrap.c)
479 ${PM3_ROOT}/client/src/pm3_luawrap.c
481 add_definitions(-DHAVE_LUA_SWIG)
482 message(STATUS "Lua SWIG: wrapper found")
483 endif (EXISTS ${PM3_ROOT}/client/src/pm3_luawrap.c)
486 if (NOT SKIPPYTHON EQUAL 1)
487 if (PYTHON3EMBED_FOUND OR PYTHON3_FOUND)
488 if (EXISTS ${PM3_ROOT}/client/src/pm3_pywrap.c)
490 ${PM3_ROOT}/client/src/pm3_pywrap.c
492 add_definitions(-DHAVE_PYTHON_SWIG)
493 message(STATUS "Python SWIG: wrapper found")
494 endif (EXISTS ${PM3_ROOT}/client/src/pm3_pywrap.c)
495 endif (PYTHON3EMBED_FOUND OR PYTHON3_FOUND)
496 endif (NOT SKIPPYTHON EQUAL 1)
497 message(STATUS "===================================================================")
499 add_library(pm3rrg_rdv4 SHARED
500 ${PM3_ROOT}/client/src/proxmark3.c
505 target_compile_definitions(pm3rrg_rdv4 PRIVATE LIBPM3)
507 target_compile_options(pm3rrg_rdv4 PUBLIC -Wall -Werror -O3)
509 if (NOT SKIPREADLINE EQUAL 1)
510 add_dependencies(pm3rrg_rdv4 ncurses readline)
511 endif (NOT SKIPREADLINE EQUAL 1)
512 endif (EMBED_READLINE)
514 add_dependencies(pm3rrg_rdv4 bzip2)
518 # Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
519 # and setting _ISOC99_SOURCE sets internally __USE_MINGW_ANSI_STDIO=1
520 # FTR __USE_MINGW_ANSI_STDIO seems deprecated in Mingw32
521 # but not Mingw64 https://fr.osdn.net/projects/mingw/lists/archive/users/2019-January/000199.html
522 target_compile_definitions(pm3rrg_rdv4 PRIVATE _ISOC99_SOURCE)
524 set(CMAKE_C_FLAGS "-mno-ms-bitfields -fexec-charset=cp850 ${CMAKE_C_FLAGS}")
525 set(CMAKE_CXX_FLAGS "-mno-ms-bitfields -fexec-charset=cp850 ${CMAKE_CXX_FLAGS}")
528 target_include_directories(pm3rrg_rdv4 PRIVATE
530 ${PM3_ROOT}/common_fpga
532 ${PM3_ROOT}/client/src
533 ${PM3_ROOT}/client/include
538 # required for Raspberry Pi, but breaks with clang (OSX). Need to be at the end of the linker line.
539 set(ADDITIONAL_LNK ${ADDITIONAL_LNK} -Wl,--as-needed -latomic -Wl,--no-as-needed)
542 if (NOT JANSSON_FOUND)
543 set(ADDITIONAL_LNK pm3rrg_rdv4_jansson ${ADDITIONAL_LNK})
544 endif (NOT JANSSON_FOUND)
545 if (NOT WHEREAMI_FOUND)
546 set(ADDITIONAL_LNK pm3rrg_rdv4_whereami ${ADDITIONAL_LNK})
547 endif (NOT WHEREAMI_FOUND)
549 target_link_libraries(pm3rrg_rdv4 PRIVATE
552 pm3rrg_rdv4_cliparser
557 pm3rrg_rdv4_hardnested
560 if (NOT SKIPPTHREAD EQUAL 1)
561 target_link_libraries(pm3rrg_rdv4 PRIVATE pthread)
562 endif (NOT SKIPPTHREAD EQUAL 1)
564 if (NOT SKIPPYTHON EQUAL 1)
565 # OSX have a hard time compiling python3 dependency with older cmake.
566 if (PYTHON3EMBED_FOUND OR PYTHON3_FOUND)
567 if (NOT CMAKE_VERSION VERSION_LESS 3.13)
568 target_link_directories(pm3rrg_rdv4 PRIVATE ${ADDITIONAL_LNKDIRS})
570 message( SEND_ERROR "Your CMAKE version is too old for Apple platform, please update to a version >=3.13" )
571 endif (NOT CMAKE_VERSION VERSION_LESS 3.13)
572 endif (PYTHON3EMBED_FOUND OR PYTHON3_FOUND)
573 endif (NOT SKIPPYTHON EQUAL 1)