Skip to content

Commit

Permalink
build: Switching completely to cmake for builds
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Collins <[email protected]>
  • Loading branch information
benmcollins committed Dec 24, 2024
1 parent caa375c commit 4e87e53
Show file tree
Hide file tree
Showing 35 changed files with 89 additions and 1,956 deletions.
32 changes: 2 additions & 30 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,50 +1,22 @@
# Generic ignores for libtool project
Makefile.in
Makefile
/INSTALL
/autom4te.cache
/aclocal.m4
/compile
/configure
/configure~
/depcomp
/install-sh
/missing
/stamp-h1
/m4/**
/config.guess
/config.sub
/config.log
/config.status
/ltmain.sh
/libtool
**/.deps/**
*.la
*.lo
*.o
**/.libs/**
*/config.h
*/config.h.in
*/config.h.in~
*/stamp-h1
/test-driver
/coverage.info
/coveragereport/*
*.gcno
/.vscode/*
*~
*.tmp
.dirstamp
.*.swp

# Generic ignores for cmake project
/out/*
/out/**
/build/**

/doxygen-doc/**
/libjwt/libjwt.pc
/include/jwt_export.h
/dist/libjwt.spec
/dist/rpmbuild/**

# Cmake
/build
25 changes: 9 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ before_install:

before_script:
- set -ev
- autoreconf --version
- autoreconf -fi
- mkdir build
- cd build

Expand All @@ -32,30 +30,25 @@ after_script:

jobs:
include:
- name: "Autotools Build (focal)"
- name: "Focal"
dist: focal
script:
- ../configure
- make
- rm -rf *
- cmake -DWITH_TESTS=NO ..
- make

- name: "CMake Build"
dist: jammy
script:
- cmake -DWITH_GNUTLS=YES -DWITH_OPENSSL=YES ..
- make check

- name: "Autotools Build"
- name: "Jammy"
dist: jammy
script:
- ../configure --with-openssl --with-gnutls
- cmake -DWITH_GNUTLS=YES -DWITH_OPENSSL=YES ..
- make check

- name: "Coverage Build"
dist: jammy
script:
- ../configure --without-gnutls --enable-code-coverage --enable-valgrind
- make check-valgrind check-code-coverage doxygen-doc
- cmake -DWITH_GNUTLS=NO -DWITH_OPENSSL=YES -DENABLE_COVERAGE ..
- make
- ctest -T memcheck
- make doxygen-doc
- make package_source
- make check-code-coverage
- codecov
41 changes: 25 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cmake_minimum_required (VERSION 3.7...3.15)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

# Extract info from configure.ac
include(AutoToolsVersion)
include(LibJWTVersions)
include(GenerateExportHeader)

project(${LIBJWT_PROJECT}
Expand Down Expand Up @@ -168,6 +168,8 @@ add_definitions(-DKEYDIR=\"${CMAKE_SOURCE_DIR}/tests/keys\")
install(FILES include/jwt.h
${CMAKE_BINARY_DIR}/jwt_export.h
DESTINATION include)
install(FILES LICENSE README.md
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/${LIBJWT_PROJECT_LOWER})

# Install library
install(TARGETS jwt
Expand All @@ -183,25 +185,22 @@ install(TARGETS jwt_static
ARCHIVE DESTINATION lib
)

# For cmake users
install(EXPORT ${LIBJWT_PROJECT}Targets
FILE ${LIBJWT_PROJECT}Config.cmake
NAMESPACE ${LIBJWT_PROJECT}::
DESTINATION lib/cmake/${LIBJWT_PROJECT}
)

# We do this to make it compatible with autotools
set(PACKAGE_NAME ${PROJECT_NAME})
set(PACKAGE_VERSION ${PROJECT_VERSION})
set(prefix ${CMAKE_INSTALL_PREFIX})
string(JOIN " " JANSSON_LIBS ${JANSSON_LDFLAGS})
if (OPENSSL_FOUND)
string(JOIN " " OPENSSL_LIBS ${OPENSSL_LDFLAGS})
endif()
if (GNUTLS_FOUND)
string(JOIN " " GNUTLS_LIBS ${GNUTLS_LDFLAGS})
endif()
# For pkg-config users
unset(LIBJWT_LDFLAGS)
foreach (FLAG ${JANSSON_LDFLAGS} ${OPENSSL_LDFLAGS} ${GNUTLS_LDFLAGS})
string(APPEND LIBJWT_LDFLAGS " " ${FLAG})
endforeach()

configure_file(libjwt/libjwt.pc.in libjwt.pc @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/libjwt.pc DESTINATION lib/pkgconfig)
install(FILES ${CMAKE_BINARY_DIR}/libjwt.pc
DESTINATION lib/pkgconfig)

find_package(Doxygen)

Expand All @@ -219,7 +218,7 @@ if (DOXYGEN_FOUND)
COMMAND ${CMAKE_COMMAND} -E env
${DOXYGEN_ENV_VARS}
${DOXYGEN_EXECUTABLE}
${CMAKE_SOURCE_DIR}/Doxyfile
${CMAKE_SOURCE_DIR}/doxygen/Doxyfile
COMMENT "Generating documentation with Doxygen"
VERBATIM
)
Expand All @@ -229,8 +228,14 @@ option(ENABLE_COVERAGE "Enable code coverage rules" OFF)

# Tests and coverage depend on this, but optional
if (WITH_TESTS)
option(ENABLE_COVERAGE "Enable code coverage rules" OFF)
pkg_check_modules(CHECK check>=0.9.10 IMPORTED_TARGET)
if (ENABLE_COVERAGE)
set(CHECK_REQUIRED "REQUIRED")
endif()
pkg_check_modules(CHECK check>=0.9.10 IMPORTED_TARGET ${CHECK_REQUIRED})
else()
if (ENABLE_COVERAGE)
message(SEND_ERROR "You must set WITH_TESTS=ON to enable code coverage")
endif()
endif()

function(jwt_add_test)
Expand Down Expand Up @@ -280,6 +285,10 @@ if (CHECK_FOUND)
EXECUTABLE ctest -j ${PROCESSOR_COUNT}
DEPENDENCIES ${UNIT_TESTS})
endif()
else()
if (ENABLE_COVERAGE)
message(SEND_ERROR "Coverage enabled, but did not find check library")
endif()
endif()

set(CPACK_PROPERTIES_FILE "${CMAKE_SOURCE_DIR}/cmake/CPackConfig.cmake")
Expand Down
188 changes: 0 additions & 188 deletions Doxygen.mk

This file was deleted.

Loading

0 comments on commit 4e87e53

Please sign in to comment.