How to Build an Edge Application with CMake
CMake is an open-source, cross-platform set of tools that have been created to facilitate the tasks of building, testing, and packaging software. You can use CMake to control the compilation of your applications by using its platform- and compiler-independent configuration files and to generate native makefiles and projects to use in your compiler environment. The minimum required version of CMake to use with the ThingWorx Edge C SDK is 3.4.1. It is recommended that CMake be on your system path. If you installed CMake on Linux, it is on the system path already. If on Windows, you can use the CMake UI or, if using it from a Command Prompt, add CMake to your system PATH.
For complete information about CMake, visit the CMake web site, at
https://cmake.org/. At the top of the home page, select > to find the training materials, reference documents for CMake, among other resources.
|
It is STRONGLY recommended that you use one of the provided examples as a starting point for your custom application.
|
Best Practices for CMake
The CMake files have been refactored following best practices recommended by Craig Scott in
Professional CMake: A Practical Guide, which is available at
https://crascit.com/professional-cmake.
The specific best practices follow:
• Compartmentalize the code base into targets. Third-party libraries can be compiled as their own targets, then linked to the targets that require them.
• Use target settings for the compiler and linker instead of global settings. For example, disable warnings-as-errors for third-party libraries, but enable it for in-house code.
These changes to the CMake files for the C SDK enable isolation of different parts of the code base that may require different compile or link options. Further, the changes support more rigorous build settings, which provides for more robust code.