|
xentara-cpp-control v1.0.1
The Xentara C++ Control Framework
|
In this tutorial, we will create a CMakeLists.txt file to build a Xentara control using CMake. The CMake file will define the minimum CMake version, specify project settings, find necessary dependencies, add the control source file, and link to the Xentara library.
The objectives of this tutorial are to:
CMakeLists.txt.First, define the minimum required version of CMake. Debian Bookworm uses CMake version 3.25, which we set as the minimum to ensure compatibility with the available system version.
Define the project name and language settings using the project command. The name my-control is used here as an example, and LANGUAGES CXX specifies that this project is written in C++.
To build the control, we need to find the XentaraCPPControl package, which provides the necessary headers and libraries. The find_package command searches for this package and ensures it is available for use. The REQUIRED keyword means CMake will throw an error if the package is not found.
Use the add_library command to specify the output target for the project. Here, we create a library module named my-control and include the source file for the control. Adjust "src/MyControl.cpp" to the actual location of your control's source file.
my-control: The name of the target library.MODULE: Specifies that this library should be compiled as a loadable module.The target_link_libraries command links the control to the required Xentara library (Xentara::cpp-control). This allows the control to use functionality from Xentara's C++ library.
PRIVATE: This keyword restricts the link to internal use within the target (no other target can directly link to this).Xentara::cpp-control: The library target provided by XentaraCPPControl that is needed to build the control.Here is the complete CMakeLists.txt file, combining all the sections explained above:
In this tutorial, we created a CMakeLists.txt file to build a Xentara control. This CMake file defines the minimum required version, specifies the project and dependencies, and links to the necessary Xentara libraries. This setup provides the foundation to build and integrate custom controls into the Xentara framework.