# pycmake **Repository Path**: yhyu13/pycmake ## Basic Information - **Project Name**: pycmake - **Description**: python cmake interface to generate cmake files based only .cmake.py files - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-02-09 - **Last Updated**: 2026-04-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # PyCMake : OOP CMake wrapper in python ## Overview pycamke is a simple wrapper for cmake that helps describe cmake objects in a object oriented manner. Required Python>=3.7 ## Install ### Local install To be able to debug the code, you can install the package in editable mode. ``` pip uninstall pycamke pip install -e . ``` ### Wheel install To build a wheel, run the following command: ``` pip uninstall pycamke pip install build wheel rm -rf ./dist python -m build --wheel . pip install ./dist/*.whl ``` or simply run `./install_wheel.sh` ### Release on gitee PyCmake is available to install from gitee release https://gitee.com/yhyu13/pycmake.git ## Project Initiative The problem with using CMake scripts (IMO): In CMake, you can write add_compilation_definitions() for global compile macros, and target_compilation_definitions() for compile macros for specific targets. So you need to remember to not overlaop global and target compile macros. This is an example of a potential erroneous scope management. And for the above task, you kind of want to use procedural language to manage the relationship between different object (object oriented programming, specifically). But CMake is declarative. It is just a Domain Specific Markup language that cope with the complexity of building software packages. And markup languages are not good desgined describing the flow of execution, they just give a meaningful strcuture for plain text, just like XML, HTML, YAML, etc. So my goal is to bound CMake by enforcing user to use a procedural language to manage the flow of underlying CMake in a object orientated way. That's why I use Python to write a CMake wrapper that describe `Project`, `Module`, `Packages`, etc and their relationships. And the python package only describe a handy subset of CMake commands. ## Features - Function - Project - Module - Fetch content - Find Package ## Usage Examples: 1. https://github.com/yhyu13/HLVM-Engine 2. [GenerateProject.sh](https://github.com/yhyu13/HLVM-Engine/blob/c163c623a360cf214fe1ef8c0bee5a4a1691b39f/GenerateCMakeProjects.sh) 3. [.cmake.py](https://github.com/yhyu13/HLVM-Engine/blob/c163c623a360cf214fe1ef8c0bee5a4a1691b39f/Engine/Source/Common/Common.cmake.py) Take HLVM-Engine as an example, it has a project directory like this: ``` HLVM-Engine/ ├── Engine/ # Main engine source code │ ├── Source/ # All C++ source files │ │ ├── Common/ # Core shared functionality │ │ │ ├── Public/ # Public headers │ │ │ ├── Private/ # Implementation files │ │ │ └── ThirdParty/ # Third-party libraries │ │ ├── Runtime/ # Runtime-specific components │ │ ├── Editor/ # Editor functionality │ │ ├── Plugin/ # Plugin system │ │ └── Dependency/ # vcpkg dependencies │ └── Scripts/ # Python build and utility scripts │ ├── pycmake/ # Custom OOP CMake wrapper │ └── pyarg/ # Argument parsing utilities ├── Binary/ # Build output and toolchain binaries ├── Document/ # Documentation ├── Samples/ # Example code ├── build/ # CMake build directory ├── env.yaml # Conda environment specification ├── Setup.sh # Initial setup script └── GenerateCMakeProjects.sh # Build generation script ``` example GenerateCMakeProjects.sh ``` #!/bin/bash pycmake --root_dir ./Engine/Source/ ``` example Engine/Source/Common/Common_cmake.py scripts: ``` from PyCMake.cmakecpp import * # Create a VcpkgContext object with the specified path for vcpkg root and version vcpkg_cxt_common = VcpkgContenxt(vcpkg_root_path='../Dependency/vcpkg', vcpkg_config=VcpkgConfigModel(name='Common', version='0.2.1', dependencies=[ "spdlog", VcpkgPackage(name="mimalloc", features=["asm", "secure"],# asm no longer work on mimalloc2.2.3 #features=["secure"], default_features=False), "magic-enum", "boost", "libbacktrace", # used by boost stack trace on linux "zstd", "botan", "rapidjson", "gperftools", # linux cpu sampling "minitrace", # chrome format tracing VcpkgPackage(name="luajit", features=["buildvm-64"], default_features=True), "sol2", "pybind11", "taskflow", VcpkgPackage(name="bitserializer", features=["rapidjson-archive", "msgpack-archive"], default_features=True), ])) # Find the spdlog package with the specified options spdlog = FindPackage(name='spdlog', config=True, required=True, dependant_target_link_libs=[DomainValueModel(domain=DomainEnum.PUBLIC, values=['spdlog::spdlog'])]) # Find the mimalloc package with the specified options mimalloc = FindPackage(name='mimalloc', config=True, required=True, dependant_target_link_libs=[ DomainValueModel(domain=DomainEnum.PUBLIC, values=['mimalloc-static'])]) # Find the magic_enum package with the specified options magic_enum = FindPackage(name='magic_enum', config=True, required=True, dependant_target_link_libs=[ DomainValueModel(domain=DomainEnum.PUBLIC, values=['magic_enum::magic_enum'])]) # Find the Boost package with the specified options Boost = FindPackage(name='Boost', config=False, required=True, components=['iostreams filesystem system thread fiber date_time program_options serialization'], dependant_target_include_dirs=[ DomainValueModel(domain=DomainEnum.PUBLIC, values=['${Boost_INCLUDE_DIRS}'])], dependant_target_link_dirs=[ DomainValueModel(domain=DomainEnum.PUBLIC, values=['${Boost_LIBRARY_DIRS}'])], dependant_target_link_libs=[DomainValueModel(domain=DomainEnum.PUBLIC, values=['${Boost_LIBRARIES}', 'backtrace'])]) # Find the Botan3 package with the specified options botan3 = FindPackage(name='Botan', config=False, required=True, dependant_target_link_libs=[ DomainValueModel(domain=DomainEnum.PUBLIC, values=['Botan::Botan'])]) # Find the zstd package with the specified options zstd = FindPackage(name='zstd', config=True, required=True, dependant_target_link_libs=[ DomainValueModel(domain=DomainEnum.PUBLIC, values=['zstd::libzstd_static'])]) # Find the rapidjson package with the specified options rapidjson = FindPackage(name='RapidJSON', config=True, required=True, dependant_target_link_libs=[ DomainValueModel(domain=DomainEnum.PUBLIC, values=['rapidjson'])]) # Find the gperftools package with the specified options gperftools = FindPackage(name='Gperftools', config=False, required=True, components=['profiler'], dependant_target_link_libs=[ DomainValueModel(domain=DomainEnum.PUBLIC, values=['${GPERFTOOLS_LIBRARIES}'])]) # Find the minitrace package with the specified options minitrace = FindPackage(name='minitrace', config=True, required=True, dependant_target_link_libs=[ DomainValueModel(domain=DomainEnum.PUBLIC, values=['minitrace::minitrace'])]) # Find the luajit package with the specified options luajit = FindPackage(name='luajit', config=False, required=True, dependant_target_link_libs=[ DomainValueModel(domain=DomainEnum.PUBLIC, values=['luajit::luajit'])]) # Find the sol2 package with the specified options sol2 = FindPackage(name='sol2', config=True, required=True, dependant_target_link_libs=[ DomainValueModel(domain=DomainEnum.PUBLIC, values=['sol2'])]) # Find the taskflow package with the specified options taskflow = FindPackage(name='Taskflow', config=True, required=True, dependant_target_link_libs=[ DomainValueModel(domain=DomainEnum.PUBLIC, values=['Taskflow::Taskflow'])]) ########################################################## # Fetch the Yalantinglibs package from GitHub with the specified options yalantinlibs = FetchContent(name='yalantinglibs', git_repo_url='https://github.com/yhyu13/yalantinglibs.git', git_tag='abf6016a8f7841d29303ef68f118ea85b69a1051', # target_compile_options=[TargetDomainValueModel(target='yalantinglibs', # domain=DomainEnum.INTERFACE, # values=[#'-DYLT_ENABLE_PMR=ON', # #'-DIGUANA_ENABLE_PMR=ON', # '-DENABLE_PMR=ON', # '-DENABLE_STRUCT_PACK_OPTIMIZE=ON'])], option_overrides=[ OptionOverrideModel(option='YLT_ENABLE_PMR', value='ON'), OptionOverrideModel(option='IGUANA_ENABLE_PMR', value='ON'), OptionOverrideModel(option='YLT_ENABLE_STRUCT_PACK_OPTIMIZE', value='ON') ], dependant_target_link_libs=[ DomainValueModel(domain=DomainEnum.PUBLIC, values=['yalantinglibs::yalantinglibs'])] ) # Fetch the parallel-hashmap package from GitHub with the specified options parallel_hashmap = FetchContent(name='parallel-hashmap', git_repo_url='https://github.com/yhyu13/parallel-hashmap.git', git_tag='67c24619e4f5ab2097b74cc397732c17a25d6944', dependant_target_include_dirs=[ DomainValueModel(domain=DomainEnum.PUBLIC, values=['${parallel-hashmap_SOURCE_DIR}'])], ) # Fetch the ctre package from GitHub with the specified options ctre = FetchContent(name='ctre', git_repo_url='https://github.com/yhyu13/compile-time-regular-expressions.git', git_tag='9725886582a928491a086bba1c07909b2e583157', dependant_target_link_libs=[DomainValueModel(domain=DomainEnum.PUBLIC, values=['ctre::ctre'])] ) # TODO : TracyClient should be added as ThirdParty cpp like Effil.cpp # Fetch the Tracy package from GitHub with the specified options tracy = FetchContent(name='Tracy', git_repo_url='https://github.com/yhyu13/tracy.git', git_tag='58d112e89245ae1d6221aa2a4842e24f56df213d', # target_compile_options=[TargetDomainValueModel(target='TracyClient', domain=DomainEnum.INTERFACE, # values=[ # # '-DTRACY_ON_DEMAND=ON', On demand not work on Linux # '-DTRACY_ONLY_LOCALHOST=ON', # '-DTRACY_NO_FRAME_IMAGE=ON', # '-DTRACY_ONLY_IPV4=ON', # '-DTRACY_USE_RPMALLOC=ON', # # No exit will make client program wait unitl profiler finish, which prolong exit time especially for client release build # '-DTRACY_NO_EXIT=OFF', # '-DTRACY_LIBBACKTRACE_ELF_DYNLOAD_SUPPORT=ON', # ])], option_overrides=[ OptionOverrideModel(option='TRACY_ONLY_LOCALHOST', value='ON'), OptionOverrideModel(option='TRACY_NO_FRAME_IMAGE', value='ON'), OptionOverrideModel(option='TRACY_ONLY_IPV4', value='ON'), OptionOverrideModel(option='TRACY_USE_RPMALLOC', value='ON'), OptionOverrideModel(option='TRACY_NO_EXIT', value='OFF'), OptionOverrideModel(option='TRACY_LIBBACKTRACE_ELF_DYNLOAD_SUPPORT', value='ON'), ], dependant_target_link_libs=[ DomainValueModel(domain=DomainEnum.PUBLIC, values=['Tracy::TracyClient'])] ) """ Global Config : """ bThreadSanitizer = False bBuildShared = False # Create a CommonModule object with the specified options class CommonModule(BaseModule): def __init__(self): super().__init__(module=ModuleTargetModel(target='Common', type=ModuleEnum.SHARED if bBuildShared else ModuleEnum.STATIC, source_files=PyCMakeUtil.glob( [PyCMakeUtil.GlobModel(path='./Private/**/*.cpp', recursive=True) ]), unity_build=True), fetch_packages=[yalantinlibs, parallel_hashmap, ctre, tracy, ], find_packages=[spdlog, mimalloc, magic_enum, Boost, botan3, zstd, rapidjson, gperftools, minitrace, luajit, sol2, taskflow, ] ) self.target_interface.add_compile_options(domain=DomainEnum.PUBLIC, values=[ '$<$: -Wall -Wextra -pedantic -Werror>', '$<$:-Wall -Wextra -pedantic -Werror -Wunused-variable -Wconversion -Weverything>', '$<$:-Wno-padded -Wno-gnu-zero-variadic-macro-arguments -Wno-reserved-identifier -Wno-exit-time-destructors -Wno-global-constructors -Wno-c++98-compat-pedantic -Wno-float-equal -Wno-covered-switch-default -Wno-c++20-compat>', '$<$:-Wno-error=global-constructors -Wno-error=exit-time-destructors -Wno-error=unsafe-buffer-usage -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=unused-member-function>' ]) self.target_interface.add_include_dirs(domain=DomainEnum.PUBLIC, values=['./Public']) self.target_interface.add_pch_files(domain=DomainEnum.PUBLIC, values=['./Public/Common.shared.pch']) if bThreadSanitizer: self.target_interface.add_compile_options(domain=DomainEnum.PUBLIC, values=['${HLVM_CMAKE_CXX_FLAGS_TSAN}']) self.target_interface.add_link_libs(domain=DomainEnum.PUBLIC, values=['tsan']) # Create a CommonTestModule object with the specified options class CommonTestModule(BaseModule): def __init__(self, cpp_path: str): super().__init__(module=ModuleTargetModel(target=os.path.basename(cpp_path).split('.')[0], type=ModuleEnum.EXECUTABLE_AND_TEST, source_files=[cpp_path], unity_build=False), fetch_packages=[], find_packages=[] ) self.target_interface.add_pch_files(domain=DomainEnum.REUSE_FROM, values=['Common']) self.target_interface.add_link_libs(domain=DomainEnum.PRIVATE, values=['Common']) if bBuildShared: # TODO : windows platform compatibility check! # https://gitlab.kitware.com/cmake/cmake/-/issues/20289 self.target_interface.add_compile_options(domain=DomainEnum.PRIVATE, values=['-fPIC']) # Create a CommonProject object with the specified options class CommonProject(BaseProject): def __init__(self, **kwargs): super().__init__(name='Common', version='3.14', vcpkg_context=vcpkg_cxt_common, **kwargs) # Proxy self.global_interface.add_global_set('ENV{HTTP_PROXY}', ["http://127.0.0.1:8889"]) self.global_interface.add_global_set('ENV{HTTPS_PROXY}', ["http://127.0.0.1:8889"]) self.global_interface.add_global_set('ENV{http_proxy}', ["http://127.0.0.1:8889"]) self.global_interface.add_global_set('ENV{https_proxy}', ["http://127.0.0.1:8889"]) # Linker if bBuildShared: self.global_interface.add_global_set('CMAKE_POSITION_INDEPENDENT_CODE', ['ON']) else: self.global_interface.add_global_set('CMAKE_POLICY_DEFAULT_CMP0069', ['NEW']) self.global_interface.add_global_set('CMAKE_INTERPROCEDURAL_OPTIMIZATION', ['ON']) self.global_interface.add_global_set('CMAKE_LINKER_TYPE', ['GOLD']) # Compiler self.global_interface.add_global_set('CMAKE_EXPORT_COMPILE_COMMANDS', ['ON']) self.global_interface.add_global_set('CMAKE_C_STANDARD', ['23']) self.global_interface.add_global_set('CMAKE_CXX_STANDARD', ['23']) self.global_interface.add_global_set('CMAKE_DEBUG_POSTFIX', ['d']) # Output bin_output_dir = '${PROJECT_SOURCE_DIR}/Binary/${CMAKE_BUILD_TYPE}' self.global_interface.add_global_set('CMAKE_RUNTIME_OUTPUT_DIRECTORY', [bin_output_dir]) self.global_interface.add_global_set('CMAKE_LIBRARY_OUTPUT_DIRECTORY', [bin_output_dir]) self.global_interface.add_global_set('CMAKE_ARCHIVE_OUTPUT_DIRECTORY', [bin_output_dir]) # Definitions self.global_interface.add_global_set('HLVM_CMAKE_CXX_FLAGS_TSAN', ['-fsanitize=thread']) self.global_interface.add_compile_definitions(domain=DomainEnum.GLOBAL, values=["$<$:HLVM_BUILD_DEBUG=1>", "$<$:HLVM_BUILD_DEVELOPMENT=1>", "$<$:HLVM_BUILD_RELEASE=1>", "$<$:HLVM_BUILD_RELEASE=1>", f"HLVM_COMMON_DYNAMIC_LINKED={bBuildShared * 1}"]) # Create a CommonModule object for the main project self.modules.append(CommonModule()) # Create CommonTestModule objects for all tests self.modules.extend([CommonTestModule(path) for path in glob.glob("./Test/*.cpp")]) # Main function if __name__ == '__main__': # cd to script dir logging.info(f'Exec {__file__}') from pathlib import Path _dir = Path(__file__).parent logging.debug(f'change dir to {_dir}') os.chdir(_dir) # write cmake file PyCMakeUtil.dump_to_cmake_list([ CommonProject() ], './') ``` which creates a Engine/Source/Common/CMakeLists.txt file in the current directory: ``` # THIS FILE IS AUTOMATICALLY GENERATED. DO NOT MODIFY UNLESS BY WILL. #################################################################### # Begin Function function(function_unity_build TARGET SOURCE_VARIABLE_NAME) set_target_properties(${TARGET} PROPERTIES UNITY_BUILD ON) endfunction() function(function_unity_build_exclusions SOURCE_VARIABLE_NAME) set(files ${${SOURCE_VARIABLE_NAME}}) foreach(source_file ${files}) set_property(SOURCE ${source_file} PROPERTY SKIP_UNITY_BUILD_INCLUSION ON) endforeach() endfunction() function(function_build_and_test_executable source) get_filename_component(TEST_TARGET ${source} NAME_WE) add_executable(${TEST_TARGET} ${source}) install(TARGETS ${TEST_TARGET} RUNTIME) add_test(NAME ${TEST_TARGET} COMMAND $ ${ARGN}) endfunction() # End Function #################################################################### list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../Dependency/vcpkg/scripts/buildsystems/vcpkg.cmake" CACHE STRING "Vcpkg toolchain file") cmake_minimum_required(VERSION 3.14) project(Common C CXX) # global sets message("PyCMake: global sets") set(ENV{HTTP_PROXY} http://127.0.0.1:8889) set(ENV{HTTPS_PROXY} http://127.0.0.1:8889) set(ENV{http_proxy} http://127.0.0.1:8889) set(ENV{https_proxy} http://127.0.0.1:8889) set(CMAKE_POLICY_DEFAULT_CMP0069 NEW) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) set(CMAKE_LINKER_TYPE GOLD) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_C_STANDARD 23) set(CMAKE_CXX_STANDARD 23) set(CMAKE_DEBUG_POSTFIX d) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/Binary/${CMAKE_BUILD_TYPE}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/Binary/${CMAKE_BUILD_TYPE}) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/Binary/${CMAKE_BUILD_TYPE}) set(HLVM_CMAKE_CXX_FLAGS_TSAN -fsanitize=thread) # global compile definitions message("PyCMake: global compile definitions") add_compile_definitions(GLOBAL $<$:HLVM_BUILD_DEBUG=1> $<$:HLVM_BUILD_DEVELOPMENT=1> $<$:HLVM_BUILD_RELEASE=1> $<$:HLVM_BUILD_RELEASE=1> HLVM_COMMON_DYNAMIC_LINKED=0) #################################################################### # Begin Module include(CTest) # set source files set(Common_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Private/Global.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Platform/GenericPlatformFile.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Platform/GenericPlatform.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Platform/GenericPlatformStackTrace.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Platform/GenericPlatformCrashDump.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Platform/Windows/WindowsPlatformThreadUtil.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Platform/Windows/WindowsPlatformDebuggerUtil.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Platform/FileSystem/FileHandle.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Platform/FileSystem/Path.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Platform/FileSystem/Boost/BoostPlatformFile.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Platform/FileSystem/Boost/BoostStreamFileHandle.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Platform/FileSystem/Boost/BoostMapFileHandle.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Platform/FileSystem/Boost/BoostFileStat.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Platform/FileSystem/Packed/PackedPlatformFile.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Platform/FileSystem/Packed/PackedEntryHandle.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Platform/FileSystem/Packed/PackedToken.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Platform/FileSystem/Packed/PackedFileHandle.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Platform/FileSystem/Packed/PackedContainerFragment.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Platform/LinuxGNU/LinuxGNUPlatformThreadUtil.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Platform/LinuxGNU/LinuxGNUPlatformDebuggerUtil.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Platform/LinuxGNU/LinuxGNUPlatformCrashDump.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/ThirdParty/Effil.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Utility/Hash.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Utility/Profiler/ProfilerCPU.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Core/Log.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Core/Assert.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Core/Parallel/Lock.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Core/Parallel/Async/WorkStealThreadPool.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Core/Parallel/Async/WorkStealFiberPool.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Core/Encrypt/RSA.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Core/Compress/Zstd.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Core/Mallocator/Mallocator.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Core/Mallocator/_Deprecated/VMMallocator/VMArena.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Private/Core/Mallocator/_Deprecated/VMMallocator/VMHeap.cpp) # add module add_library(Common STATIC ${Common_SRC}) # try unity build message("PyCMake: Common unity build is on") function_unity_build(Common Common_SRC) # Common compile options message("PyCMake: Common compile options") target_compile_options(Common PUBLIC $<$: -Wall -Wextra -pedantic -Werror> $<$:-Wall -Wextra -pedantic -Werror -Wunused-variable -Wconversion -Weverything> $<$:-Wno-padded -Wno-gnu-zero-variadic-macro-arguments -Wno-reserved-identifier -Wno-exit-time-destructors -Wno-global-constructors -Wno-c++98-compat-pedantic -Wno-float-equal -Wno-covered-switch-default -Wno-c++20-compat> $<$:-Wno-error=global-constructors -Wno-error=exit-time-destructors -Wno-error=unsafe-buffer-usage -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=unused-member-function>) # Common include dir message("PyCMake: Common include dir") target_include_directories(Common PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/Public) # Common pch files message("PyCMake: Common pch files") target_precompile_headers(Common PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/Public/Common.shared.pch) #################################################################### # Begin fetch packages include(FetchContent) Set(FETCHCONTENT_QUIET FALSE) set(YLT_ENABLE_PMR_old f'${YLT_ENABLE_PMR}') set(YLT_ENABLE_PMR ON) set(IGUANA_ENABLE_PMR_old f'${IGUANA_ENABLE_PMR}') set(IGUANA_ENABLE_PMR ON) set(YLT_ENABLE_STRUCT_PACK_OPTIMIZE_old f'${YLT_ENABLE_STRUCT_PACK_OPTIMIZE}') set(YLT_ENABLE_STRUCT_PACK_OPTIMIZE ON) # Fetch yalantinglibs message("PyCMake: fetching yalantinglibs") FetchContent_Declare(yalantinglibs GIT_REPOSITORY https://github.com/yhyu13/yalantinglibs.git GIT_TAG abf6016a8f7841d29303ef68f118ea85b69a1051 GIT_SHALLOW 1 # optional ( --depth=1 ) GIT_PROGRESS TRUE SYSTEM # optional, the include directory will be treated as system directory ) FetchContent_MakeAvailable(yalantinglibs) set(YLT_ENABLE_PMR f'${YLT_ENABLE_PMR_old}') unset(YLT_ENABLE_PMRold) set(IGUANA_ENABLE_PMR f'${IGUANA_ENABLE_PMR_old}') unset(IGUANA_ENABLE_PMRold) set(YLT_ENABLE_STRUCT_PACK_OPTIMIZE f'${YLT_ENABLE_STRUCT_PACK_OPTIMIZE_old}') unset(YLT_ENABLE_STRUCT_PACK_OPTIMIZEold) # Fetch parallel-hashmap message("PyCMake: fetching parallel-hashmap") FetchContent_Declare(parallel-hashmap GIT_REPOSITORY https://github.com/yhyu13/parallel-hashmap.git GIT_TAG 67c24619e4f5ab2097b74cc397732c17a25d6944 GIT_SHALLOW 1 # optional ( --depth=1 ) GIT_PROGRESS TRUE SYSTEM # optional, the include directory will be treated as system directory ) FetchContent_MakeAvailable(parallel-hashmap) # Fetch ctre message("PyCMake: fetching ctre") FetchContent_Declare(ctre GIT_REPOSITORY https://github.com/yhyu13/compile-time-regular-expressions.git GIT_TAG 9725886582a928491a086bba1c07909b2e583157 GIT_SHALLOW 1 # optional ( --depth=1 ) GIT_PROGRESS TRUE SYSTEM # optional, the include directory will be treated as system directory ) FetchContent_MakeAvailable(ctre) set(TRACY_ONLY_LOCALHOST_old f'${TRACY_ONLY_LOCALHOST}') set(TRACY_ONLY_LOCALHOST ON) set(TRACY_NO_FRAME_IMAGE_old f'${TRACY_NO_FRAME_IMAGE}') set(TRACY_NO_FRAME_IMAGE ON) set(TRACY_ONLY_IPV4_old f'${TRACY_ONLY_IPV4}') set(TRACY_ONLY_IPV4 ON) set(TRACY_USE_RPMALLOC_old f'${TRACY_USE_RPMALLOC}') set(TRACY_USE_RPMALLOC ON) set(TRACY_NO_EXIT_old f'${TRACY_NO_EXIT}') set(TRACY_NO_EXIT OFF) set(TRACY_LIBBACKTRACE_ELF_DYNLOAD_SUPPORT_old f'${TRACY_LIBBACKTRACE_ELF_DYNLOAD_SUPPORT}') set(TRACY_LIBBACKTRACE_ELF_DYNLOAD_SUPPORT ON) # Fetch Tracy message("PyCMake: fetching Tracy") FetchContent_Declare(Tracy GIT_REPOSITORY https://github.com/yhyu13/tracy.git GIT_TAG 58d112e89245ae1d6221aa2a4842e24f56df213d GIT_SHALLOW 1 # optional ( --depth=1 ) GIT_PROGRESS TRUE SYSTEM # optional, the include directory will be treated as system directory ) FetchContent_MakeAvailable(Tracy) set(TRACY_ONLY_LOCALHOST f'${TRACY_ONLY_LOCALHOST_old}') unset(TRACY_ONLY_LOCALHOSTold) set(TRACY_NO_FRAME_IMAGE f'${TRACY_NO_FRAME_IMAGE_old}') unset(TRACY_NO_FRAME_IMAGEold) set(TRACY_ONLY_IPV4 f'${TRACY_ONLY_IPV4_old}') unset(TRACY_ONLY_IPV4old) set(TRACY_USE_RPMALLOC f'${TRACY_USE_RPMALLOC_old}') unset(TRACY_USE_RPMALLOCold) set(TRACY_NO_EXIT f'${TRACY_NO_EXIT_old}') unset(TRACY_NO_EXITold) set(TRACY_LIBBACKTRACE_ELF_DYNLOAD_SUPPORT f'${TRACY_LIBBACKTRACE_ELF_DYNLOAD_SUPPORT_old}') unset(TRACY_LIBBACKTRACE_ELF_DYNLOAD_SUPPORTold) # Finish fetch packages #################################################################### #################################################################### # Begin find packages # Find package spdlog message("PyCMake: Find package spdlog") find_package(spdlog CONFIG REQUIRED ) # Find package mimalloc message("PyCMake: Find package mimalloc") find_package(mimalloc CONFIG REQUIRED ) # Find package magic_enum message("PyCMake: Find package magic_enum") find_package(magic_enum CONFIG REQUIRED ) # Find package Boost message("PyCMake: Find package Boost") find_package(Boost REQUIRED COMPONENTS iostreams filesystem system thread fiber date_time program_options serialization) # Find package Botan message("PyCMake: Find package Botan") find_package(Botan REQUIRED ) # Find package zstd message("PyCMake: Find package zstd") find_package(zstd CONFIG REQUIRED ) # Find package RapidJSON message("PyCMake: Find package RapidJSON") find_package(RapidJSON CONFIG REQUIRED ) # Find package Gperftools message("PyCMake: Find package Gperftools") find_package(Gperftools REQUIRED COMPONENTS profiler) # Find package minitrace message("PyCMake: Find package minitrace") find_package(minitrace CONFIG REQUIRED ) # Find package luajit message("PyCMake: Find package luajit") find_package(luajit REQUIRED ) # Find package sol2 message("PyCMake: Find package sol2") find_package(sol2 CONFIG REQUIRED ) # Find package Taskflow message("PyCMake: Find package Taskflow") find_package(Taskflow CONFIG REQUIRED ) # Finish find packages #################################################################### # Common include dir message("PyCMake: Common include dir") target_include_directories(Common PUBLIC ${parallel-hashmap_SOURCE_DIR}) target_include_directories(Common PUBLIC ${Boost_INCLUDE_DIRS}) # Common link dir message("PyCMake: Common link dir") target_link_directories(Common PUBLIC ${Boost_LIBRARY_DIRS}) # Common link libs message("PyCMake: Common link libs") target_link_libraries(Common PUBLIC yalantinglibs::yalantinglibs) target_link_libraries(Common PUBLIC ctre::ctre) target_link_libraries(Common PUBLIC Tracy::TracyClient) target_link_libraries(Common PUBLIC spdlog::spdlog) target_link_libraries(Common PUBLIC mimalloc-static) target_link_libraries(Common PUBLIC magic_enum::magic_enum) target_link_libraries(Common PUBLIC ${Boost_LIBRARIES} backtrace) target_link_libraries(Common PUBLIC Botan::Botan) target_link_libraries(Common PUBLIC zstd::libzstd_static) target_link_libraries(Common PUBLIC rapidjson) target_link_libraries(Common PUBLIC ${GPERFTOOLS_LIBRARIES}) target_link_libraries(Common PUBLIC minitrace::minitrace) target_link_libraries(Common PUBLIC luajit::luajit) target_link_libraries(Common PUBLIC sol2) target_link_libraries(Common PUBLIC Taskflow::Taskflow) # set source files set(TestSol2_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Test/TestSol2.cpp) # add exe and test function_build_and_test_executable(${TestSol2_SRC}) # try unity build message("PyCMake: TestSol2 unity build is off") # TestSol2 link libs message("PyCMake: TestSol2 link libs") target_link_libraries(TestSol2 PRIVATE Common) # TestSol2 pch files message("PyCMake: TestSol2 pch files") target_precompile_headers(TestSol2 REUSE_FROM Common) # set source files set(TestFileSystem_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Test/TestFileSystem.cpp) # add exe and test function_build_and_test_executable(${TestFileSystem_SRC}) # try unity build message("PyCMake: TestFileSystem unity build is off") # TestFileSystem link libs message("PyCMake: TestFileSystem link libs") target_link_libraries(TestFileSystem PRIVATE Common) # TestFileSystem pch files message("PyCMake: TestFileSystem pch files") target_precompile_headers(TestFileSystem REUSE_FROM Common) # set source files set(TestSerialization_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Test/TestSerialization.cpp) # add exe and test function_build_and_test_executable(${TestSerialization_SRC}) # try unity build message("PyCMake: TestSerialization unity build is off") # TestSerialization link libs message("PyCMake: TestSerialization link libs") target_link_libraries(TestSerialization PRIVATE Common) # TestSerialization pch files message("PyCMake: TestSerialization pch files") target_precompile_headers(TestSerialization REUSE_FROM Common) # set source files set(TestMallocator_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Test/TestMallocator.cpp) # add exe and test function_build_and_test_executable(${TestMallocator_SRC}) # try unity build message("PyCMake: TestMallocator unity build is off") # TestMallocator link libs message("PyCMake: TestMallocator link libs") target_link_libraries(TestMallocator PRIVATE Common) # TestMallocator pch files message("PyCMake: TestMallocator pch files") target_precompile_headers(TestMallocator REUSE_FROM Common) # set source files set(TestException_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Test/TestException.cpp) # add exe and test function_build_and_test_executable(${TestException_SRC}) # try unity build message("PyCMake: TestException unity build is off") # TestException link libs message("PyCMake: TestException link libs") target_link_libraries(TestException PRIVATE Common) # TestException pch files message("PyCMake: TestException pch files") target_precompile_headers(TestException REUSE_FROM Common) # set source files set(TestUtility_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Test/TestUtility.cpp) # add exe and test function_build_and_test_executable(${TestUtility_SRC}) # try unity build message("PyCMake: TestUtility unity build is off") # TestUtility link libs message("PyCMake: TestUtility link libs") target_link_libraries(TestUtility PRIVATE Common) # TestUtility pch files message("PyCMake: TestUtility pch files") target_precompile_headers(TestUtility REUSE_FROM Common) # set source files set(TestLogger_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Test/TestLogger.cpp) # add exe and test function_build_and_test_executable(${TestLogger_SRC}) # try unity build message("PyCMake: TestLogger unity build is off") # TestLogger link libs message("PyCMake: TestLogger link libs") target_link_libraries(TestLogger PRIVATE Common) # TestLogger pch files message("PyCMake: TestLogger pch files") target_precompile_headers(TestLogger REUSE_FROM Common) # set source files set(TestLuajit_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Test/TestLuajit.cpp) # add exe and test function_build_and_test_executable(${TestLuajit_SRC}) # try unity build message("PyCMake: TestLuajit unity build is off") # TestLuajit link libs message("PyCMake: TestLuajit link libs") target_link_libraries(TestLuajit PRIVATE Common) # TestLuajit pch files message("PyCMake: TestLuajit pch files") target_precompile_headers(TestLuajit REUSE_FROM Common) # set source files set(TestParallel_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Test/TestParallel.cpp) # add exe and test function_build_and_test_executable(${TestParallel_SRC}) # try unity build message("PyCMake: TestParallel unity build is off") # TestParallel link libs message("PyCMake: TestParallel link libs") target_link_libraries(TestParallel PRIVATE Common) # TestParallel pch files message("PyCMake: TestParallel pch files") target_precompile_headers(TestParallel REUSE_FROM Common) # set source files set(TestString_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Test/TestString.cpp) # add exe and test function_build_and_test_executable(${TestString_SRC}) # try unity build message("PyCMake: TestString unity build is off") # TestString link libs message("PyCMake: TestString link libs") target_link_libraries(TestString PRIVATE Common) # TestString pch files message("PyCMake: TestString pch files") target_precompile_headers(TestString REUSE_FROM Common) # set source files set(Test3rdParty_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Test/Test3rdParty.cpp) # add exe and test function_build_and_test_executable(${Test3rdParty_SRC}) # try unity build message("PyCMake: Test3rdParty unity build is off") # Test3rdParty link libs message("PyCMake: Test3rdParty link libs") target_link_libraries(Test3rdParty PRIVATE Common) # Test3rdParty pch files message("PyCMake: Test3rdParty pch files") target_precompile_headers(Test3rdParty REUSE_FROM Common) # set source files set(TestTaskFlow_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Test/TestTaskFlow.cpp) # add exe and test function_build_and_test_executable(${TestTaskFlow_SRC}) # try unity build message("PyCMake: TestTaskFlow unity build is off") # TestTaskFlow link libs message("PyCMake: TestTaskFlow link libs") target_link_libraries(TestTaskFlow PRIVATE Common) # TestTaskFlow pch files message("PyCMake: TestTaskFlow pch files") target_precompile_headers(TestTaskFlow REUSE_FROM Common) # End Module #################################################################### ``` and Engine/Source/Common/vcpkg.json: ``` { "name": "common", "version": "0.2.1", "dependencies": [ "spdlog", { "name": "mimalloc", "features": [ "asm", "secure" ], "default-features": false }, "magic-enum", "boost", "libbacktrace", "zstd", "botan", "rapidjson", "gperftools", "minitrace", { "name": "luajit", "features": [ "buildvm-64" ], "default-features": true }, "sol2", "pybind11", "taskflow", { "name": "bitserializer", "features": [ "rapidjson-archive", "msgpack-archive" ], "default-features": true } ] } ```