magiatranslate-client/CMakeLists.txt
segfault-bilibili 2e4f815732
Automatic build with GitHub Actions (#5)
* extract armv7 lib; make build.bat immune to spaced path

* update submodules

1.update dobby to latest:
original commit hash: b0176de574104726bb68dff3b77ee666300fc338
plus compilation error fix

2.update untp to include plistlib fix

* fix build errors

1. define RS_SUCCESS in MagiaClient.cpp,
which was deleted in Dobby f4643b8d14d7cc94516b446ca77d952d0b986d50

2. fix dobby not being statically linked

* terminate build script on error

let build.sh exit on error
let build.bat fail if signing fails

* sign_example.bat: use zipalign and apksigner

* upgrade to apktool 2.7.0; check hash of apktool

* handle fake python3

* control whether to include audiofix

* build.bat: go back to base dir on exit

* update readme

* update suggested ndk path

* build and release with GitHub Actions

* avoid unnecessary rebuild

* remove nodejs dependency

fix Dobby so that we can implement audiofix in MagiaHook again

* automatic build

* update apktool to 2.8.1

* fix max method number exceeded
2023-08-10 20:11:14 +01:00

95 lines
3 KiB
CMake

# CMakeList.txt : CMake project for MagiaClient, include source and define
# project specific logic here.
#
#set(CMAKE_CXX_STANDARD 11)
cmake_minimum_required (VERSION 3.8)
project ("MagiaClient")
set(TARGET_NAME uwasa)
#if (CMAKE_BUILD_TYPE STREQUAL "Debug")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++ -fsanitize=address -fno-omit-frame-pointer")
#else
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
#endif(CMAKE_BUILD_TYPE STREQUAL "Debug")
# Options
set(compile_definitions "")
option(MAGIA_TRANSLATE_AUDIOFIX_3_0_1 "Include audiofix for 3.0.1 and above" ON)
if (MAGIA_TRANSLATE_AUDIOFIX_3_0_1)
set(compile_definitions "${compile_definitions} -DMAGIA_TRANSLATE_AUDIOFIX_3_0_1")
endif ()
message(STATUS "[MagiaClient] MAGIA_TRANSLATE_AUDIOFIX_3_0_1: ${MAGIA_TRANSLATE_AUDIOFIX_3_0_1}")
if(CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fvisibility=hidden -fvisibility-inlines-hidden -g0 -O3 -ffunction-sections -fdata-sections")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fvisibility=hidden -fvisibility-inlines-hidden -g0 -O3 -ffunction-sections -fdata-sections")
endif(CMAKE_BUILD_TYPE STREQUAL "Release")
set(DobbyHome ${CMAKE_CURRENT_SOURCE_DIR}/lib/Dobby)
include_directories(
${DobbyHome}/include
${DobbyHome}/builtin-plugin
${DobbyHome}/builtin-plugin/SymbolResolver
${DobbyHome}/external/logging
${DobbyHome}/source
${CMAKE_CURRENT_SOURCE_DIR}/lib
${CMAKE_CURRENT_SOURCE_DIR}/lib/cocos
${CMAKE_CURRENT_SOURCE_DIR}/abiproxy/src
)
include(FetchContent)
FetchContent_Declare(json
GIT_REPOSITORY https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent
GIT_TAG v3.9.1)
FetchContent_GetProperties(json)
if(NOT json_POPULATED)
FetchContent_Populate(json)
add_subdirectory(${json_SOURCE_DIR} ${json_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Release")
link_libraries("-Wl,--strip-all")
endif(CMAKE_BUILD_TYPE STREQUAL "Release")
add_library( # Sets the name of the library.
${TARGET_NAME}
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
"lib/cocos/math/CCGeometry.cpp"
"lib/cocos/math/Vec2.cpp"
"src/MagiaClient.cpp"
"src/Utils.cpp"
"src/rest/MagiaRest.cpp"
)
target_compile_definitions(${TARGET_NAME} PRIVATE "COMPILE_DEFINITIONS ${compile_definitions}")
find_library(ANDROID_LOG_LIB log)
target_link_libraries(${TARGET_NAME} PRIVATE ${ANDROID_LOG_LIB})
target_link_libraries(${TARGET_NAME} PRIVATE dobby_static)
target_link_libraries(${TARGET_NAME} PRIVATE nlohmann_json::nlohmann_json)
macro(SET_OPTION option value)
set(${option} ${value} CACHE INTERNAL "" FORCE)
endmacro()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
SET_OPTION(DOBBY_DEBUG ON)
endif(CMAKE_BUILD_TYPE STREQUAL "Debug")
SET_OPTION(DOBBY_GENERATE_SHARED OFF)
SET_OPTION(DynamicBinaryInstrument ON)
SET_OPTION(NearBranch ON)
SET_OPTION(Plugin.SymbolResolver ON)
add_subdirectory(${DobbyHome} dobby)