cmake: make DaemonPlatform, Architecture, Compiler, etc. autonomous and reusable as Yokai framework#1641
cmake: make DaemonPlatform, Architecture, Compiler, etc. autonomous and reusable as Yokai framework#1641illwieckz wants to merge 27 commits into
Conversation
|
Why would we need a variable called NACL_PIE? There is no PIE for NaCl and never will be. |
Note that some of the facilities here duplicate CMake built-in functionality, or have more fully developed alternatives available from other projects. Effort is likely to be wasted in such cases:
DaemonArchitecture looks most likely to be useful. I think I saw a similar thing with SDL, but Daemon's looked more complete. |
Well maybe I'm wrong about that: the native_client scons build has a |
|
Then again, there is a comment explaining that it is not useful: Also there is another comment confirming that Saigo does not have PIC. |
745bede to
d2b73ca
Compare
|
I removed the unused NaCl PIE thing. |
f01bf1f to
10ae04b
Compare
| # Collection of reusable CMake helpers written for the Dæmon engine and related | ||
| # projects. | ||
| ################################################################################ | ||
|
|
There was a problem hiding this comment.
Why do we need this file? Are some of the files dependent on each other and so have to be included in a specific order?
There was a problem hiding this comment.
We need to include them in specific order, and the Compiler stuff (and maybe other things) are writing constants (like compiler name and version) that is generated as source with SourceGenerator to be embedded in the binary.
There was a problem hiding this comment.
Also Architecture requires System to be included first so it can select amd64 as NACL_ARCH on arm64 macOS, and things like that.
There was a problem hiding this comment.
Could we use this instead? https://cmake.org/cmake/help/v3.17/command/include_guard.html
Then each file can include its own dependencies and the user does not need to take care to call them in a special order.
There was a problem hiding this comment.
You'll end up loading them anyway.
The only thing that seems to be interesting to do is to provide an option to not generate the source files with the various discovered things, for projects not caring about reporting the build environment to the user. For example we don't need such reporting in NaCl.
There was a problem hiding this comment.
With the latest version, if you only include Detection.cmake without having included SourceGenerator.cmake first (or the Platform.cmake entry point which is meant to include everything supported), then no source is generated when detecting the build environment.
5d31fb8 to
a9191be
Compare
We already renamed “unsupported” as “unknown” so it was just by luck we didn't stop the build (what we wanted when changing that).
a9191be to
cd64470
Compare
|
I landed my rewrite of This defines variables like A good example of usage of them is to avoid the ambiguity of Instead of It may also help to do things differently with MinGW on Linux and MinGW on Windows, when needed. It may also help in the future as cross-compiler evolves, for example the day Zig becomes suitable for us to cross-compile for macOS on Linux, and things like that. I also renamed |
3227432 to
5712ef4
Compare
| ) | ||
| elseif (LINUX) | ||
| # We don't know if this works outside of Linux, | ||
| # so we don't use YOKAI_TARGET_SYSTEM_LINUX_COMPATIBILITY. |
There was a problem hiding this comment.
It definitely won't work, see https://forums.freebsd.org/threads/porting-google-breakpad.18039/
There was a problem hiding this comment.
In fact it was indeed meant to be LINUX_COMPATIBILITY, so it can be used on Android even if not a Linux Desktop.
It's just that I defined twice LINUX_COMPATIBILITY, and the second one with another meaning:
Now I use XDG_COMPATIBILITY when the desktop is linux-like, while LINUX_COMPATIBILITY means the Linux API is actually there.
And for completeness, LINUX means Linux desktop, not Android (that one of the ambiguity I also wanted to remove).
|
I should mention that besides the Clang that pretends to be MSVC, there is also Clang that pretends to be MinGW. I don't have it installed currently so I can't say how the compiler is detected. |
|
I still don't understand the claimed problems with making each cmake file self-contained (by including dependencies using the (Also I think it's bad how build info is done with gamelogic currently, though that can go in another PR. |
6bfb4db to
95c6284
Compare
|
The NaCl architecture stuff is now removed from Yokai and stored in |
Right now Dæmon's yokai_write_buildinfo("DaemonEngine")And game's yokai_write_buildinfo("DaemonGame")The buildinfo is never mixed between engine and game. |
Also the list of things in engine and game buildinfo aren't the same anymore, for example the game buildinfo doesn't have the Also it's not possible for the game to use engine's buildinfo because the nexe build is done in a subfolder. The name passed to |
I'm saying the write_buildinfo should be in Unvanquished CMakeLists.txt, not in DaemonGame.cmake. I'm hoping this could fix #1599. |
| #endif | ||
|
|
||
| #if defined(__unix__) || defined(__unix) || defined(unix) | ||
| #pragma message(REPORT_COMPATIBILITY("Unix")) |
There was a problem hiding this comment.
I suggest removing this as it has unexpected semantics: Mac OS is a Unix, but does not define these. Anyhow the good old idiom for Unix-like is NOT WIN32 :)
| # implementing standards like FHS, XDG, GLVND… | ||
| # Makes possible to do that in CMake code: | ||
| # > if (YOKAI_HOST_SYSTEM_XDG_COMPATIBILITY) | ||
| # > if (YOKAI_SYSTEM_XDG_COMPATIBILITY) |
There was a problem hiding this comment.
Instead of XDG_COMPATIBILITY I prefer the GNU_COMPATIBILITY name you used in some other places. This makes sense by reflecting the "GNU/Linux" userland/kernel distinction. So we have Linux compatibility include Android's Linux-based kernel, and GNU compatibility including the FreeBSD using a similar userland to the Linux desktops.
There was a problem hiding this comment.
Well it's not that great since GNU compatibility could also be confused for the "GNU compiler id" that CMake identifier for GCC. But at least it relates to the "GNU/Linux" meme. For me XDG doesn't suggest the concept you want to get at at all.
There was a problem hiding this comment.
In some iterations I wrote GNU too, then switched to XDG. The thing is that GNU means GNU Hurd in System context.
One may say that GNU Linux is probably similar to GNU Hurd, not less then FreeBSD, but well…
The SYSTEM_GNU_COMPATIBILITY in some other places are leftovers remaining from that first iteration I failed to clean-up properly. I'll fix it.
|
|
||
| set(box64_usage ppc64el riscv64) | ||
| if ("${arch_name}" IN_LIST box64_usage) | ||
| option(YOKAI_NACL_BOX64_EMULATION "Use Box64 to emulate x86_64 NaCl loader on unsupported platforms" ON) |
There was a problem hiding this comment.
can go back to its original name
There was a problem hiding this comment.
Especially since I renamed it in C++ code already. 😆️
Now fixed.
95c6284 to
813b85c
Compare
Right now this does: And this doesn't do any: So for now I expect it to just be reported as If needed we can make it be reported as One can use the |
4ce1846 to
726fb11
Compare
|
|
||
| # Make sure to always call this macro from within a function, not in the global scope. | ||
| # As a macro it produces a lot of variables in the parent scope but it is meant to | ||
| # only be called by functions so they should never pollute the globale scope. |
| PARENT_SCOPE) | ||
| endforeach() | ||
| endif() | ||
| yokai_run_detection("${lang}" "COMPILER" "Compiler${${lang}_EXT}" "GCC;Clang;generic") |
There was a problem hiding this comment.
"generic" string seems to be unused
| endif() | ||
|
|
||
| if (NACL AND USE_NACL_SAIGO AND SAIGO_ARCH STREQUAL "arm") | ||
| if (YOKAI_TARGET_SYSTEM_NACL AND USE_NACL_SAIGO AND YOKAI_NACL_ARCH_armhf) |
| if (YOKAI_CXX_COMPILER_ICC) | ||
| set(GCC_GENERIC_ARCH "pentium4") | ||
| elseif (DAEMON_CXX_COMPILER_Zig) | ||
| elseif (YOKAI_CXX_COMPILER_Zig) |
Some revamp of the
DaemonPlatform/DaemonArchitecture/DaemonCompiler/DaemonBuildInfohelper code for CMake.I want this framework to be reusable for other projects, the first user outside of the engine may be the NaCl loader itself, and I may use it for NetRadiant as well at some point. So I made the code fully autonomous and contained in a single folder (so it can be copied and kept it sync easily).
It happens that the endian stuff we did in the
DaemonCompilercode usingEndian.hwas useless (it was not doing better than what theqprocessordetection.hcode does anyway), so I removed it.I also renamed
GAME_PIEtoNACL_PIEbecause it's an NaCl option, it was namedGAME_PIEbecause we only build games as NaCl, but for a self-contained framework we better name the NaCl optionNACL. For now this code setsGAME_PIEto theNACL_PIEvalue but once the game is modified to useNACL_PIEthe code setting theGAME_PIEalias will be deleted.Edit: That framework now has its own name: Yokai.
Yokai is the name of that reusable generic CMake framework. CMake variables are prefixed with
YOKAI_, C variables and definitions are prefixed withYOKAI_as well, and the folder for generated files is prefixed withYokai.The name is inspired from that third race mod that was named Unvanquished, from which we already inherited the Dæmon name (Dæmon was the third team name along Humans and Aliens, the Yokai model was one of those Dæmons).