ccmakemakefileembeddedelf

CMAKE error while building the application (No SOURCES given to target)


I am trying to build an application that will generate an .elf file. This build is done with the Hi-tech compiler and CMAKE environment. I have some .c source files, corresponding .h files, and generated files from another tool. Below are my CMake files.

Cmakelists.txt

 include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/main_test.cmake)
    include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/test/test2.cmake)

main_test.cmake

set(PROJ_NAME "Test_Project")
set(PROJ_EXECUTABLE_NAME "my_application")

add_executable(${PROJ_EXECUTABLE_NAME})

set_target_properties(${PROJ_EXECUTABLE_NAME}
    PROPERTIES
    RUNTIME_OUTPUT_DIRECTORY "${PROJ_OUTPUT_PATH}/bin"
    OUTPUT_NAME "${PROJ_EXECUTABLE_NAME}"
    SUFFIX ".elf" # extension
)

test2 make file

set(MY_SRC_PATH "${PROJ_CMAKE_CONFIG_ROOT}/temp/testfiles.cmake")

if(EXISTS ${MY_SRC})
    set(MYSRC_LIB_NAME MYSRC)
    set(MYSRC_ASM_LIB_NAME MYSRC_ASM)
    set(MYSRC_INTERFACE_LIB_NAME MYSRC_INTERFACE)
    include(${MY_SRC})
    message(STATUS "files are included")
else()
    message(SEND_ERROR "Couldn't find config file: ${MY_SRC}")
endif()

target_link_libraries(${PROJ_EXECUTABLE_NAME} PUBLIC ${MYSRC_LIB_NAME} ${MYSRC_ASM_LIB_NAME} ${MYSRC_INTERFACE_LIB_NAME}) #link files

target_link_options(${PROJ_EXECUTABLE_NAME} PUBLIC -Wl,--whole-archive)

The main CMake file will call another make file and include the .c files.

testfiles.cmake

include_header_all(LOCAL_INC "${MYCODE_SRC_PATH}/component/testscript/src") #.h files include function
include_source_all(LOCAL_SRC "${IMMUTABLE_SRC_PATH}/component/testscript/src") #.c files include function
include_assembly_all(LOCAL_ASM "${GENERATED_SRC_PATH}") #Generated files from another tool include function

add_library(${MYSRC_LIB_NAME} STATIC ${LOCAL_SRC})
add_library(${MYSRC_ASM_LIB_NAME} STATIC ${LOCAL_ASM})
add_library(${MYSRC_INTERFACE_LIB_NAME} INTERFACE)

target_include_directories(${MYSRC_INTERFACE_LIB_NAME} INTERFACE ${LOCAL_INC})

While building, I am getting the 'No SOURCES given to target' error. All the paths are correct and given to cmake file. But I am getting below error.

No SOURCES given to target: my_application

If anybody knows what I am missing here, please help me solve this error so that I can understand what I am doing wrong.


Solution

  • As per the @Tsyvarev Comment, I have updated the target_sources for the executable. Like, int main(){ return 0;} . It worked.