Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ commands:
- run: make -j 16 VERBOSE=1
run-linkage-tests:
steps:
- run:
name: C-only build
command: |
BUILD=$(mktemp -d)
cmake -S test/c-only -B "$BUILD" -DCMAKE_BUILD_TYPE=Debug -DSANITIZE=OFF
cmake --build "$BUILD" --parallel
ctest --test-dir "$BUILD" -VV
- run:
name: Linkage test (static)
command: |
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Template:
Next
---------------------

- Allow the library and examples to build with a C-only toolchain when using CMake 3.12 or newer and disabling the optional test suite
- [Replay fuzz test inputs with allocation failures](https://github.com/PJK/libcbor/pull/438) (by [Alb3e3](https://github.com/Alb3e3)), checking decoder error reporting and cleanup for every `malloc` and `realloc` failure ([#86](https://github.com/PJK/libcbor/issues/86))
- BREAKING: [`cbor_encode_single` and `cbor_encode_double` now preserve NaN sign and payload bits](https://github.com/PJK/libcbor/pull/447)
- Previously, every NaN was encoded as the canonical quiet NaN (`0x7FC00000` / `0x7FF8000000000000`), discarding the sign and payload. The bit pattern is now copied verbatim, matching `cbor_encode_half` since 0.14.0 ([#412](https://github.com/PJK/libcbor/pull/412)) and making decode/encode round trips of NaNs lossless at all three widths
Expand Down
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.5)

project(libcbor VERSION 0.14.0 LANGUAGES C CXX)
project(libcbor VERSION 0.14.0 LANGUAGES C)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
"${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/")
include(CTest)
Expand All @@ -25,6 +25,11 @@ set(CBOR_MAX_STACK_SIZE

option(WITH_TESTS "[TEST] Build unit tests (requires CMocka)" OFF)

# Before CMake 3.12, GenerateExportHeader also requires a C++ compiler.
if(WITH_TESTS OR CMAKE_VERSION VERSION_LESS "3.12")
enable_language(CXX)
endif()

option(WITH_EXAMPLES "Build examples" ON)

option(HUGE_FUZZ
Expand Down
5 changes: 4 additions & 1 deletion doc/source/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ Prerequisites:
- CMake_ 3.5 or newer (might also be called ``cmakesetup``, ``cmake-gui`` or ``ccmake`` depending on the installed version and system)
- C build system CMake can target (make, Apple Xcode, MinGW, ...)

A C++ compiler is also required when building the optional test suite or using
CMake older than 3.12 (whose ``GenerateExportHeader`` module requires C++).

.. _CMake: http://cmake.org/

**Configuration options**
Expand Down Expand Up @@ -62,7 +65,7 @@ A handful of configuration flags can be passed to `cmake`. The following table l
- ``OFF``
- ``ON``, ``OFF``
* - ``WITH_TESTS``
- Build unit tests (requires CMocka; see :doc:`development`)
- Build unit tests (requires CMocka and a C++ compiler; see :doc:`development`)
- ``OFF``
- ``ON``, ``OFF``
* - ``WITH_EXAMPLES``
Expand Down
18 changes: 18 additions & 0 deletions test/c-only/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
cmake_minimum_required(VERSION 3.12)
project(libcbor_c_only_test LANGUAGES C)

# Model a C-only toolchain even on CI machines with a C++ compiler installed.
set(CMAKE_CXX_COMPILER "${CMAKE_CURRENT_BINARY_DIR}/cxx-not-available"
CACHE FILEPATH "Unavailable C++ compiler for this test" FORCE)
set(WITH_TESTS OFF CACHE BOOL "Do not build the optional C++ test" FORCE)
add_subdirectory(../.. libcbor)

get_property(enabled_languages GLOBAL PROPERTY ENABLED_LANGUAGES)
if("CXX" IN_LIST enabled_languages)
message(FATAL_ERROR "Building libcbor without tests must not require C++")
endif()

add_executable(c_only_linkage ../linkage/main.c)
target_link_libraries(c_only_linkage PRIVATE libcbor::libcbor)
enable_testing()
add_test(NAME c_only_linkage COMMAND c_only_linkage)
Loading