So, I'm wondering if it would be more useful to have one file that lists everything in one place which is easier to edit and check; and then use a script to generate the required CMakeLists.txt in all the necessary locations from this file.
I also wonder why CMake doesn't do this in the first place.
Thoughts?
G
#!/usr/bin/python
"""Handle Cmakelists.txt from one recipe."""
import getopt
import os
import re
import sys
def show_help():
"""Help message function."""
print "Cmake Sorter creates and places your CMakeLists.txts"
print " where they should go, all from one place."
print "\nOptions:"
print "-r recipe -- name of your recipe file."
print "-d dry-run -- show where all the files would go."
print "-c collect -- create a recipe file from existing CMakeLists.txt"
def load_in_file(inputfile):
"""Function to read file and return contents.
Input:
inputfile: Name of recipe file.
Output:
lines: array of lines
"""
lines = []
with open(inputfile, 'r') as the_file:
lines = the_file.readlines()
return lines
def collect_files_make_recipe_file():
"""Collect all the existing CMakeLists.txt files
Output: A recipe file containing all the contents of the
CMakeLists.txt in your existing project.
"""
pass
def get_list_of_cmake_files(input_text):
"""Gather all the directory names
Input:
input_text: Contents of recipe file as []
Output:
List of thruples as (path, line nr. start, line nr. end)
"""
pass
def show_dry_run(input_text):
"""List all the locations anticipated
Input:
input_text: Contents of recipe file as []
Output:
List of paths to stdout
List of paths to CMakeListsLocations.txt
"""
pass
def write_cmake_files(input_text, method):
"""Generate and list or write resulting CMakeLists.txt files
Input:
input_text: Contents of recipe file as []
Output:
create CMakeLists.txt in the desired locations from
given file contents.
"""
pass
def main(argv):
''' Read a CMake recipe from file and list or generate CMakeLists.txt '''
try:
opts, args = getopt.getopt(argv, "h:r:d:c",
["help", "recipe=", "dry-run","collect"])
except getopt.GetoptError:
show_help()
sys.exit(2)
for opt, arg in opts:
if opt in ("-h", "--help"):
show_help()
sys.exit()
elif opt in ("-r", "--recipe"):
input_text = load_in_file(arg)
if input_text == []:
print ("The file you specified could not be found " +
"or is not readable.\n")
sys.exit()
generate_cmake_files(input_text)
elif opt in ("-d", "--dry-run"):
input_text = load_in_file(arg)
if input_text == []:
print ("The file you specified could not be found " +
"or is not readable.\n")
sys.exit()
show_dry_run(input_text)
elif opt in ("-c", "--collect"):
collect_files_make_recipe_file()
sys.exit()
if __name__ == "__main__":
main(sys.argv[1:])
-------------------------------------------------------------------------------
Just needed a break from logger and all those CMakeLists.txt kind of got to me a bit. :-D
G
I am highly against only having only having one cmake file...you could make the same case why have multiple directories.For me the seperation is important, when I work on a CMAKE file, I know it only works on this particular subdir.We also have conflicting settings, which would make 1 central cmake file unreadable.Actually your case is a good example too...because if your cmake file creates problems, we comment the add_dir() out in the central one, and the rest works.No thanks to 1 big file (small files, small problems)rgdsjan
Thoughts?
G
--
You received this message because you are subscribed to the Google Groups "CorinthiaTeam" group.
To unsubscribe from this group and stop receiving emails from it, send an email to corinthiatea...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Sent from My iPad, sorry for any misspellings.
On Wednesday, September 9, 2015 at 8:03:13 PM UTC+1, jan i wrote:
> On Wednesday, September 9, 2015, jan i <ja...@apache.org> wrote:
>
>
> On Wednesday, September 9, 2015, Gabriela Gibson <gabriel...@gmail.com> wrote:
> I find the CMakeLists.txt in every directory an inconvenience.
>
>
>
> So, I'm wondering if it would be more useful to have one file that lists everything in one place which is easier to edit and check; and then use a script to generate the required CMakeLists.txt in all the necessary locations from this file.
>
>
>
> I also wonder why CMake doesn't do this in the first place.
>
>
> I am highly against only having only having one cmake file...you could make the same case why have multiple directories.
>
>
> For me the seperation is important, when I work on a CMAKE file, I know it only works on this particular subdir.
>
>
> We also have conflicting settings, which would make 1 central cmake file unreadable.
>
>
> Actually your case is a good example too...because if your cmake file creates problems, we comment the add_dir() out in the central one, and the rest works.
>
>
> No thanks to 1 big file (small files, small problems)
>
>
> rgds
>
> jan
Thank you for the input Jan,
I guess it's more suited to small projects or if you want to quickly set up something with a nice structure that uses a build and bin directory without getting lost in a jungle of CMakeList.txt files. (I am the lazy kind)
:)
G, who was bitten by Makefile and then got bit some more by Cmake last night