diff --git a/CMakeLists.txt b/CMakeLists.txt index 134fdebb4dbc6e33987d209aced3b96b135acc84..24f665f3d18d2fd4e52e825d57ca55a1372a8627 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -243,6 +243,7 @@ install(FILES README.rst DESTINATION "${CMAKE_INSTALL_DOCDIR}") add_subdirectory(lib) add_subdirectory(tests) +add_subdirectory(crypto) add_subdirectory(third-party) add_subdirectory(examples) diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..0e7059691f46d4e1ab3b0b2c0417f838ae7f690b --- /dev/null +++ b/crypto/CMakeLists.txt @@ -0,0 +1,29 @@ +# ngtcp2 + +# Copyright (c) 2019 ngtcp2 + +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: + +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +if(OPENSSL_FOUND) + add_subdirectory(includes) + add_subdirectory(openssl) +else() + message(WARNING "libngtcp2_crypto_openssl library is disabled due to lack of good OpenSSL") +endif() diff --git a/crypto/includes/CMakeLists.txt b/crypto/includes/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..87d97b3d79d14281e9fc225c7308bbb8fd74eba5 --- /dev/null +++ b/crypto/includes/CMakeLists.txt @@ -0,0 +1,26 @@ +# ngtcp2 + +# Copyright (c) 2019 ngtcp2 + +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: + +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +install(FILES + ngtcp2/ngtcp2_crypto.h + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/ngtcp2") diff --git a/crypto/openssl/CMakeLists.txt b/crypto/openssl/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..576b738f9fa219fd51eecf927f1918024280949c --- /dev/null +++ b/crypto/openssl/CMakeLists.txt @@ -0,0 +1,58 @@ +# ngtcp2 + +# Copyright (c) 2019 ngtcp2 + +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: + +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +add_definitions(-DBUILDING_NGTCP2) + +set(ngtcp2_crypto_openssl_SOURCES + openssl.c + ../shared.c +) + +set(ngtcp2_crypto_openssl_INCLUDE_DIRS + "${CMAKE_SOURCE_DIR}/lib/includes" + "${CMAKE_BINARY_DIR}/lib/includes" + "${CMAKE_SOURCE_DIR}/lib" + "${CMAKE_SOURCE_DIR}/crypto/includes" + "${CMAKE_BINARY_DIR}/crypto/includes" + "${OPENSSL_INCLUDE_DIRS}" +) + +# Public shared library +add_library(ngtcp2_crypto_openssl ${ngtcp2_crypto_openssl_SOURCES}) +set_target_properties(ngtcp2_crypto_openssl PROPERTIES + COMPILE_FLAGS "${WARNCFLAGS}" + VERSION ${LT_VERSION} SOVERSION ${LT_SOVERSION} + C_VISIBILITY_PRESET hidden +) + +target_include_directories(ngtcp2_crypto_openssl PUBLIC + ${ngtcp2_crypto_openssl_INCLUDE_DIRS}) +if(NOT BUILD_SHARED_LIBS) + target_compile_definitions(ngtcp2_crypto_openssl PUBLIC "-DNGTCP2_STATICLIB") +endif() + +install(TARGETS ngtcp2_crypto_openssl + DESTINATION "${CMAKE_INSTALL_LIBDIR}") + +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libngtcp2_crypto_openssl.pc" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index c995f8fee29d61951014ae600440c0f6d7b5677b..b1e0a680cdb99d450995c41db08476509cf9c3e7 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -26,6 +26,7 @@ if(LIBEV_FOUND AND OPENSSL_FOUND AND LIBNGHTTP3_FOUND) ${CMAKE_SOURCE_DIR}/lib/includes ${CMAKE_BINARY_DIR}/lib/includes ${CMAKE_SOURCE_DIR}/third-party + ${CMAKE_SOURCE_DIR}/crypto/includes ${OPENSSL_INCLUDE_DIRS} ${LIBEV_INCLUDE_DIRS} @@ -33,6 +34,7 @@ if(LIBEV_FOUND AND OPENSSL_FOUND AND LIBNGHTTP3_FOUND) ) link_libraries( + ngtcp2_crypto_openssl ngtcp2 ${OPENSSL_LIBRARIES} ${LIBEV_LIBRARIES} @@ -44,8 +46,6 @@ if(LIBEV_FOUND AND OPENSSL_FOUND AND LIBNGHTTP3_FOUND) debug.cc util.cc keylog.cc - crypto_openssl.cc - crypto.cc shared.cc ) @@ -54,8 +54,6 @@ if(LIBEV_FOUND AND OPENSSL_FOUND AND LIBNGHTTP3_FOUND) debug.cc util.cc keylog.cc - crypto_openssl.cc - crypto.cc http.cc shared.cc )