From f87ab2109d0312704c3171f020a25bf143bb65c2 Mon Sep 17 00:00:00 2001 From: Benedek Kupper Date: Tue, 19 Nov 2024 12:30:46 +0100 Subject: [PATCH] zephyr: skip library build when C++ isn't enabled --- CMakeLists.txt | 24 +++++++++++++++++++----- c2usb/CMakeLists.txt | 2 +- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e263b81..00a1227 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,27 @@ cmake_minimum_required(VERSION 3.19) project(c2usb - LANGUAGES CXX + LANGUAGES CXX ) -# this library only works with C++20 (and above?) -set(CMAKE_CXX_STANDARD 20) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS ON) +if(DEFINED ENV{ZEPHYR_BASE}) + set(ZEPHYR_BUILD ON) +else() + set(ZEPHYR_BUILD OFF) +endif() +set(ZEPHYR_BUILD ${ZEPHYR_BUILD} CACHE BOOL "Indicates if this is a Zephyr build") +if(ZEPHYR_BUILD) + if (NOT CONFIG_REQUIRES_FULL_LIBCPP) + message(INFO "Zephyr build without C++ support, skipping c2usb build") + return() + endif() + # using zephyr's C++ settings via zephyr_interface +else() + # this library only works with C++20 (and above?) + set(CMAKE_CXX_STANDARD 20) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(CMAKE_CXX_EXTENSIONS ON) +endif() add_library(${PROJECT_NAME}) add_subdirectory(${PROJECT_NAME}) diff --git a/c2usb/CMakeLists.txt b/c2usb/CMakeLists.txt index cd86fa5..261d94a 100644 --- a/c2usb/CMakeLists.txt +++ b/c2usb/CMakeLists.txt @@ -53,7 +53,7 @@ target_sources(${PROJECT_NAME} ) # ports -if (DEFINED ENV{ZEPHYR_BASE}) +if(ZEPHYR_BUILD) add_subdirectory_ifdef(CONFIG_C2USB_UDC_MAC port/zephyr) add_subdirectory_ifdef(CONFIG_C2USB_BLUETOOTH