sfdk-cmake
Configure SFDK projects using CMake
TLDR
Run cmake
Run cmake in specified project directory
Run cmake with extra arguments
Run cmake build in current directory
Run cmake build in current directory with extra cmake arguments
Run cmake build in current directory with extra build tool arguments
SYNOPSIS
sfdk-cmake [options] path-to-source
sfdk-cmake --build build-directory [options]
sfdk-cmake --install build-directory [options]
PARAMETERS
-G
Specifies the build system generator. Common choices include 'Unix Makefiles' or 'Ninja'. sfdk-cmake might default to a suitable generator if not specified.
-D
Defines a CMake variable. This is commonly used to pass configuration options to the project, such as enabling/disabling features or specifying paths. sfdk-cmake may set some default variables internally.
-B
Specifies the directory where the build files (e.g., Makefiles, Ninja files) will be generated. It's good practice to build outside the source directory.
-S
Specifies the path to the source directory containing the CMakeLists.txt file. Often inferred from the positional argument.
--build
Builds a previously configured project. This command invokes the native build tool (e.g., make or ninja) within the specified build directory.
--install
Installs the project targets. This command runs the 'install' target of the build system, typically after a successful build.
--clean-first
Used with '--build' to clean a project before building it.
--target
Used with '--build' to specify a particular target to build (e.g., 'all', 'install', a specific library).
--config
Used with '--build' (primarily for multi-configuration generators like Visual Studio) to specify the build configuration (e.g., 'Debug', 'Release').
-DCMAKE_INSTALL_PREFIX=
Specifies the installation directory for the project. When building for Sailfish OS, this often defaults to the SDK's sysroot structure.
A positional argument representing the path to the source directory containing the top-level CMakeLists.txt file. Often used as the first argument when configuring a project.
DESCRIPTION
The sfdk-cmake command is a specialized wrapper for the standard CMake build system generator, provided as part of the Sailfish OS SDK (SDK). Its primary purpose is to simplify the process of configuring and building applications or libraries for the Sailfish OS platform, especially in cross-compilation environments. Instead of manually setting complex toolchain files, sysroots, and build environments for different Sailfish OS targets (e.g., specific device architectures or SDK versions), sfdk-cmake automates these configurations.
It essentially invokes the underlying CMake executable with pre-configured settings tailored for Sailfish OS development, making the cross-compilation setup seamless for developers. Developers can use it much like the regular cmake command, passing most of the standard CMake options and arguments, which sfdk-cmake then relays to the actual CMake process after applying its Sailfish OS-specific adjustments.
CAVEATS
sfdk-cmake is not a standalone command; it requires the Sailfish OS SDK to be installed and properly configured. It is specifically designed for cross-compiling projects for Sailfish OS and may not function correctly or be suitable for native development environments outside the SDK. Its behavior is tightly coupled with the SDK's internal toolchain and environment settings, which are dynamically applied before invoking CMake.
SIMPLIFYING CROSS-COMPILATION
One of the core benefits of sfdk-cmake is its ability to automatically set up the CMake toolchain file (CMAKE_TOOLCHAIN_FILE) and other critical variables required for cross-compilation to the Sailfish OS target. This eliminates the need for developers to manually specify these often complex paths and settings, significantly reducing configuration errors and setup time.
INTEGRATION WITH SFDK ENVIRONMENT
sfdk-cmake operates within the context of the currently active Sailfish OS SDK environment (as managed by the sfdk command). This means it automatically picks up the correct target architecture, SDK version, and sysroot location defined by the sfdk configuration, ensuring that projects are built against the correct platform components.
HISTORY
The sfdk-cmake command emerged as part of the Sailfish OS SDK, developed by Jolla. As Sailfish OS application development embraced CMake as a primary build system, a need arose to simplify the complex cross-compilation setup. sfdk-cmake was introduced to abstract away the intricate details of toolchain configuration, sysroot management, and environment variables necessary for building against the SDK. Its evolution is closely tied to the development of the Sailfish OS platform and the sfdk utility itself, aiming to provide a streamlined and developer-friendly experience for building native applications.