aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/project/cmake
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--project/cmake/build.py16
-rw-r--r--project/cmake/toolchain.py37
2 files changed, 16 insertions, 37 deletions
diff --git a/project/cmake/build.py b/project/cmake/build.py
index 1e9a90d..a2fea78 100644
--- a/project/cmake/build.py
+++ b/project/cmake/build.py
@@ -34,7 +34,7 @@ from project.toolchain import ToolchainType
from project.utils import normalize_path, mkdir_parent, run, setup_logging
-DEFAULT_PLATFORM = None
+DEFAULT_PLATFORM = Platform.AUTO
DEFAULT_CONFIGURATION = Configuration.DEBUG
DEFAULT_TOOLSET = ToolchainType.AUTO
@@ -81,18 +81,14 @@ class GenerationPhase:
def _get_boost_args(self):
if self.boost_dir is None:
return []
- stagedir = self._stagedir(self.boost_dir, self.platform, self.configuration)
+ root = self.boost_dir
+ librarydir = self.platform.boost_librarydir(self.configuration)
+ librarydir = os.path.join(self.boost_dir, librarydir)
return [
- '-D', f'BOOST_ROOT={self.boost_dir}',
- '-D', f'BOOST_LIBRARYDIR={stagedir}',
+ '-D', f'BOOST_ROOT={root}',
+ '-D', f'BOOST_LIBRARYDIR={librarydir}',
]
- @staticmethod
- def _stagedir(boost_dir, platform, configuration):
- if platform is None:
- platform = Platform.native()
- return os.path.join(boost_dir, 'stage', str(platform), str(configuration), 'lib')
-
def run(self, toolchain):
run_cmake(self._cmake_args(toolchain))
diff --git a/project/cmake/toolchain.py b/project/cmake/toolchain.py
index 14197aa..0e68738 100644
--- a/project/cmake/toolchain.py
+++ b/project/cmake/toolchain.py
@@ -11,7 +11,6 @@ import shutil
import project.mingw
from project.os import on_windows
-from project.platform import Platform
from project.toolchain import ToolchainType
@@ -68,11 +67,9 @@ class MSVC(Auto):
self.platform = platform
def get_cmake_args(self):
- if self.platform is None:
- return []
# This doesn't actually specify the generator of course, but I don't
# want to implement VS detection logic.
- return ['-A', self.platform.get_cmake_arch()]
+ return self.platform.cmake_msvc_args()
def get_build_args(self):
return ['/m']
@@ -102,17 +99,6 @@ class Makefile(Toolchain):
file.write(contents)
return cls(path)
- @staticmethod
- def _format_platform_compiler_flags(platform):
- if platform is None:
- # If the platform wasn't specified, don't use the -m flag, etc.
- return ''
- # Otherwise, use the standard -m32/-m64 flags.
- return f'''
-set(CMAKE_C_FLAGS -m{platform.get_address_model()})
-set(CMAKE_CXX_FLAGS -m{platform.get_address_model()})
-'''
-
def get_cmake_args(self):
return [
'-D', f'CMAKE_TOOLCHAIN_FILE={self.path}',
@@ -131,7 +117,7 @@ class GCC(Makefile):
return f'''
set(CMAKE_C_COMPILER gcc)
set(CMAKE_CXX_COMPILER g++)
-{Makefile._format_platform_compiler_flags(platform)}'''
+{platform.makefile_toolchain_file()}'''
@staticmethod
def setup(platform, build_dir):
@@ -141,16 +127,13 @@ set(CMAKE_CXX_COMPILER g++)
class MinGW(Makefile):
@staticmethod
def _format(platform):
- if platform is None:
- # MinGW only supports x86/x64, plus we need the platform for the
- # compiler file name, so default to x64 unless specified.
- platform = Platform.X64
+ paths = project.mingw.MinGW(platform)
return f'''
-set(CMAKE_C_COMPILER {project.mingw.get_gcc(platform)})
-set(CMAKE_CXX_COMPILER {project.mingw.get_gxx(platform)})
-set(CMAKE_AR {project.mingw.get_ar(platform)})
-set(CMAKE_RANLIB {project.mingw.get_ranlib(platform)})
-set(CMAKE_RC_COMPILER {project.mingw.get_windres(platform)})
+set(CMAKE_C_COMPILER {paths.gcc()})
+set(CMAKE_CXX_COMPILER {paths.gxx()})
+set(CMAKE_AR {paths.ar()})
+set(CMAKE_RANLIB {paths.ranlib()})
+set(CMAKE_RC_COMPILER {paths.windres()})
set(CMAKE_SYSTEM_NAME Windows)
'''
@@ -170,7 +153,7 @@ else()
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
endif()
-{Makefile._format_platform_compiler_flags(platform)}'''
+{platform.makefile_toolchain_file()}'''
def _get_makefile_generator(self):
if on_windows():
@@ -192,7 +175,7 @@ class ClangCL(Clang):
set(CMAKE_C_COMPILER clang-cl)
set(CMAKE_CXX_COMPILER clang-cl)
set(CMAKE_SYSTEM_NAME Windows)
-{Makefile._format_platform_compiler_flags(platform)}'''
+{platform.makefile_toolchain_file()}'''
@staticmethod
def setup(platform, build_dir):