Skip to content

Commit

Permalink
fix: comp error on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
mhduiy committed Dec 29, 2024
1 parent a0ffe14 commit 82eb881
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ add_subdirectory(${CMAKE_SOURCE_DIR}/src/cpp/settingPageTool)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/cpp/utils)

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
message("Enable Qml Debug")
target_compile_definitions(${EXE_NAME} PRIVATE QT_QML_DEBUG)
endif()

Expand Down
12 changes: 7 additions & 5 deletions src/cpp/imagePageTool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ set(QSC_DEPLOY_PATH ${CMAKE_BINARY_DIR}/lib)

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/scrcpy/core)

# ffmpeg
set(FFMPEG_PATH "F:\\Soft\\libffmpeg_7.1_msvc17_x64")
target_include_directories(${EXE_NAME} PRIVATE ${FFMPEG_PATH}\\include)
target_link_directories(${EXE_NAME} PRIVATE ${FFMPEG_PATH}\\lib)

find_program(ADB_PATH adb)
if(ADB_PATH)
message(STATUS "Found adb at: ${ADB_PATH}")
target_compile_definitions(${EXE_NAME} PRIVATE ADB_PATH="${ADB_PATH}")
else()
message(FATAL_ERROR "adb not found on your system")
endif()

if(ADB_PATH)
add_definitions(-DADB_PATH="${ADB_PATH}")
endif()

# MacOS
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
find_package(PkgConfig REQUIRED)
Expand All @@ -33,4 +35,4 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
target_link_directories(${EXE_NAME} PRIVATE ${FFMPEG_LIBRARY_DIRS})

target_link_libraries(${EXE_NAME} PRIVATE ${FFMPEG_LIBRARIES})
endif()
endif()
16 changes: 11 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,28 @@

bool checkADB() {
QProcess process;
QString trueADBPath;

if (QSysInfo::productType() == "windows") {
process.start("where", {"adb"});
} else {
process.start("which", {"adb"});
}
process.waitForFinished();
QString output = process.readAll().simplified();

if (!output.isEmpty() && QFile::exists(output)) {
qInfo() << "find adb: " << output;

qputenv("QTSCRCPY_ADB_PATH", output.toLocal8Bit());
if (!output.isEmpty() && QFile::exists(output)) {
trueADBPath = output;
} else {
trueADBPath = ADB_PATH;
}

if (!trueADBPath.isEmpty()) {
qInfo() << "find adb: " << trueADBPath;
qputenv("QTSCRCPY_ADB_PATH", trueADBPath.toLocal8Bit());
return true;
}

qWarning() << "can not fount adb!";
return false;
}
Expand Down

0 comments on commit 82eb881

Please sign in to comment.