file(GLOB_RECURSE PROJECT_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR} *.c *.cpp
)
file(GLOB_RECURSE PROJECT_HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR} *.h *.hpp
)
set(CLANG_FORMAT_FILES ${PROJECT_SOURCE_FILES} ${PROJECT_HEADER_FILES} PARENT_SCOPE)
list(FILTER PROJECT_SOURCE_FILES EXCLUDE REGEX startup_stm32h7a3xxq)
list(FILTER PROJECT_SOURCE_FILES EXCLUDE REGEX ETLQuestionMain.cpp)
set(CLANG_TIDY_FILES ${PROJECT_SOURCE_FILES} PARENT_SCOPE)

add_subdirectory(Interfaces)
add_subdirectory(Support)

# The following folders are currently target-only
if(CMAKE_CROSSCOMPILING)
	add_subdirectory(HwPlatform)
	add_subdirectory(State)
	add_subdirectory(ErrorHandler)
endif()

# For build machine tests
if(NOT CMAKE_CROSSCOMPILING)
	add_subdirectory(HwPlatform/devices)
	set(CMAKE_BUILD_TYPE Debug)
endif()

if(CPF_TESTING_IS_ENABLED)
	add_subdirectory(Tests)
endif()

#######################
# Primary Application #
#######################

if(CMAKE_CROSSCOMPILING)
	add_executable(cpf)
	target_sources(cpf PRIVATE main.cpp CPFStateProcessing.cpp)
	target_include_directories(cpf PRIVATE .)
	target_link_libraries(cpf PRIVATE cpf_interfaces etl::etl hw_platform_dep error_handler cpf_state cpf_support)
	if(USING_VISUAL_GDB)
		target_link_libraries(cpf PRIVATE EFP)
	endif()
	target_linker_map(cpf)
endif()
