Skip to content

Commit

Permalink
add capnp patches
Browse files Browse the repository at this point in the history
  • Loading branch information
NielsMommen committed Apr 20, 2023
1 parent 7e8a4e1 commit 9325002
Show file tree
Hide file tree
Showing 2 changed files with 181 additions and 0 deletions.
38 changes: 38 additions & 0 deletions capnpCMakeLists.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
--- capnproto-0.10.4/c++/CMakeLists.txt 2023-04-13 16:14:33.000000000 +0200
+++ capnproto-0.10.4.patch/c++/CMakeLists.txt 2023-04-20 09:14:31.073828400 +0200
@@ -46,6 +46,10 @@
# define list of values GUI will offer for the variable
set_property(CACHE WITH_OPENSSL PROPERTY STRINGS AUTO ON OFF)

+set(WITH_ZLIB "AUTO" CACHE STRING
+ "Whether or not to build libkj-gzip by linking against zlib")
+set_property(CACHE WITH_ZLIB PROPERTY STRINGS AUTO ON OFF)
+
# shadow cache variable original value with ON/OFF,
# so from now on OpenSSL-specific code just has to check:
# if (WITH_OPENSSL)
@@ -64,6 +68,24 @@
find_package(OpenSSL REQUIRED COMPONENTS Crypto SSL)
endif()

