From 3d82c97ae60c44433d48bbe3e8d4d2fafbb9eeb1 Mon Sep 17 00:00:00 2001 From: Aiden Woodruff Date: Mon, 27 Oct 2025 08:17:23 -0500 Subject: improve SNAP patch and build - cmake/GetSNAP.cmake: only build the SNAP library; saves a minute of building examples. - cmake/snap-glib.patch: rename from snap-glib-base.patch since fl.cpp is also being patched. Signed-off-by: Aiden Woodruff --- cmake/GetSNAP.cmake | 7 +++---- cmake/snap-glib-base.patch | 47 ---------------------------------------------- cmake/snap-glib.patch | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 51 deletions(-) delete mode 100644 cmake/snap-glib-base.patch create mode 100644 cmake/snap-glib.patch (limited to 'cmake') diff --git a/cmake/GetSNAP.cmake b/cmake/GetSNAP.cmake index d3e55e2..5ff6293 100644 --- a/cmake/GetSNAP.cmake +++ b/cmake/GetSNAP.cmake @@ -2,10 +2,10 @@ find_package(OpenMP REQUIRED) find_program(PATCH patch) if(PATCH) - set(SNAP_PATCHCMD ${PATCH} -p1 < "${CMAKE_SOURCE_DIR}/cmake/snap-glib-base.patch") + set(SNAP_PATCHCMD ${PATCH} -p1 < "${CMAKE_SOURCE_DIR}/cmake/snap-glib.patch") else() find_program(GIT git REQUIRED) - set(SNAP_PATCHCMD ${GIT} patch apply < "${CMAKE_SOURCE_DIR}/cmake/snap-glib-base.patch") + set(SNAP_PATCHCMD ${GIT} patch apply < "${CMAKE_SOURCE_DIR}/cmake/snap-glib.patch") endif() if(CMAKE_SIZEOF_VOID_P EQUAL 4) @@ -39,8 +39,7 @@ ExternalProject_Add( PATCH_COMMAND ${SNAP_PATCHCMD} CONFIGURE_COMMAND "" BUILD_IN_SOURCE TRUE - BUILD_COMMAND make "CXXFLAGS=${SNAP_CXX_FLAGS}" - COMMAND make -C snap-core lib + BUILD_COMMAND make -C snap-core lib "CXXFLAGS=${SNAP_CXX_FLAGS}" BUILD_BYPRODUCTS snap-core/libsnap.a INSTALL_COMMAND "" LOG_BUILD TRUE diff --git a/cmake/snap-glib-base.patch b/cmake/snap-glib-base.patch deleted file mode 100644 index 669f797..0000000 --- a/cmake/snap-glib-base.patch +++ /dev/null @@ -1,47 +0,0 @@ ---- a/glib-core/base.h -+++ b/glib-core/base.h -@@ -66,7 +66,11 @@ - #include - #include - #include -- #include -+ #if defined(SNAP_HAVE_POLL_H) -+ #include -+ #elif defined(SNAP_HAVE_SYS_POLL_H) -+ #include -+ #endif - #include - #include - #include -@@ -89,7 +93,7 @@ - #define GLib_32Bit - #elif __WORDSIZE == 64 || defined(GLib_WIN64) || defined(__CYGWIN64__) - #define GLib_64Bit --#else -+#elif !defined(GLib_32Bit) && !defined(GLib_64Bit) - #error "Undefined word size" - #endif - -@@ -98,10 +102,8 @@ - #if defined(GLib_MACOSX) - #include - #define _environ (*_NSGetEnviron()) -- #elif !defined(GLib_CYGWIN) -- #define _environ __environ -- extern int _daylight; - #else -+ extern char **environ; - #define _environ environ - #endif - #endif ---- a/glib-core/fl.cpp -+++ a/glib-core/fl.cpp -@@ -1210,7 +1210,7 @@ - - filesize = lseek(input, 0, SEEK_END); - lseek(output, filesize - 1, SEEK_SET); -- write(output, '\0', 1); -+ write(output, "\0", 1); - - if((source = mmap(0, filesize, PROT_READ, MAP_SHARED, input, 0)) == (void *) -1) { - close(input); diff --git a/cmake/snap-glib.patch b/cmake/snap-glib.patch new file mode 100644 index 0000000..669f797 --- /dev/null +++ b/cmake/snap-glib.patch @@ -0,0 +1,47 @@ +--- a/glib-core/base.h ++++ b/glib-core/base.h +@@ -66,7 +66,11 @@ + #include + #include + #include +- #include ++ #if defined(SNAP_HAVE_POLL_H) ++ #include ++ #elif defined(SNAP_HAVE_SYS_POLL_H) ++ #include ++ #endif + #include + #include + #include +@@ -89,7 +93,7 @@ + #define GLib_32Bit + #elif __WORDSIZE == 64 || defined(GLib_WIN64) || defined(__CYGWIN64__) + #define GLib_64Bit +-#else ++#elif !defined(GLib_32Bit) && !defined(GLib_64Bit) + #error "Undefined word size" + #endif + +@@ -98,10 +102,8 @@ + #if defined(GLib_MACOSX) + #include + #define _environ (*_NSGetEnviron()) +- #elif !defined(GLib_CYGWIN) +- #define _environ __environ +- extern int _daylight; + #else ++ extern char **environ; + #define _environ environ + #endif + #endif +--- a/glib-core/fl.cpp ++++ a/glib-core/fl.cpp +@@ -1210,7 +1210,7 @@ + + filesize = lseek(input, 0, SEEK_END); + lseek(output, filesize - 1, SEEK_SET); +- write(output, '\0', 1); ++ write(output, "\0", 1); + + if((source = mmap(0, filesize, PROT_READ, MAP_SHARED, input, 0)) == (void *) -1) { + close(input); -- cgit