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 support for generating Reflex targets #204

Closed
wants to merge 1 commit into from

Conversation

simmplecoder
Copy link

This PR addresses #203, adds a cmake function to create Reflex targets from the specified sources. It aims to provide easy-to-use CMake interface for users wishing to use Reflex as lexer generator. The product of the function is self-sufficient target. In case of a library the users can freely target_link_libraries against it.

The signature of the function is straightforward:

add_reflex_target(
    TARGET_TYPE <EXECUTABLE|LIBRARY>
    TARGET <target_name>
    LIBRARY_TYPE <whataever add_library accepts as type>
    FILES <list of reflex source files>
    INCLUDE_DIRECTORIES <list of public include directories>
    DEPENDENCY_TARGETS <list of targets to put inside target_link_libraries(<target_name> PUBLIC )>
)

@simmplecoder
Copy link
Author

I would like to add an example that creates a library and then the library is linked into final executable. CMake has a concept of libraries and executables, but with bison it seems the headers are inside executable target, while the lexer library would depend on that. It makes creating a target rather awkward, so I thought I could get your opinion on other bits first. I also looked at the github actions, but it seems like it does not use cmake at all.

@genivia-inc
Copy link
Member

I would like to add an example that creates a library and then the library is linked into final executable. CMake has a concept of libraries and executables, but with bison it seems the headers are inside executable target, while the lexer library would depend on that. It makes creating a target rather awkward, so I thought I could get your opinion on other bits first. I also looked at the github actions, but it seems like it does not use cmake at all.

Sorry, my working knowledge of cmake is limited to help you out. Perhaps check SO, Quora etc for answers? A similar SO Q&A: https://stackoverflow.com/questions/19398113/cmake-and-flex-bison

Perhaps create a couple of example cmake files? E.g. one for just using the reflex library, one for just using a scanner and one for using a scanner and Bison parse?

@genivia-inc genivia-inc marked this pull request as ready for review April 19, 2024 23:54
Added a function that calls reflex for lexer files and adds them to
the specified target along with generated headers's directory, the
privacy of the include directory on the target must be specified.
@simmplecoder
Copy link
Author

I have looked at the examples and assuming they are how people usually use it, my code unfortunately will not be helpful as the cmake I wrote would require some valid (not necessarily useful) headers to be generated from reflex. Also it requires a bit more rigid naming with headers, which most people might not find useful. It came against my own usage cases, which is why I will have to abandon this PR for now. Please feel free to incorporate/modify/remove my code as you see fit.

@genivia-inc
Copy link
Member

OK. It is a always good sign of a grown-up attitude to give something up if it doesn't meet expectations in the end. Don't get me wrong, I appreciate your work on this. I will keep your suggestions in mind!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants