diff options
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 22756c1..2d40b05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,8 +14,6 @@ include("${PICO_SDK_PATH}/external/pico_sdk_import.cmake") project(sbc_harness) -add_subdirectory(3rd-party/pico-fmt/pico_fmt) -add_subdirectory(3rd-party/pico-fmt/pico_printf) pico_sdk_init() if ((PICO_PLATFORM STREQUAL "host") AND (NOT PICO_NO_GC_SECTIONS)) @@ -24,13 +22,18 @@ if ((PICO_PLATFORM STREQUAL "host") AND (NOT PICO_NO_GC_SECTIONS)) add_link_options("LINKER:--gc-sections") endif() +# Use modern C... +set(CMAKE_C_STANDARD 23) +# ... but with some misfeatures disabled. +add_compile_options(-Werror=vla) + +# Have the compiler help detect mistakes. add_compile_options(-Wall -Wextra -Wswitch-enum -Werror) string(TOUPPER "${CMAKE_BUILD_TYPE}" _upper_cmake_build_type) string(REPLACE " " ";" _build_type_flags "${CMAKE_C_FLAGS_${_upper_cmake_build_type}}") if ("-DNDEBUG" IN_LIST _build_type_flags) add_compile_options(-Wno-unused-variable -Wno-unused-parameter -Wno-unused-but-set-variable) - target_compile_definitions(pico_printf INTERFACE PICO_PRINTF_ALWAYS_INCLUDED=1) endif() function(_suppress_tinyusb_warnings) @@ -41,6 +44,11 @@ function(_suppress_tinyusb_warnings) COMPILE_OPTIONS "-Wno-switch-enum") endfunction() +if (PICO_PLATFORM STREQUAL "host") + add_compile_options(--coverage) + add_link_options(--coverage) +endif() + function(target_embed_sources arg_compile_target arg_link_target arg_hdrname) set(embed_objs) foreach(embed_src IN LISTS ARGN) @@ -112,14 +120,41 @@ function(add_lib_test arg_libname arg_testname) target_include_directories("${arg_testname}" PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tests) add_test( NAME "${arg_libname}/${arg_testname}" - COMMAND valgrind --error-exitcode=2 "./${arg_testname}" + COMMAND "${CMAKE_SOURCE_DIR}/build-aux/valgrind" "./${arg_testname}" ) endif() endfunction() +function(_apply_matrix_helper _m_depth _m_assignments) + list(LENGTH _m_arg_matrix _m_dimensions) + math(EXPR _m_dimensions ${_m_dimensions}/2) + if("${_m_depth}" EQUAL "${_m_dimensions}") + cmake_language(CALL "${_m_arg_action}" "${_m_n}" "${_m_assignments}") + math(EXPR _m_n "${_m_n}+1") + set(_m_n "${_m_n}" PARENT_SCOPE) + else() + math(EXPR _m_ik "${_m_depth}*2") + list(GET _m_arg_matrix "${_m_ik}" _m_tmp_key) + + math(EXPR _m_iv "${_m_ik}+1") + list(GET _m_arg_matrix "${_m_iv}" _m_tmp_vals) + string(REGEX REPLACE "^\\[(.*)\\]$" "\\1" _m_tmp_vals "${_m_tmp_vals}") + + foreach(_m_tmp_val IN LISTS _m_tmp_vals) + math(EXPR _m_tmp_depth "${_m_depth}+1") + set(_m_tmp_assignments "${_m_assignments}") + list(APPEND _m_tmp_assignments "${_m_tmp_key}=${_m_tmp_val}") + _apply_matrix_helper("${_m_tmp_depth}" "${_m_tmp_assignments}") + set(_m_n "${_m_n}" PARENT_SCOPE) + endforeach() + endif() +endfunction() +function(apply_matrix _m_arg_action _m_arg_matrix) + set(_m_n 0) + _apply_matrix_helper(0 "") +endfunction() + add_subdirectory(libmisc) -add_subdirectory(libobj) -add_subdirectory(libfmt) add_subdirectory(libcr) add_subdirectory(libcr_ipc) add_subdirectory(libhw_generic) @@ -129,4 +164,5 @@ add_subdirectory(libusb) add_subdirectory(lib9p) add_subdirectory(lib9p_util) -add_subdirectory(cmd/sbc_harness) +add_subdirectory(flashimg/cpu_main) +add_subdirectory(flashimg/cpu_hdmi) |