Closed simmplecoder closed 4 months ago
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.
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?
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.
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!
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: