CMakeLists.txt problem with the file

I have project, the main,c in the src folder,
in the src folder - I open folder in the name sensor
and in this folder i have the sensor.c file, and the sensor.h file.

when I try to build and flash - it's build and flash, but i didn't see any message...

when I took the sensor.c code, and put in the main.c - it's working like a magic!!

what the problem with my CMakeLists.txt files?

in the sensor folder, in the CMakeLists.txt file:

target_include_directories(app PRIVATE .)
target_sources(app PRIVATE sensor.c  sensor.h)

in the CMakeLists.txt (in the project):

# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(hello_world)
add_subdirectory(src/sensor)
target_sources(app PRIVATE ${app_sources})

Parents Reply Children
  • Thank you so much for your help, there is probably some problem with the code and I guess I can get along with it.

    In any case, I will upload the structure of the CMAKE I defined and it does run for those who need to be needed later.

    in the CMakeLists.txt file (in the main folder):

    # SPDX-License-Identifier: Apache-2.0

    cmake_minimum_required(VERSION 3.20.0)

    find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
    project(hello_world)
    add_subdirectory(src/sensor_folder)
    target_sources(app PRIVATE ${app_sources})


    CMakeLists.txt file in the sensor folder: (src\sensor_folder)

    target_include_directories(app PRIVATE .)
    target_sources(app PRIVATE sensor.c sensor.h)





Related