Skip to content
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

Add cmake-init-include target property #2432

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

erlingrj
Copy link
Collaborator

@erlingrj erlingrj commented Nov 5, 2024

This PR adds a new target property called cmake-init-include (I am open to other naming suggestions). You can pass it a list of paths to cmake files, which will be included in the generated CMakeLists.txt at the very beginning, before the project( statement.

I am also removing the quotation marks on the LF_SOURCE_DIRECTORY compile def. The quotation mark makes it awkward to use it in the included cmake files, which is where they are likely to be used the most.

This means that the user can override the TOOLCHAIN_FILE cmake variable and can easily set up cross-compilation.

This PR enables STM32F4 support without piling on more platform and build logic into lfc but instead requiring the user to configure CMake correctly and add the right paths, compile defs and options.

In this PR I use the target property to enable cross compiling for STM32: lf-lang/stm32-nucleo-f446re-template#1

This PR is blocking #2185

@erlingrj erlingrj added enhancement Enhancement of existing feature c Related to C target cpp Related to C++ target build system cmake labels Nov 5, 2024
@erlingrj erlingrj requested a review from edwardalee November 6, 2024 06:07
@edwardalee
Copy link
Collaborator

The change to LF_SOURCE_DIRECTORY and related definitions will break a number of demos in the playground. In fact, without the quotation marks, I'm not sure it is possible to use these definitions in the way they are used in the playground examples. See for example Uptime.lf. Maybe we actually need to have two variants of these constants, one with quotation marks and one without? Seems ugly, but I can't think of any other solution.

@erlingrj
Copy link
Collaborator Author

erlingrj commented Dec 9, 2024

Hi Edward, thanks for your feedback. The problem you identify is solved with the companion PR here: lf-lang/reactor-c#494

It adds back the quotation marks when they are defined as compiler flags. So the change is subtle, basically it only means that the CMake variable does not have the quotation marks and can thus conveniently be used in the cmake-include files, but the compiler defs will have quotation marks so that it can be conveniently used by the C code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build system c Related to C target cmake cpp Related to C++ target enhancement Enhancement of existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants