Get setup to reproduce use of bare CMake
This commit is contained in:
@@ -48,34 +48,6 @@ def setup_build_path(build_path):
|
||||
os.makedirs(build_path, 0o755)
|
||||
|
||||
|
||||
def test_adapt_cmake_command_to_platform():
|
||||
|
||||
cmake_command = "FC=foo CC=bar CXX=RABOOF cmake -DTHIS -DTHAT='this and that cmake' .."
|
||||
res = adapt_cmake_command_to_platform(cmake_command, 'linux')
|
||||
assert res == cmake_command
|
||||
res = adapt_cmake_command_to_platform(cmake_command, 'win32')
|
||||
assert res == "set FC=foo && set CC=bar && set CXX=RABOOF && cmake -DTHIS -DTHAT='this and that cmake' .."
|
||||
|
||||
cmake_command = "cmake -DTHIS -DTHAT='this and that cmake' .."
|
||||
res = adapt_cmake_command_to_platform(cmake_command, 'linux')
|
||||
assert res == cmake_command
|
||||
res = adapt_cmake_command_to_platform(cmake_command, 'win32')
|
||||
assert res == cmake_command
|
||||
|
||||
|
||||
def adapt_cmake_command_to_platform(cmake_command, platform):
|
||||
"""
|
||||
Adapt CMake command to MS Windows platform.
|
||||
"""
|
||||
if platform == 'win32':
|
||||
pos = cmake_command.find('cmake')
|
||||
s = ['set {0} &&'.format(e) for e in cmake_command[:pos].split()]
|
||||
s.append(cmake_command[pos:])
|
||||
return ' '.join(s)
|
||||
else:
|
||||
return cmake_command
|
||||
|
||||
|
||||
def run_cmake(command, build_path, default_build_path):
|
||||
"""
|
||||
Execute CMake command.
|
||||
@@ -84,7 +56,6 @@ def run_cmake(command, build_path, default_build_path):
|
||||
from shutil import rmtree
|
||||
|
||||
topdir = os.getcwd()
|
||||
os.chdir(build_path)
|
||||
p = Popen(command,
|
||||
shell=True,
|
||||
stdin=PIPE,
|
||||
@@ -164,8 +135,7 @@ def configure(root_directory, build_path, cmake_command, only_show):
|
||||
if not only_show:
|
||||
setup_build_path(build_path)
|
||||
|
||||
cmake_command = adapt_cmake_command_to_platform(cmake_command, sys.platform)
|
||||
|
||||
cmake_command += ' -B' + build_path
|
||||
print('{0}\n'.format(cmake_command))
|
||||
if only_show:
|
||||
sys.exit(0)
|
||||
|
@@ -20,7 +20,7 @@ def gen_cmake_command(config):
|
||||
s.append(' command.append({0})'.format(definition))
|
||||
|
||||
s.append(" command.append('-DCMAKE_BUILD_TYPE={0}'.format(arguments['--type']))")
|
||||
s.append(" command.append('-G \"{0}\"'.format(arguments['--generator']))")
|
||||
s.append(" command.append('-G\"{0}\"'.format(arguments['--generator']))")
|
||||
s.append(" if arguments['--cmake-options'] != \"''\":")
|
||||
s.append(" command.append(arguments['--cmake-options'])")
|
||||
s.append(" if arguments['--prefix']:")
|
||||
@@ -110,7 +110,7 @@ def gen_setup(config, default_build_type, relative_path, setup_script_name):
|
||||
s.append("build_path = arguments['<builddir>']")
|
||||
s.append("\n")
|
||||
s.append("# create cmake command")
|
||||
s.append("cmake_command = '{0} {1}'.format(gen_cmake_command(options, arguments), root_directory)")
|
||||
s.append("cmake_command = '{0} -H{1}'.format(gen_cmake_command(options, arguments), root_directory)")
|
||||
s.append("\n")
|
||||
s.append("# run cmake")
|
||||
s.append("configure.configure(root_directory, build_path, cmake_command, arguments['--show'])")
|
||||
|
Reference in New Issue
Block a user