-
Notifications
You must be signed in to change notification settings - Fork 143
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
cmake implementation #568
cmake implementation #568
Conversation
Yes, I'm very glad you're integrating your changes back into modm!
No? We're not adding more indirection by hiding our
Nah, CMake must not automatically manage compile flags. The optimization is PS: Note that we ran out of free credits for CircleCI for this month, and thus speed has been degraded significantly. |
Maybe |
tools/build_script_generator/cmake/resources/CompilerWarnings.cmake.in
Outdated
Show resolved
Hide resolved
@salkinium please is head comment, a few questions there. The only functionality missing is flags on file level, is there any examples on this?. I think, it turned out to be a simple but strong CMake integration. I have some strange error's "ResouceBusy" in the circleci, anyone knows what's that about?. |
The CMSIS-DSP examples use per-file compile flags. We've run out of free credits for this month, so CircleCI is running our CI on vapour. |
What IDE should I test this PR with? CLion? QT Creator? VS Code? I'm using Sublime Text, but that's not an IDE… |
The CMake options should be put into the CMake module.md documentation. I'd be happy to have a CMake-only example in modm, with the |
Personally i use vscode in the moment. clion also works flawlessly. but a simple text editor will also work, some times i use neo-vim. vscode requires some plugins before it works acceptable. Plugins: |
Full support for DSP library and per-file flags from lbuild is now implemented. My Python skills is very very rusty and per-files flags was not trivial to implement so i hope the code is not to terrible. No new features will be added for now. |
tools/build_script_generator/cmake/resources/ModmConfiguration.cmake.in
Outdated
Show resolved
Hide resolved
tools/build_script_generator/cmake/resources/ci_CMakeLists.txt.in
Outdated
Show resolved
Hide resolved
I've only skimmed the code so far and haven't had time to test the new CMake generator on my computer. I would actually still like to remove the Makefile from the CMake generator, since CMake (by now) should be able to generate a Makefile itself, right? I'll have a look at it next week... |
Ok, I've gotten around to using this in VSCode: I like it a lot! Good job!
I think we should have an lbuild option for using the |
I does not make sense to be used in an IDE (we would need some adapter to the IDE-Debugger-Interface...) but people like me will call the |
This comment has been minimized.
This comment has been minimized.
You can have different compiler versions. So why not let the user choose what he want.
Flags can be changed, see below how to configure CMake. Some IDE's support it.
It is set in the root CMakeLists.txt.
You can set the build path to whatever you want but not from 2 places at once. It might not work with everything if lbuild rules, but it could be fix in the CMakeFile.txt for the CI.
CMake generates the build script (make, ninja, whatever) in the build folder and you can run `make (program | size | gdb) from there. It has nothing to do with the src folder. Something is definitely wrong if that's the case.
It makes sense to me, are cmake users not allowed to debug? CMake actually works and often used without IDE. Don't use vscode as reference, is not that perfect.
You can configure everything from IDE, ccmake, cmake-gui (if installed) or command line. look here
Never tried it.
CMake reads enviroment variable GCC_PATH and sets MODM_GCC_PATH (cached variable) if present. I can change this behavior for the default CMakeLists.txt to the CI. The old solution is platform dependent and will not work everywhere. The library path is totally different on many platforms because gcc is configured differently. On my machine the GCC install path is It's programmed to give a warning and it works here:
The default generated CMakeLists.txt is the non-src version and it's working with the CI and all examples. (note. it's not overwritten by lbuild if it exists). The example project is a src version. lbuild don't know anything about other organizations source structure so why worry about that. My goal in the design was to keep it flexible so it easily can be modified to everyone's platform and there build setup. instead of forcing a build setup from modm's CI to anyone. The only thing modm/CMakelists.txt and the included file worries about is how modm itself should be build and nothing else. The lbuild generated main CMakeLists.txt with globing is only for the CI and the user is supposed to make his own for his needs. |
This CMake implementation don't change any flags regarding building modm. Only the responsibility is changed since CMake isn't acting like scons. This can be verified by: Example: |
Ok, I definitely want to work these changes into modm, since I want to have a standardized way of integrating third-party code via CMake. However, since this is all fairly complicated and overwhelming for me, I want to do the following:
|
This comment has been minimized.
This comment has been minimized.
What is the true purpose for -ffile-prefix-map=${MODM_GCC_PATH}=. in modm. |
Yes, we want to archive ELF files automatically for group projects, so that anyone can debug the currently running firmware on the hardware. That's why we added the artifact store for scons, the GNU Build ID and the relative paths. In theory, the artifact path is on a server, and you should just get the current build id from the log and do So to be specific, since people have different OSes with different project paths, the absolute paths will prevent the ELF file from finding the right sources. |
I have made a few changes you might like @salkinium. I think maybe this is a better way to handle conflicts with external modules and in-source builds are not allowed now. Now no flags are filtered except -Ox which is set to:
Target interfaces defined:
All modm sources is compiled with lbuild generated flags no matter what. target_link_libraries(MainUserCode
PRIVATE
modm_options
modm_warnings
modm) If a external xyz_module with conflicting flags are added the flags from modm_options has to be redefined locally. Following applies: target_compile_features(xyz_module INTERFACE cxx_std_17) # adds -std=c++17
target_compile_options(xyz_module
PRIVATE
-fdata-sections -ffunction-sections etc....
$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions -fno-rtti -fno-unwind-tables -fstrict-enums -fuse-cxa-atexit>)
target_link_libraries(xyz_module
PRIVATE
modm_arch_options
modm_warnings)
You cheated on me, CMake make has never done that. It's your own Makefile there are creating the build path. 😃 |
Ok, sorry for the long wait. The latest changes are indeed much cleaner, I like it much more. I'd prefer to merge this sooner rather than later, even without the flags splitting support for the other build systems (not motivated to do that right now). Todo before merge:
|
@Jasa Hi - suggestion..
to:
in: |
@Jasa any idea how to add start-group and end-group linker flags? They are pretty important for modm. Are you ok with relicensing your CMakeLists.txt as BSD 2-clause? |
If you have a really good reason. CMake has a more convenient way to achieve the same, In Since CMake introduced Object libraries there is no need to create a static library unless you want to install them permanently on the host. There are also plenty examples on Stack Exchange.
No problem at all. |
Excellent! I've updated the module docs, however, I'm not an expert so please review @Jasa. |
These scripts are intended to be modified by the user for their project without the need to publish their changes to it.
Hello @Jasa
To:
I ran the 'lbuild build' command and was expecting to see the CMakeLists.txt file in the working directory alongside the project.xml file. Using ubuntu 20.04 under windows terminal, Python 3.8.5 The modm directory looks complete Any hints welcome.. Thanks.. |
You need to set the |
Hello! in README.md https://github.com/modm-ext/modm_starter_project.git |
Good catch, I've fixed it. |
A initial test of a modern cmake implementation.
All flags from lbuild is mapped to a proper CMake model also per-file flags. CMake can be responsible for compiler choice and build type without implications. Flags like -O, -std and -ffile-attr-map is filtered and controlled by CMake.
Full support for DSP library.
CMake interface targets
modm_warnings
- lbuild defined warningsmodm_options
- lbuild defined build optionsmodm
- modm itself (all headers is defines as system headers to isolate modm warnings from users. Easy changeable, do we need a option for that?)Cached entries
A draft example on usage is here. (I need a better place to put it?)