Adapnex CMake Command Reference
The Adapnex SDK provides a set of CMake commands that simplify project configuration. These commands automate dependency management, platform abstraction, driver linking, and toolchain integration, ensuring your project remains portable across different hardware targets and simulation environments.
adapnex_executable
The adapnex_executable command adds an executable target and links it against the Adapnex runtime and selected hardware drivers. It wraps the standard add_executable() command, automatically handling the platform-specific linking required for your target device.
adapnex_executable(<name> <sources>...)
| Argument | Description |
|---|---|
|
The name of the executable target to create. |
|
One or more source files (e.g., |
project(my_project)
# Creates 'my_app' from main.cpp and links all necessary Adapnex libraries
adapnex_executable(my_app main.cpp)
adapnex_library
The adapnex_library command adds a library target. It wraps add_library() and ensures the target has access to the Adapnex Core API, making it ideal for modularizing code into reusable components or Function Blocks.
adapnex_library(<name> <sources>...)
| Argument | Description |
|---|---|
|
The name of the library target to create. |
|
One or more source files to include in the library. |
# Creates 'my_components' library
adapnex_library(my_components src/motor_control.cpp src/pid.cpp)
# Link the library to your main application
adapnex_executable(my_app main.cpp)
target_link_libraries(my_app PRIVATE my_components)
adapnex_tests
The adapnex_tests command creates a test executable. It wraps add_executable() and pre-configures the target with the Google Test framework and the Adapnex Simulation platform, allowing you to run hardware-independent unit tests. Make sure to call enable_testing() in your CMakeLists.txt to register the tests with CTest.
adapnex_tests(<name> <sources>...)
| Argument | Description |
|---|---|
|
The name of the test executable to create. |
|
One or more test source files (containing |
# Enable testing in the root project
enable_testing()
# Create the test runner
adapnex_tests(my_project_tests tests/main_test.cpp)