From 42c387807fe0313b21b5280d9d55d4d641fe429c Mon Sep 17 00:00:00 2001 From: jacqueline Date: Thu, 17 Nov 2022 20:18:01 +1100 Subject: Basic libmad build --- CMakeLists.txt | 3 ++- common.cmake | 27 --------------------------- test/CMakeLists.txt | 3 ++- tools/cmake/common.cmake | 27 +++++++++++++++++++++++++++ tools/cmake/extra-libs.cmake | 1 + tools/cmake/libmad.cmake | 19 +++++++++++++++++++ 6 files changed, 51 insertions(+), 29 deletions(-) delete mode 100644 common.cmake create mode 100644 tools/cmake/common.cmake create mode 100644 tools/cmake/extra-libs.cmake create mode 100644 tools/cmake/libmad.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 54fa1818..751ee3ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.16) -include(common.cmake) +include($ENV{PROJ_PATH}/tools/cmake/common.cmake) set(SDKCONFIG_DEFAULTS "sdkconfig.common") @@ -10,3 +10,4 @@ idf_build_set_property(COMPILE_OPTIONS "-DRESULT_DISABLE_EXCEPTIONS" APPEND) list(APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/src") project(gay-ipod-fw) +include($ENV{PROJ_PATH}/tools/cmake/extra-libs.cmake) diff --git a/common.cmake b/common.cmake deleted file mode 100644 index 53a6a243..00000000 --- a/common.cmake +++ /dev/null @@ -1,27 +0,0 @@ -# For more information about build system see -# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -# Build only the subset of components that we actually depend on. -set(COMPONENTS "") - -# External dependencies -list(APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/lib/result") -list(APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/lib/lvgl") -list(APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/lib/catch2") - -include($ENV{IDF_PATH}/tools/cmake/project.cmake) - -# Additional warnings used when compiling our components. -# Unable to be used due to issues in ESP-IDF includes are: -Wpedantic -# -Wuseless-cast -Wconversion -Wold-style-cast -Wsign-conversion -Wcast-align -set(EXTRA_WARNINGS "-Wshadow" "-Wnon-virtual-dtor" "-Wunused" - "-Woverloaded-virtual" "-Wmisleading-indentation" "-Wduplicated-cond" - "-Wduplicated-branches" "-Wlogical-op" "-Wnull-dereference" - "-Wdouble-promotion" "-Wformat=2" "-Wimplicit-fallthrough") - -# Extra build flags that should apply to the entire build. This should mostly -# just be used to setting flags that our external dependencies requires. -# Otherwise, prefer adding per-component build flags to keep things neat. -idf_build_set_property(COMPILE_OPTIONS "-DLV_CONF_INCLUDE_SIMPLE" APPEND) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0834a2b8..e7af4ab1 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.16) -include(../common.cmake) +include($ENV{PROJ_PATH}/tools/cmake/common.cmake) set(SDKCONFIG_DEFAULTS "../sdkconfig.common;sdkconfig.test") @@ -18,3 +18,4 @@ list(APPEND EXTRA_COMPONENT_DIRS set(TEST_COMPONENTS "drivers") project(device_tests) +include($ENV{PROJ_PATH}/tools/cmake/extra-libs.cmake) diff --git a/tools/cmake/common.cmake b/tools/cmake/common.cmake new file mode 100644 index 00000000..53a6a243 --- /dev/null +++ b/tools/cmake/common.cmake @@ -0,0 +1,27 @@ +# For more information about build system see +# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# Build only the subset of components that we actually depend on. +set(COMPONENTS "") + +# External dependencies +list(APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/lib/result") +list(APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/lib/lvgl") +list(APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/lib/catch2") + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) + +# Additional warnings used when compiling our components. +# Unable to be used due to issues in ESP-IDF includes are: -Wpedantic +# -Wuseless-cast -Wconversion -Wold-style-cast -Wsign-conversion -Wcast-align +set(EXTRA_WARNINGS "-Wshadow" "-Wnon-virtual-dtor" "-Wunused" + "-Woverloaded-virtual" "-Wmisleading-indentation" "-Wduplicated-cond" + "-Wduplicated-branches" "-Wlogical-op" "-Wnull-dereference" + "-Wdouble-promotion" "-Wformat=2" "-Wimplicit-fallthrough") + +# Extra build flags that should apply to the entire build. This should mostly +# just be used to setting flags that our external dependencies requires. +# Otherwise, prefer adding per-component build flags to keep things neat. +idf_build_set_property(COMPILE_OPTIONS "-DLV_CONF_INCLUDE_SIMPLE" APPEND) diff --git a/tools/cmake/extra-libs.cmake b/tools/cmake/extra-libs.cmake new file mode 100644 index 00000000..2d665b63 --- /dev/null +++ b/tools/cmake/extra-libs.cmake @@ -0,0 +1 @@ +include($ENV{PROJ_PATH}/tools/cmake/libmad.cmake) diff --git a/tools/cmake/libmad.cmake b/tools/cmake/libmad.cmake new file mode 100644 index 00000000..5126bd69 --- /dev/null +++ b/tools/cmake/libmad.cmake @@ -0,0 +1,19 @@ +set(LIBMAD_SRC "$ENV{PROJ_PATH}/lib/libmad") +set(LIBMAD_BIN "${CMAKE_CURRENT_BINARY_DIR}/libmad") + +externalproject_add(libmad_build + SOURCE_DIR "${LIBMAD_SRC}" + PREFIX "${LIBMAD_BIN}" + CONFIGURE_COMMAND ${LIBMAD_SRC}/configure CC=${CMAKE_C_COMPILER} --srcdir=${LIBMAD_SRC} --prefix=${LIBMAD_BIN} --host=xtensa-elf --disable-debugging --disable-shared + BUILD_COMMAND "make" + INSTALL_COMMAND "make install" + BUILD_BYPRODUCTS "${LIBMAD_BIN}/libmad.a" +) + + add_library(libmad STATIC IMPORTED GLOBAL) + add_dependencies(libmad libmad_build) + + set_target_properties(libmad PROPERTIES IMPORTED_LOCATION + "${LIBMAD_BIN}/libmad.a") + set_target_properties(libmad PROPERTIES INTERFACE_INCLUDE_DIRECTORIES + "${LIBMAD_BIN}") -- cgit v1.2.3