# Tool to generate all CMakeLists.txt for existing project

**URL:** https://discourse.cmake.org/t/tool-to-generate-all-cmakelists-txt-for-existing-project/4321
**Category:** Community
**Created:** [October 22, 2021, 8:15pm UTC](https://discourse.cmake.org/t/tool-to-generate-all-cmakelists-txt-for-existing-project/4321 "2021-10-22T20:15:48Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![SamuelMarks](https://discourse.cmake.org/user_avatar/discourse.cmake.org/samuelmarks/32/1619_2.png) [@SamuelMarks](https://discourse.cmake.org/u/SamuelMarks)
#### Post date: [October 22, 2021, 8:15pm UTC](https://discourse.cmake.org/t/tool-to-generate-all-cmakelists-txt-for-existing-project/4321/1 "2021-10-22T20:15:48Z")

</div>

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](https://forums.ogre3d.org/viewtopic.php?f=1&t=54842)
- 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`?

---

<div class="post-metadata">

### Author: ![Nicholas\_Yue](https://discourse.cmake.org/user_avatar/discourse.cmake.org/nicholas_yue/32/464_2.png) [@Nicholas\_Yue](https://discourse.cmake.org/u/Nicholas_Yue)
#### Post date: [December 15, 2022, 4:24pm UTC](https://discourse.cmake.org/t/tool-to-generate-all-cmakelists-txt-for-existing-project/4321/2 "2022-12-15T16:24:31Z")

</div>

Is there any update ? If you did not proceed, are you able to share the reasons why ?

---

<div class="post-metadata">

### Author: ![SamuelMarks](https://discourse.cmake.org/user_avatar/discourse.cmake.org/samuelmarks/32/1619_2.png) [@SamuelMarks](https://discourse.cmake.org/u/SamuelMarks)
#### Post date: [June 4, 2023, 5:16pm UTC](https://discourse.cmake.org/t/tool-to-generate-all-cmakelists-txt-for-existing-project/4321/3 "2023-06-04T17:16:06Z")

</div>

@Nicholas_Yue Did not proceed due to lack of interest
