I’ve contributed to maybe 20 open-source projects to try and improve my cmake-fu (amongst other things).
Now, with a reasonable idea of commonalities betwixt projects, I’m ready to write a code-generator to automatically create the CMakeLists.txt and associated CPack files for an arbitrary project.
Ideal workflow:
- Clone non CMake project
- Run
<toolname> generate
- Interactive and CLI arg variants
- Options:
- Language
- Standard version (e.g., C90)
- License †
- Welcome.txt †
- Author (for CPack vendor) †
- Repo/website (for CPack and project) †
- Work with existent
include
directory adding to likely target (e.g.,"$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>"
)
†will try to infer contents
Not sure if additional features are [reasonably] doable:
- Figure out dependencies and add them with
find_package
- Generate flex/bison graph
- Figure out OS-specific switching (e.g., only include these files on macOS, and these on Windows)
What do you think, is this a project worth writing?
Related work (GitHub org/repo):
- Neumann-A/CMakeJSON
- astavonin/gen-cmake
- vyivanov/cmakegen
- Project generator (Latest release: January 20'th 2012) - Ogre Forums
- espressif/esp-idf/blob/master/tools/cmake/convert_to_cmake.py
- &etc. (there was one old unmaintained one that also allowed adding dependencies on CLI)
If it is worth doing, how do you want this built? - I guess I can do the whole thing in C… or CMake, or something else. Should it try and be a tool included with CMake itself, like cpack
and ctest
?