V1 (#2)
Some checks failed
Conan Packaging / Package Bin2CPP/1.0.0 (push) Has been cancelled
Bin2CPP / Build & Test Debug with ./ConanProfiles/clangd (Unity Build: OFF) (push) Has been cancelled
Bin2CPP / Build & Test Debug with ./ConanProfiles/clangd (Unity Build: ON) (push) Has been cancelled
Bin2CPP / Build & Test Debug with ./ConanProfiles/clangd_asan (Unity Build: OFF) (push) Has been cancelled
Bin2CPP / Build & Test Debug with ./ConanProfiles/clangd_asan (Unity Build: ON) (push) Has been cancelled
Bin2CPP / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: OFF) (push) Has been cancelled
Bin2CPP / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: ON) (push) Has been cancelled
Bin2CPP / Build & Test RelWithDebInfo with ./ConanProfiles/clangd (Unity Build: OFF) (push) Has been cancelled
Bin2CPP / Build & Test RelWithDebInfo with ./ConanProfiles/clangd (Unity Build: ON) (push) Has been cancelled
Bin2CPP / Build & Test RelWithDebInfo with ./ConanProfiles/clangd_asan (Unity Build: OFF) (push) Has been cancelled
Bin2CPP / Build & Test Release with ./ConanProfiles/clangd (Unity Build: ON) (push) Has been cancelled
Bin2CPP / Build & Test Release with ./ConanProfiles/clangd_asan (Unity Build: OFF) (push) Has been cancelled
Bin2CPP / Build & Test Debug with ./ConanProfiles/clang (Unity Build: ON) (push) Has been cancelled
Bin2CPP / Build & Test RelWithDebInfo with ./ConanProfiles/clangd_asan (Unity Build: ON) (push) Has been cancelled
Bin2CPP / Build & Test Release with ./ConanProfiles/clang (Unity Build: OFF) (push) Has been cancelled
Bin2CPP / Build & Test Release with ./ConanProfiles/clang (Unity Build: ON) (push) Has been cancelled
Bin2CPP / Build & Test Release with ./ConanProfiles/clangd (Unity Build: OFF) (push) Has been cancelled
Bin2CPP / Build & Test Release with ./ConanProfiles/clangd_asan (Unity Build: ON) (push) Has been cancelled
Bin2CPP / Clang Format Checks (push) Has been cancelled
Bin2CPP / Build & Test Debug with ./ConanProfiles/clang (Unity Build: OFF) (push) Has been cancelled
Bin2CPP / Sonarqube (push) Has been cancelled

Reviewed-on: #2
Co-authored-by: Romain BOULLARD <romain.boullard@protonmail.com>
Co-committed-by: Romain BOULLARD <romain.boullard@protonmail.com>
This commit was merged in pull request #2.
This commit is contained in:
2026-03-29 09:30:59 +00:00
committed by Romain BOULLARD
parent 1f61574360
commit a116731e46
45 changed files with 1848 additions and 950 deletions

View File

@@ -0,0 +1,23 @@
if(NOT TARGET Bin2CPP)
if(CMAKE_CROSSCOMPILING)
find_program(BIN2CPP_EXECUTABLE
NAMES Bin2CPP
PATHS ENV PATH
NO_DEFAULT_PATH
)
else()
find_program(BIN2CPP_EXECUTABLE
NAMES Bin2CPP
PATHS "${CMAKE_CURRENT_LIST_DIR}"
NO_DEFAULT_PATH
)
endif()
if(BIN2CPP_EXECUTABLE)
get_filename_component(BIN2CPP_EXECUTABLE "${BIN2CPP_EXECUTABLE}" ABSOLUTE)
add_executable(Bin2CPP IMPORTED)
set_property(TARGET Bin2CPP PROPERTY IMPORTED_LOCATION ${BIN2CPP_EXECUTABLE})
else()
message(WARNING "Bin2CPP executable not found in ${CMAKE_CURRENT_LIST_DIR}")
endif()
endif()

32
CMake/CustomTargets.cmake Normal file
View File

@@ -0,0 +1,32 @@
foreach(CONFIG DEBUG RELWITHDEBINFO)
if("${CMAKE_EXE_LINKER_FLAGS_${CONFIG}}" MATCHES "/INCREMENTAL:NO")
string(REGEX REPLACE "/INCREMENTAL([^:]|$)" ""
CMAKE_EXE_LINKER_FLAGS_${CONFIG}
"${CMAKE_EXE_LINKER_FLAGS_${CONFIG}}")
endif()
if("${CMAKE_SHARED_LINKER_FLAGS_${CONFIG}}" MATCHES "/INCREMENTAL:NO")
string(REGEX REPLACE "/INCREMENTAL([^:]|$)" ""
CMAKE_SHARED_LINKER_FLAGS_${CONFIG}
"${CMAKE_SHARED_LINKER_FLAGS_${CONFIG}}")
endif()
endforeach()
add_library(Bin2CPPCompileAndLinkFlags INTERFACE)
target_compile_options(Bin2CPPCompileAndLinkFlags INTERFACE
$<$<CXX_COMPILER_ID:MSVC>:/W4 /WX>
$<$<CXX_COMPILER_ID:Clang,GNU>:-Wall -Wextra -Wpedantic -Werror>
$<$<AND:$<BOOL:${COVERAGE}>,$<CXX_COMPILER_ID:Clang>>:-fprofile-instr-generate -fcoverage-mapping>
)
target_link_options(Bin2CPPCompileAndLinkFlags INTERFACE
$<$<AND:$<BOOL:${COVERAGE}>,$<CXX_COMPILER_ID:Clang>>:-fprofile-instr-generate>
)
target_compile_definitions(Bin2CPPCompileAndLinkFlags INTERFACE
$<$<CONFIG:Release>:BIN2CPP_OPTIMIZED>
$<$<CONFIG:Debug,RelWithDebInfo>:BIN2CPP_NOT_OPTIMIZED>
$<$<PLATFORM_ID:Windows>:BIN2CPP_WINDOWS>
$<$<PLATFORM_ID:Linux>:BIN2CPP_LINUX>
$<$<PLATFORM_ID:Windows>:NOMINMAX>
$<$<PLATFORM_ID:Windows>:WIN32_LEAN_AND_MEAN>)

