cmake: make DaemonPlatform, Architecture, Compiler, etc. autonomous and reusable#1641
cmake: make DaemonPlatform, Architecture, Compiler, etc. autonomous and reusable#1641illwieckz wants to merge 13 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
|
There is now a unique |
|
Actually I noticed that we can report the native architecture built with Saigo (since Saigo does direct-to-nexe): |
3c3ea82 to
1ed9ae1
Compare
3cbaa2e to
6eecf0a
Compare
6eecf0a to
a9cb80e
Compare
|
I rebased on current master. |
|
As a side quest, I'm questioning the prefix. I wanted the variables produced by this framework to have a single prefix to 1. make it obvious it's generated by the framework, 2. have them share a namespace, 3. have them explicitly different with stock The thing is that I want this framework reusable. I plan to use it for the NaCl loader, I want to use it in NetRadiant, I may use it in XQF if the need arise. In those context, another name would be fine, though |
a9cb80e to
49f356c
Compare
|
@slipher I would like to merge this so I can move on. Also I need to rebase the NaCl loader cmake code above it. In the future I may find a more generic prefix than |
|
Actually I just did that. This CMake framework was written for the Dæmon engine first but isn't specific to the engine and is meant to be reusable for any CMake-based project, like the NaCl loader, NetRadiant, etc. So I gave it a name: Yokai. Yokai is the name of that reusable generic CMake framework. CMake variables are prefixed with 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). |
|
One commit renames the framework to Yokai and but keeps a variable substitution mechanism to not break the existing |
43f13f8 to
ad6906a
Compare
Please no. The built-in |
| # Daemon BSD Source Code | ||
| # Copyright (c) 2025, Daemon Developers | ||
| # YOKAI BSD Source Code | ||
| # Copyright (c) 2025, YOKAI Developers |
There was a problem hiding this comment.
It's annoying to proliferate different author names because then we would have to update the author lists whenever moving things between files.
| ${LIB_DIR}/breakpad/src/client/windows/handler/exception_handler.h | ||
| ) | ||
| elseif (LINUX) | ||
| elseif (YOKAI_SYSTEM_Linux_COMPATIBILITY) |
There was a problem hiding this comment.
Does Breakpad Linux code seriously work on some non-Linux OS? Would be surprising since debugger APIs are very OS-specific. But if you want to try it I have a testing script: #1785
| # Look for OpenGL here before we potentially switch to looking for static libs. | ||
| if (BUILD_CLIENT) | ||
| if (LINUX OR FREEBSD) | ||
| if (YOKAI_SYSTEM_Unix_COMPATIBILITY) |
There was a problem hiding this comment.
I assume "Unix compatibility" would include Mac? Then this is wrong because this GLVND stuff should not be set on Mac.
| # Target options. | ||
| if (MSVC) | ||
| if (ARCH STREQUAL "i686") | ||
| if (YOKAI_CXX_COMPILER_MSVC) |
There was a problem hiding this comment.
Replacing MSVC conditionals with this breaks the clang-cl compiler which is both Clang and MSVC. It is correctly detected by CMake:
-- The C compiler identification is Clang 19.1.5 with MSVC-like command-line
-- The CXX compiler identification is Clang 19.1.5 with MSVC-like command-line
clang-cl works on master but this PR breaks it by feeding it GCC-specific options.
Was there anything wrong with CMake's compiler detection that you saw?
|
Besides clang-cl being broken, regular old MSVC also doesn't work.
|
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.