diff --git a/.github/workflows/build-qv2ray-cmake.yml b/.github/workflows/build-qv2ray-cmake.yml index e3c51e4e..ac2dd79d 100644 --- a/.github/workflows/build-qv2ray-cmake.yml +++ b/.github/workflows/build-qv2ray-cmake.yml @@ -107,20 +107,10 @@ jobs: shell: bash if: matrix.platform == 'windows-latest' run: | - curl -o ./libs/grpc-${{ matrix.arch }}-windows.7z -L https://github.com/Qv2ray/Qv2ray-deps/releases/download/release/grpc-${{ matrix.arch }}-windows.7z - curl -o ./libs/curl-${{ matrix.arch }}-windows.7z -L https://github.com/Qv2ray/Qv2ray-deps/releases/download/release/curl-${{ matrix.arch }}-windows.7z - - name: Win-${{ matrix.arch }} - Build preparation - Extract Dependencies - if: matrix.platform == 'windows-latest' - uses: DuckSoft/extract-7z-action@v1.0 - with: - pathSource: ./libs/grpc-${{ matrix.arch }}-windows.7z - pathTarget: ./libs - - name: Win-${{ matrix.arch }} - Build preparation - Extract Dependencies - if: matrix.platform == 'windows-latest' - uses: DuckSoft/extract-7z-action@v1.0 - with: - pathSource: ./libs/curl-${{ matrix.arch }}-windows.7z - pathTarget: ./libs + cd ./libs + export QV2RAY_LIBS=windows + export QV2RAY_LIBS_ARCH=${{ matrix.arch }} + ./setup-libs.sh # ========================================================================================================= Generate MakeFile and Build - uses: actions/setup-node@v1 @@ -154,6 +144,7 @@ jobs: cmake .. -GNinja -DCMAKE_INSTALL_PREFIX=./deployment -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} cmake --build . --parallel $(nproc) cmake --install . + cp -v ./*.pdb ./deployment || true # -------------------------------------------------------- - name: Linux - ${{ matrix.qt_version }} - Generate Dependencies and Build if: matrix.platform == 'ubuntu-16.04' diff --git a/.github/workflows/nsis.yml b/.github/workflows/nsis.yml index 5d286029..4e1457cc 100644 --- a/.github/workflows/nsis.yml +++ b/.github/workflows/nsis.yml @@ -83,18 +83,10 @@ jobs: - name: Win-${{ matrix.arch }} - ${{ matrix.qt_version }} - Build preparation - Download Dependencies shell: bash run: | - curl -o ./libs/grpc-${{ matrix.arch }}-windows.7z -L https://github.com/Qv2ray/Qv2ray-deps/releases/download/release/grpc-${{ matrix.arch }}-windows.7z - curl -o ./libs/curl-${{ matrix.arch }}-windows.7z -L https://github.com/Qv2ray/Qv2ray-deps/releases/download/release/curl-${{ matrix.arch }}-windows.7z - - name: Win-${{ matrix.arch }} - Build preparation - Extract Dependencies - uses: DuckSoft/extract-7z-action@v1.0 - with: - pathSource: ./libs/grpc-${{ matrix.arch }}-windows.7z - pathTarget: ./libs - - name: Win-${{ matrix.arch }} - Build preparation - Extract Dependencies - uses: DuckSoft/extract-7z-action@v1.0 - with: - pathSource: ./libs/curl-${{ matrix.arch }}-windows.7z - pathTarget: ./libs + cd libs + export QV2RAY_LIBS=windows + export QV2RAY_LIBS_ARCH=${{ matrix.arch }} + ./setup-libs.sh # ========================================================================================================= Generate MakeFile and Build - name: Win-${{ matrix.arch }} - ${{ matrix.qt_version }} - Generate Dependencies and Build shell: bash diff --git a/CMakeLists.txt b/CMakeLists.txt index 064a1ee7..305d7635 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,37 @@ if(ANDROID) set(ANDROID_PACKAGE_SOURCE ${CMAKE_SOURCE_DIR}/assets/android) set(QT_ANDROID_PACKAGE_SOURCE_DIR "\"android-package-source-directory\":\"${ANDROID_PACKAGE_SOURCE}\",") message("Configuring for Android, ABI: ${ANDROID_ABI}") - include(cmake/platforms/android.cmake) + if(NOT ANDROID_SDK) + set(ANDROID_SDK $ENV{ANDROID_SDK_ROOT}) + endif() + include(${ANDROID_SDK}/android_openssl/CMakeLists.txt) + set(ANDROID_LIB_ARCH ${CMAKE_ANDROID_ARCH}) + if(${ANDROID_LIB_ARCH} STREQUAL "x86_64") + set(ANDROID_LIB_ARCH "x64") + endif() + message("Android SDK: ${ANDROID_SDK}, ${CMAKE_ANDROID_ARCH}") + set(QV2RAY_PLATFORM_LIBS_BIN_PATH_PREFIX ${CMAKE_SOURCE_DIR}/libs/tools) + set(QV2RAY_PLATFORM_LIBS_PATH_PREFIX ${CMAKE_SOURCE_DIR}/libs/${ANDROID_LIB_ARCH}-android) + include(cmake/platforms/prefixes.cmake) + set(APK_PACKAGE_NAME "net.qv2ray.qv2ray") + set(APK_PACKAGE_VERSION "v${QV2RAY_VERSION_STRING}") + set(APK_DISPLAY_NAME "Qv2ray") + set(APK_PACKAGE_VERSIONCODE 0) + configure_file(${CMAKE_SOURCE_DIR}/assets/AndroidManifest.xml.in ${CMAKE_SOURCE_DIR}/assets/android/AndroidManifest.xml @ONLY) +endif() + +if(WIN32) + add_compile_options("/std:c++17") + add_compile_options("/utf-8") + add_definitions(-DUNICODE -D_UNICODE -DNOMINMAX) + add_definitions(-D_WIN32_WINNT=0x600 -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS) + set(GUI_TYPE WIN32) + if(CMAKE_CL_64) + set(QV2RAY_PLATFORM_LIBS_PATH_PREFIX ${CMAKE_SOURCE_DIR}/libs/x64-windows/) + else() + set(QV2RAY_PLATFORM_LIBS_PATH_PREFIX ${CMAKE_SOURCE_DIR}/libs/x86-windows/) + endif() + include(cmake/platforms/prefixes.cmake) endif() if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.17.0") @@ -65,22 +95,6 @@ message("| Welcome to contribute! |") message("|-------------------------------------------------|") message(" ") -if(WIN32) - add_compile_options("/std:c++17") - add_compile_options("/utf-8") - add_definitions(-DUNICODE -D_UNICODE -DNOMINMAX) - add_definitions(-D_WIN32_WINNT=0x600 -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS) - set(GUI_TYPE WIN32) - if(NOT DEFINED CMAKE_TOOLCHAIN_FILE) - if(CMAKE_CL_64) - include(${CMAKE_SOURCE_DIR}/libs/windows-x64/scripts/buildsystems/vcpkg.cmake) - else() - include(${CMAKE_SOURCE_DIR}/libs/windows-x86/scripts/buildsystems/vcpkg.cmake) - endif() - endif() -endif() - - # ================================================================================== # Qv2ray compile arguments # ================================================================================== diff --git a/cmake/libcurl.cmake b/cmake/libcurl.cmake index 5d80bce9..d473034d 100644 --- a/cmake/libcurl.cmake +++ b/cmake/libcurl.cmake @@ -1,8 +1,7 @@ if(ANDROID) set(CURL_LIBRARIES -lcurl -lssl -lcrypto -lz) +elseif(WIN32) + set(CURL_LIBRARIES libcurl libssl libcrypto zlib) endif() -if(WIN32 OR ANDROID) - find_package(CURL CONFIG REQUIRED) -else() - find_package(CURL REQUIRED) -endif() + +find_package(CURL REQUIRED) diff --git a/cmake/platforms/android.cmake b/cmake/platforms/android.cmake index 757c03b1..e69de29b 100644 --- a/cmake/platforms/android.cmake +++ b/cmake/platforms/android.cmake @@ -1,56 +0,0 @@ -if(NOT ANDROID_SDK) - set(ANDROID_SDK $ENV{ANDROID_SDK_ROOT}) -endif() - -include(${ANDROID_SDK}/android_openssl/CMakeLists.txt) - -set(ANDROID_LIB_ARCH ${CMAKE_ANDROID_ARCH}) -if(${ANDROID_LIB_ARCH} STREQUAL "x86_64") - set(ANDROID_LIB_ARCH "x64") -endif() - -message("Android SDK: ${ANDROID_SDK}, ${CMAKE_ANDROID_ARCH}") - -list(APPEND CMAKE_PROGRAM_PATH - ${CMAKE_SOURCE_DIR}/libs/tools/grpc - ${CMAKE_SOURCE_DIR}/libs/tools/protobuf - ${CMAKE_SOURCE_DIR}/libs/tools/openssl - ) - -set(QV2RAY_ANDROID_ROOT ${CMAKE_SOURCE_DIR}/libs/${ANDROID_LIB_ARCH}-android) - -if(CMAKE_BUILD_TYPE MATCHES "^[Dd][Ee][Bb][Uu][Gg]$" OR NOT DEFINED CMAKE_BUILD_TYPE) #Debug build: Put Debug paths before Release paths. - list(APPEND CMAKE_PREFIX_PATH - ${QV2RAY_ANDROID_ROOT}/debug - ${QV2RAY_ANDROID_ROOT} - ) - link_directories( - ${QV2RAY_ANDROID_ROOT}/debug/lib - ${QV2RAY_ANDROID_ROOT}/lib - ) - list(APPEND CMAKE_FIND_ROOT_PATH - ${QV2RAY_ANDROID_ROOT}/debug - ${QV2RAY_ANDROID_ROOT} - ) -else() #Release build: Put Release paths before Debug paths. Debug Paths are required so that CMake generates correct info in autogenerated target files. - list(APPEND CMAKE_PREFIX_PATH - ${QV2RAY_ANDROID_ROOT} - ${QV2RAY_ANDROID_ROOT}/debug - ) - link_directories( - ${QV2RAY_ANDROID_ROOT}/lib - ${QV2RAY_ANDROID_ROOT}/debug/lib - ) - list(APPEND CMAKE_FIND_ROOT_PATH - ${QV2RAY_ANDROID_ROOT} - ${QV2RAY_ANDROID_ROOT}/debug - ) -endif() - -if(ANDROID) - set(APK_PACKAGE_NAME "net.qv2ray.qv2ray") - set(APK_PACKAGE_VERSION "v${QV2RAY_VERSION_STRING}") - set(APK_DISPLAY_NAME "Qv2ray") - set(APK_PACKAGE_VERSIONCODE 0) - configure_file(${CMAKE_SOURCE_DIR}/assets/AndroidManifest.xml.in ${CMAKE_SOURCE_DIR}/assets/android/AndroidManifest.xml @ONLY) -endif() diff --git a/cmake/platforms/prefixes.cmake b/cmake/platforms/prefixes.cmake new file mode 100644 index 00000000..e1cbbe2d --- /dev/null +++ b/cmake/platforms/prefixes.cmake @@ -0,0 +1,52 @@ +if(NOT QV2RAY_PLATFORM_LIBS_BIN_PATH_PREFIX) + set(QV2RAY_PLATFORM_LIBS_BIN_PATH_PREFIX ${QV2RAY_PLATFORM_LIBS_PATH_PREFIX}/tools) +endif() + + +list(APPEND CMAKE_PROGRAM_PATH + ${QV2RAY_PLATFORM_LIBS_BIN_PATH_PREFIX}/grpc/ + ${QV2RAY_PLATFORM_LIBS_BIN_PATH_PREFIX}/protobuf/ + ${QV2RAY_PLATFORM_LIBS_BIN_PATH_PREFIX}/openssl/ + ) + +message("CMAKE_PROGRAM_PATH=${CMAKE_PROGRAM_PATH}") + +# From vcpkg +#If CMake does not have a mapping for MinSizeRel and RelWithDebInfo in imported targets +#it will map those configuration to the first valid configuration in CMAKE_CONFIGURATION_TYPES or the targets IMPORTED_CONFIGURATIONS. +#In most cases this is the debug configuration which is wrong. +if(NOT DEFINED CMAKE_MAP_IMPORTED_CONFIG_MINSIZEREL) + set(CMAKE_MAP_IMPORTED_CONFIG_MINSIZEREL "MinSizeRel;Release;") + message(STATUS "CMAKE_MAP_IMPORTED_CONFIG_MINSIZEREL set to MinSizeRel;Release;") +endif() +if(NOT DEFINED CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO) + set(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO "RelWithDebInfo;Release;") + message(STATUS "CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO set to RelWithDebInfo;Release;") +endif() + +if(CMAKE_BUILD_TYPE MATCHES "^[Dd][Ee][Bb][Uu][Gg]$" OR NOT DEFINED CMAKE_BUILD_TYPE) + #Debug build: Put Debug paths before Release paths. + list(APPEND CMAKE_PREFIX_PATH + ${QV2RAY_PLATFORM_LIBS_PATH_PREFIX}/debug + ${QV2RAY_PLATFORM_LIBS_PATH_PREFIX} + ) + link_directories( + ${QV2RAY_PLATFORM_LIBS_PATH_PREFIX}/debug/lib + ${QV2RAY_PLATFORM_LIBS_PATH_PREFIX}/lib + ) + list(APPEND CMAKE_FIND_ROOT_PATH + ${QV2RAY_PLATFORM_LIBS_PATH_PREFIX}/debug + ${QV2RAY_PLATFORM_LIBS_PATH_PREFIX} + ) +else() + #Release build: Put Release paths before Debug paths. Debug Paths are required so that CMake generates correct info in autogenerated target files. + list(APPEND CMAKE_PREFIX_PATH + ${QV2RAY_PLATFORM_LIBS_PATH_PREFIX} + ) + link_directories( + ${QV2RAY_PLATFORM_LIBS_PATH_PREFIX}/lib + ) + list(APPEND CMAKE_FIND_ROOT_PATH + ${QV2RAY_PLATFORM_LIBS_PATH_PREFIX} + ) +endif() diff --git a/libs/setup-libs.sh b/libs/setup-libs.sh index e1bf8715..6bd23fff 100755 --- a/libs/setup-libs.sh +++ b/libs/setup-libs.sh @@ -20,6 +20,7 @@ do done if [[ "$QV2RAY_LIBS" == "tools" ]]; then + mkdir -p ../tools cp -rvf ./tools ../ rm -rvf ./tools else diff --git a/makespec/BUILDVERSION b/makespec/BUILDVERSION index a37e2a83..d628a8d4 100644 --- a/makespec/BUILDVERSION +++ b/makespec/BUILDVERSION @@ -1 +1 @@ -5980 +5984