+# shadow cache variable original value with ON/OFF,
+# so from now on ZLIB-specific code just has to check:
+# if (WITH_ZLIB)
+# ...
+# endif()
+if(CAPNP_LITE)
+ set(WITH_ZLIB OFF)
+elseif (WITH_ZLIB STREQUAL "AUTO")
+ find_package(ZLIB)
+ if(ZLIB_FOUND)
+ set(WITH_ZLIB ON)
+ else()
+ set(WITH_ZLIB OFF)
+ endif()
+elseif (WITH_ZLIB)
+ find_package(ZLIB REQUIRED)
+endif()
+
set(WITH_FIBERS "AUTO" CACHE STRING
"Whether or not to build libkj-async with fibers")
# define list of values GUI will offer for the variable
143 changes: 143 additions & 0 deletions capnp_src_kjCMakeLists.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
--- capnproto-0.10.4/c++/src/kj/CMakeLists.txt 2023-04-13 16:14:33.000000000 +0200
+++ capnproto-0.10.4.patch/c++/src/kj/CMakeLists.txt 2023-04-20 09:14:32.821304800 +0200
@@ -86,7 +86,7 @@
target_compile_definitions(kj PUBLIC ${CAPNP_LITE_FLAG})
#make sure external consumers don't need to manually set the include dirs
get_filename_component(PARENT_DIR ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)
-target_include_directories(kj INTERFACE
+target_include_directories(kj PUBLIC
$<BUILD_INTERFACE:${PARENT_DIR}>
$<INSTALL_INTERFACE:include>
)
@@ -172,7 +172,12 @@
if(NOT CAPNP_LITE)
add_library(kj-http ${kj-http_sources})
add_library(CapnProto::kj-http ALIAS kj-http)
- target_link_libraries(kj-http PUBLIC kj-async kj)
+ if(WITH_ZLIB)
+ target_compile_definitions(kj-http PRIVATE KJ_HAS_ZLIB)
+ target_link_libraries(kj-http PUBLIC kj-async kj ZLIB::ZLIB)
+ else()
+ target_link_libraries(kj-http PUBLIC kj-async kj)
+ endif()
# Ensure the library has a version set to match autotools build
set_target_properties(kj-http PROPERTIES VERSION ${VERSION})
install(TARGETS kj-http ${INSTALL_TARGETS_DEFAULT_ARGS})
@@ -180,50 +185,51 @@
endif()

# kj-tls ======================================================================
-set(kj-tls_sources
- compat/readiness-io.c++
- compat/tls.c++
-)
-set(kj-tls_headers
- compat/readiness-io.h
- compat/tls.h
-)
-if(NOT CAPNP_LITE)
- add_library(kj-tls ${kj-tls_sources})
- add_library(CapnProto::kj-tls ALIAS kj-tls)
- target_link_libraries(kj-tls PUBLIC kj-async)
- if(WITH_OPENSSL)
+if(WITH_OPENSSL)
+ set(kj-tls_sources
+ compat/readiness-io.c++
+ compat/tls.c++
+ )
+ set(kj-tls_headers
+ compat/readiness-io.h
+ compat/tls.h
+ )
+ if(NOT CAPNP_LITE)
+ add_library(kj-tls ${kj-tls_sources})
+ add_library(CapnProto::kj-tls ALIAS kj-tls)
+ target_link_libraries(kj-tls PUBLIC kj-async)
+
target_compile_definitions(kj-tls PRIVATE KJ_HAS_OPENSSL)
target_link_libraries(kj-tls PRIVATE OpenSSL::SSL OpenSSL::Crypto)
+
+ # Ensure the library has a version set to match autotools build
+ set_target_properties(kj-tls PROPERTIES VERSION ${VERSION})
+ install(TARGETS kj-tls ${INSTALL_TARGETS_DEFAULT_ARGS})
+ install(FILES ${kj-tls_headers} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/kj/compat")
endif()
- # Ensure the library has a version set to match autotools build
- set_target_properties(kj-tls PROPERTIES VERSION ${VERSION})
- install(TARGETS kj-tls ${INSTALL_TARGETS_DEFAULT_ARGS})
- install(FILES ${kj-tls_headers} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/kj/compat")
endif()

# kj-gzip ======================================================================

-set(kj-gzip_sources
- compat/gzip.c++
-)
-set(kj-gzip_headers
- compat/gzip.h
-)
-if(NOT CAPNP_LITE)
- add_library(kj-gzip ${kj-gzip_sources})
- add_library(CapnProto::kj-gzip ALIAS kj-gzip)
+if(WITH_ZLIB)
+ set(kj-gzip_sources
+ compat/gzip.c++
+ )
+ set(kj-gzip_headers
+ compat/gzip.h
+ )
+ if(NOT CAPNP_LITE)
+ add_library(kj-gzip ${kj-gzip_sources})
+ add_library(CapnProto::kj-gzip ALIAS kj-gzip)

- find_package(ZLIB)
- if(ZLIB_FOUND)
- add_definitions(-D KJ_HAS_ZLIB=1)
+ target_compile_definitions(kj-gzip PRIVATE KJ_HAS_ZLIB)
target_link_libraries(kj-gzip PUBLIC kj-async kj ZLIB::ZLIB)
- endif()

- # Ensure the library has a version set to match autotools build
- set_target_properties(kj-gzip PROPERTIES VERSION ${VERSION})
- install(TARGETS kj-gzip ${INSTALL_TARGETS_DEFAULT_ARGS})
- install(FILES ${kj-gzip_headers} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/kj/compat")
+ # Ensure the library has a version set to match autotools build
+ set_target_properties(kj-gzip PROPERTIES VERSION ${VERSION})
+ install(TARGETS kj-gzip ${INSTALL_TARGETS_DEFAULT_ARGS})
+ install(FILES ${kj-gzip_headers} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/kj/compat")
+ endif()
endif()

# Tests ========================================================================
@@ -238,6 +244,8 @@
table-test.c++
map-test.c++
exception-test.c++
+ # this test overrides symbolizer and has to be linked separately
+ # exception-override-symbolizer-test.c++
debug-test.c++
io-test.c++
mutex-test.c++
@@ -279,13 +287,21 @@
compat/gzip-test.c++
compat/tls-test.c++
)
- target_link_libraries(kj-heavy-tests kj-http kj-gzip kj-tls kj-async kj-test kj)
+ target_link_libraries(kj-heavy-tests kj-http kj-async kj-test kj)
if(WITH_OPENSSL)
+ target_link_libraries(kj-heavy-tests kj-tls)
set_property(
SOURCE compat/tls-test.c++
APPEND PROPERTY COMPILE_DEFINITIONS KJ_HAS_OPENSSL
)
endif()
+ if(WITH_ZLIB)
+ target_link_libraries(kj-heavy-tests kj-gzip)
+ set_property(
+ SOURCE compat/gzip-test.c++
+ APPEND PROPERTY COMPILE_DEFINITIONS KJ_HAS_ZLIB
+ )
+ endif()
add_dependencies(check kj-heavy-tests)
add_test(NAME kj-heavy-tests-run COMMAND kj-heavy-tests)
endif() # NOT CAPNP_LITE

0 comments on commit 9325002

Please sign in to comment.