Skip to content

Commit 3b7b4d2

Browse files
authored
Merge pull request libgit2#5523 from libgit2/pks/cmake-sort-reproducible-builds
cmake: Sort source files for reproducible builds
2 parents b7b872f + b85eefb commit 3b7b4d2

File tree

5 files changed

+36
-25
lines changed

5 files changed

+36
-25
lines changed

cmake/Modules/SelectHashes.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,6 @@ ELSE()
5656
MESSAGE(FATAL_ERROR "Asked for unknown SHA1 backend: ${USE_SHA1}")
5757
ENDIF()
5858

59+
list(SORT SRC_SHA1)
60+
5961
ADD_FEATURE_INFO(SHA ON "using ${USE_SHA1}")

deps/http-parser/CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
FILE(GLOB SRC_HTTP "*.c" "*.h")
1+
file(GLOB SRC_HTTP "*.c" "*.h")
2+
list(SORT SRC_HTTP)
23

3-
ADD_LIBRARY(http-parser OBJECT ${SRC_HTTP})
4+
add_library(http-parser OBJECT ${SRC_HTTP})
45

5-
ENABLE_WARNINGS(implicit-fallthrough=1)
6+
enable_warnings(implicit-fallthrough=1)

deps/ntlmclient/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
FILE(GLOB SRC_NTLMCLIENT "ntlm.c" "unicode_builtin.c" "util.c")
2+
LIST(SORT SRC_NTLMCLIENT)
23

34
ADD_DEFINITIONS(-DNTLM_STATIC=1)
45

deps/zlib/CMakeLists.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
DISABLE_WARNINGS(implicit-fallthrough)
2-
ADD_DEFINITIONS(-DNO_VIZ -DSTDC -DNO_GZIP)
3-
FILE(GLOB SRC_ZLIB "*.c" "*.h")
4-
INCLUDE_DIRECTORIES(".")
5-
ADD_LIBRARY(zlib OBJECT ${SRC_ZLIB})
1+
disable_warnings(implicit-fallthrough)
2+
add_definitions(-DNO_VIZ -DSTDC -DNO_GZIP)
3+
file(GLOB SRC_ZLIB "*.c" "*.h")
4+
list(SORT SRC_ZLIB)
5+
include_directories(".")
6+
add_library(zlib OBJECT ${SRC_ZLIB})

src/CMakeLists.txt

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,13 @@ ENDIF()
7676
ADD_FEATURE_INFO(threadsafe THREADSAFE "threadsafe support")
7777

7878

79-
IF (WIN32 AND EMBED_SSH_PATH)
80-
FILE(GLOB SRC_SSH "${EMBED_SSH_PATH}/src/*.c")
81-
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES "${EMBED_SSH_PATH}/include")
82-
FILE(WRITE "${EMBED_SSH_PATH}/src/libssh2_config.h" "#define HAVE_WINCNG\n#define LIBSSH2_WINCNG\n#include \"../win32/libssh2_config.h\"")
83-
SET(GIT_SSH 1)
84-
ENDIF()
79+
if(WIN32 AND EMBED_SSH_PATH)
80+
file(GLOB SRC_SSH "${EMBED_SSH_PATH}/src/*.c")
81+
list(SORT SRC_SSH)
82+
list(APPEND LIBGIT2_SYSTEM_INCLUDES "${EMBED_SSH_PATH}/include")
83+
file(WRITE "${EMBED_SSH_PATH}/src/libssh2_config.h" "#define HAVE_WINCNG\n#define LIBSSH2_WINCNG\n#include \"../win32/libssh2_config.h\"")
84+
set(GIT_SSH 1)
85+
endif()
8586

8687
IF (WIN32 AND WINHTTP)
8788
SET(GIT_WINHTTP 1)
@@ -267,33 +268,38 @@ ENDIF()
267268
ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64)
268269

269270
# Collect sourcefiles
270-
FILE(GLOB SRC_H
271+
file(GLOB SRC_H
271272
"${libgit2_SOURCE_DIR}/include/git2.h"
272273
"${libgit2_SOURCE_DIR}/include/git2/*.h"
273274
"${libgit2_SOURCE_DIR}/include/git2/sys/*.h")
275+
list(SORT SRC_H)
274276

275277
# On Windows use specific platform sources
276-
IF (WIN32 AND NOT CYGWIN)
277-
IF(MSVC)
278+
if(WIN32 AND NOT CYGWIN)
279+
if(MSVC)
278280
SET(WIN_RC "win32/git2.rc")
279-
ENDIF()
281+
endif()
280282

281-
FILE(GLOB SRC_OS win32/*.c win32/*.h)
282-
ELSEIF (AMIGA)
283-
ADD_DEFINITIONS(-DNO_ADDRINFO -DNO_READDIR_R -DNO_MMAP)
284-
ELSE()
285-
FILE(GLOB SRC_OS unix/*.c unix/*.h)
286-
ENDIF()
283+
file(GLOB SRC_OS win32/*.c win32/*.h)
284+
list(SORT SRC_OS)
285+
elseif(AMIGA)
286+
add_definitions(-DNO_ADDRINFO -DNO_READDIR_R -DNO_MMAP)
287+
else()
288+
file(GLOB SRC_OS unix/*.c unix/*.h)
289+
list(SORT SRC_OS)
290+
endif()
287291

288292
IF (USE_LEAK_CHECKER STREQUAL "valgrind")
289293
ADD_DEFINITIONS(-DVALGRIND)
290294
ENDIF()
291295

292-
FILE(GLOB SRC_GIT2 *.c *.h
296+
file(GLOB SRC_GIT2 *.c *.h
293297
allocators/*.c allocators/*.h
294298
streams/*.c streams/*.h
295299
transports/*.c transports/*.h
296300
xdiff/*.c xdiff/*.h)
301+
list(SORT SRC_GIT2)
302+
297303
IF(APPLE)
298304
# The old Secure Transport API has been deprecated in macOS 10.15.
299305
SET_SOURCE_FILES_PROPERTIES(streams/stransport.c PROPERTIES COMPILE_FLAGS -Wno-deprecated)

0 commit comments

Comments
 (0)