jimon / premake-ninja

Premake extension to support Ninja
MIT License
58 stars 17 forks source link

precompiled not first include error #31

Closed Enhex closed 1 year ago

Enhex commented 1 year ago

generating two "-include precompiled.h" args, once in CFLAGS & CXXFLAGS and once in rule cc/cxx's command.

this causes compilation error:

clang-15: warning: precompiled header 'obj/precompiled.h.gch' was ignored because '-include obj/precompiled.h' is not first '-include'
clang-15: warning: argument unused during compilation: '-MD' [-Wunused-command-line-argument]
<built-in>:2:10: fatal error: 'obj/precompiled.h' file not found

removing -include obj/precompiled.h from command fixes this problem.

Jarod42 commented 1 year ago

Warning about -MD just fixed by https://github.com/jimon/premake-ninja/commit/50798a57a070b7dd9a0340ea88ca0202cb98a3c5

About pch, the test projects https://github.com/Jarod42/premake-sample-projects/tree/master/projects/project-03-pch passes successfully with ninja (both gcc/clang and even msvc :-) ).

According to https://premake.github.io/docs/Precompiled-Headers/#considerations-for-non-visual-studio-tools, no needs to add extra forceinclude (which might be your issue).

Else, can you show your (simplified) premake5.lua? Would it compile fine with other generators?

Enhex commented 1 year ago

looking at my code compared to these tests i use both pchheader and forceincludes:

pchheader "precompiled.h"
pchsource "src/precompiled.cpp"
forceincludes{ precompiled.h" }

if i recall correctly i did it few years ago because using only one of them will cause either GCC or MSVC to not work. I'll need to test it again and report back.

Jarod42 commented 1 year ago

From what I can see from the tests,

Enhex commented 1 year ago

to narrow down the checking I got the error on Linux with premake5 and gmake2

Jarod42 commented 1 year ago

Do you mean you need forceinclude with gmake2? My sample project works for all generators but xcode4.

For now, on my side, it seems more an issue with your script. If you have one script which fails without the forceinclude (even with another generators except on macos), I might investigate.

Jarod42 commented 1 year ago

Closing. (Assuming error was in your script, and pch testing project works).