From 63da2ed359a39fb6fd4018ce2453bff1f6f27c43 Mon Sep 17 00:00:00 2001 From: Keith Derrick Date: Fri, 6 Mar 2026 14:21:05 -0800 Subject: [PATCH 1/3] Cleanup tests CMakeLists --- tests/CMakeLists.txt | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 614ecd8..298f186 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -42,12 +42,4 @@ target_compile_options(oscms_codecs_bridge_tests PRIVATE -std=c++17 -g -O0 add_test(NAME oscms_codecs_bridge_tests COMMAND oscms_codecs_bridge_tests) -# file(GLOB TEST_JSON CONFIGURE_DEPENDS "*.json") file(GLOB TEST_CSV -# CONFIGURE_DEPENDS "*.csv") file(GLOB TEST_TXT CONFIGURE_DEPENDS "*.txt") - -# foreach(TEST_FILE ${TEST_JSON} ${TEST_CSV} ${TEST_TXT}) cmake_path(GET -# TEST_FILE FILENAME TEST_BASENAME) message(STATUS "Configuring TEST FILE: -# ${TEST_BASENAME}") configure_file(${TEST_BASENAME} ${TEST_BASENAME} COPYONLY) -# endforeach() - gtest_discover_tests(oscms_codecs_bridge_tests) From 070ee28a97034e4e20cd24e97fa978410034daa3 Mon Sep 17 00:00:00 2001 From: Keith Derrick Date: Mon, 9 Mar 2026 09:18:21 -0700 Subject: [PATCH 2/3] Use Cmake Helpers --- CMakeLists.txt | 160 ++++++++----------------------------------------- README.md | 23 +++---- 2 files changed, 37 insertions(+), 146 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7cda8a8..2e5582c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,136 +14,22 @@ # # SPDX-License-Identifier: Apache-2.0 -# Enforce out-of-source builds -if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) - message( - FATAL_ERROR - "In-source builds are not allowed. Please create a build directory and run CMake from there.\n" - "You will need to remove CMakeCache.txt and CMakeFiles/ to clean up the generated files." - ) -endif() - -# Ensure one of the two acceptable build types are selected: DEBUG or RELEASE. -# Default to DEBUG -if(NOT CMAKE_BUILD_TYPE) - # No build type specified, default to Debug and force it into the cache - message(STATUS "No build type specified, defaulting to Debug") - set(CMAKE_BUILD_TYPE - Debug - CACHE STRING "Build type" FORCE) -else() - # Check they chose an acceptable one - set(valid_build_types "Debug" "Release") - list(FIND valid_build_types ${CMAKE_BUILD_TYPE} _index) - if(${_index} EQUAL -1) - message( - FATAL_ERROR - "Unknown build type ${CMAKE_BUILD_TYPE}. Supported build types are Debug and Release" - ) - endif() - unset(valid_build_types) -endif() - cmake_minimum_required(VERSION 3.28.3) project( OscmsCodecsBridge VERSION 1.0.0 LANGUAGES C CXX) # CXX added for testing support -# set cmake build options -option(BUILD_TESTS "Build unit tests" ON) -option(RUN_CPPCHECK "Enable cppcheck" ON) - -# set compiler flags Standard compile options -set(CMAKE_C_STANDARD 11) -set(CMAKE_C_STANDARD_REQUIRED TRUE) -set(C_EXTENSIONS ON) # Enable gnu11 -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED TRUE) -set(CXX_EXTENSIONS ON) # Enable gnu11 - -# Enforce C compiler minimum version of 11 (which is what comes with Ubuntu -# 22.04). CI jobs actually use gcc:12 -# -# C++ is only used for unit tests, so we don't care about its version - -if(CMAKE_C_COMPILER_ID STREQUAL "GNU") - if(CMAKE_C_COMPILER_VERSION VERSION_LESS 11) - message( - FATAL_ERROR - "C compiler version must be at least 11.0.0, you are running ${CMAKE_C_COMPILER_VERSION}. Please update your C compiler.\n" - "You will need to remove CMakeCache.txt and CMakeFiles/ to clean up the generated files." - ) - endif() -else() - message( - FATAL_ERROR - "C compiler must be GNU, version >= 11. Please update your C compiler.\n" - "You will need to remove CMakeCache.txt and CMakeFiles/ to clean up the generated files." - ) -endif() - -if(BUILD_TESTS) - # Set up for unit testing using googletest - include(FetchContent) - - # Disable installation of googletest into the install tree - set(INSTALL_GTEST - OFF - CACHE BOOL "" FORCE) +# Pull in the CMake helpers module +include(FetchContent) +FetchContent_Declare( + oscms_cmake_helpers + GIT_REPOSITORY https://github.com/OpenSCMS/oscms-cmake-helpers.git + GIT_TAG main) +FetchContent_MakeAvailable(oscms_cmake_helpers) - # Disable installation of gmock - set(INSTALL_GMOCK - OFF - CACHE BOOL "" FORCE) - - # Download and unpack googletest at configure time - FetchContent_Declare( - googletest # Specify the commit you depend on and update it regularly. - URL https://github.com/google/googletest/archive/refs/tags/v1.16.0.zip) - - # For Windows: Prevent overriding the parent project's compiler/linker - # settings - set(gtest_force_shared_crt - ON - CACHE BOOL "" FORCE) - - # Add googletest directly to our build. This adds the following targets: * - # gtest * gtest_main - FetchContent_MakeAvailable(googletest) - # FetchContent_MakeAvailable(googlemock) - - # Enable unit testing - enable_testing() - - include(GoogleTest) - - set(MEMORYCHECK_COMMAND_OPTIONS - "--tool=memcheck --leak-check=full --num-callers=50 --show-reachable=yes \ - --suppressions=${PROJECT_SOURCE_DIR}/.valgrind.suppressions \ - ${EXTRA_MEMCHECK_OPTIONS}") - include(CTest) -endif() - -# Find cppcheck -option(RUN_CPPCHECK "Enable cppcheck" ON) -if(RUN_CPPCHECK) - find_program(CPPCHECK cppcheck) - if(NOT CPPCHECK) - message(WARNING "cppcheck not found. Disabling cppcheck.") - set(RUN_CPPCHECK OFF) - else() - message(STATUS "Found cppcheck: ${CPPCHECK}") - set(CPPCHECK_OPTIONS - --language=c - --inline-suppr - --platform=unix64 - --enable=all - "--suppressions-list=${PROJECT_SOURCE_DIR}/.cppcheck-suppress" - --force - --error-exitcode=1) - endif() -endif() +oscms_enable_cppcheck() +oscms_enable_testing() # Find OpenSSL find_package(OpenSSL REQUIRED) @@ -232,19 +118,21 @@ target_compile_options( include(GNUInstallDirs) -install( - TARGETS oscms_bridge - DESTINATION ${CMAKE_INSTALL_LIBDIR} - FILE_SET public_headers - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - -install( - DIRECTORY - ${CMAKE_CURRENT_SOURCE_DIR}/codecs/asn1c/submodules/api/include/public/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp") +if(NOT SKIP_INSTALL) + install( + TARGETS oscms_bridge + DESTINATION ${CMAKE_INSTALL_LIBDIR} + FILE_SET public_headers + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + + install( + DIRECTORY + ${CMAKE_CURRENT_SOURCE_DIR}/codecs/asn1c/submodules/api/include/public/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + FILES_MATCHING + PATTERN "*.h" + PATTERN "*.hpp") +endif() if(RUN_CPPCHECK) message(STATUS "Adding cppcheck custom command") diff --git a/README.md b/README.md index 3d91951..6f278dd 100644 --- a/README.md +++ b/README.md @@ -29,16 +29,16 @@ As such, it has knowledge of the implementation of both the server and the under ## Table of Contents -- [Development](#development) - - [Installing Dependencies](#installing-dependencies) - - [Using Docker](#using-docker) - - [Getting the Code](#getting-the-code) - - [Building the code](#building-the-code) - - [Running Unit Tests](#running-unit-tests) - - [Running Valgrind](#running-valgrind) -- [Using a Different Set of CODECs](#using-a-different-set-of-codecs) -- [Contributing](#contributing) -- [License](#license) +* [Development](#development) + * [Installing Dependencies](#installing-dependencies) + * [Using Docker](#using-docker) + * [Getting the Code](#getting-the-code) + * [Building the code](#building-the-code) + * [Running Unit Tests](#running-unit-tests) + * [Running Valgrind](#running-valgrind) +* [Using a Different Set of CODECs](#using-a-different-set-of-codecs) +* [Contributing](#contributing) +* [License](#license) ## Development @@ -115,6 +115,8 @@ The list of repositories, and their relative submodule dependencies is as follow * [etsi_ts103097-asn]() * [ieee1609dot2dot1-asn]() +The project also makes use of the [Cmake Helpers project](https://github.com/OpenSCMS/oscms-cmake-helpers.git) + ### Building the code All C code is built using `CMake` and the `CMake` scripts will enforce out-of-source builds. @@ -138,6 +140,7 @@ All CMake scripts support a common set of options and command line definitions. | CMAKE_BUILD_TYPE | Debug | Defines the build type. Acceptable values are Debug or Release. This primarily affects debug symbols and optimization levels. | | EXTRA_MEMCHECK_OPTIONS | empty | Allows the specification of additional arguments to `valgrind`| | RUN_CPPCHECK | On | Enables or disables running `cppcheck` on all code during the build. | +| SKIP_INSTALL | Off | If set to On, suppresses generation of any `install` targets | ### Running Unit Tests From 4596625e724b7352a0e95b71282ef2f90ca72bae Mon Sep 17 00:00:00 2001 From: Keith Derrick Date: Mon, 9 Mar 2026 09:18:34 -0700 Subject: [PATCH 3/3] Update submodule --- codecs/asn1c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codecs/asn1c b/codecs/asn1c index 6559d0b..40c8c7e 160000 --- a/codecs/asn1c +++ b/codecs/asn1c @@ -1 +1 @@ -Subproject commit 6559d0b94b2194fb830798d02dcae3c4816bcad0 +Subproject commit 40c8c7e2614976871c10ab33d43f1e6bf8197133