File tree Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,17 @@ else()
44
44
-Wall -Wextra -Wno-missing-braces -Werror=undef -Werror=return-type )
45
45
endif ()
46
46
47
+ include (CheckCXXCompilerFlag )
48
+
49
+ # This is needed for reproducible builds across different build directories.
50
+ # Without this, the usage of the __FILE__ macro leaves the build directory in
51
+ # the binary. When building the Python extension with build isolation enabled
52
+ # this would lead to random paths in the binary.
53
+ set (FILE_PREFIX_ARG "-ffile-prefix-map=${CMAKE_CURRENT_SOURCE_DIR} =" )
54
+ check_cxx_compiler_flag ("${FILE_PREFIX_ARG} " HAS_FILE_PREFIX_ARG )
55
+ if (HAS_FILE_PREFIX_ARG )
56
+ set (ZXING_CORE_LOCAL_DEFINES ${ZXING_CORE_LOCAL_DEFINES} "${FILE_PREFIX_ARG} " )
57
+ endif ()
47
58
48
59
################# Source files
49
60
@@ -458,8 +469,6 @@ target_compile_options (ZXing
458
469
PRIVATE ${ZXING_CORE_LOCAL_DEFINES}
459
470
)
460
471
461
- include (CheckCXXCompilerFlag )
462
-
463
472
target_compile_features (ZXing PUBLIC cxx_std_17 )
464
473
465
474
target_link_libraries (ZXing PRIVATE Threads::Threads )
Original file line number Diff line number Diff line change @@ -17,8 +17,16 @@ if (NOT hasParent)
17
17
option (BUILD_WRITERS "Build with writer support (encoders)" ON )
18
18
option (BUILD_READERS "Build with reader support (decoders)" ON )
19
19
set (BUILD_DEPENDENCIES "AUTO" )
20
- if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR} /core )
21
- add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /core ZXing EXCLUDE_FROM_ALL )
20
+
21
+ set (CORE_PATH ${CMAKE_CURRENT_SOURCE_DIR} /core )
22
+ if (IS_SYMLINK ${CORE_PATH} )
23
+ # This is needed because otherwise GCC resolves the symlink which causes paths to randomly
24
+ # be prefixed by /core or by /wrappers/python/core depending on include order.
25
+ set (CORE_PATH ${CMAKE_CURRENT_SOURCE_DIR} /../../core )
26
+ endif ()
27
+
28
+ if (EXISTS ${CORE_PATH} )
29
+ add_subdirectory (${CORE_PATH} ZXing EXCLUDE_FROM_ALL )
22
30
include (${CMAKE_CURRENT_SOURCE_DIR} /zxing.cmake )
23
31
else ()
24
32
message (FATAL_ERROR "Unable to locate zxing source code" )
You can’t perform that action at this time.
0 commit comments