Skip to content

Commit

Permalink
zephyr: skip library build when C++ isn't enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
benedekkupper committed Nov 19, 2024
1 parent aa494c3 commit f87ab21
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
24 changes: 19 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
Expand Down
2 changes: 1 addition & 1 deletion c2usb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f87ab21

Please sign in to comment.