How to setup CMAKE to compile with more than one executable(main.c)?
Posted: Tue Apr 26, 2022 4:02 pm
the main file main.c in my project got quite large more than 1000 lines a code with more than 30 lines of lib #include<lib.h> code.
I'd like to split the main source file into two or more files and have them work as one and shade includes and relation with each other like how you're able to split executables with more than one .ino file in arduino, my question is how do you setup CMake in ESP IDF to achieve it? here's the content of my projects CMAKE according to their directories:
project/CMakeLists.txt:
project/main/CMakeLists.txt:
I saw in stackoverflow that you do it with add_executable() how it's suppose to be typed in terms of syntax with more than one source file, and how to integrate it with the Custom mess the ESP IDF creates and can't find and explanation for it, is something I don't understand.
I'd like to split the main source file into two or more files and have them work as one and shade includes and relation with each other like how you're able to split executables with more than one .ino file in arduino, my question is how do you setup CMake in ESP IDF to achieve it? here's the content of my projects CMAKE according to their directories:
project/CMakeLists.txt:
Code: Select all
# The following lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)
# set(COMPONENT_DIRS C:/Coding/ESP32_sketches/libraries/esp-idf-lib/components)
set(EXTRA_COMPONENT_DIRS C:/Coding/ESP32_sketches/libraries/esp-idf-lib/components;
$ENV{IDF_PATH}/examples/common_components/protocol_examples_common)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(my_timer)
Code: Select all
# Edit following two lines to set component requirements (see docs)
set(COMPONENT_REQUIRES)
set(COMPONENT_PRIV_REQUIRES)
set(COMPONENT_SRCS "u8g2_esp32_hal.c" "main.c")
set(COMPONENT_SRCDIRS "." "../components")
set(COMPONENT_ADD_INCLUDEDIRS "." "../components")
register_component()