Defining the path for multiple files

Hello,

I am starting to work on a sample project, wherein I need to include multiple C++ files, all present under a common folder.
Can I define that common file path under a variable like "app_sources", so that in CMakelists.txt I can define as: 

target_sources(app PRIVATE
  ${app_sources/sample.cpp}
  )

where can I define this path "app_sources"..?

I am using nRF Connect extension on VScode.

Parents
  • cmake_minimum_required(VERSION 3.20.0)
    
    
    
    find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
    
    project(NONE)
    
    
    
    # NORDIC SDK APP START
    
    FILE(GLOB app_sources ../Code/uC/nRF52/*.cpp)
    
    FILE(GLOB app_includes ../Code/uC/nRF52/*.h)
    
    FILE(GLOB app_Interface_sources ../Nordic_SDK/Interface_Files/*.c)
    
    FILE(GLOB app_Interface_includes ../Nordic_SDK/Interface_Files/*.h)
    
    target_sources(app PRIVATE
    
        src/main.cpp
    
        src/model_handler.c
    
        src/chat_cli.c
    
        ${app_sources}
    
        ${app_Interface_sources})
    
    target_include_directories(app PRIVATE include ${app_includes} ${app_Interface_includes})
    
    
    
    zephyr_library_include_directories(${ZEPHYR_BASE}/samples/bluetooth include)
    
    # NORDIC SDK APP END

    Attaching the error snaps and CMakeLists.txt changes I made for your kind reference.!

    Where else do I need to add file paths.?

  • Oops, missed this update. I'll take a look at this now.

  • cmake_minimum_required(VERSION 3.20.0)
    
    find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
    project(NONE)
    
    # NORDIC SDK APP START
    
    set(MY_APP_SOURCES D:/Nordic_App/Nordic_SDK/Interface_Files)
    
    target_sources(app PRIVATE
    	src/main.cpp
    	src/model_handler.c
    	src/chat_cli.c
    	${MY_APP_SOURCES}/app_bluetooth.c)
    
    target_include_directories(app PRIVATE include ${MY_APP_SOURCES}/app_bluetooth.h)
    
    zephyr_library_include_directories(${ZEPHYR_BASE}/samples/bluetooth include)
    # NORDIC SDK APP END
    

    Hi ,

    I made above changes to CMakeLists.txt, yet I am having the same error.

    Also, I clicked on disable squabbles, somehow all other build errors are hidden now.
    How can i undo this and enable squabbles again..?
    Using VSCode.!

  • May I ask where the nRF Connect SDK is installed? Is it also on the D:/ drive?

    To re-enable error squiggles, I think you can just go to View->Command Palette and type "Enable Error Squiggles" and select it in the drop-down.

Reply Children
Related