Fixed compilation with MSVC.
This commit is contained in:
@@ -6,7 +6,7 @@ import shutil
|
||||
from SCons.Script import *
|
||||
|
||||
_BUILT_STAMPFILE = '.spp_built'
|
||||
_VERSION = 0 # bump if you change how the projects are build to trigger a clean build
|
||||
_VERSION = 2 # bump if you change how the projects are build to trigger a clean build
|
||||
|
||||
Import('env')
|
||||
|
||||
@@ -14,19 +14,31 @@ def cmd_quote(s: str) -> str:
|
||||
escaped = s.replace('\\', '\\\\')
|
||||
return f'"{escaped}"'
|
||||
|
||||
def _generate_cmake_c_flags(dependencies: 'list[dict]') -> str:
|
||||
parts = []
|
||||
def _generate_cmake_c_flags(env, dependencies: 'list[dict]') -> str:
|
||||
parts = env['DEPS_CFLAGS'].copy()
|
||||
for dependency in dependencies:
|
||||
for path in dependency.get('CPPPATH', []):
|
||||
parts.append(cmd_quote(f'-I{path}'))
|
||||
return ' '.join(parts)
|
||||
parts.append(f'-I{path}')
|
||||
return cmd_quote(' '.join(parts))
|
||||
|
||||
def _generate_cmake_cxx_flags(dependencies: 'list[dict]') -> str:
|
||||
parts = []
|
||||
def _generate_cmake_cxx_flags(env, dependencies: 'list[dict]') -> str:
|
||||
parts = env['DEPS_CXXFLAGS'].copy()
|
||||
for dependency in dependencies:
|
||||
for path in dependency.get('CPPPATH', []):
|
||||
parts.append(cmd_quote(f'-I{path}'))
|
||||
return ' '.join(parts)
|
||||
parts.append(f'-I{path}')
|
||||
return cmd_quote(' '.join(parts))
|
||||
|
||||
def _get_cmake_cxx_standard(env: Environment) -> str:
|
||||
return env['CXX_STANDARD'][3:] # we use "C++XX", CMake just "XX"
|
||||
|
||||
def _generate_cmake_args(env: Environment, dependencies: 'list[dict]') -> 'list[str]':
|
||||
args = [f'-DCMAKE_C_FLAGS={_generate_cmake_c_flags(env, dependencies)}',
|
||||
f'-DCMAKE_CXX_FLAGS={_generate_cmake_cxx_flags(env, dependencies)}',
|
||||
f'-DCMAKE_CXX_STANDARD={_get_cmake_cxx_standard(env)}']
|
||||
for dependency in dependencies:
|
||||
for name, value in dependency.get('CMAKE_VARS', {}).items():
|
||||
args.append(f'-D{name}={cmd_quote(value)}')
|
||||
return args
|
||||
|
||||
def _calc_version_hash(dependencies: 'list[dict]') -> str:
|
||||
return json.dumps({
|
||||
@@ -63,14 +75,14 @@ def _cmake_project(env: Environment, project_root: str, generate_args: 'list[str
|
||||
'profile': 'RelWithDebInfo'
|
||||
}.get(env['BUILD_TYPE'], 'RelWithDebInfo')
|
||||
def run_cmd(args):
|
||||
env.Execute(' '.join([str(s) for s in args]))
|
||||
if env.Execute(' '.join([str(s) for s in args])):
|
||||
Exit(1)
|
||||
# TODO: is this a problem?
|
||||
# environ = os.environ.copy()
|
||||
# environ['CXXFLAGS'] = ' '.join(f'-D{define}' for define in env['CPPDEFINES']) # TODO: who cares about windows?
|
||||
run_cmd(['cmake', '-G', 'Ninja', '-B', build_dir, f'-DCMAKE_BUILD_TYPE={build_type}',
|
||||
f'-DCMAKE_INSTALL_PREFIX={cmd_quote(install_dir)}', '-DBUILD_TESTING=OFF',
|
||||
f'-DCMAKE_C_FLAGS={_generate_cmake_c_flags(dependencies)}',
|
||||
f'-DCMAKE_CXX_FLAGS={_generate_cmake_cxx_flags(dependencies)}', *generate_args, project_root])
|
||||
*_generate_cmake_args(env, dependencies), *generate_args, project_root])
|
||||
run_cmd(['cmake', '--build', *build_args, cmd_quote(build_dir)])
|
||||
run_cmd(['cmake', '--install', *install_args, cmd_quote(build_dir)])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user