diff --git a/.appveyor.yml b/.appveyor.yml index b812496..d03957c 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -8,7 +8,7 @@ cache: before_build: - vcpkg install getopt:x64-windows - vcpkg integrate install - - cmake -DLSQPACK_TESTS=ON -DCMAKE_GENERATOR_PLATFORM=x64 -DVCPKG_TARGET_TRIPLET=x64-windows -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CONFIGURATION_TYPES=Debug -DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake -DGETOPT_INCLUDE_DIR=c:/tools/vcpkg/installed/x64-windows/include -DGETOPT_LIB=c:/tools/vcpkg/installed/x64-windows/lib/getopt.lib . + - cmake -DLSQPACK_TESTS=ON -DLSQPACK_XXH=ON -DCMAKE_GENERATOR_PLATFORM=x64 -DVCPKG_TARGET_TRIPLET=x64-windows -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CONFIGURATION_TYPES=Debug -DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake -DGETOPT_INCLUDE_DIR=c:/tools/vcpkg/installed/x64-windows/include -DGETOPT_LIB=c:/tools/vcpkg/installed/x64-windows/lib/getopt.lib . build_script: - cmake --build . diff --git a/.cirrus.yml b/.cirrus.yml index ed372c5..bb66d70 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -2,5 +2,5 @@ freebsd_instance: image: freebsd-13-3-release-amd64 task: - install_script: pkg install -y cmake bash perl5 - script: cmake -DLSQPACK_TESTS=ON . && make && make test + install_script: pkg install -y cmake bash perl5 p5-PkgConfig-LibPkgConf devel/xxhash + script: cmake -DLSQPACK_TESTS=ON -DLSQPACK_XXH=OFF . && make && make test diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a1f8e9..675c1db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,20 +9,34 @@ # LDFLAGS cmake_minimum_required(VERSION 3.1) -project(ls-qpack LANGUAGES C) +project(ls-qpack + LANGUAGES C + HOMEPAGE_URL "https://github.com/litespeedtech/ls-qpack" + DESCRIPTION "QPACK compression library for use with HTTP/3" + VERSION 2.5.3) option(LSQPACK_TESTS "Build tests") option(LSQPACK_BIN "Build binaries" ON) option(LSQPACK_XXH "Include XXH" ON) +option(BUILD_SHARED_LIBS OFF) # Use `cmake -DBUILD_SHARED_LIBS=OFF` to build a static library. add_library(ls-qpack "") +set_target_properties(ls-qpack PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR}) target_include_directories(ls-qpack PUBLIC .) target_sources(ls-qpack PRIVATE lsqpack.c) -target_include_directories(ls-qpack PRIVATE deps/xxhash/) -if(LSQPACK_XXH) +if(LSQPACK_XXH OR MSVC) + target_include_directories(ls-qpack PRIVATE deps/xxhash/) target_sources(ls-qpack PRIVATE deps/xxhash/xxhash.c) + set(LSQPACK_DEPENDS "") +else() + find_package(PkgConfig REQUIRED) + pkg_check_modules(XXH REQUIRED IMPORTED_TARGET libxxhash) + target_link_libraries(ls-qpack PUBLIC PkgConfig::XXH) + set(LSQPACK_DEPENDS "libxxhash") endif() if(WIN32) @@ -102,8 +116,23 @@ if(LSQPACK_BIN) add_subdirectory(bin) endif() -install(TARGETS ls-qpack) -install(FILES lsqpack.h lsxpack_header.h DESTINATION include) +include(GNUInstallDirs) +configure_file(lsqpack.pc.in lsqpack.pc @ONLY) + +install(TARGETS ls-qpack + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) +install(FILES lsqpack.h lsxpack_header.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/bin/encode-int + ${CMAKE_CURRENT_BINARY_DIR}/bin/fuzz-decode + ${CMAKE_CURRENT_BINARY_DIR}/bin/interop-decode + ${CMAKE_CURRENT_BINARY_DIR}/bin/interop-encode + DESTINATION ${CMAKE_INSTALL_BINDIR}) + if(WIN32) install(DIRECTORY wincompat/sys DESTINATION include) +else() + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/lsqpack.pc" + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) endif() diff --git a/bin/CMakeLists.txt b/bin/CMakeLists.txt index c58b526..9856306 100644 --- a/bin/CMakeLists.txt +++ b/bin/CMakeLists.txt @@ -2,8 +2,13 @@ function(lsqpack_add_executable TARGET) add_executable(${TARGET} "") target_link_libraries(${TARGET} PRIVATE ls-qpack) - target_sources(${TARGET} PRIVATE ${TARGET}.c ../deps/xxhash/xxhash.c) - target_include_directories(${TARGET} PRIVATE ../deps/xxhash) + if(LSQPACK_XXH OR MSVC) + target_sources(${TARGET} PRIVATE ${TARGET}.c ../deps/xxhash/xxhash.c) + target_include_directories(${TARGET} PRIVATE ../deps/xxhash) + else() + target_sources(${TARGET} PRIVATE ${TARGET}.c) + target_link_libraries(${TARGET} PUBLIC PkgConfig::XXH) + endif() if(WIN32) target_include_directories(${TARGET} PRIVATE ../wincompat) diff --git a/lsqpack.pc.in b/lsqpack.pc.in new file mode 100644 index 0000000..7eac772 --- /dev/null +++ b/lsqpack.pc.in @@ -0,0 +1,12 @@ +prefix="@CMAKE_INSTALL_PREFIX@" +exec_prefix="${prefix}" +libdir="${prefix}/@CMAKE_INSTALL_LIBDIR@" +includedir="${prefix}/@CMAKE_INSTALL_INCLUDEDIR@" + +Name: @PROJECT_NAME@ +Description: @CMAKE_PROJECT_DESCRIPTION@ +URL: @CMAKE_PROJECT_HOMEPAGE_URL@ +Version: @PROJECT_VERSION@ +Requires: @LSQPACK_DEPENDS@ +Cflags: -I"${includedir}" +Libs: -L"${libdir}" -llsqpack diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index be848bf..b0677da 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,9 +1,13 @@ function(lsqpack_add_test TARGET) add_executable(test_${TARGET} "") target_sources(test_${TARGET} PRIVATE test_${TARGET}.c) - target_link_libraries(test_${TARGET} ls-qpack) - + if(LSQPACK_XXH OR MSVC) + target_link_libraries(test_${TARGET} ls-qpack) + else() + target_link_libraries(test_${TARGET} ls-qpack PkgConfig::XXH) + endif() if(WIN32) + target_include_directories(test_${TARGET} PRIVATE ../wincompat) target_link_libraries(test_${TARGET} ${GETOPT_LIB}) else()