From df9748c514487204e36aca43670c740c5b4d9a6c Mon Sep 17 00:00:00 2001 From: trns1997 Date: Fri, 26 Sep 2025 21:24:27 +0200 Subject: [PATCH] testing/cxx-oot-build: Exclude cxx-oot-build in CMake projects. Remove the previous guard logic and use a proper CMake `exclude` rule to prevent `cxx-oot-build` from being included when building projects with CMake. * Ensures OOT test project is not pulled into normal apps. * Keeps CI and export tests isolated from regular builds. Signed-off-by: trns1997 --- testing/CMakeLists.txt | 2 +- testing/cxx-oot-build/CMakeLists.txt | 46 ++++++++++++---------------- 2 files changed, 20 insertions(+), 28 deletions(-) diff --git a/testing/CMakeLists.txt b/testing/CMakeLists.txt index dcccb6f0983..5e3759f2c54 100644 --- a/testing/CMakeLists.txt +++ b/testing/CMakeLists.txt @@ -20,5 +20,5 @@ # # ############################################################################## -nuttx_add_subdirectory() +nuttx_add_subdirectory(EXCLUDE cxx-oot-build) nuttx_generate_kconfig(MENUDESC "Testing") diff --git a/testing/cxx-oot-build/CMakeLists.txt b/testing/cxx-oot-build/CMakeLists.txt index d60dc36620f..b3b89d6a866 100644 --- a/testing/cxx-oot-build/CMakeLists.txt +++ b/testing/cxx-oot-build/CMakeLists.txt @@ -22,37 +22,29 @@ cmake_minimum_required(VERSION 3.12...3.31) -# --- Guard option --- -option(BUILD_OOTCPP "Build the Out Of Tree C++ project" OFF) +project( + OOTCpp + VERSION 1.0 + DESCRIPTION "Out Of Tree Build C++ NuttX") -if(BUILD_OOTCPP) - project( - OOTCpp - VERSION 1.0 - DESCRIPTION "Out Of Tree Build C++ NuttX") +message(STATUS "Building OOTCpp project") - message(STATUS "Building OOTCpp project") +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) - set(CMAKE_CXX_STANDARD 17) - set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(SOURCE_FILES ${CMAKE_SOURCE_DIR}/src/HelloWorld.cpp + ${CMAKE_SOURCE_DIR}/src/main.cpp) - set(SOURCE_FILES ${CMAKE_SOURCE_DIR}/src/HelloWorld.cpp - ${CMAKE_SOURCE_DIR}/src/main.cpp) +set(EXE_NAME oot) - set(EXE_NAME oot) +add_executable(${EXE_NAME} ${SOURCE_FILES}) - add_executable(${EXE_NAME} ${SOURCE_FILES}) +target_include_directories(${EXE_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/include) - target_include_directories(${EXE_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/include) - - # Generate a .bin file from the ELF after build - add_custom_command( - TARGET ${EXE_NAME} - POST_BUILD - COMMAND ${CMAKE_OBJCOPY} -S -O binary ${CMAKE_BINARY_DIR}/${EXE_NAME} - ${CMAKE_BINARY_DIR}/${EXE_NAME}.bin - COMMENT "Generating binary image ${EXE_NAME}.bin") - -else() - message(STATUS "Skipping OOTCpp project") -endif() +# Generate a .bin file from the ELF after build +add_custom_command( + TARGET ${EXE_NAME} + POST_BUILD + COMMAND ${CMAKE_OBJCOPY} -S -O binary ${CMAKE_BINARY_DIR}/${EXE_NAME} + ${CMAKE_BINARY_DIR}/${EXE_NAME}.bin + COMMENT "Generating binary image ${EXE_NAME}.bin")