def str_cmake_config( out_directory : str ) -> str: cmake_config_template = """ # ---------------------------------------------------------------- # This CMake file is generated automatically by the Shake3 CMake Generator # Don't change this file. Reconfigure the generator instead. cmake_minimum_required( VERSION 3.12 ) # ---------------------------------------------------------------- # CMake configuration set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY {SHAKE_CMAKE_GENERATOR_out_directory} ) set( CMAKE_LIBRARY_OUTPUT_DIRECTORY {SHAKE_CMAKE_GENERATOR_out_directory} ) set( CMAKE_RUNTIME_OUTPUT_DIRECTORY {SHAKE_CMAKE_GENERATOR_out_directory} ) set( CMAKE_EXECUTABLE_OUTPUT_PATH {SHAKE_CMAKE_GENERATOR_out_directory} ) # this option is necessary to automatically export ALL symbols in a library on Windows, # without needing to specify __declspec( export ). # That means it also creates a .lib file for shared libraries set( CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON ) """ cmake_config_string = cmake_format( cmake_config_template, out_directory = quote( out_directory ) ) return cmake_config_string
def str_cmake_config(out_directory: str) -> str: cmake_config_template = ( "# ----------------------------------------------------------------\n" "# This CMake file is generated automatically by the Shake3 CMake Generator\n" "# Don't change this file. Reconfigure the generator instead.\n" "# For more info see: https://github.com/berryvansomeren/cmake_generator\n" "\n" "cmake_minimum_required( VERSION 3.17 )\n" "\n" "# ----------------------------------------------------------------\n" "# CMake configuration\n" "\n" "set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY {SHAKE_CMAKE_GENERATOR_out_directory} )\n" "set( CMAKE_LIBRARY_OUTPUT_DIRECTORY {SHAKE_CMAKE_GENERATOR_out_directory} )\n" "set( CMAKE_RUNTIME_OUTPUT_DIRECTORY {SHAKE_CMAKE_GENERATOR_out_directory} )\n" "set( CMAKE_EXECUTABLE_OUTPUT_PATH {SHAKE_CMAKE_GENERATOR_out_directory} )\n" "\n" "# this option is necessary to automatically export ALL symbols in a library on Windows,\n" "# without needing to specify __declspec( export ).\n" "# That means it also creates a .lib file for shared libraries\n" "set( CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON )\n" "\n") cmake_config_string = cmake_format(cmake_config_template, out_directory=quote(out_directory)) return cmake_config_string
def python_list_to_cmake_list_quoted(l: List[Any]) -> str: quoted_elements = [] for e in l: if e[0] == '$': quoted_elements.append(e) else: quoted_elements.append(quote(e)) result = '\n'.join(quoted_elements) return result
def str_import_target(target: ImportTarget, all_targets: Dict[str, Target]) -> str: target_names = ', '.join([subtarget for subtarget in target.subtargets]) target_str = cmake_format(""" # ---------------------------------------------------------------- # Import Targets: {SHAKE_CMAKE_GENERATOR_target_names} """, target_names=target_names) target_str += target.pre_import_inline_cmake target_str += cmake_format(""" add_subdirectory( {SHAKE_CMAKE_GENERATOR_src_dir_path} ) """, src_dir_path=quote(target.src_dir_path)) target_str += target.post_import_inline_cmake return target_str
def _str_list_files(set_file_template: str, file_variable_name: str, glob_expression: str) -> str: set_file_str = cmake_format(set_file_template, file_variable_name=file_variable_name, glob_expression=quote(glob_expression)) return set_file_str