Skip to content

Configuration options

David K edited this page Jan 12, 2024 · 9 revisions

Basic project configurations

Name, version and description of the project are configured in vcpkg.json.

Due to the limitations of vcpkg, the name can only contain lowercase letters and dashes, the dashes(-) are converted to underscores (_) for use in cmake.

Several CMake presets are provided as well.

Cmake options

The common cmake options are centralized in the cmake/options.cmake file. For more detailed configuration see other files in the cmake directory.

This is a list of all available options and their defaults

  • Target names
    • EXE_NAME
      • Description: name of the compiled executable.
      • Default: same as project name.
    • OBJLIB_NAME
      • Description: name of the object "library". This is a cmake mechanism which allows object files to be shared between the main executable and the tests.
      • Default: EXE_NAME_objlib.
    • TEST_NAME
      • Description: name of the test executable.
      • Default: EXE_NAME_test.
    • DOXYGEN_SUFFIX
      • Description: name of the target which builds documentation.
      • Default: EXE_NAME_docs.
  • Main file
    • MAIN
      • Description: the file containing the main function. This file will not be included in the test executable (because it provides its own main) so functions/classes defined in it cannot be tested.
      • Default: ./src/main.cpp.
  • Compiled binary location
    • CMAKE_ARCHIVE_OUTPUT_DIRECTORY
      • Description: compiled archive (.a/.lib) output directory.
      • Default: build/lib
    • CMAKE_LIBRARY_OUTPUT_DIRECTORY
      • Description: compiled library (.so/.dll) output directory.
      • Default: build/lib
    • CMAKE_RUNTIME_OUTPUT_DIRECTORY
      • Description: compiled executable (' '/.exe) output directory.
      • Default: build/bin
  • Testing (see testing)
    • BUILD_TESTING
      • Description: should the tests be built
      • Default: ON.
  • Analyzers (see analyzers)
    • ENABLE_CPPCHECK
      • Default: OFF
    • ENABLE_CLANG_TIDY
      • Default: OFF
    • ENABLE_INCLUDE_WHAT_YOU_USE
      • Default: OFF
  • Sanitizers (see sanitizers)
    • ENABLE_SANITIZERS
      • Default: OFF
    • SANITIZER_LIST
      • Default: address,leak,undefined
  • Documentation (See documentation)
    • ENABLE_DOXYGEN
      • Default: OFF
  • Warnings
    • WARNINGS_AS_ERRORS
      • Description: Treat all warnings as errors
      • Default: ON
  • Caching
    • ENABLE_CACHE
      • Description: Use ccache to cache compiled object files
      • Default: OFF
    • CACHE_PROGRAM
      • Description: Name of the caching program
      • Default: ccache
  • Language
    • CMAKE_CXX_STANDARD
      • Description: Standard of the language to use
      • Default: 17
    • CMAKE_CXX_EXTENSIONS
      • Description: Whether to allow compiler specific language extensions
      • Default: OFF
  • Compile commands
    • CMAKE_EXPORT_COMPILE_COMMANDS
      • Description: Enable generation of compile_commands.json used by various clang based tools.
      • Default: OFF
Clone this wiki locally