diff --git a/CMakeLists.txt b/CMakeLists.txt index ac989b5a2..bafcacfb1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,8 @@ include(${PROJECT_SOURCE_DIR}/cmake/config.cmake) include(${PROJECT_SOURCE_DIR}/cmake/utils.cmake) include(${PROJECT_SOURCE_DIR}/cmake/version.cmake) # include(${PROJECT_SOURCE_DIR}/cmake/nuget.cmake) -if(WITH_THRIFT) + +if(WITH_THRIFT AND NOT MAA_CROSSCOMPILE) include(${PROJECT_SOURCE_DIR}/cmake/thrift-gen.cmake) endif() if(WITH_GRPC) @@ -34,7 +35,7 @@ find_package(Boost REQUIRED COMPONENTS system) find_package(ZLIB REQUIRED) find_package(fastdeploy_ppocr REQUIRED) find_package(ONNXRuntime) -if(WITH_THRIFT) +if(WITH_THRIFT AND NOT MAA_CROSSCOMPILE) find_package(Thrift CONFIG REQUIRED) endif() if(WITH_GRPC) diff --git a/cmake/thrift-gen.cmake b/cmake/thrift-gen.cmake index 60799fc80..f795df4ee 100644 --- a/cmake/thrift-gen.cmake +++ b/cmake/thrift-gen.cmake @@ -6,7 +6,7 @@ macro(GENERATE_THRIFT_LIB LIB_NAME FILENAME OUTPUTDIR SOURCES) execute_process(COMMAND ${THRIFT_COMPILER} --gen cpp:no_skeleton -out ${OUTPUTDIR} ${FILENAME} RESULT_VARIABLE CMD_RESULT) if(CMD_RESULT) - message("Error generating ${FILENAME} with generator ${GENERATOR}") + message(FATAL_ERROR "Error generating ${FILENAME} with generator ${GENERATOR}") endif() file(GLOB_RECURSE GENERATED_SOURCES ${OUTPUTDIR}/*.cpp) add_library(${LIB_NAME} STATIC ${GENERATED_SOURCES}) diff --git a/cmake/utils.cmake b/cmake/utils.cmake index a6d35f388..75db7f20d 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -50,3 +50,9 @@ if(NOT DEFINED MAADEPS_TRIPLET) detect_maadeps_triplet(MAADEPS_TRIPLET) endif() set(MAADEPS_TARGET_TOOLS ${PROJECT_SOURCE_DIR}/MaaDeps/vcpkg/installed/${MAADEPS_TRIPLET}/tools) + +if(maa-${MAADEPS_HOST_TRIPLET} STREQUAL ${MAADEPS_TRIPLET}) + set(MAA_CROSSCOMPILE OFF) +else() + set(MAA_CROSSCOMPILE ON) +endif() diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index eb2e9d399..62ad582ba 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -1,6 +1,6 @@ add_subdirectory(MaaUtils) add_subdirectory(MaaControlUnit) -if(WITH_THRIFT) +if(WITH_THRIFT AND NOT MAA_CROSSCOMPILE) add_subdirectory(MaaThriftController) endif(WITH_THRIFT) if(WITH_GRPC)