WIP: CMake Build System Changes#707
Conversation
|
CC @YaLTeR for comments about meson. |
|
@YaLTeR in terms of Meson I was thinking it might be simpler to wrap the cmake approach using the cmake module https://mesonbuild.com/CMake-module.html. That would reduce duplication and means that the project would only need to maintain a single build system. Currently I believe there are 4 build systems (win, make, cmake, meson) |
|
I haven't used this meson CMake integration before, I guess we'll need to see how well it ends up working. Especially with regards to static/dynamic library, generated pkg-config and installing. |
|
Looks like i need to fixup the shared vscode config. Ill quickly do this so that the existing commands in |
This is not the issue I am concerned with. Adding vcpkg adds yet another component to the build system that will inevitably break sooner or later. I don't want to be debugging why some tool I don't see the need for has stopped working and is breaking builds. FWIW, you could probably just skip the vcpkg step on windows, since using whatever cmake provides to download and compile sources is functionally equivalent to how vcpkg is currently used (again, on windows).
Yes, apparently adding a single source file to the build, which is the recommended method, is too difficult for some.
Providing software packages is literally the only thing a Linux distribution does, and the way it does it is the only thing that differentiates them. The correct solution is to switch to a working distribution, not to insist that broken software be supported.
What you are trying to do with |
I originally planned on doing this however due to our conversation in the issue thread I decided to make it work. In all fairness vcpkg worked really well but will be easy to remove and fallback to CPM. CPM again doesnt need to be used but as its a single file include in CMake it helps reduce the amount of CMake needed to pull dependencies using fetch instead of submodules |
No, the executables must be launchable from VS Code and you need some configuration for that to happen. See the |
84e21f7 to
b38cfea
Compare
|
WASM was a little soul destroying but I got there 🎉 Changes specific for WASM support Gives this in the binary folder Had to add another header to |
|
Added back
Below is the tracy test application build and run using the launch command |
|
@YaLTeR Im not sure we need to touch the Meson as it looks like this only depends on |
2a1b1cf to
8668fc9
Compare
|
How would the current single CMakeLists.txt solution affect things for people that have it already integrated into their projects using the previously existing CMake solution? People may rely on the CMakeLists.txt defining only the client part of the build and changes such as bumping the C++ standard, defining macros, or introducing new dependencies that may need to be downloaded from network may break things. |
|
Next time I can look at this is Thursday (possibly the weekend). My main goal is to iron out the developer experience. I agree with you this is too far from the original! Also, a little ironic but I did experience an incident today where a demo didn't work because GitHub was down when attempting to pull source of third parties! So it might be best to stick to system dependencies unless pulling is explicitly set and of course re-add source as we discussed |
|
Hah! Anyways, here's a bit of discussion on this topic: https://mastodon.gamedev.place/@wolfpld/111722945441538372 |
|
Great read! You might not like yarn/npm or any web stack. 90% of code is pulled from a singular source (NPM) 😅 This is likely where my leniency for pulling third parties comes from. Most projects I work on build entirely from source and CI will pull that source when it builds. There are rarely any instances where a 5 minute PR cant fix a broken version or a hitch in the pipeline That said, I am still onboard with finding the best compromises. I've had an opportunity to show alternative solutions to the CMake problem. They don't all need to stick 😄. Excited to see where this PR goes. Hopefully it's not getting on your nerves too much! |
|
Apologies for my absence. Work has been busy! Hoping to pick this one back up over the weekend |
|
No worries, things happen. |
c4fc57b to
443662b
Compare
Temp: Remove CI linux dependencies auto download dependencies install libs with choco name artifacts use LINK_LIBRARIES add concurrency install dependencies install dependencies install dependencies passwordless sudo windows fix more windows fixes more windows fixes no statistics
443662b to
28bd9d1
Compare
|
Hey @wolfpld. Apologies again for the delay! Due to the original PR taking the wrong direction in terms of the project goals I decided to start again. This version is closer to your original suggestion and drops the idea of a single cmake build system entirely. I also made sure to not delete the makefiles - originally this was useful for me to understand the project but I can see how that would make reviewing a nightmare!!!
There are still a few issues with Windows and my CMake doesnt conform 1:1 with the compile defines you have in Makefiles. My goals in the coming week will be to make sure this version matches the makefiles and that the extension usage we discussed above also works I have highjacked the current linux.yml workflow so that I could test out the CI. In the long run the original CI will stay and there will be a |
|
If you add these options to |
86d8de3 to
132106c
Compare
|
I have adapted parts of this PR to the Other than that, the following two things must be working before a merge to master:
wl_proto = dependency('wayland-protocols')
wl_scanner = dependency('wayland-scanner')
wl_proto_dir = wl_proto.get_variable('pkgdatadir')
wl_scanner_bin = find_program(wl_scanner.get_variable('wayland_scanner'))
protocols = {
'xdg-shell': wl_proto_dir / 'stable/xdg-shell/xdg-shell.xml',
'xdg-decoration': wl_proto_dir / 'unstable/xdg-decoration/xdg-decoration-unstable-v1.xml',
}
foreach name, path : protocols
code = custom_target(
name.underscorify() + '_c',
input: path,
output: '@BASENAME@-protocol.c',
command: [wl_scanner_bin, 'private-code', '@INPUT@', '@OUTPUT@']
)
files += code
client_header = custom_target(
name.underscorify() + '_client_h',
input: path,
output: '@BASENAME@-client-protocol.h',
command: [wl_scanner_bin, 'client-header', '@INPUT@', '@OUTPUT@']
)
files += client_header
endforeachThis needs to be replicated in CMake. Review and further help would be appreciated. |
|
Ok, I have pushed further and now all the tools can be compiled both on Linux and Windows. Some random notes:
|
|
Thanks for taking a look, I plan to work on the emcsripten toolchain and the Wayland function later today. In terms of your recent questions: I found that using current source dir gave incorrect paths depending on which file included the server cmake. Using list dir made sure the path was as I expected No significance to the minimum version, we should be able to lower this. Most systems now ship with 3.19 or higher afaik (I'd have to double check android studio a few years a go it got a bump to 3.18) Windows builds should be parallel if you build with --parallel or -j N. Those options have worked for me in the past. I can double check later though. Docs say that these map to native parallelism flags |
The server file, sure, but I am asking about the build file in the root of the repository, which you would use to integrate Tracy with applications, and which is not referenced by any other build file.
I'm doing this through the VS Code extension and it doesn't seem to work no matter what I enter into the parallel build entry field. The default value of 0 is supposed to be a reasonable default. It works as intended on Linux. Supposedly there are some magic values you can input on the command line to setup the MSVC generator to do the correct thing, but it's just a hack instead of a proper solution. From what I have found with a cursory look on the Internet, they seem to be confusing parallel building of multiple projects with parallel building of source files within a single project. It's a bit disappointing. |
|
We could append the required parallel compile flags if MSVC through CMake. I'll have to have a look when I'm at my desk but I believe it's something like "/MP" |
|
List of remaining things:
Overall, I'd say the merge is very close now. |
|
In terms of CI and build docs. The CI I added can be moved to its own pipeline. I piggy backed on existing yml's in order for it to run. I intend on keeping the original CI. My workflow should generate a zip for each platform as an artifact - not necessary but a nice to have I'm assuming build docs just need a CMake section. Alongside the existing docs? |
|
The old build system is already removed on the |
|
It is done. |






This PR is currently a WIP. This PR has taken many shapes. This version of the PR intends to be less intrusive
CI has been altered to run the CMake version. This will be reverted in the future and is purely for testing - CI needs to exist in main to run.
TODO:
[ ] Double check build vars are adhered too in CMake
[ ] Explore vscode cmake extension usage
[ ] Run tests in CI
[ ] Fix windows CI
[ ] Emscripten