Implementation of JOSE for C/C++
MAC OS X All of the prerequisites can be installed via brew.
- CMake (>= 3.22)
- A C99 compiler (LLVM/Clang >= 5.1, GCC >= 4.5 or MSVC >= 14)
- Check (>= 0.9.4) - unit testing (e.g. check-devel)
- Doxygen (>= 1.8) - API documentation (optional)
- clang-format - source formatting (optional)
The autotools toolchain (pkg-config, GNU Make, Autoconf, Automake, libtool) is only required for the deprecated build described at the end of this document.
- OpenSSL >= 1.0.1h (or its API equivalent)
- Jansson >= 2.3
cjose builds with CMake (>= 3.23):
git clone https://github.com/cisco/cjose.git
cd cjose
cmake -S . -B build
cmake --build build
By default both the shared and static libraries are built (and, when cjose is the top-level project, the unit tests).
Pass options with -D<OPTION>=<VALUE> at configure time:
| Option | Default | Description |
|---|---|---|
CJOSE_BUILD_SHARED |
ON |
Build the shared/dynamic library |
CJOSE_BUILD_STATIC |
ON |
Build the static library |
CJOSE_BUILD_TESTS |
ON when top-level |
Build the unit tests (requires Check) |
CJOSE_MSVC_STATIC_RUNTIME |
OFF |
(MSVC) Link against the static C runtime (/MT) |
CJOSE_MACOS_DYLIB |
OFF |
(macOS) Build a plain .dylib instead of a framework |
For example, to build only the static library in debug mode:
cmake -S . -B build -DCJOSE_BUILD_SHARED=OFF -DCMAKE_BUILD_TYPE=Debug
cmake --build build
OpenSSL and Jansson are located automatically. If they live in a custom prefix, point CMake at it:
cmake -S . -B build -DCMAKE_PREFIX_PATH="/usr/local/opt/openssl;/usr/local/opt/jansson"
To run the unit tests:
ctest --test-dir build --output-on-failure -V
To generate the Doxygen API documentation (requires Doxygen):
cmake --build build --target doxygen
The generated HTML is placed in build/doc/html.
cmake --install build --prefix /your/install/prefix
This installs the libraries, the public headers, a cjose.pc pkg-config file
and a CMake package config.
After installing, consume cjose from a CMake project via find_package:
find_package(cjose REQUIRED)
target_link_libraries(myapp PRIVATE cjose::cjose_shared) # or cjose::cjose_static
Alternatively, embed the sources directly with add_subdirectory() or
FetchContent; the same cjose::cjose_shared / cjose::cjose_static targets
are provided.
- Run
cmake --build build --target clang-format - Run
ctest --test-dir build
Deprecated. The autotools (autoconf/automake/libtool) build below is kept for reference only and will be removed soon. Please use the CMake build described above.
As with most autoconf/automake projects:
git clone https://github.com/cisco/cjose.git
cd cjose
./configure && make
--with-openssl: Specify the location where OpenSSL/CiscoSSL is installed
--with-jansson: Specify the location where Jansson is installed
--disable-shared: Only build static library
To compile in debug mode (minimal optimization, active asserts, etc), specify the appropriate CFLAGS as a command-line argument when executing configure:
./configure CFLAGS="-g -O0 -DDEBUG"
To execute the unit tests:
make test
If successful, the list of checks will be displayed on the console. Otherwise, the file "test/test-suite.log" will list the specific test(s) that failed.
To generate Doxygen API documentation:
make doxygen
Which will place the generated documentation in "doc/html".
To rebuild all of the project -- including those files generated by autoconf and automake:
autoreconf --force --install
This has been seen on Mac OSX 10.8 and 10.9 when check has been installed via brew. A solution is to explicitly include the /usr/local/include directory in the cflags:
./configure CFLAGS="-I/usr/local/include"
This has been seen on Mac OSX 10.9 when openssl 1.0.1h or newer has been installed via brew. A solution is to explicitly include the openssl directory in the configure command:
./configure --with-openssl=/usr/local/opt/openssl
This has been seen on Mac OSX 10.9 when Jansson has been installed via brew. A solution is to explicitly include the jansson directory in the configure command:
./configure --with-jansson=/usr/local/opt/jansson
- Run
make clang-format - Run
make test