Building Serenity




General Build Steps


If building Serenity from source, the first thing you'll need installed is CMake, which you can find HERE. CMake is a free to use software that is used for cross-platform project file generation. This project uses CMake version 3.14 as its minimum version for generating the project files. Once you have both CMake installed and Serenity's source code downloaded, you're free to generate the project files from anywhere of your choosing. Just note, that Serenity's root folder is off-limits as a folder to generate the files into, however, you're free to generate the files in another user made folder in Serenity's root folder and everywhere else outside Serenity's root folder.

For Example:

If in the root folder of Serenity, you could run

" cmake -B build -S . "
  • This will generate the build files in a folder named "build" inside the Serenity project root folder.

If you were to generate the files in any other location, that location will need to be specified after the '-B' flag above as well as the location to Serenity's root folder location after the '-S' flag. Such as:

" cmake -B build -S Serenity "
OR
" cmake -B ../build -S . "

Generally speaking, the flow that users tend to use with CMake is to change directories to the project's root folder and run the first command listed above or to change directories to the project root folder and run

" mkdir build_folder_name "
" cd build_folder_name "
" cmake .. "

Build Options

Generally Speaking, you will be able to find all related build options for Serenity under the folder named 'cmake' in the file named 'Options.cmake'. How you tack on build options is by adding the build option to the CMake configure command from above with the '-D' flag and either enabling or disabling the option with '="ON"' or '="OFF"'.

Options available are:

  • BUILD_SANDBOX - If this build option is set, then the sandbox sub project will be included in the generation step.
  • BUILD_BENCHMARKS - If this build option is set, this will add the bench suite sub project. This project also depends on spdlog as it benches Serenity against spdlog.
  • BUILD_TESTS - If this build option is set, it will add the tests sub project upon project generation. This includes tests created to ensure Serenity is working as expected.
  • BUILD_DEMOS - If this build option is set, it will add the demos sub project. Right now, this only includes a text color demo.
  • BUILD_ALL - If this build option is set, all four of the above options are more or less set and all sub projects will be generated along with Serenity.
  • USE_STDFMT - If this build option is set, then Serenity will use the 'format' header and std::format for backend formatting of log messages.
  • USE_FMTLIB - If this build option is set, then Serenity will use the 'fmt' project and fmt::format for backend formatting of log messages. The version of 'fmt' included is version 9.1.0 by default.
  • USE_NATIVEFMT - This is the default formatter build option. If this build option is set, it will use the 'ArgFormatter' project and formatter::format for backend formatting of log messages.
  • DISABLE_NATIVE_WARNING - When using 'ArgFormatter' as the backend, there's a short message reminding you that 'fmt' and 'format' are available as backend formatters. Enabling this option disables that message on project compilation. This message is primarily in the case that `ArgFormatter` doesn't cover a use case that the other two do cover.
An Example of using the above build options would be:
  1. " cmake -B build -S . -DUSE_NATIVEFMT="OFF" -DUSE_NATIVEFMT="ON" "
    • The above line would generate the project files in the build folder 'build' using "fmtlib" as the formatting backend.
  2. " cmake -B build -S . -DDISABLE_NATIVE_WARNING="ON" "
    • The above line would generate the project files in the build folder 'build' using "ArgFormatter" as the formatting backend while disabling the compilation message.