cmake: Add support for using c++ bin2cpp instead of perl

This commit is contained in:
TellowKrinkle 2021-08-02 01:55:11 -05:00 committed by Kojin
parent 122de7a7d7
commit 284ca6ae68
4 changed files with 18 additions and 45 deletions

View File

@ -19,6 +19,13 @@ option(DISABLE_BUILD_DATE "Disable including the binary compile date")
option(ENABLE_TESTS "Enables building the unit tests" ON)
option(USE_SYSTEM_YAML "Uses a system version of yaml, if found")
if(WIN32)
set(DEFAULT_NATIVE_TOOLS ON)
else()
set(DEFAULT_NATIVE_TOOLS OFF)
endif()
option(USE_NATIVE_TOOLS "Uses c++ tools instead of ones written in scripting languages. OFF requires perl, ON may fail if cross compiling" ${DEFAULT_NATIVE_TOOLS})
if(DISABLE_BUILD_DATE OR openSUSE)
message(STATUS "Disabling the inclusion of the binary compile date.")
list(APPEND PCSX2_DEFS DISABLE_BUILD_DATE)

View File

@ -224,3 +224,10 @@ if(NOT USE_SYSTEM_YAML)
endif()
add_subdirectory(3rdparty/libchdr/libchdr EXCLUDE_FROM_ALL)
if(USE_NATIVE_TOOLS)
add_subdirectory(tools/bin2cpp EXCLUDE_FROM_ALL)
set(BIN2CPP bin2cpp)
else()
set(BIN2CPP perl ${CMAKE_SOURCE_DIR}/linux_various/hex2h.pl)
endif()

View File

@ -499,7 +499,7 @@ foreach(result_file IN ITEMS
arrow_bottom arrow_left arrow_right)
add_custom_command(
OUTPUT "${PADImgHeader}/${result_file}.h"
COMMAND perl ${CMAKE_SOURCE_DIR}/linux_various/hex2h.pl "${PADImg}/${result_file}.png" "${PADImgHeader}/${result_file}" )
COMMAND ${BIN2CPP} "${PADImg}/${result_file}.png" "${PADImgHeader}/${result_file}" )
endforeach()
add_custom_command(
@ -1268,7 +1268,7 @@ foreach(res_file IN ITEMS
AppIcon16 AppIcon32 AppIcon64 BackgroundLogo Logo NoIcon ButtonIcon_Camera
ConfigIcon_Cpu ConfigIcon_Gamefixes ConfigIcon_MemoryCard
ConfigIcon_Paths ConfigIcon_Speedhacks ConfigIcon_Video Breakpoint_Active Breakpoint_Inactive)
add_custom_command(OUTPUT "${res_bin}/${res_file}.h" COMMAND perl ${CMAKE_SOURCE_DIR}/linux_various/hex2h.pl "${res_src}/${res_file}.png" "${res_bin}/${res_file}" )
add_custom_command(OUTPUT "${res_bin}/${res_file}.h" COMMAND ${BIN2CPP} "${res_src}/${res_file}.png" "${res_bin}/${res_file}" )
endforeach()
### Generate Recording resource files
@ -1276,7 +1276,7 @@ endforeach()
foreach(res_file IN ITEMS
circlePressed controllerFull controllerHalf controllerThreeQuarters crossPressed downPressed l1Pressed l2Pressed l3Pressed leftPressed
r1Pressed r2Pressed r3Pressed rightPressed selectPressed squarePressed startPressed trianglePressed upPressed)
add_custom_command(OUTPUT "${res_rec_vp_src}/${res_file}.h" COMMAND perl ${CMAKE_SOURCE_DIR}/linux_various/hex2h.pl "${res_rec_vp_src}/${res_file}.png" "${res_rec_vp_src}/${res_file}" )
add_custom_command(OUTPUT "${res_rec_vp_src}/${res_file}.h" COMMAND ${BIN2CPP} "${res_rec_vp_src}/${res_file}.png" "${res_rec_vp_src}/${res_file}" )
endforeach()
if(USE_VTUNE)

View File

@ -1,47 +1,6 @@
# bin2cpp tool
# executable name
set(bin2cppName bin2cpp)
# Debug - Build
if(CMAKE_BUILD_TYPE STREQUAL Debug)
# add defines
set(bin2cppFinalFlags
-s -Wall -fexceptions
)
endif(CMAKE_BUILD_TYPE STREQUAL Debug)
# Devel - Build
if(CMAKE_BUILD_TYPE STREQUAL Devel)
# add defines
set(bin2cppFinalFlags
-s -Wall -fexceptions
)
endif(CMAKE_BUILD_TYPE STREQUAL Devel)
# Release - Build
if(CMAKE_BUILD_TYPE STREQUAL Release)
# add defines
set(bin2cppFinalFlags
-s -Wall -fexceptions
)
endif(CMAKE_BUILD_TYPE STREQUAL Release)
# variable with all sources of this executable
set(bin2cppSources
bin2cpp.cpp)
set(bin2cppHeaders
)
# add executable
set(bin2cppFinalSources
${bin2cppSources}
${bin2cppHeaders}
)
add_pcsx2_executable(${bin2cppName} "${bin2cppFinalSources}" "" "${bin2cppFinalFlags}")
add_executable(bin2cpp bin2cpp.cpp)
# set output directory
# set_target_properties(${bin2cppName} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/tools/bin)