-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide cmake build system? #146
Comments
The MPS primary build system is The reasons for using autoconf are:
The configure script outputs a message saying it's not really the thing to use. It's just a front end to the real "system" which is in GNU Make, NMAKE, or Xcodebuild. See "Building the MPS for development". So we could consider replacing GNU Make, NMAKE, and Xcodebuild with cmake. Autoconf is a red herring. |
Not sure whether this is relevant, but cmake is written in C++. Hence a C++ compiler is required to compile cmake for each target platform. (AFAIK cmake must be run on the build platform; it cannot generate portable scripts like GNU automake.) This might make it more difficult to work with some embedded or experimental targets, but perhaps it will not. |
This brings up a useful requirement to define. Whatever "make" we're using needs to be available to developers of the MPS on the "supported" platforms. GNU Make, NMAKE, and Xcodebuild together meet that requirement. But we can ensure things stay easy for developers porting to platforms that don't have many tools. From the beginning it's been a design principle that the MPS can be built by a command like:
so that we don't start getting tangly nests of dependencies on tools and the MPS stays easy to port. That in turn means that people should easily be able to cook up some alternative where they need it. If we introduce a tool like cmake for convenience, keep that build principle, and give a few instructions, then I think things could work out well. |
This is defined in detail in design.mps.config.build.cc.
And this point is covered in design.mps.config.build.rat, which says:
|
OK, so kind of interesting, but what do we gain? It seems like a lot of work to switch. |
@waywardmonkeys you could demonstrate one of the things you mentioned in #146 (comment) ? CMake only seems to be able to make one target variety (build config) at a time by default. |
Yes! I will do so (probably Monday).
You can use separate build directories, so this isn't an issue. You can do this either via:
or:
(You could just run |
So, for clang-tidy for doing static analysis, on your cmake branch, you can do this from the base directory (assuming that like me, you have
And then you'll get a ton of output from clang-tidy including some interesting stuff which doesn't belong in this bug. :) |
At the moment, if you |
This sort of thing
If you can combine |
Woah. Well, it certainly makes a lot of false but interesting claims 😉 |
Hmm. https://stackoverflow.com/a/12024211 says:
The horror. |
So it seems CMake calls what we do with GNU Make a "multi target config". That is, we build multiple varieties of the same targets with different options. CMake's template using makefiles is only "single configuration". See https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#build-configurations . I'm not sure how important this is. |
I think the main benefits of CMake for the MPS project could be:
|
For cross-compiling, you use toolchain files. Some SDKs / toolchains ship with the appropriate files for their target. It tends to work out pretty well. The fewer checks you do in the cmake config, the better things are of course. (Much like doing fewer things in autoconf as well...) |
Yes. What I've done so far is to kind of duplicate the way we currently build, without trying to optimise. I bet we could make a pass where we use CMake a bit more "naturally". |
This is the feeling I get from reading the documentation and trying to figure out how to do anything. I'm a bit concerned about the dependency. |
The CMake manual says, of
Therefore useless. I'm not sure why they have a variable that might be useful, or might be random junk, and don't even say when it might be useful. |
CheckSymbolExists quietly just doesn't work. e.g.
I've noticed there's a pattern of "quietly doesn't work". Not great for high reliability software development. |
Wow. The time is ripe for a |
Here's my current target detection hack. Feels a bit like building on sand. Lines 47 to 67 in c1d929f
|
I'm not sure why we can't just access |
|
Before committing to CMake, we should consider other systems. There's a handy list at https://github.com/ninja-build/ninja/wiki/List-of-generators-producing-ninja-build-files |
I looked in to creating a "multi target config" Makefile generator. Unfortunately, CMake's generators are baked-in C++, such as cmGlobalUnixMakefileGenerator3.cxx. Shame. |
The pull request #148 and its branch demonstrate how CMake might work for the MPS. I think the next steps are:
An interesting case is #192 which is currently blocked because the i386 platform was dropped from the Xcode project, and I do not have a convenient macOS box to do the necessary merge and validate the result. I can arrange all that and do it, but it's expensive in time. |
A
cmake
build system could possibly replace theautoconf
-based build system.This would be able to generate project files for various IDEs, integrate with something like
vcpkg
, generatescommands.json
to make it easier to driveclang-tidy
and the static analysis tools, etc.This could be pretty self-contained and would be fewer files than the
autoconf
system. Perhaps it could even replace the main / primary build system!The text was updated successfully, but these errors were encountered: