ChrisDodd / btyacc

Backtracking yacc
18 stars 5 forks source link

Add CMake build tooling #27

Closed friendlyanon closed 2 years ago

friendlyanon commented 2 years ago

This PR adds CMake build scripts.

The AWK script is replaced with a CMake script as well. It produces the exact same output as the AWK script. There is one edge case for this however. Due to how CMake handles lists, I have to transform end-of-line backslashes to \, so they do not unintentionally escape separators.

unistd.h does not exist on Windows. On Windows, io.h is included instead.

The install rules are as complicated as they are only because I wanted to also support clients using CMake, so they can just use btyacc like so:

find_package(btyacc REQUIRED)
execute_process(COMMAND "${BTYACC_EXECUTABLE}" ...)

Everything after line 60 in CMakeLists.txt and the cmake/install.cmake script are there to implement that.

ChrisDodd commented 2 years ago

My experience with CMake in the past has not been good -- it seems extremely complex and fragile. These scripts seem pretty clean and clear, however, so hopefully will not be a maintenance issue.

friendlyanon commented 2 years ago

I very much appreciate the swift response!

Depending on when you touched CMake last, that is not surprising. CMake 3.0 released only 8 years ago and that is when things started to change for the better, albeit tutorial style documentation still makes things a bit harder for most.

Please do ping me anytime you need assistance with anything CMake related. I am also developing cmake-init to help show people how to best structure a CMake managed project with plenty of examples for complete projects.