Files
projectm/cmake/TestAPIHeadersProject.cmake
Kai Blaschke b742bc0082 Add API header compile tests for C
This will enable any future changes to the header to be tested. These additional build checks are only executed if BUILD_TESTING is enabled (e.g. in our automated build checks) to speed up release builds.
2025-03-24 10:00:24 +01:00

21 lines
720 B
CMake

cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
project(TestAPIHeaders
LANGUAGES C
)
include(CheckIncludeFile)
set(CMAKE_REQUIRED_INCLUDES "${INCLUDE_DIRS}")
foreach(INCLUDE_HEADER ${INCLUDE_FILES})
cmake_path(GET INCLUDE_HEADER FILENAME INCLUDE_FILENAME)
string(REPLACE "." "_" INCLUDE_FILENAME "${INCLUDE_FILENAME}")
check_include_file(${INCLUDE_HEADER} PROJECTM_${INCLUDE_FILENAME}_INCLUDE_OK)
if(NOT PROJECTM_${INCLUDE_FILENAME}_INCLUDE_OK)
message(FATAL_ERROR "projectM API include file ${INCLUDE_HEADER} does not compile on its own!\nSee logs in ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/ for additional information.")
endif()
endforeach()
file(TOUCH ${OUTPUT_FILE})