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

A variable pointing to the main LF source file should be code-generated into the CMake file #2126

Open
erlingrj opened this issue Dec 3, 2023 · 1 comment
Labels
c Related to C target cmake good first issue Good for newcomers

Comments

@erlingrj
Copy link
Collaborator

erlingrj commented Dec 3, 2023

The generated CMakeLists.txt should contain a variable pointing to the LF src directory, e.g. LF_SRC_DIR. This can be used by any user-written CMake file to include files relative the main LF file. Currently the user must also use the files target property to have all the files they want copied into the src-gen directory. This is unnecessary duplicate work.

This should be an easy fix. Check out the CCmakeGenerator.java file.

@erlingrj erlingrj added c Related to C target cmake good first issue Good for newcomers labels Dec 3, 2023
@cmnrd
Copy link
Collaborator

cmnrd commented Dec 13, 2023

Great! I have argued for this before and never understood the files property in the C target. I think not even a variable like LF_SRC_DIR is required, as cmake already defines a bunch of sensible variables. For instance, CMAKE_CURRENT_LIST_DIR points to the directory in which the current cmake script is located. We use this in the C++ target to refer to external C++ files. See here for instance. Defining the variable LF_SRC_DIR in addition could be convenient, though.

In the C++ target, we also always add the src directory to the include paths so that we can resolve header files relative to the src directory and don't need to add them explicitly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c Related to C target cmake good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants