def add_target_property_sheet(context, attr_name, filename, node): """ Find and set in current context property sheets :param context: :param attr_name: :param filename: :param node: :return: """ del attr_name, node if 'Microsoft' in filename: # ignore props provided by Microsoft return if filename[-8:] == '.targets': # ignore targets files return working_path = os.path.dirname(context.vcxproj_path) props_cmake_path = normalize_path(context, working_path, filename, False).replace('.props', '.cmake') props_cmake_path = cleaning_output(context, props_cmake_path) message(context, 'cmake from property sheet: {}'.format(props_cmake_path), '') context.settings[context.current_setting]['property_sheets'].append( props_cmake_path)
def set_path_and_name_from_node(context, node_name, value, path_property, name_property): """ Common routine for evaluating path and name from node text """ file_path_value = value.strip() if not file_path_value: return file_path_value = replace_vs_vars_with_cmake_vars( context, file_path_value) file_path_value = set_native_slash(file_path_value) path, name = get_dir_name_with_vars(context, file_path_value) result_name = replace_vs_vars_with_cmake_vars(context, name) result_path = cleaning_output(context, path) result_path = check_for_relative_in_path(context, result_path) message(context, '{} directory = {}'.format(node_name, result_path), '') message(context, '{} name = {}'.format(node_name, result_name), '') context.settings[context.current_setting][path_property] = [ result_path ] context.settings[context.current_setting][name_property] = [ result_name ]
def set_target_additional_library_directories( context, flag_name, additional_library_directories, node): """ Find and set additional library directories in context """ del flag_name, node if additional_library_directories: list_depends = additional_library_directories.replace( '%(AdditionalLibraryDirectories)', '') if list_depends != '': add_lib_dirs = [] for d in list_depends.split(';'): d = d.strip() if d != '': add_lib_dirs.append( check_for_relative_in_path( context, cleaning_output(context, d))) message( context, 'Additional Library Directories = {}'.format(add_lib_dirs), '') context.settings[ context.current_setting]['target_link_dirs'] = add_lib_dirs
def __set_additional_options(self, context, flag_name, flag_value): """ Set Additional options """ # for setting in context.settings: add_opts = flag_value if add_opts: add_opts = set_unix_slash(add_opts).split() ready_add_opts = [] for add_opt in add_opts: add_opt = add_opt.strip() if '/Qprof-dir' in add_opt: name_value = add_opt.split(':') prof_dir = normalize_path( context, os.path.dirname(context.vcxproj_path), name_value[1]) prof_dir = cleaning_output(context, prof_dir) add_opt = name_value[0] + ':' + prof_dir add_opt = '-' + add_opt[1:] ready_add_opts.append(add_opt) unix_option = add_opt.replace(':', ' ') if 'gen-interfaces' in unix_option: pass elif 'Qprec-div' in unix_option: unix_option = FortranFlags.__get_no_prefix( unix_option) + '-prec-div' elif unix_option == '-static': pass elif 'Qprof-dir' in unix_option: unix_option = unix_option.replace('Qprof-dir', 'prof-dir') elif 'Qprof-gen' in unix_option: unix_option = unix_option.replace('Qprof-gen', 'prof-gen') elif 'Qprof-use' in unix_option: unix_option = unix_option.replace('Qprof-use', 'prof-use') elif 'Qprec-sqrt' in unix_option: unix_option = FortranFlags.__get_no_prefix( unix_option) + '-prec-sqrt' elif 'Qopenmp-lib' in unix_option: unix_option = unix_option.replace('Qopenmp-lib', 'qopenmp-lib') unix_option = unix_option.replace('lib ', 'lib=') else: message( context, 'Unix ifort option "{0}" may be incorrect. ' 'Check it and set it with visual studio UI if possible.' .format(unix_option), 'warn') if ifort_cl_win not in self.flags[flag_name]: self.flags[flag_name][ifort_cl_win] = [] self.flags[flag_name][ifort_cl_win].append(add_opt) if ifort_cl_unix not in self.flags[flag_name]: self.flags[flag_name][ifort_cl_unix] = [] self.flags[flag_name][ifort_cl_unix].append(unix_option) message(context, 'Additional Options : {0}'.format(str(ready_add_opts)), '')
def set_output_dir_impl(context, output_node_text): """ :param context: :param output_node_text: :return: """ output_path = cleaning_output(context, output_node_text) output_path = output_path.strip().replace('\n', '') output_path = check_for_relative_in_path(context, output_path) context.settings[context.current_setting]['OUTPUT_DIRECTORY'] = [ output_path ] message(context, 'Output Dir = {0}'.format(output_path), '')
def set_output_file_impl(context, output_file_node_text): """ Common routine for evaluating path and name of output file """ if output_file_node_text: # next 2 properties are special. check Default.cmake for understanding if not context.settings[ context.current_setting]['OUTPUT_DIRECTORY']: context.settings[context.current_setting]['OUTPUT_DIRECTORY'] = \ ['${OUTPUT_DIRECTORY}'] if not context.settings[context.current_setting]['TARGET_NAME']: context.settings[context.current_setting]['TARGET_NAME'] = [ '${TARGET_NAME}' ] output_path = context.settings[ context.current_setting]['OUTPUT_DIRECTORY'][0] output_file = cleaning_output(context, output_file_node_text) output_file = output_file.replace('${OUTPUT_DIRECTORY}', output_path) output_path = os.path.dirname(output_file) name, _ = os.path.splitext(os.path.basename(output_file)) name = name.replace( '${TARGET_NAME}', context.settings[context.current_setting]['TARGET_NAME'][0]) context.settings[context.current_setting]['TARGET_NAME'] = \ [replace_vs_vars_with_cmake_vars(context, name)] output_path = check_for_relative_in_path(context, output_path) context.settings[context.current_setting]['OUTPUT_DIRECTORY'] = [ output_path ] message( context, 'Output File : dir="{}" name="{}"'.format( context.settings[ context.current_setting]['OUTPUT_DIRECTORY'][0], context.settings[context.current_setting]['TARGET_NAME']), '')