File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,7 @@ cmake_dependent_option(
101
101
option (PCAPPP_BUILD_TESTS "Build Tests" ${PCAPPP_MAIN_PROJECT} )
102
102
option (PCAPPP_BUILD_COVERAGE "Generate Coverage Report" OFF )
103
103
option (PCAPPP_BUILD_FUZZERS "Build Fuzzers binaries" OFF )
104
+ option (PCAPPP_BUILD_REPRODUCIBLE "Build a reproducible version" OFF )
104
105
105
106
option (BUILD_SHARED_LIBS "Build using shared libraries" OFF )
106
107
@@ -259,6 +260,23 @@ if(PCAPPP_TARGET_COMPILER_CLANG
259
260
add_compile_options (-Wall)
260
261
endif ()
261
262
263
+ if (PCAPPP_BUILD_REPRODUCIBLE)
264
+ add_definitions (-DPCAPPP_BUILD_REPRODUCIBLE)
265
+ if (APPLE )
266
+ if (NOT $ENV{ZERO_AR_DATE} )
267
+ message (FATAL_ERROR "You need to set `export ZERO_AR_DATE=1`" )
268
+ endif ()
269
+ elseif (MSVC )
270
+ message (FATAL_ERROR "Unsupported with MSVC compiler" )
271
+ # Try to build a reproducible static library with MSVC doesn't work but this option should make it work for shared
272
+ # libraries or executables. add_compile_options(/Brepro) add_compile_options(/experimental:deterministic)
273
+ # add_link_options(/Brepro) add_link_options(/experimental:deterministic) add_link_options(/INCREMENTAL:NO)
274
+ else ()
275
+ # We should not use __DATE__ nor __TIME__ in case of reproducible build
276
+ add_compile_options (-Wdate-time)
277
+ endif ()
278
+ endif ()
279
+
262
280
if (PCAPPP_BUILD_FUZZERS)
263
281
add_compile_options (-w)
264
282
endif ()
Original file line number Diff line number Diff line change @@ -37,10 +37,17 @@ namespace pcpp
37
37
/* *
38
38
* @return The build date and time in a format of "Mmm dd yyyy hh:mm:ss"
39
39
*/
40
+ #ifdef PCAPPP_BUILD_REPRODUCIBLE
41
+ inline std::string getBuildDateTime ()
42
+ {
43
+ return " " ;
44
+ }
45
+ #else
40
46
inline std::string getBuildDateTime ()
41
47
{
42
48
return std::string (__DATE__) + " " + std::string (__TIME__);
43
49
}
50
+ #endif
44
51
45
52
/* *
46
53
* @return The Git commit (revision) the binaries are built from
You can’t perform that action at this time.
0 commit comments