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(
101101option (PCAPPP_BUILD_TESTS "Build Tests" ${PCAPPP_MAIN_PROJECT} )
102102option (PCAPPP_BUILD_COVERAGE "Generate Coverage Report" OFF )
103103option (PCAPPP_BUILD_FUZZERS "Build Fuzzers binaries" OFF )
104+ option (PCAPPP_BUILD_REPRODUCIBLE "Build a reproducible version" OFF )
104105
105106option (BUILD_SHARED_LIBS "Build using shared libraries" OFF )
106107
@@ -259,6 +260,23 @@ if(PCAPPP_TARGET_COMPILER_CLANG
259260 add_compile_options (-Wall)
260261endif ()
261262
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+
262280if (PCAPPP_BUILD_FUZZERS)
263281 add_compile_options (-w)
264282endif ()
Original file line number Diff line number Diff line change @@ -37,10 +37,17 @@ namespace pcpp
3737 /* *
3838 * @return The build date and time in a format of "Mmm dd yyyy hh:mm:ss"
3939 */
40+ #ifdef PCAPPP_BUILD_REPRODUCIBLE
41+ inline std::string getBuildDateTime ()
42+ {
43+ return " " ;
44+ }
45+ #else
4046 inline std::string getBuildDateTime ()
4147 {
4248 return std::string (__DATE__) + " " + std::string (__TIME__);
4349 }
50+ #endif
4451
4552 /* *
4653 * @return The Git commit (revision) the binaries are built from
You can’t perform that action at this time.
0 commit comments