View File

@@ -5,18 +5,18 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
find_package(Threads REQUIRED)
endif()
find_package(EASTL REQUIRED)
find_package(mimalloc REQUIRED)
find_package(magic_enum REQUIRED)
find_package(CLI11 REQUIRED)
find_package(rapidhash REQUIRED)
find_package(quill REQUIRED)
if(${IS_MULTI_CONFIG})
find_package(cpptrace REQUIRED)
elseif(${CMAKE_BUILD_TYPE} STREQUAL "Debug" OR ${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo")
find_package(cpptrace REQUIRED)
if(${ASAN})
find_package(mimalloc-asan REQUIRED)
else()
find_package(mimalloc REQUIRED)
endif()
find_package(cpptrace REQUIRED)
if(BUILD_TESTS)
find_package(GTest REQUIRED)
endif()

View File

@@ -1,58 +0,0 @@
function(bin2cpp_setup_dependencies ParentFolder)
set(CONAN_DEPLOYER_DIR "${CMAKE_SOURCE_DIR}/build/full_deploy/host")
if(EXISTS ${CONAN_DEPLOYER_DIR})
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
file(GLOB_RECURSE SHARED_BINARIES ${CONAN_DEPLOYER_DIR}/*mimalloc*.dll)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
file(GLOB_RECURSE SHARED_BINARIES ${CONAN_DEPLOYER_DIR}/*mimalloc*.so*)
endif()
if(${IS_MULTI_CONFIG})
foreach(CONFIG ${CMAKE_CONFIGURATION_TYPES})
foreach(file ${SHARED_BINARIES})
if(file MATCHES "/${CONFIG}/")
list(APPEND SHARED_BINARIES_${CONFIG} ${file})
endif()
endforeach()
endforeach()
add_custom_target(${PROJECT_NAME}CopySharedBinaries
ALL DEPENDS SHARED_BINARIES
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:${PROJECT_NAME}>
COMMAND ${CMAKE_COMMAND} -E $<IF:$<CONFIG:Debug>,copy_if_different,true> ${SHARED_BINARIES_Debug} $<TARGET_FILE_DIR:${PROJECT_NAME}>
COMMAND ${CMAKE_COMMAND} -E $<IF:$<CONFIG:Release>,copy_if_different,true> ${SHARED_BINARIES_Release} $<TARGET_FILE_DIR:${PROJECT_NAME}>
COMMAND ${CMAKE_COMMAND} -E $<IF:$<CONFIG:RelWithDebInfo>,copy_if_different,true> ${SHARED_BINARIES_RelWithDebInfo} $<TARGET_FILE_DIR:${PROJECT_NAME}>
COMMENT "Copy shared binaries for ${PROJECT_NAME}"
)
add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}CopySharedBinaries)
set_target_properties(${PROJECT_NAME}CopySharedBinaries PROPERTIES FOLDER UtilityTargets/${ParentFolder})
else()
foreach(file ${SHARED_BINARIES})
if(file MATCHES "/${CMAKE_BUILD_TYPE}/")
list(APPEND SHARED_BINARIES_${CMAKE_BUILD_TYPE} ${file})
endif()
endforeach()
add_custom_target(${PROJECT_NAME}CopySharedBinaries ALL
DEPENDS ${SHARED_BINARIES_${CMAKE_BUILD_TYPE}}
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:${PROJECT_NAME}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SHARED_BINARIES_${CMAKE_BUILD_TYPE}} $<TARGET_FILE_DIR:${PROJECT_NAME}>
COMMENT "Copy shared binaries for ${PROJECT_NAME}"
)
add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}CopySharedBinaries)
set_target_properties(${PROJECT_NAME}CopySharedBinaries PROPERTIES FOLDER UtilityTargets/${ParentFolder})
endif()
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
add_custom_target(${PROJECT_NAME}PatchMinject ALL
COMMAND ${MINJECT_EXECUTABLE} -i -f $<TARGET_FILE:${PROJECT_NAME}>
COMMENT "Patching ${PROJECT_NAME} to ensure mimalloc dynamic override"
)
add_dependencies(${PROJECT_NAME}PatchMinject ${PROJECT_NAME})
set_target_properties(${PROJECT_NAME}PatchMinject PROPERTIES FOLDER "UtilityTargets/${ParentFolder}")
endif()
endfunction()