Hi @Peter19
If you want to have one root CMakeFiles.
You can try to this.
project-root/
├── CMakeLists.txt
├── app1/
│ ├── CMakeLists.txt
│ ├── main.c
├── app2/
│ ├── CMakeLists.txt
│ ├── main.c
Root CMakeLists.txt
cmake_minimum_required(VERSION 3.13)
project(MultiTargetExample)
# Include NXP MCUXpresso SDK
set(MCUX_SDK_PROJECT_NAME ${PROJECT_NAME})
include($ENV{MCUX_SDK_PATH}/tools/cmake/sdk.cmake)
# Add subdirectories for each application
add_subdirectory(app1)
add_subdirectory(app2)
app1/CMakeLists.txt
# Define the first application
set(TARGET_NAME app1)
add_executable(${TARGET_NAME} main.c)
# Link the NXP SDK components (adjust as necessary for your dependencies)
target_link_libraries(${TARGET_NAME} PRIVATE
${MCUX_SDK_PROJECT_NAME}.board
${MCUX_SDK_PROJECT_NAME}.drivers
${MCUX_SDK_PROJECT_NAME}.utilities
)
# Specify any additional compile definitions or flags for app1
target_compile_definitions(${TARGET_NAME} PRIVATE APP1_BUILD)
app2/CMakeLists.txt
# Define the second application
set(TARGET_NAME app2)
add_executable(${TARGET_NAME} main.c)
# Link the NXP SDK components (adjust as necessary for your dependencies)
target_link_libraries(${TARGET_NAME} PRIVATE
${MCUX_SDK_PROJECT_NAME}.board
${MCUX_SDK_PROJECT_NAME}.drivers
${MCUX_SDK_PROJECT_NAME}.utilities
)
# Specify any additional compile definitions or flags for app2
target_compile_definitions(${TARGET_NAME} PRIVATE APP2_BUILD)
BR
Harry