premake / premake/premake-core
Can't create a precompiled header for Visual Studio 2019
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 3.6k
- Forks
- 654
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 13
Description
What are you trying to do?
I'm trying to create a precompiled header for Visual Studio 2019.
What problem are you having?
My pchheader is set correctly but my pchsource is not. When I right click on the pch source file and go to Properties > Configuration Properties > C/C++ > Precompiled Headers, my source file is set to Use (/Yu) instead of Create (Yc).
What have you tried so far?
I made minimal example to replicate my issue. My project structure is like so:
MyProject/
src/
main.cpp
pch.cpp
pch.h
PremakeConfig/
main.lua
premake.5.exe
My premake config is as follows:
workspace "MyWorkspace"
location ".."
startproject "MyProject"
configurations { "Debug", "Release" }
OutputDir = "%{cfg.buildcfg}"
TargetDir = "%{wks.location}/bin/%{OutputDir}"
ObjDir = "%{wks.location}/bin-int/%{OutputDir}"
project "MyProject"
kind "ConsoleApp"
location "%{wks.location}/%{prj.name}"
language "C++"
targetdir "%{TargetDir}/%{prj.name}"
objdir "%{ObjDir}/%{prj.name}"
pchheader "pch.h"
pchsource "%{prj.location}/src/pch.cpp"
files {
"%{prj.location}/src/**.h",
"%{prj.location}/src/**.cpp"
}
includedirs "%{prj.location}/src"
I ran the command .\premake5.exe --file="PremakeConfig\main.lua" vs2019.
Explicitly adding every file in files like so:
files {
"%{prj.location}/src/pch.h",
"%{prj.location}/src/pch.cpp",
"%{prj.location}/src/main.cpp"
}
solves the problem. The problem is that the real project I'm working on has a lot of files and I don't wan't to list them all in my config and have to change it every time I add a new file.
Is this a bug or is there something I'm not understanding about precompiled headers?
What version of Premake are you using?
premake5 (Premake Build Script Generator) 5.0.0-alpha15
Thanks in advance.
Clément
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with PremakeConfig/main.lua and reproduce the issue using the supplied vs2019 command and project layout containing src/pch.cpp and src/pch.h. Inspect how the Visual Studio 2019 generator handles wildcard files and pchsource; the work is done when the generated project marks pch.cpp as Create (Yc) without listing every source file explicitly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, lua
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100