add_library(stm32h7_target STATIC)
target_include_directories(stm32h7_target PUBLIC .)
target_sources(stm32h7_target PRIVATE
	startup_stm32h7a3xxq.c
	stm32h7xx_it.c
	stm32h7xx_it.h
	system_stm32h7xx.c
	stm32h7xx_hal_conf.h
)
# We private link the dependency because we want this library to be
# where we compile the source files.
# Then we link the include dependency so that users of this target will
# get the proper STM32H7 headers.
target_link_libraries(stm32h7_target PRIVATE stm32h7a3zi_dependency)
target_link_libraries(stm32h7_target INTERFACE stm32h7_include_dep)

add_library(stm32h7_target_include_dep INTERFACE)
target_include_directories(stm32h7_target_include_dep INTERFACE .)
target_link_libraries(stm32h7_target_include_dep INTERFACE stm32h7_include_dep)

# Disable warnings on vendor code that we will not address
set_source_files_properties(startup_stm32h7a3xxq.c
	PROPERTIES COMPILE_OPTIONS "-Wno-missing-declarations")
set_source_files_properties(${CMAKE_SOURCE_DIR}/external/stm32h7/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_uart.c
	PROPERTIES COMPILE_OPTIONS "-Wno-conversion;-Wno-cast-align;-Wno-switch-enum")
set_source_files_properties(${CMAKE_SOURCE_DIR}/external/stm32h7/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_uart_ex.c
	PROPERTIES COMPILE_OPTIONS "-Wno-cast-align;-Wno-switch-enum;-Wno-conversion")
set_source_files_properties(${CMAKE_SOURCE_DIR}/external/stm32h7/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_spi.c
	PROPERTIES COMPILE_OPTIONS "-Wno-cast-align;-Wno-switch-enum;-Wno-conversion")
set_source_files_properties(${CMAKE_SOURCE_DIR}/external/stm32h7/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2c.c
	PROPERTIES COMPILE_OPTIONS "-Wno-conversion")
set_source_files_properties(${CMAKE_SOURCE_DIR}/external/stm32h7/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_spi.c
	PROPERTIES COMPILE_OPTIONS "-Wno-conversion;-Wno-cast-align")
set_source_files_properties(${CMAKE_SOURCE_DIR}/external/stm32h7/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_spi_ex.c
	PROPERTIES COMPILE_OPTIONS "-Wno-conversion;-Wno-cast-align")
set_source_files_properties(${CMAKE_SOURCE_DIR}/external/stm32h7/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_exti.c
	PROPERTIES COMPILE_OPTIONS "-Wno-unused-parameter")
set_source_files_properties(${CMAKE_SOURCE_DIR}/external/stm32h7/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pwr.c
	PROPERTIES COMPILE_OPTIONS "-Wno-unused-parameter")
set_source_files_properties(${CMAKE_SOURCE_DIR}/external/stm32h7/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rtc.c
	PROPERTIES COMPILE_OPTIONS "-Wno-conversion")
set_source_files_properties(${CMAKE_SOURCE_DIR}/external/stm32h7/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dma.c
	PROPERTIES COMPILE_OPTIONS "-Wno-switch-enum")
set_source_files_properties(${CMAKE_SOURCE_DIR}/external/stm32h7/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_mdma.c
	PROPERTIES COMPILE_OPTIONS "-Wno-switch-enum")
set_source_files_properties(${CMAKE_SOURCE_DIR}/external/stm32h7/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_mmc.c
	PROPERTIES COMPILE_OPTIONS "-Wno-conversion;-Wno-sign-conversion")
