## libultrahdr CMake Build Instructions [![Build Status](https://github.com/google/libultrahdr/actions/workflows/cmake_linux.yml/badge.svg?event=push)](https://github.com/google/libultrahdr/actions/workflows/cmake_linux.yml?query=event%3Apush) [![Build Status](https://github.com/google/libultrahdr/actions/workflows/cmake_mac.yml/badge.svg?event=push)](https://github.com/google/libultrahdr/actions/workflows/cmake_mac.yml?query=event%3Apush) [![Build Status](https://github.com/google/libultrahdr/actions/workflows/cmake_win.yml/badge.svg?event=push)](https://github.com/google/libultrahdr/actions/workflows/cmake_win.yml?query=event%3Apush) [![Build Status](https://github.com/google/libultrahdr/actions/workflows/cmake_android.yml/badge.svg?event=push)](https://github.com/google/libultrahdr/actions/workflows/cmake_android.yml?query=event%3Apush) [![Fuzz Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/libultrahdr.svg)](https://introspector.oss-fuzz.com/project-profile?project=libultrahdr) ### Requirements - [CMake](http://www.cmake.org) v3.15 or later - C++ compiler, supporting at least C++17. - libultrahdr uses jpeg compression format to store sdr image and gainmap quotient. So, libjpeg or any other jpeg codec that is ABI and API compatible with libjpeg. The library offers a way to skip installing libjpeg by passing `UHDR_BUILD_DEPS=1` at the time of configure. That is, `cmake -DUHDR_BUILD_DEPS=1` will clone jpeg codec from [link](https://github.com/libjpeg-turbo/libjpeg-turbo.git) and include it in the build process. This is however not recommended. If jpeg is included in the build process then, - C compiler - For building x86/x86_64 SIMD optimizations, [NASM](http://www.nasm.us) or [Yasm](http://yasm.tortall.net). * If using NASM, 2.13 or later is required. * If using Yasm, 1.2.0 or later is required. ### CMake Options There are a few options that can be passed to CMake to modify how the code is built.
To set these options and parameters, use `-D=`. All CMake options are passed at configure time, i.e., by running `cmake -DOPTION_ONE=1 -DOPTION_TWO=0 ...`
before running `cmake --build ...`
For example, to build unit tests in a new subdirectory called 'build', run: ```sh cmake -G "Unix Makefiles" -S. -Bbuild -DUHDR_BUILD_TESTS=1 ../ ``` and then build with: ```sh cmake --build build ``` Following is a list of available options: | CMake Option | Default Value | Notes | |:-------------|:--------------|:-----| | `CMAKE_BUILD_TYPE` | Release | See CMake documentation [here](https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html). | | `BUILD_SHARED_LIBS` | ON | See CMake documentation [here](https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html). | | `UHDR_BUILD_EXAMPLES` | ON | Build sample application. This application demonstrates how to use [ultrahdr_api.h](../ultrahdr_api.h). | | `UHDR_BUILD_TESTS` | OFF | Build Unit Tests. Mostly for Devs. During development, different modules of libuhdr library are validated using GoogleTest framework. Developers after making changes to library are expected to run these tests to ensure every thing is functional. | | `UHDR_BUILD_BENCHMARK` | OFF | Build Benchmark Tests. These are for profiling libuhdr encode/decode API. Resources used by benchmark tests are shared [here](https://storage.googleapis.com/android_media/external/libultrahdr/benchmark/UltrahdrBenchmarkTestRes-1.1.zip). These are downloaded and extracted automatically during the build process for later benchmarking. | | `UHDR_BUILD_FUZZERS` | OFF | Build Fuzz Test Applications. Mostly for Devs. | | `UHDR_BUILD_DEPS` | OFF | Clone and Build project dependencies and not use pre-installed packages. | | `UHDR_BUILD_JAVA` | OFF | Build JNI wrapper, Java front-end classes and Java sample application. | | `UHDR_ENABLE_LOGS` | OFF | Build with verbose logging. | | `UHDR_ENABLE_INSTALL` | ON | Enable install and uninstall targets for libuhdr package.