You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
2.7 KiB
63 lines
2.7 KiB
#Declareing header directory for the project
|
|
#To add a new directory
|
|
# -> list(APPEND PROJECT_HEADERS_DIR ${PROJECT_DIR}/YOUR_DESIRED_DIRECTORY)
|
|
# list() = List declaration "DON'T CHANGE"
|
|
# PROJECT_HEADERS_DIR = Variable containing the listed direcotries "DON'T CHANCE
|
|
# ${PROJECT_DIR} = Direcotry of the main project this is per default the current direcotry it is defined in ked/CMakeLists.txt
|
|
list(APPEND PROJECT_HEADERS_DIR ${PROJECT_DIR}/headers)
|
|
|
|
#Declaring sources directory for the project
|
|
#To add a new directory
|
|
# -> list(APPEND PROJECT_SOURCES_DIR ${PROJECT_DIR}/YOUR_DESIRED_DIRECTORY)
|
|
# list() = List declaration "DON'T CHANGE"
|
|
# PROJECT_SOURCES_DIR = Variable containing the listed direcotries "DON'T CHANCE
|
|
# ${PROJECT_DIR} = Direcotry of the main project this is per default the current direcotry it is defined in ked/CMakeLists.txt
|
|
list(APPEND PROJECT_SOURCES_DIR ${PROJECT_DIR}/src)
|
|
list(APPEND PROJECT_SOURCES_DIR ${PROJECT_DIR}/sensors)
|
|
|
|
#Declaring sources to be compiled for the project.
|
|
#CMake will look in each previsouly declarec sources directory until to find this files.
|
|
set(PROJECT_SOURCES_DIR_LIST uartComm.c sensor.c)
|
|
|
|
#Searching if the given header directory exists if not we brake the compilation
|
|
function(projectHeadersCheck)
|
|
foreach(X IN LISTS PROJECT_HEADERS_DIR)
|
|
if(EXISTS ${X})
|
|
message("|--> ${X} : INCLUDED")
|
|
else()
|
|
message(FATAL_ERROR "Header directory ${X} : NOT FOUND")
|
|
endif()
|
|
endforeach()
|
|
endfunction()
|
|
|
|
#Searching if the given Source exists if not we brake the compilation
|
|
function(projectCheckSourcesCheck)
|
|
foreach(X IN LISTS PROJECT_SOURCES_DIR)
|
|
if(EXISTS ${X})
|
|
message("|--> ${X} : INCLUDED")
|
|
else()
|
|
message(FATAL_ERROR "Source directory ${X} : NOT FOUND")
|
|
endif()
|
|
endforeach()
|
|
endfunction()
|
|
|
|
#Searching each sources directory to find the desired source file and generate a libaray submodule for the linker
|
|
function(projectAddItem alias _currentItem)
|
|
foreach(X IN LISTS PROJECT_SOURCES_DIR)
|
|
if(EXISTS ${X})
|
|
if(EXISTS ${X}/${alias}) #For each directory we chanek if the given source file exitst
|
|
message("|-->${alias} FOUND in : ${X}")
|
|
message(" |-> Creating sub::${alias} library submodule")
|
|
add_library(${alias}_submodule ${X}/${alias})
|
|
target_compile_options(${alias}_submodule PRIVATE ${C_FLAGS})
|
|
target_compile_definitions(${alias}_submodule PRIVATE ${C_DEFS})
|
|
target_include_directories(${alias}_submodule PUBLIC ${PROJECT_HEADERS_DIR} ${PERIFERALS_DIR} ${CSL_INCLUDES})
|
|
add_library(sub::${alias} ALIAS ${alias}_submodule)
|
|
set(${_currentItem} sub::${alias} PARENT_SCOPE)
|
|
endif()
|
|
else()
|
|
message(FATAL_ERROR "Source directory ${X} : NOT FOUND")
|
|
endif()
|
|
endforeach()
|
|
endfunction()
|