make minimum CMake version configurable; fixes #109
This commit is contained in:
parent
51bdac40e2
commit
704de471eb
24
update.py
24
update.py
@ -180,22 +180,16 @@ def gen_setup(config, relative_path):
|
|||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
def gen_cmakelists(config, relative_path, modules):
|
def gen_cmakelists(project_name, minimum_required_version, relative_path, modules):
|
||||||
"""
|
"""
|
||||||
Generate CMakeLists.txt.
|
Generate CMakeLists.txt.
|
||||||
"""
|
"""
|
||||||
if not config.has_option('project', 'name'):
|
|
||||||
sys.stderr.write("ERROR: you have to specify the project name\n")
|
|
||||||
sys.stderr.write(" in autocmake.cfg under [project]\n")
|
|
||||||
sys.exit(-1)
|
|
||||||
project_name = config.get('project', 'name')
|
|
||||||
|
|
||||||
s = []
|
s = []
|
||||||
|
|
||||||
s.append(autogenerated_notice())
|
s.append(autogenerated_notice())
|
||||||
|
|
||||||
s.append('\n# set minimum cmake version')
|
s.append('\n# set minimum cmake version')
|
||||||
s.append('cmake_minimum_required(VERSION 2.8 FATAL_ERROR)')
|
s.append('cmake_minimum_required(VERSION %s FATAL_ERROR)' % minimum_required_version)
|
||||||
|
|
||||||
s.append('\n# project name')
|
s.append('\n# project name')
|
||||||
s.append('project(%s)' % project_name)
|
s.append('project(%s)' % project_name)
|
||||||
@ -355,6 +349,18 @@ def main(argv):
|
|||||||
config = RawConfigParser(dict_type=OrderedDict)
|
config = RawConfigParser(dict_type=OrderedDict)
|
||||||
config.read('autocmake.cfg')
|
config.read('autocmake.cfg')
|
||||||
|
|
||||||
|
if not config.has_option('project', 'name'):
|
||||||
|
sys.stderr.write("ERROR: you have to specify the project name\n")
|
||||||
|
sys.stderr.write(" in autocmake.cfg under [project]\n")
|
||||||
|
sys.exit(-1)
|
||||||
|
project_name = config.get('project', 'name')
|
||||||
|
|
||||||
|
if not config.has_option('project', 'minimum_required_version'):
|
||||||
|
sys.stderr.write("ERROR: you have to specify the minimum_required_version for CMake\n")
|
||||||
|
sys.stderr.write(" in autocmake.cfg under [project]\n")
|
||||||
|
sys.exit(-1)
|
||||||
|
minimum_required_version = config.get('project', 'minimum_required_version')
|
||||||
|
|
||||||
# get relative path from setup.py script to this directory
|
# get relative path from setup.py script to this directory
|
||||||
relative_path = os.path.relpath(os.path.abspath('.'), project_root)
|
relative_path = os.path.relpath(os.path.abspath('.'), project_root)
|
||||||
|
|
||||||
@ -363,7 +369,7 @@ def main(argv):
|
|||||||
|
|
||||||
# create CMakeLists.txt
|
# create CMakeLists.txt
|
||||||
print('- generating CMakeLists.txt')
|
print('- generating CMakeLists.txt')
|
||||||
s = gen_cmakelists(config, relative_path, modules)
|
s = gen_cmakelists(project_name, minimum_required_version, relative_path, modules)
|
||||||
with open(os.path.join(project_root, 'CMakeLists.txt'), 'w') as f:
|
with open(os.path.join(project_root, 'CMakeLists.txt'), 'w') as f:
|
||||||
f.write('%s\n' % '\n'.join(s))
|
f.write('%s\n' % '\n'.join(s))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user