diff --git a/cmake/CMakeBuild/bin/pyhhi/build/app/cmk.py b/cmake/CMakeBuild/bin/pyhhi/build/app/cmk.py index eb351881c9571586e19549ccacfbbf37fb571abc..f231c70c4f0eb392f86cc0daab632ea994a3dc5a 100755 --- a/cmake/CMakeBuild/bin/pyhhi/build/app/cmk.py +++ b/cmake/CMakeBuild/bin/pyhhi/build/app/cmk.py @@ -11,6 +11,7 @@ import sys import pyhhi.build.common.system as system import pyhhi.build.common.util as util import pyhhi.build.common.ver as ver +import pyhhi.build.common.bldtools as bldtools import pyhhi.build.cmksupp as cmksupp from pyhhi.build.common.bldtools import BuildScriptInstaller from pyhhi.build.common.error import InvalidCommandLineArgumentError @@ -24,7 +25,7 @@ class CMakeLauncherApp(object): self._cmake_launcher = None self._dict_generator_choice = {'linux': ['umake', 'ninja'], 'macosx': ['xcode', 'umake', 'ninja'], - 'windows': ['vs15', 'vs14', 'vs12', 'vs11', 'vs10', 'umake', 'mgwmake', 'ninja']} + 'windows': ['vs16', 'vs15', 'vs14', 'vs12', 'vs11', 'vs10', 'umake', 'mgwmake', 'ninja']} self._top_dir = None self._cmake_mod_list = ['pyhhi.build.app.cmk', 'pyhhi.build.cmkfnd', @@ -93,14 +94,14 @@ class CMakeLauncherApp(object): %(prog)s [options] [variant=debug,release,relwithdebinfo,minsizerel] [link=static,shared] [toolset=<toolset_spec>] [address-model=32] %(prog)s is a script front end to cmake to simplify its usage on Linux, -Windows, MacOSX using cmake's generators "Unix Makefiles", "Xcode" and -"Visual Studio 15 - Visual Studio 10" and its compilers. +Windows, MacOSX using cmake's generators "Unix Makefiles", "Ninja", "Xcode" and +"Visual Studio 16 - Visual Studio 10" and its compilers. arguments: variant: debug if not specified link: static if not specified toolset: default c++ compiler if not specified - examples/windows: msvc-19.13, msvc-19.0, msvc-18.0, msvc-17.0, msvc-16.0, intel, gcc + examples/windows: msvc-19.1x, msvc-19.0, msvc-18.0, msvc-17.0, msvc-16.0, intel, gcc examples/linux: gcc-4.9, gcc-5, gcc-6, clang, intel address-model=32: windows: builds 32 bit binaries instead of 64 bit binaries @@ -131,7 +132,7 @@ usage examples: parser.add_argument("-g", "-G", action="store", dest="generator", choices=self._dict_generator_choice[self._sys_info.get_platform()], help="""specify a cmake generator the script has special support for. - Supported generators: ninja, umake, mgwmake, vs15, vs14, vs12, vs11, vs10, xcode. + Supported generators: ninja, umake, mgwmake, vs16, vs15, vs14, vs12, vs11, vs10, xcode. The choices accepted are platform and installation dependent. The environment variable DEFAULT_CMAKE_GENERATOR may be used to override the default value.""") @@ -155,13 +156,14 @@ usage examples: parser.add_argument("--clean-first", action="store_true", dest="clean_first", default=False, help="build target clean first, then build the active target.") - parser.add_argument("--verbosity", action="store", dest="build_verbosity", choices=['quiet', 'minimal', 'normal', 'detailed', 'diagnostic'], default='minimal', - help="specify msbuild verbosity level [default: %(default)s].") + parser.add_argument("--verbosity", action="store", dest="build_verbosity", choices=['cmake', 'quiet', 'minimal', 'normal', 'detailed', 'diagnostic'], default='minimal', + help="""specify (ms)build verbosity level [default: %(default)s]. + The choice 'cmake' requires cmake 3.14.x or higher to increase build verbosity for Visual Studio and other generators.""") util.app_args_add_log_level(parser) g = parser.add_argument_group("advanced options") - g.add_argument("-i", action="store", dest="install_dir", nargs='?', const=os.path.join(self._sys_info.get_home_dir(), 'bin'), + g.add_argument("-i", action="store", dest="install_dir", nargs='?', const=os.path.join(self._sys_info.get_home_dir(native=True), 'bin'), help="install this script and exit. The default destination directory is %(const)s.") g.add_argument("--py-cache-clean", action="store", dest="py_cache_dirs", nargs='+', @@ -282,11 +284,26 @@ usage examples: # looks like a cross compiler specification which requires a toolchain file matching the toolset spec and the linux system. toolset_spec_norm = self._find_toolchain_file(toolset_spec_norm) elif self._sys_info.is_windows(): - # msvc-19.00 -> normalized to 19.0 - re_match = re.match(r'msvc-(\d+)\.(\d+)', toolset_spec) - if re_match: - minor_version = int(re_match.group(2)) - toolset_spec_norm = "msvc-{0}.{1:d}".format(re_match.group(1), minor_version) + if toolset_spec.startswith('msvc-'): + msvc_registry = bldtools.MsvcRegistry() + if toolset_spec == 'msvc-19.2x': + if msvc_registry.is_version_installed((14, 2)): + cl_version = msvc_registry.get_compiler_version((14, 2)) + toolset_spec_norm = "msvc-{0:d}.{1:d}".format(cl_version[0], cl_version[1]) + else: + raise InvalidCommandLineArgumentError("toolset={} not available.".format(toolset_spec)) + elif toolset_spec == 'msvc-19.1x': + if msvc_registry.is_version_installed((14, 1)): + cl_version = msvc_registry.get_compiler_version((14, 1)) + toolset_spec_norm = "msvc-{0:d}.{1:d}".format(cl_version[0], cl_version[1]) + else: + raise InvalidCommandLineArgumentError("toolset={} not available.".format(toolset_spec)) + else: + # msvc-19.00 -> normalized to 19.0 + re_match = re.match(r'msvc-(\d+)\.(\d+)', toolset_spec) + if re_match: + minor_version = int(re_match.group(2)) + toolset_spec_norm = "msvc-{0}.{1:d}".format(re_match.group(1), minor_version) elif self._sys_info.is_macosx(): pass else: diff --git a/cmake/CMakeBuild/bin/pyhhi/build/cmksupp.py b/cmake/CMakeBuild/bin/pyhhi/build/cmksupp.py index 078586a78187fdc7b183989ee300e7ba80b86c3b..07754e6e03143caab41b35e0fe4987dce3b5a1c2 100755 --- a/cmake/CMakeBuild/bin/pyhhi/build/cmksupp.py +++ b/cmake/CMakeBuild/bin/pyhhi/build/cmksupp.py @@ -155,6 +155,7 @@ class CMakeLauncher(object): 'mgwmake': 'MinGW Makefiles', 'ninja': 'Ninja', 'xcode': 'Xcode', + 'vs16': 'Visual Studio 16 2019', 'vs15': 'Visual Studio 15 2017', 'vs14': 'Visual Studio 14 2015', 'vs12': 'Visual Studio 12 2013', @@ -178,13 +179,30 @@ class CMakeLauncher(object): 'vs12': ['msvc-18.0', 'msvc-17.0', 'msvc-16.0'], 'vs11': ['msvc-17.0', 'msvc-16.0'], 'vs10': ['msvc-16.0']} + # vs15 has not a fixed compiler version and therefore the mapping is generated dynamically. if self._msvc_registry.is_version_installed((14, 1)): cl_version = self._msvc_registry.get_compiler_version((14, 1)) msvc_str = 'msvc-' + ver.version_tuple_to_str(cl_version[:2]) if cl_version[1] < 20: self._dict_to_vs_platform_toolset[msvc_str] = 'v141' - self._dict_generator_alias_to_msvc_toolsets['vs15'] = [msvc_str, 'msvc-19.0', 'msvc-18.0', 'msvc-17.0', 'msvc-16.0'] + if not self._msvc_registry.is_vs2019_toolset((14, 1)): + self._dict_generator_alias_to_msvc_toolsets['vs15'] = [msvc_str, 'msvc-19.0', 'msvc-18.0', 'msvc-17.0', 'msvc-16.0'] + else: + assert False + + # vs16 has not a fixed compiler version and therefore the mapping is generated dynamically. + if self._msvc_registry.is_version_installed((14, 2)): + cl_version = self._msvc_registry.get_compiler_version((14, 2)) + msvc_str = 'msvc-' + ver.version_tuple_to_str(cl_version[:2]) + if cl_version[1] < 30: + self._dict_to_vs_platform_toolset[msvc_str] = 'v142' + msvc_version_list = [msvc_str] + if self._msvc_registry.is_version_installed((14, 1)): + cl_version = self._msvc_registry.get_compiler_version((14, 1)) + msvc_version_list.append("msvc-{0:d}.{1:d}".format(cl_version[0], cl_version[1])) + msvc_version_list.extend(['msvc-19.0', 'msvc-18.0', 'msvc-17.0', 'msvc-16.0']) + self._dict_generator_alias_to_msvc_toolsets['vs16'] = msvc_version_list else: assert False @@ -259,38 +277,43 @@ class CMakeLauncher(object): vs_toolset = "Intel C++ Compiler %d.%d" % (compiler_info.version_major_minor[0], compiler_info.version_major_minor[1]) else: assert False - cmake_argv = ['-G', self._dict_to_cmake_generator[generator_alias], - '-T', vs_toolset, - '-A', self._dict_to_vs_platform_name[compiler_info.target_arch]] + cmake_argv = ['-G', self._dict_to_cmake_generator[generator_alias]] + if generator_alias == 'vs16': + if ver.version_compare(compiler_info.version_major_minor, (19, 20)) < 0: + cmake_argv.extend(['-T', self._dict_to_vs_platform_toolset['msvc-' + ver.version_tuple_to_str(compiler_info.version_major_minor)]]) + if compiler_info.target_arch != 'x86_64': + cmake_argv.extend(['-A', self._dict_to_vs_platform_name[compiler_info.target_arch]]) + else: + cmake_argv.extend(['-T', vs_toolset, '-A', self._dict_to_vs_platform_name[compiler_info.target_arch]]) + elif generator_alias == 'xcode': cmake_argv = ['-G', self._dict_to_cmake_generator[generator_alias]] elif generator_alias in ['umake', 'mgwmake', 'ninja']: cmake_argv = ['-G', self._dict_to_cmake_generator[generator_alias], - '-DCMAKE_BUILD_TYPE=' + self._dict_to_cmake_config[cfg]] + '-DCMAKE_BUILD_TYPE:STRING=' + self._dict_to_cmake_config[cfg]] if compiler_info.is_cross_compiler(): - cmake_argv.append('-DCMAKE_TOOLCHAIN_FILE=' + compiler_info.cmake_toolchain_file) + cmake_argv.append('-DCMAKE_TOOLCHAIN_FILE:FILEPATH=' + compiler_info.cmake_toolchain_file) else: if compiler_info.cmake_cxx_compiler: - cmake_argv.append('-DCMAKE_CXX_COMPILER=' + compiler_info.cmake_cxx_compiler) + cmake_argv.append('-DCMAKE_CXX_COMPILER:FILEPATH=' + compiler_info.cmake_cxx_compiler) if compiler_info.cmake_c_compiler: - cmake_argv.append('-DCMAKE_C_COMPILER=' + compiler_info.cmake_c_compiler) + cmake_argv.append('-DCMAKE_C_COMPILER:FILEPATH=' + compiler_info.cmake_c_compiler) if cmake_argv_optional: # Add any additional arguments to the cmake command line. cmake_argv.extend(cmake_argv_optional) if lnk_variant == 'shared': - cmake_argv.append('-DBUILD_SHARED_LIBS=1') + cmake_argv.append('-DBUILD_SHARED_LIBS:BOOL=ON') if self._is_multi_configuration_generator(): cmake_config_types = [self._dict_to_cmake_config[x] for x in self._default_config_types] for b_cfg in build_configs: if b_cfg not in self._default_config_types: cmake_config_types.append(self._dict_to_cmake_config[b_cfg]) - cmake_argv.append('-DCMAKE_CONFIGURATION_TYPES=' + ';'.join(cmake_config_types)) + cmake_argv.append('-DCMAKE_CONFIGURATION_TYPES:STRING=' + ';'.join(cmake_config_types)) # cmake_argv.append(self._top_dir) # print("launch_config(): cmake_args", cmake_argv) # print("build dir:", b_dir) # print("top dir:", self._top_dir) - if (not self._sys_info.is_windows()) and (ver.version_compare(self._cmake_finder.get_cmake_version(), (3, 13, 0)) >= 0): - # Not done for windows yet avoiding potential issues with command line length limits. + if ver.version_compare(self._cmake_finder.get_cmake_version(), (3, 13, 0)) >= 0: cmake_argv.extend(['-S', self._top_dir, '-B', b_dir]) retv = self.launch_cmake(cmake_argv) else: @@ -410,9 +433,11 @@ class CMakeLauncher(object): elif self._sys_info.get_platform() == 'macosx': generator_alias = 'xcode' elif self._sys_info.get_platform() == 'windows': - # e.g. 14.1, 14.0, 12.0 etc. + # e.g. 14.2, 14.1, 14.0, 12.0 etc. bb_vs_latest_version = self._msvc_registry.get_latest_version() - if ver.version_compare(bb_vs_latest_version, (14,1)) == 0: + if ver.version_compare(bb_vs_latest_version, (14, 2)) == 0: + generator_alias = 'vs16' + elif ver.version_compare(bb_vs_latest_version, (14, 1)) == 0: generator_alias = 'vs15' else: generator_alias = 'vs' + str(bb_vs_latest_version[0]) @@ -565,8 +590,20 @@ class CMakeLauncher(object): self._add_cmake_build_tool_options(cmake_argv, ['-parallelizeTargets', '-jobs', str(build_jobs)]) def _add_cmake_build_verbosity_option(self, cmake_argv, generator_alias, verbosity_level): - if generator_alias.startswith('vs'): - self._add_cmake_build_tool_options(cmake_argv, ['/verbosity:' + verbosity_level]) + if verbosity_level == 'cmake': + cmake_version = self._cmake_finder.get_cmake_version() + if ver.version_compare(cmake_version, (3, 14)) >= 0: + # self._add_cmake_build_tool_options(cmake_argv, ['-v']) + # -v is a cmake option and not a build tool option and therefore + # it has to be inserted left of '--' + if '--' in cmake_argv: + index = cmake_argv.index('--') + cmake_argv.insert(index, '-v') + else: + cmake_argv.append('-v') + else: + if generator_alias.startswith('vs'): + self._add_cmake_build_tool_options(cmake_argv, ['/verbosity:' + verbosity_level]) def _add_cmake_build_tool_options(self, cmake_argv, build_tool_options): if not build_tool_options: diff --git a/cmake/CMakeBuild/bin/pyhhi/build/common/bldtools.py b/cmake/CMakeBuild/bin/pyhhi/build/common/bldtools.py index 7db8ae7f1e1f4497ae2203e7114d1ca0578d5c02..bbb6f70b925c50470b04c637fae4faa5f16371b0 100755 --- a/cmake/CMakeBuild/bin/pyhhi/build/common/bldtools.py +++ b/cmake/CMakeBuild/bin/pyhhi/build/common/bldtools.py @@ -23,33 +23,51 @@ class MsvcRegistry(object): def __init__(self): self._logger = logging.getLogger(__name__) self._sys_info = system.SystemInfo() - self._supported_msvc_versions = ['14.1', '14.0', '12.0', '11.0', '10.0'] + self._supported_msvc_versions = ['14.2', '14.1', '14.0', '12.0', '11.0', '10.0'] program_dir = self._sys_info.get_program_dir('x86') - self._msvc_install_dir_dict = {'14.1': [os.path.join(program_dir, "Microsoft Visual Studio", '2017', 'Enterprise', 'VC'), - os.path.join(program_dir, "Microsoft Visual Studio", '2017', 'Professional', 'VC'), - os.path.join(program_dir, "Microsoft Visual Studio", '2017', 'Community', 'VC')], - '14.0': [os.path.join(program_dir, "Microsoft Visual Studio 14.0", 'VC')], + # VS2019, VS2017 come with a locator tool vswhere to search for the installation directory. + # The dictionary _msvc_install_dir_dict will be augmented with keys 14.2 and 14.1 by method _do_inventory_vc14x(). + self._msvc_install_dir_dict = {'14.0': [os.path.join(program_dir, "Microsoft Visual Studio 14.0", 'VC')], '12.0': [os.path.join(program_dir, "Microsoft Visual Studio 12.0", 'VC')], '11.0': [os.path.join(program_dir, "Microsoft Visual Studio 11.0", 'VC')], '10.0': [os.path.join(program_dir, "Microsoft Visual Studio 10.0", 'VC')]} - # a list of sorted version tuples identifying the installed MSVC products self._installed_msvc_versions = [] # key = msvc_version, value = full path of vcvarsall.bat self._compiler_command_dict = {} - # key = msvc_version, value = options to be passed to the setup command; e.g. -vcvars_ver=14.0 + # key = msvc_version, value = options to be passed to the setup command; e.g. -vcvars_ver=14.0, -vcvars_ver=14.1x self._compiler_command_option_dict = {} # key = msvc_version, value = vc version self._compiler_version_dict = {} # key = msvc_version, value = True/False self._is_vs2017_toolset_dict = {} + # key = msvc_version, value = True/False; e.g. '14.1' -> True indicates 14.1 is an alternative toolset installed with vs2019. + self._is_vs2019_toolset_dict = {} + # clear information on alternative toolset upfront + for version in self._supported_msvc_versions: + self._is_vs2017_toolset_dict[version] = False + self._is_vs2019_toolset_dict[version] = False if self._logger.isEnabledFor(logging.DEBUG): self._logger.debug("performing in-depth VS inventory for debugging.") self._do_inventory_winreg() - # Update VS2017 installation paths via vswhere.exe - self._do_inventory_vc141() + vswhere = self._find_vswhere() + if vswhere: + # Update VS2019 installation paths via vswhere.exe + self._do_inventory_vc14x('14.2', vswhere) + # Update VS2017 installation paths via vswhere.exe + self._do_inventory_vc14x('14.1', vswhere) + else: + pass self._do_inventory() + self._dump_inventory() + + def _dump_inventory(self): + if self._logger.isEnabledFor(logging.DEBUG): + for version in self._installed_msvc_versions: + version_str = ver.version_tuple_to_str(version) + cl_version_str = ver.version_tuple_to_str(self._compiler_version_dict[version_str]) + self._logger.debug("found MSVC version {}, CL version {}, setup={}".format(version_str, cl_version_str, self._compiler_command_dict[version_str])) def get_compiler_command(self, version=None): if version is None: @@ -87,6 +105,14 @@ class MsvcRegistry(object): return self._is_vs2017_toolset_dict[version_str] return False + def is_vs2019_toolset(self, version): + if not self.is_version_installed(version): + return False + version_str = ver.version_tuple_to_str(version) + if version_str in self._is_vs2019_toolset_dict: + return self._is_vs2019_toolset_dict[version_str] + return False + def _do_inventory(self): for version in self._supported_msvc_versions: if version not in self._msvc_install_dir_dict: @@ -98,13 +124,18 @@ class MsvcRegistry(object): cl_cmd = self._find_cl_cmd(vc_dir, version) if cl_cmd: self._logger.debug("found VC compiler %s", cl_cmd) - if version in ['14.1']: + if version in ['14.2', '14.1']: setup_cmd = os.path.normpath(os.path.join(os.path.dirname(cl_cmd), '..', '..', '..', '..', '..', '..', 'Auxiliary', 'Build', 'vcvarsall.bat')) elif version in ['14.0']: if os.path.exists(os.path.join(vc_dir, '..', 'Common7', 'IDE', 'devenv.exe')): self._logger.debug("found VS 2015 IDE installed.") setup_cmd = os.path.join(vc_dir, 'vcvarsall.bat') - self._is_vs2017_toolset_dict[version] = False + elif '14.2' in self._compiler_command_dict: + # We've got 14.0 as an alternative VS 2019 toolset. + self._logger.debug("found msvc-14.0 installed as an alternative VS 2019 toolset.") + setup_cmd = self._compiler_command_dict['14.2'] + self._is_vs2019_toolset_dict[version] = True + self._compiler_command_option_dict[version] = '-vcvars_ver=14.0' elif '14.1' in self._compiler_command_dict: # We've got 14.0 as an alternative VS 2017 toolset. self._logger.debug("found msvc-14.0 installed as an alternative VS 2017 toolset.") @@ -119,6 +150,19 @@ class MsvcRegistry(object): cl_version = self._query_msvc_compiler_version(cl_cmd) self._compiler_command_dict[version] = setup_cmd self._compiler_version_dict[version] = cl_version + if (version == '14.2') and ('14.1' not in self._msvc_install_dir_dict): + # Search for alternative toolset vc141 installed with vs2019 + self._logger.debug("searching for alternative VS2019 toolset vc141.") + vc_dir in self._msvc_install_dir_dict[version][0] + setup_cmd = self._compiler_command_dict['14.2'] + cl_cmd = self._find_cl_cmd(vc_dir, '14.1') + if cl_cmd: + self._logger.debug("found alternative VC compiler {}".format(cl_cmd)) + cl_version = self._query_msvc_compiler_version(cl_cmd) + self._compiler_command_dict['14.1'] = setup_cmd + self._compiler_version_dict['14.1'] = cl_version + self._compiler_command_option_dict['14.1'] = '-vcvars_ver=14.1x' + self._is_vs2019_toolset_dict['14.1'] = True msvc_version_list = [] for version in self._compiler_version_dict: @@ -127,32 +171,36 @@ class MsvcRegistry(object): self._installed_msvc_versions = ver.version_list_sort(msvc_version_list) self._installed_msvc_versions.reverse() # print("sorted msvc versions: ", self._installed_msvc_versions) - for version in self._installed_msvc_versions: - version_str = ver.version_tuple_to_str(version) - if version_str in ['14.1']: - self._is_vs2017_toolset_dict[version_str] = True - elif version_str not in self._is_vs2017_toolset_dict: - self._is_vs2017_toolset_dict[version_str] = False def _find_cl_cmd(self, vc_inst_dir, version_str): cl_cmd = None - if version_str in ['14.1']: + if version_str in ['14.2', '14.1']: msvc_dir = os.path.join(vc_inst_dir, 'Tools', 'MSVC') if os.path.exists(msvc_dir): version_dir_list = [ver.version_tuple_from_str(x) for x in os.listdir(msvc_dir) if re.match(r'[0-9.]+$', x)] if version_dir_list: version_dir_list = ver.version_list_sort(version_dir_list) version_dir_list.reverse() + # VS2019 installs toolset v141 side-by-side in a folder named '14.16.27023', toolset v142 is + # installed in a folder named '14.20.27508'. for version in version_dir_list: + if (version_str == '14.2') and (version[1] >= 30): + self._logger.debug("ignoring cl installation folder: {}".format(os.path.join(msvc_dir, ver.version_tuple_to_str(version)))) + continue + if (version_str == '14.1') and (version[1] >= 20): + self._logger.debug("ignoring cl installation folder: {}".format(os.path.join(msvc_dir, ver.version_tuple_to_str(version)))) + continue cl_cmd = os.path.join(msvc_dir, ver.version_tuple_to_str(version), 'bin', 'HostX64', 'x64', 'cl.exe') if os.path.exists(cl_cmd): - return cl_cmd + break else: cl_cmd = None else: cl_cmd = os.path.join(vc_inst_dir, 'bin', 'amd64', 'cl.exe') if not os.path.exists(cl_cmd): cl_cmd = None + if cl_cmd: + self._logger.debug("found cl: {}".format(cl_cmd)) return cl_cmd def _query_msvc_compiler_version(self, cl_cmd): @@ -208,39 +256,46 @@ class MsvcRegistry(object): continue return vc_install_dir_dict - def _do_inventory_vc141(self): - vswhere = self._find_vswhere() - vc_dir_fnd = False - if vswhere: - self._logger.debug("found VS2017 locator: %s", vswhere) - try: - vswhere_argv = [vswhere, '-latest'] - # vswhere_argv.extend(['-products', 'Enterprise']) - # vswhere_argv.extend(['-products', 'Professional']) - # vswhere_argv.extend(['-products', 'Community']) - vswhere_argv.extend(['-products', '*']) - vswhere_argv.extend(['-requires', 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64']) - vswhere_argv.extend(['-property', 'installationPath']) - vswhere_argv.extend(['-version', '[15.0,16.0)']) - retv = subprocess.check_output(vswhere_argv, universal_newlines=True).rstrip() - if retv != '': - self._logger.debug("VS2017 install path: %s", retv) - vc_dir = os.path.join(retv, 'VC') - if os.path.exists(vc_dir): - self._logger.debug("VS2017 VC install path: %s", vc_dir) - self._msvc_install_dir_dict['14.1'] = [vc_dir] - vc_dir_fnd = True - else: - self._logger.debug("VS2017 install path: <none>") - except subprocess.CalledProcessError: - self._logger.debug("VS2017 locator call failed for some reason.") + def _do_inventory_vc14x(self, msvc_version_str, vswhere=None): + if msvc_version_str == '14.2': + vswhere_version_expr = '[16.0,17.0)' + vs_alias_str = 'VS2019' + elif msvc_version_str == '14.1': + vswhere_version_expr = '[15.0,16.0)' + vs_alias_str = 'VS2017' + else: + assert False + if vswhere is None: + vswhere = self._find_vswhere() + if vswhere is None: + self._logger.debug("{0} locator vswhere.exe not found, {0} detection disabled.".format(vs_alias_str)) + return else: - self._logger.debug("VS2017 locator vswhere.exe not found, VS2017 detection disabled.") + self._logger.debug("found {} locator: {}".format(vs_alias_str, vswhere)) + vc_dir_fnd = False + try: + vswhere_argv = [vswhere, '-latest'] + # vswhere_argv.extend(['-products', 'Enterprise']) + # vswhere_argv.extend(['-products', 'Professional']) + # vswhere_argv.extend(['-products', 'Community']) + vswhere_argv.extend(['-products', '*']) + vswhere_argv.extend(['-requires', 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64']) + vswhere_argv.extend(['-property', 'installationPath']) + vswhere_argv.extend(['-version', vswhere_version_expr]) + retv = subprocess.check_output(vswhere_argv, universal_newlines=True).rstrip() + if retv != '': + self._logger.debug("{} install path: {}".format(vs_alias_str, retv)) + vc_dir = os.path.join(retv, 'VC') + if os.path.exists(vc_dir): + self._logger.debug("{} VC install path: {}".format(vs_alias_str, vc_dir)) + self._msvc_install_dir_dict[msvc_version_str] = [vc_dir] + vc_dir_fnd = True + else: + self._logger.debug("{} install path: <none>".format(vs_alias_str)) + except subprocess.CalledProcessError: + self._logger.debug("{} vswhere locator call failed for some reason.".format(vs_alias_str)) if not vc_dir_fnd: - self._logger.debug("VS2017 VC not found, VS2017 detection disabled.") - # Disable VS2017 detection by path? - if '14.1' in self._msvc_install_dir_dict: - self._msvc_install_dir_dict.pop('14.1') + self._logger.debug("{0} VC not found, {0} detection disabled.".format(vs_alias_str)) def _find_vswhere(self): vswhere_prog = None @@ -264,68 +319,6 @@ class MsvcRegistry(object): return getattr(MsvcRegistry.instance, item) -class BjamToolset(object): - def __init__(self, sys_info, bb_version=None): - self._logger = logging.getLogger(__name__) - self._bjam_toolset_build_script = None - - if sys_info.is_linux(): - self._bjam_toolset = 'gcc' - elif sys_info.is_macosx(): - self._bjam_toolset = 'darwin' - elif sys_info.is_windows(): - # On windows the Boost.Build version is required as vsXXXX is only supported by Boost.Build x.y.z or higher. - assert bb_version is not None - self._msvc_registry = MsvcRegistry() - - # We have to constrain the search for the latest msvc because the bjam build scripts must have support for it. - # e.g. vc14 works only for 1.59.0 or higher. - if ver.version_compare(bb_version, (1, 50, 0)) < 0: - max_msvc_version = (10, 0) - elif ver.version_compare(bb_version, (1, 55, 0)) < 0: - max_msvc_version = (11, 0) - elif ver.version_compare(bb_version, (1, 59, 0)) < 0: - max_msvc_version = (12, 0) - elif ver.version_compare(bb_version, (1, 64, 0)) < 0: - max_msvc_version = (14, 0) - elif ver.version_compare(bb_version, (1, 64, 0)) == 0: - # This is Boost.Build 1.64.0 or higher. - # Since msvc-14.1 is supported by 1.64.0 but building bjam requires a suitable VC command prompt or patched - # bjam build scripts, a previous msvc-x.y is preferred. - max_msvc_version = None - for v in ['14.0', '12.0', '11.0', '10.0']: - if self._msvc_registry.is_version_installed(ver.version_tuple_from_str(v)): - max_msvc_version = ver.version_tuple_from_str(v) - break - else: - # Allow vc141 for 1.65.0 and higher by default, the toolset detection vswhere is now available. - max_msvc_version = None - - # mingw does not work the same way as msvc when launching helper scripts or programs and - # is not used to build bjam/b2. - msvc_version = self._msvc_registry.get_latest_version(max_msvc_version) - msvc_version_str = ver.version_tuple_to_str(msvc_version) - self._bjam_toolset = 'msvc-' + msvc_version_str - - # map the msvc toolset spec into a string supported by the bjam build script build.bat - if msvc_version[1] > 0: - # vc141 - self._bjam_toolset_build_script = 'vc' + str(msvc_version[0])+ str(msvc_version[1]) - else: - # vc14, vc12, vc11, vc10 - self._bjam_toolset_build_script = 'vc' + str(msvc_version[0]) - else: - raise Exception('Unknown platform detected, please contact technical support.') - if self._bjam_toolset_build_script is None: - self._bjam_toolset_build_script = self._bjam_toolset - - def get_bjam_toolset(self, build_script_format=False): - if build_script_format: - return self._bjam_toolset_build_script - else: - return self._bjam_toolset - - class Toolset(object): class PlatformInfo(object): @@ -463,6 +456,8 @@ class Toolset(object): if self._toolset.startswith('msvc'): if self._msvc_registry.is_vs2017_toolset(self._version): s += "VS 2017 toolset!\n" + if self._msvc_registry.is_vs2019_toolset(self._version): + s += "VS 2019 toolset!\n" s += "platform(s):\n" for platform_info in self._platform_info: diff --git a/cmake/CMakeBuild/bin/pyhhi/build/common/cmbldver.py b/cmake/CMakeBuild/bin/pyhhi/build/common/cmbldver.py index d065c13a0878ef863fceb52428fd41791ee74447..ea821ef1046d573193c3c6ef4e0843924c998651 100755 --- a/cmake/CMakeBuild/bin/pyhhi/build/common/cmbldver.py +++ b/cmake/CMakeBuild/bin/pyhhi/build/common/cmbldver.py @@ -4,4 +4,4 @@ # Any manual changes here will be overridden by the next build. #------------- -CMAKE_BUILD_VERSION_STR = "3.13.0.2" +CMAKE_BUILD_VERSION_STR = "3.14.4.4" diff --git a/cmake/CMakeBuild/bin/pyhhi/build/common/system.py b/cmake/CMakeBuild/bin/pyhhi/build/common/system.py index 69b02ea583eccf03b5874e87fad9041468c27a9e..b51f0fc6c2d2826e1f2d988592c130d36013d6db 100755 --- a/cmake/CMakeBuild/bin/pyhhi/build/common/system.py +++ b/cmake/CMakeBuild/bin/pyhhi/build/common/system.py @@ -98,18 +98,18 @@ class SystemInfo(object): if self._os_arch == 'x86_64': if self._python_arch == 'x86': - self._program_dir = os.getenv('PROGRAMW6432') - self._programx86_dir = os.getenv('PROGRAMFILES') + self._program_dir = os.path.normpath(os.getenv('PROGRAMW6432')) + self._programx86_dir = os.path.normpath(os.getenv('PROGRAMFILES')) else: - self._program_dir = os.getenv('PROGRAMFILES') - self._programx86_dir = os.getenv('PROGRAMFILES(X86)') + self._program_dir = os.path.normpath(os.getenv('PROGRAMFILES')) + self._programx86_dir = os.path.normpath(os.getenv('PROGRAMFILES(X86)')) assert self._programx86_dir is not None elif self._os_arch == 'x86': - self._program_dir = os.getenv('PROGRAMFILES') + self._program_dir = os.path.normpath(os.getenv('PROGRAMFILES')) else: assert False assert self._program_dir is not None - self._program_data_dir = os.getenv('PROGRAMDATA') + self._program_data_dir = os.path.normpath(os.getenv('PROGRAMDATA')) if self._windows_msys: pass @@ -315,8 +315,12 @@ class SystemInfo(object): def get_path(self): return self._search_path - def get_home_dir(self): - return self._home_dir + def get_home_dir(self, native=False): + if self.is_windows_msys() and native: + home_dir = os.path.normpath(os.path.expandvars('$USERPROFILE')) + else: + home_dir = self._home_dir + return home_dir def get_default_proj_home_dir(self): return self._default_proj_home_dir @@ -339,7 +343,7 @@ class SystemInfo(object): def get_short_path(self, fpath): if self.is_windows(): - fpath = self.get_short_path_win(fpath) + fpath = os.path.normpath(self.get_short_path_win(fpath)) return fpath def get_short_path_win(self, fpath): @@ -440,13 +444,13 @@ class SystemInfo(object): # make sure the user's home directory exists if not os.path.exists(home_dir): raise Exception('home directory "' + home_dir + '" does not exist.') - self._home_dir = home_dir + self._home_dir = os.path.normpath(home_dir) def _query_default_proj_home_dir(self): if 'PROJ_HOME' in os.environ: - proj_home_dir = os.path.expandvars('$PROJ_HOME') + proj_home_dir = os.path.normpath(os.path.expandvars('$PROJ_HOME')) else: - proj_home_dir = os.path.join(self.get_home_dir(), 'projects') + proj_home_dir = os.path.join(self.get_home_dir(native=True), 'projects') if os.path.exists(proj_home_dir): self._default_proj_home_dir = proj_home_dir else: @@ -459,7 +463,8 @@ class SystemInfo(object): self._search_path.append(util.normalize_path(dir)) def _query_desktop_dir(self): - home_dir = self.get_home_dir() + # MSYS has its own environment but Desktop comes from the native windows home. + home_dir = self.get_home_dir(native=True) desktop_dir = os.path.join(home_dir, 'Desktop') if os.path.exists(desktop_dir): self._desktop_dir = desktop_dir diff --git a/cmake/CMakeBuild/cmake/modules/BBuildEnv.cmake b/cmake/CMakeBuild/cmake/modules/BBuildEnv.cmake index 202c7e309cea573fcd40af14889ffbbff742eff5..07532ba3ef188edb7a1f52d08434ff82341b0eab 100644 --- a/cmake/CMakeBuild/cmake/modules/BBuildEnv.cmake +++ b/cmake/CMakeBuild/cmake/modules/BBuildEnv.cmake @@ -16,34 +16,30 @@ Unless explicitly disabled by configuration option ``BBuildEnv_EXCLUDE_MODULES`` module ``BBuildEnv`` loads the following submodules to provide additional support for Boost, Qt5, OpenCV, file downloads, MinGW and CPack: -- :module:`BBuildEnvAddProject` provides macros and functions to add standard - subproject like console applications, libraries, samples, UTF tests and Qt - applications to a standard workspace. -- :module:`BBuildEnvBoost` adds a few utility functions and macros helping to - use locally built Boost libraries. -- :module:`BBuildEnvOpenCV` -- :module:`BBuildEnvQt5` -- :module:`BBuildEnvDownload` -- :module:`BBuildEnvVersionUtil` -- :module:`BBuildEnvCPack` adds a few utility functions helping to create binary - distribution packages. -- :module:`BBuildEnvMingw` adds helper functions to copy MinGW runtime DLLs. - - -Reserved Identifiers -^^^^^^^^^^^^^^^^^^^^ - -Avoiding name clashes in CMakeLists.txt or project specific CMake files all -projects including module ``BBuildEnv``, or any of its submodules, are advised -not to use CMake variables, functions or macros starting with:: - - BBuildEnv, _BBuildEnv, _bb_, bb_, BB_, _BB_ - -Users may use variables starting with ``BBuildEnv_<var>`` only to configure the -behavior of ``BuildEnv`` modules or submodules or evaluate properties of loaded -``BuildEnv`` modules or submodules exposed through documented variables -``BBuildEnv_<var>``. - +============================== =========================================================== +Module Description +============================== =========================================================== +:module:`BBuildEnvAddProject` Macros and functions to add standard + subproject like console applications, libraries, samples, + UTF tests and Qt applications to a standard workspace +:module:`BBuildEnvGitSvn` Utility functions to support Git to SVN interoperability. +:module:`BBuildEnvDownload` Supports HTTPS downloads of single files at build time +:module:`BBuildEnvVersionUtil` Functions to parse version header files +:module:`BBuildEnvCPack` Functions helping to create binary distribution packages +:module:`BBuildEnvBoost` Macros and functions helping to use locally built Boost + libraries. +:module:`BBuildEnvOpenCV` Helper functions to copy OpenCV runtime DLLs +:module:`BBuildEnvQt5` Helper functions to copy Qt5 runtime DLLs +:module:`BBuildEnvMingw` Helper functions to copy MinGW runtime DLLs on Ubuntu +============================== =========================================================== + +The following modules are not loaded by default as they provide functionality not needed +by all main projects. + +- :module:`BBuildEnvGit` provides macros and functions to checkout Git repositories at + configuration time to aggregate them into a single build tree. Similar functionality + is provided by module :module:`FetchContent` with slightly different Git clone and + update behavior. Configuration Options ^^^^^^^^^^^^^^^^^^^^^ @@ -51,12 +47,19 @@ Configuration Options This module evaluates the following variables at load time allowing users to customize its behavior: -``BBuildEnv_DEBUG`` - Enable debugging messages. ``BBuildEnv_EXCLUDE_MODULES`` List of submodules to be excluded from loading. Use ``ALL`` to disable loading any submodule. +``BBuildEnv_DEBUG`` + Enable debugging messages. + +``BBuildEnv_USE_LIBRARY_NAME_POSTFIX`` + A boolean variable to enable a configuration specific library name postfix which + allows to install all library or executable variants in the same directory. It's unset/off by + default to provide backward compatibility with earlier releases. If enabled executable + targets will need a configuration postfix as well. + How to Use ^^^^^^^^^^ @@ -99,12 +102,48 @@ as an svn:external or as a versioned Git subtree: Provided Variables ^^^^^^^^^^^^^^^^^^ +Module ``BBuildEnv`` provides the following output variables +which are supposed to be treated readonly: + ``BBuildEnv_VERSION`` Module's version in decimal dotted format with a maximum of four components. - + ``BBuildEnv_MSYS`` Set to true when using MSYS. +``BBuildEnv_GENERATOR_ALIAS`` + CMake generator specific build directory. It's a plain name without any path separators. + + ``umake`` + Unix Makefiles + + ``vs16`` + Microsoft Visual Studio 2019 + + ``vs15`` + Microsoft Visual Studio 2017 + + ``vs14`` + Microsoft Visual Studio 2015 + + ``xcode`` + Xcode generator, switching between different Xcode versions is currently not supported within a single build tree. + + ``ninja`` + Ninja generator + +``BBuildEnv_<CONFIG>_POSTFIX`` + Configuration specific postfix strings to support side-by-side installation in the same + directory. + +``BBuildEnv_SHARED_DIR_POSTFIX`` + A string specific to the shared library configuration to allow for single + output directories or installation directories. + +``BBuildEnv_OUTPUT_DIR_SUFFIX`` + A generator specific relative path to be used in installation rules to support multiple + generators or compiler versions in combination with the same installation prefix. + ``BBuildEnv_ROOT_DIR`` Optional root directory of CMakeBuild customization files. @@ -151,6 +190,40 @@ Provided Functions and Macros Compiler specific flag to enable or disable a warning. +.. command:: bb_add_subdirectory + + The ``bb_add_subdirectory()`` macro adds an external in-tree Git subproject + provided variable ``USE_GIT_SUBPROJECTS`` is ON. + The macro silently assumes the subproject is checked out to + ``${CMAKE_SOURCE_DIR}/ext/<subproject>``. If variable ``USE_GIT_SUBPROJECTS`` + is OFF, the macro will invoke :command:`add_subdirectory` for backward compatibility + with SVN repositories and subproject aggregation via SVN externals:: + + bb_add_subdirectory(<subproject>) + + **Parameters:** + + ``subproject`` + A relative path to an in-tree subproject; e.g. ``BoostAddon/src/lib/LoggerLib`` + + +.. command:: bb_set_target_output_name + + The ``bb_set_target_output_name`` macro appends a configuration specific postfix to + the output name of executable targets if variable ``BBuildEnv_USE_LIBRARY_NAME_POSTFIX`` + is ON. If applied to library targets, it will change :prop_tgt:`COMPILE_PDB_NAME_<CONFIG>` + for static libraries to align the PDB filename with the library filename. + CMake's postfix machinery does it for linker generated PDB files but not for compiler + generated PDB files:: + + bb_set_target_output_name( <target> ) + + **Parameters:** + + ``target`` + An existing target to be modified. + + .. command:: bb_set_external_dir The ``bb_set_external_dir()`` function searches for a directory given a @@ -158,15 +231,15 @@ Provided Functions and Macros a shared folder holding an external project without searching any system paths or cross compiler specific paths:: - bb_set_external_dir(<abs_path> <relative_path> [<OPTIONAL>]) + bb_set_external_dir(<abs_path> <dir> [<OPTIONAL>]) **Parameters:** ``abs_path`` Absolute path to ``relative_path`` found in one of the default locations. - ``relative_path`` - Path to search for in one of the default locations. An absolute path + ``dir`` + Directory to search for in one of the default locations. An absolute path will be returned as-is. ``OPTIONAL`` @@ -184,25 +257,26 @@ Provided Functions and Macros ``${CMAKE_SOURCE_DIR}/../..`` ``$ENV{HOME}/projects`` - Ignored on windows host systems. + Ignored on native windows host systems. It is searched when MSYS has been detected + or any other non-windows platform. ``$ENV{USERPROFILE}/projects`` Ignored on non-windows host systems. -.. command:: bb_add_subdirectory +Reserved Identifiers +^^^^^^^^^^^^^^^^^^^^ - The ``bb_add_subdirectory()`` macro adds an external in-tree Git subproject. - The macro silently assumes the subproject is checked out to - ``${CMAKE_SOURCE_DIR}/ext/<subproject>``:: - - bb_add_subdirectory(<subproject>) - - **Parameters:** - - ``subproject`` - A relative path to an in-tree subproject; e.g. ``BoostAddon/src/lib/LoggerLib`` +Avoiding name clashes in CMakeLists.txt or project specific CMake files all +projects including module ``BBuildEnv``, or any of its submodules, are advised +not to use CMake variables, functions or macros starting with:: + + BBuildEnv, _BBuildEnv, _bb_, bb_, BB_, _BB_ +Users may use variables starting with ``BBuildEnv_<var>`` only to configure the +behavior of ``BuildEnv`` modules or submodules or evaluate properties of loaded +``BuildEnv`` modules or submodules exposed through documented variables +``BBuildEnv_<var>``. #]===] @@ -224,6 +298,7 @@ set( _BBuildEnvSubmoduleList BBuildEnvBoost BBuildEnvQt5 BBuildEnvOpenCV + BBuildEnvGitSvn ) foreach( _cmod IN LISTS _BBuildEnvSubmoduleList ) @@ -251,6 +326,21 @@ macro( bb_add_subdirectory subdirectory_ ) endmacro() +macro( bb_set_target_output_name target_ ) + if( BBuildEnv_USE_LIBRARY_NAME_POSTFIX ) + get_target_property( _bb_tmp_target_type ${target_} TYPE ) + if( _bb_tmp_target_type STREQUAL "EXECUTABLE" ) + set_target_properties( ${target_} PROPERTIES OUTPUT_NAME_DEBUG ${target_}${CMAKE_DEBUG_POSTFIX} + OUTPUT_NAME_RELWITHDEBINFO ${target_}${CMAKE_RELWITHDEBINFO_POSTFIX} + OUTPUT_NAME_MINSIZEREL ${target_}${CMAKE_MINSIZEREL_POSTFIX} ) + elseif( MSVC AND (_bb_tmp_target_type STREQUAL "STATIC_LIBRARY" ) ) + # message( STATUS "${target_} is static, setting COMPILE_PDB_NAME_DEBUG ..." ) + set_target_properties( ${target_} PROPERTIES COMPILE_PDB_NAME_DEBUG ${target_}${CMAKE_DEBUG_POSTFIX} COMPILE_PDB_NAME_RELWITHDEBINFO ${target_}${CMAKE_RELWITHDEBINFO_POSTFIX} ) + endif() + endif() +endmacro() + + macro( bb_save_find_context fnd_ctx ) if( CMAKE_CROSSCOMPILING ) # find_package must be told not to expect the BOOST libraries inside "CMAKE_FIND_ROOT_PATH". @@ -291,14 +381,38 @@ macro( _bb_get_cxx_compiler_version_major_minor version_major_minor_ ) string( REGEX REPLACE "([0-9]+)\\.([0-9]+)([0-9.]+)?" "\\1.\\2" ${version_major_minor_} ${CMAKE_CXX_COMPILER_VERSION} ) endmacro() -macro( bb_get_home_dir home_dir_ ) + +function( bb_get_home_dir home_dir_ ) + set( _native FALSE ) + + if( ARGC EQUAL 2 ) + if( ${ARGV1} STREQUAL "NATIVE" ) + set( _native TRUE ) + else() + message( FATAL_ERROR "bb_get_home_dir: argument ${ARGV1} not understood." ) + endif() + elseif( ARGC GREATER 2 ) + message( FATAL_ERROR "bb_get_home_dir: too many arguments specified, expected <home_dir> [NATIVE]." ) + endif() + if( CMAKE_HOST_WIN32 ) # Force forward slashes on Windows - file( TO_CMAKE_PATH "$ENV{USERPROFILE}" ${home_dir_} ) + if( BBuildEnv_MSYS ) + if( _native ) + file( TO_CMAKE_PATH "$ENV{USERPROFILE}" _home_dir ) + else() + file( TO_CMAKE_PATH "$ENV{HOME}" _home_dir ) + endif() + else() + file( TO_CMAKE_PATH "$ENV{USERPROFILE}" _home_dir ) + endif() else() - set( ${home_dir_} "$ENV{HOME}" ) + set( _home_dir "$ENV{HOME}" ) endif() -endmacro() + + set( ${home_dir_} "${_home_dir}" PARENT_SCOPE ) + +endfunction() macro( bb_set_home_dir home_dir_ ) @@ -601,10 +715,14 @@ function( _bb_find_proj_home proj_home_ home_dir_ ) points to a non-existing directory. " ) endif() - elseif( IS_DIRECTORY "${home_dir_}/projects" ) + elseif( EXISTS "${home_dir_}/projects" ) set( _proj_home "${home_dir_}/projects" ) - #else() - # get_filename_component( _proj_home ${CMAKE_SOURCE_DIR}/.. REALPATH ) + elseif( BBuildEnv_MSYS ) + # Check for %USERPROFILE%/projects as a fallback when using MSYS. + bb_get_home_dir( _home_dir NATIVE ) + if( EXISTS "${_home_dir}/projects" ) + set( _proj_home "${_home_dir}/projects" ) + endif() endif() if( DEFINED _proj_home ) set( ${proj_home_} "${_proj_home}" PARENT_SCOPE ) @@ -647,8 +765,15 @@ function( bb_set_external_dir dir_var_ dir_ ) list( APPEND _search_path "${_dir_norm}" ) endif() endforeach() - if( EXISTS "${bb_home_dir}/projects" ) - list( APPEND _search_path "${bb_home_dir}/projects" ) + bb_get_home_dir( _home_dir ) + if( EXISTS "${_home_dir}/projects" ) + list( APPEND _search_path "${_home_dir}/projects" ) + endif() + if( BBuildEnv_MSYS ) + bb_get_home_dir( _home_dir NATIVE ) + if( EXISTS "${_home_dir}/projects" ) + list( APPEND _search_path "${_home_dir}/projects" ) + endif() endif() list( REMOVE_DUPLICATES _search_path ) foreach( _path IN LISTS _search_path ) @@ -1132,18 +1257,6 @@ macro( bb_build_env_setup ) _bb_find_proj_home( bb_proj_home "${bb_home_dir}" ) # Add a cmake generator alias - # -- - # Visual Studio 15 2017 - # Visual Studio 14 2015 - # Visual Studio 12 2013 - # Visual Studio 11 2012 - # Visual Studio 10 2010 - # -- - # Xcode - # Unix Makefiles - # Ninja - # MinGW Makefiles - # -- unset( bb_generator_alias ) if( CMAKE_GENERATOR STREQUAL "Unix Makefiles" ) set( bb_generator_alias "umake" ) @@ -1169,11 +1282,15 @@ macro( bb_build_env_setup ) # set standard output directories: gcc-5.4/x86_64 if( DEFINED bb_generator_alias ) + set( BBuildEnv_GENERATOR_ALIAS "${bb_generator_alias}" ) set( bb_default_output_dir "${bb_generator_alias}/${bb_toolset_subdir}/${bb_platform_dir}" ) else() set( bb_default_output_dir "${bb_toolset_subdir}/${bb_platform_dir}" ) endif() + # BBuildEnv_OUTPUT_DIR_SUFFIX could be a cache variable to make it customizable. + set( BBuildEnv_OUTPUT_DIR_SUFFIX "${bb_default_output_dir}" ) + # the deploy folder may be used to save installer packages. set( bb_deploy_dir "${CMAKE_SOURCE_DIR}/deploy" ) @@ -1182,23 +1299,63 @@ macro( bb_build_env_setup ) endif() if( BUILD_SHARED_LIBS ) - set( _bb_shared_suffix "-shared" ) + set( BBuildEnv_SHARED_DIR_POSTFIX "-shared" ) + else() + unset( BBuildEnv_SHARED_DIR_POSTFIX ) + endif() + + if( NOT DEFINED BBuildEnv_USE_LIBRARY_NAME_POSTFIX ) + set( BBuildEnv_USE_LIBRARY_NAME_POSTFIX OFF CACHE BOOL "Enable library name postfix" ) endif() + + #set( BBuildEnv_RELEASE_POSTFIX "" ) + set( BBuildEnv_DEBUG_POSTFIX "-d" ) + set( BBuildEnv_RELWITHDEBINFO_POSTFIX "-rd" ) + set( BBuildEnv_MINSIZEREL_POSTFIX "-mr" ) - set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}/bin/${bb_default_output_dir}/debug${_bb_shared_suffix}" ) - set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}/bin/${bb_default_output_dir}/release${_bb_shared_suffix}" ) - set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_SOURCE_DIR}/bin/${bb_default_output_dir}/relwithdebinfo${_bb_shared_suffix}" ) - set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_SOURCE_DIR}/bin/${bb_default_output_dir}/minsizerel${_bb_shared_suffix}" ) - set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}/lib/${bb_default_output_dir}/debug${_bb_shared_suffix}" ) - set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}/lib/${bb_default_output_dir}/release${_bb_shared_suffix}" ) - set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_SOURCE_DIR}/lib/${bb_default_output_dir}/relwithdebinfo${_bb_shared_suffix}" ) - set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_SOURCE_DIR}/lib/${bb_default_output_dir}/minsizerel${_bb_shared_suffix}" ) + if( BBuildEnv_USE_LIBRARY_NAME_POSTFIX ) + set( CMAKE_DEBUG_POSTFIX ${BBuildEnv_DEBUG_POSTFIX} ) + set( CMAKE_RELWITHDEBINFO_POSTFIX ${BBuildEnv_RELWITHDEBINFO_POSTFIX} ) + set( CMAKE_MINSIZEREL_POSTFIX ${BBuildEnv_MINSIZEREL_POSTFIX} ) + + set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib${BBuildEnv_SHARED_DIR_POSTFIX}/${BBuildEnv_OUTPUT_DIR_SUFFIX}" ) + set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}" ) + set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}" ) + set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}" ) + set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}" ) + + set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG}" ) + set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE}" ) + set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO}" ) + set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL}" ) + + set( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin${BBuildEnv_SHARED_DIR_POSTFIX}/${BBuildEnv_OUTPUT_DIR_SUFFIX}" ) + set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" ) + set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" ) + set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" ) + set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" ) + + else() + # Using CMake's default library name convention which is the same for all configurations. + set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}/lib/${BBuildEnv_OUTPUT_DIR_SUFFIX}/debug${BBuildEnv_SHARED_DIR_POSTFIX}" ) + set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}/lib/${BBuildEnv_OUTPUT_DIR_SUFFIX}/release${BBuildEnv_SHARED_DIR_POSTFIX}" ) + set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_SOURCE_DIR}/lib/${BBuildEnv_OUTPUT_DIR_SUFFIX}/relwithdebinfo${BBuildEnv_SHARED_DIR_POSTFIX}" ) + set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_SOURCE_DIR}/lib/${BBuildEnv_OUTPUT_DIR_SUFFIX}/minsizerel${BBuildEnv_SHARED_DIR_POSTFIX}" ) + + + set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG}" ) + set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE}" ) + set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO}" ) + set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL}" ) + + set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}/bin/${BBuildEnv_OUTPUT_DIR_SUFFIX}/debug${BBuildEnv_SHARED_DIR_POSTFIX}" ) + set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}/bin/${BBuildEnv_OUTPUT_DIR_SUFFIX}/release${BBuildEnv_SHARED_DIR_POSTFIX}" ) + set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_SOURCE_DIR}/bin/${BBuildEnv_OUTPUT_DIR_SUFFIX}/relwithdebinfo${BBuildEnv_SHARED_DIR_POSTFIX}" ) + set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_SOURCE_DIR}/bin/${BBuildEnv_OUTPUT_DIR_SUFFIX}/minsizerel${BBuildEnv_SHARED_DIR_POSTFIX}" ) + endif() + - set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}/lib/${bb_default_output_dir}/debug${_bb_shared_suffix}" ) - set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}/lib/${bb_default_output_dir}/release${_bb_shared_suffix}" ) - set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_SOURCE_DIR}/lib/${bb_default_output_dir}/relwithdebinfo${_bb_shared_suffix}" ) - set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_SOURCE_DIR}/lib/${bb_default_output_dir}/minsizerel${_bb_shared_suffix}" ) endmacro( bb_build_env_setup ) #message( STATUS "BBuildEnv.cmake: starting: ${CMAKE_GENERATOR}" ) diff --git a/cmake/CMakeBuild/cmake/modules/BBuildEnvDebug.cmake b/cmake/CMakeBuild/cmake/modules/BBuildEnvDebug.cmake index 40de4dad5071bdb71e889d7408a789e43bd07585..3f195eb40ab0e4899bb1b9dbef49f4d4e5b6eaef 100644 --- a/cmake/CMakeBuild/cmake/modules/BBuildEnvDebug.cmake +++ b/cmake/CMakeBuild/cmake/modules/BBuildEnvDebug.cmake @@ -60,6 +60,8 @@ function( bb_dump_cmake_system_info ) message( STATUS "CMAKE_PROGRAM_PATH: ${CMAKE_PROGRAM_PATH}" ) message( STATUS "CMAKE_SYSTEM_PROGRAM_PATH: ${CMAKE_SYSTEM_PROGRAM_PATH}" ) message( STATUS "CMAKE_GENERATOR: ${CMAKE_GENERATOR}" ) + message( STATUS "CMAKE_GENERATOR_PLATFORM: ${CMAKE_GENERATOR_PLATFORM}" ) + if( CMAKE_CXX_COMPILER_LOADED ) message( STATUS "CMAKE_CXX_COMPILER_LOADED: on" ) endif() @@ -73,6 +75,7 @@ function( bb_dump_cmake_system_info ) message( STATUS "CMAKE_CXX_COMPILER_ARCHITECTURE_ID: ${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" ) endif() if( MSVC ) + message( STATUS "CMAKE_VS_PLATFORM_NAME: ${CMAKE_VS_PLATFORM_NAME}" ) message( STATUS "CMAKE_VS_PLATFORM_NAME: ${CMAKE_VS_PLATFORM_NAME}" ) message( STATUS "CMAKE_VS_PLATFORM_TOOLSET: ${CMAKE_VS_PLATFORM_TOOLSET}" ) message( STATUS "MSVC_VERSION: ${MSVC_VERSION}" ) @@ -119,6 +122,10 @@ endfunction( bb_dump_cmake_system_info ) function( bb_dump_target_properties target_ prop1_ ) + if( NOT TARGET ${target_} ) + message( WARNING "target ${target_} does not exist." ) + return() + endif() set( _prop_list ${prop1_} ) list( APPEND _prop_list ${ARGN} ) list( LENGTH _prop_list _prop_list_len ) @@ -126,9 +133,12 @@ function( bb_dump_target_properties target_ prop1_ ) foreach( _prop ${_prop_list} ) get_target_property( _prop_value ${target_} ${_prop} ) if( _prop_value ) - message( STATUS "bb_dump_target_properties: ${target_}: ${_prop}=${_prop_value}" ) + message( STATUS "${target_}: ${_prop}=${_prop_value}" ) endif() endforeach() message( STATUS "bb_dump_target_properties: leaving" ) endfunction() +macro( bb_dump_imported_target_properties target_ ) + bb_dump_target_properties( ${target_} IMPORTED_LOCATION IMPORTED_IMPLIB INTERFACE_INCLUDE_DIRECTORIES INTERFACE_COMPILE_DEFINITIONS INTERFACE_LINK_LIBRARIES ) +endmacro() diff --git a/cmake/CMakeBuild/cmake/modules/BBuildEnvVersion.cmake b/cmake/CMakeBuild/cmake/modules/BBuildEnvVersion.cmake index b4543a8d442aaf20971ec34d2c6bac56f587d6ee..2f5b5ea5b5c9240d99b8b3f764375336438a9db3 100644 --- a/cmake/CMakeBuild/cmake/modules/BBuildEnvVersion.cmake +++ b/cmake/CMakeBuild/cmake/modules/BBuildEnvVersion.cmake @@ -5,9 +5,9 @@ # set( BBuildEnv_VERSION_MAJOR 3 ) -set( BBuildEnv_VERSION_MINOR 13 ) -set( BBuildEnv_VERSION_PATCH 0 ) -set( BBuildEnv_VERSION_TWEAK 2 ) +set( BBuildEnv_VERSION_MINOR 14 ) +set( BBuildEnv_VERSION_PATCH 4 ) +set( BBuildEnv_VERSION_TWEAK 4 ) # BBuildEnv version in decimal dotted format as supported by CMake's version compare operations. set( BBuildEnv_VERSION "${BBuildEnv_VERSION_MAJOR}.${BBuildEnv_VERSION_MINOR}.${BBuildEnv_VERSION_PATCH}.${BBuildEnv_VERSION_TWEAK}" ) diff --git a/cmake/CMakeBuild/cmake/toolchains/aarch64-linux-gnu-gcc-ubuntu1804.cmake b/cmake/CMakeBuild/cmake/toolchains/aarch64-linux-gnu-gcc-ubuntu1804.cmake index 9c0ec5c3f62bc2d64d4a18b4adfc2abe63a818d3..3e78dc0815936ddf8c8ada05564b1f51c7110d37 100644 --- a/cmake/CMakeBuild/cmake/toolchains/aarch64-linux-gnu-gcc-ubuntu1804.cmake +++ b/cmake/CMakeBuild/cmake/toolchains/aarch64-linux-gnu-gcc-ubuntu1804.cmake @@ -19,7 +19,12 @@ list( APPEND CMAKE_FIND_ROOT_PATH ${ARM_LINUX_SYSROOT} ) # search headers and libraries in the target environment, search # programs in the host environment set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) -set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) + +# Ubuntu/amd64 + foreign architecture arm64 +set( CMAKE_LIBRARY_PATH /usr/lib/${GNU_MACHINE}-linux-gnu ) +set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH ) +#set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) + set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) set( USE_OPENCV_TOOLCHAIN_FLAGS ON )