EDIT: This seems to be a GCC issue
The error is this:
mingw32-make[2]: *** [CMakeFiles\MyProject.dir\build.make:94: CMakeFiles/MyProject.dir/main.cpp.obj] Error 1
Line 94 in build.make looks like this:
C:\PROGRA~1\mingw64\bin\G__~1.EXE $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -Winvalid-pch -include MyProjectDirectory/build/CMakeFiles/MyProject.dir/cmake_pch.hxx -MD -MT CMakeFiles/MyProject.dir/main.cpp.obj -MF CMakeFiles\MyProject.dir\main.cpp.obj.d -o CMakeFiles\MyProject.dir\main.cpp.obj -c MyProjectDirectory\main.cpp
It appears when I try to build a project that includes certain sets of files in the precompiled header.
Through trial and error I have found two sets of includes that cause this error. The first is the single file vulkan.hpp from the Vulkan SDK. The second is the three files SDL.h from SDL, VkBootstrap.h from the Vulkan Bootstrapping Library, and "filesystem" from the standard library. I'm using GCC with MinGW-w64. If I remove any of the three includes, the error does not appear.
I've tried making a simple project with just the precompiled header and an empty main(). I have no idea what's causing this, and I would prefer not having to dig through these files manually.
Here's a minimal reproducible example:
All files are in the same directory. The directory also contains the folder named "vulkan" from the "include" folder in the Vulkan headers.
CMakeLists.txt:
cmake_minimum_required(VERSION 3.0.0)
project(MyProject VERSION 0.1.0)
add_executable(${PROJECT_NAME} main.cpp)
target_include_directories(${PROJECT_NAME}
PUBLIC .
)
target_precompile_headers(${PROJECT_NAME}
PRIVATE pch.hpp
)
main.cpp:
int main()
{
return 0;
}
pch.hpp:
#pragma once
#include "vulkan/vulkan.hpp"