diff --git a/.github/workflows/build-qv2ray-cmake.yml b/.github/workflows/build-qv2ray-cmake.yml index e57d6d2b..de2091e5 100644 --- a/.github/workflows/build-qv2ray-cmake.yml +++ b/.github/workflows/build-qv2ray-cmake.yml @@ -88,12 +88,19 @@ jobs: if: matrix.platform == 'windows-latest' run: | curl -o ./libs/Qv2ray-deps-grpc-${{ matrix.arch }}-windows.7z -L https://github.com/Qv2ray/Qv2ray-deps/releases/download/release/Qv2ray-deps-grpc-${{ matrix.arch }}-windows.7z - - name: Win-${{ matrix.arch }} - Build preparation - Extract Dependencies + curl -o ./libs/Qv2ray-deps-libiconv-${{ matrix.arch }}-windows.7z -L https://github.com/Qv2ray/Qv2ray-deps/releases/download/release/Qv2ray-deps-libiconv-${{ matrix.arch }}-windows.7z + - name: Win-${{ matrix.arch }} - gRPC- Build preparation - Extract Dependencies if: matrix.platform == 'windows-latest' uses: DuckSoft/extract-7z-action@v1.0 with: pathSource: ./libs/Qv2ray-deps-grpc-${{ matrix.arch }}-windows.7z pathTarget: ./libs + - name: Win-${{ matrix.arch }} - Iconv- Build preparation - Extract Dependencies + if: matrix.platform == 'windows-latest' + uses: DuckSoft/extract-7z-action@v1.0 + with: + pathSource: ./libs/Qv2ray-deps-libiconv-${{ matrix.arch }}-windows.7z + pathTarget: ./libs # ========================================================================================================= Generate MakeFile and Build - name: macOS - ${{ matrix.qt_version }} - Generate Dependencies and Build shell: bash diff --git a/CMakeLists.txt b/CMakeLists.txt index 30393e3f..2c2480cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,7 @@ message(" ") if(WIN32) add_compile_options("/std:c++17") add_definitions(-D_HAS_STD_BYTE=0 -D_WIN32_WINNT=0x600 -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS) + include(cmake/iconv.cmake) if(NOT DEFINED CMAKE_TOOLCHAIN_FILE) if(CMAKE_CL_64) include(${CMAKE_SOURCE_DIR}/libs/x64-windows/scripts/buildsystems/vcpkg.cmake) @@ -58,20 +59,14 @@ include(cmake/qzxing.cmake) include(cmake/protobuf.cmake) include(cmake/cpp-httplib.cmake) include(cmake/backend.cmake) + if(APPLE) - find_package(Iconv REQUIRED) + include(cmake/iconv.cmake) set(MACOSX_FRAMEWORK "-framework Carbon" "-framework Cocoa" "-framework Security" ) - set(MACOSX_ICONV_LIBRARY - Iconv::Iconv - ) - - set(MACOSX_ICONV_INCLUDE_PATH - ${Iconv_INCLUDE_DIR} - ) endif() if(DEFINED ENV{_QV2RAY_BUILD_INFO_}) @@ -173,7 +168,7 @@ add_executable(${PROJECT_NAME} target_link_libraries(${PROJECT_NAME} ${QT_LIBRARY} ${MACOSX_FRAMEWORK} - ${MACOSX_ICONV_LIBRARY} + ${ICONV_LIBRARY} ${QV2RAY_PROTOBUF_LIBRARY} ${QV2RAY_BACKEND_LIBRARIES} ) @@ -188,7 +183,7 @@ target_include_directories(${PROJECT_NAME} PRIVATE ${QZXING_INCLUDE_PATH} ${SINGLEAPPLICATION_DIR} ${Protobuf_INCLUDE_DIRS} - ${MACOSX_ICONV_INCLUDE_PATH} + ${ICONV_INCLUDE_PATH} ${cpp-httplib_INCLUDE_DIRS} ) diff --git a/cmake/iconv.cmake b/cmake/iconv.cmake new file mode 100644 index 00000000..bf9a6d68 --- /dev/null +++ b/cmake/iconv.cmake @@ -0,0 +1,7 @@ +find_package(Iconv REQUIRED) +set(ICONV_LIBRARY + Iconv::Iconv +) +set(ICONV_INCLUDE_PATH + ${Iconv_INCLUDE_DIR} +) \ No newline at end of file diff --git a/cmake/protobuf.cmake b/cmake/protobuf.cmake index 39573bbd..05d710a2 100644 --- a/cmake/protobuf.cmake +++ b/cmake/protobuf.cmake @@ -1,4 +1,7 @@ find_package(Protobuf REQUIRED) +if(MSVC) + set(Protobuf_USE_STATIC_LIBS ON) +endif() protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${CMAKE_SOURCE_DIR}/tools/v2ray_geosite.proto) set(QV2RAY_PROTOBUF_LIBRARY protobuf::libprotobuf