op-packages/trojan-plus/patches/002-Fix-boost1.89-build.patch
github-actions[bot] 32600acc60 🌴 Sync 2026-03-05 23:51:42
2026-03-05 23:51:42 +08:00

53 lines
2.0 KiB
Diff

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -184,26 +184,45 @@ endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if (ANDROID)
- set(ANDROID_MY_LIBS ${PROJECT_SOURCE_DIR}/trojan-plus-android-libs)
+ set(ANDROID_MY_LIBS ${PROJECT_SOURCE_DIR}/trojan-plus-android-libs)
+
+ find_path(BOOST_INCLUDE_DIR
+ NAMES boost/version.hpp
+ HINTS ${ANDROID_MY_LIBS}/include
+ )
+
set(ANDROID_MY_LIBS_LIBRARIES
${ANDROID_MY_LIBS}/lib/${ANDROID_ABI}/libssl.a
${ANDROID_MY_LIBS}/lib/${ANDROID_ABI}/libcrypto.a
- ${ANDROID_MY_LIBS}/lib/${ANDROID_ABI}/libboost_system.a
${ANDROID_MY_LIBS}/lib/${ANDROID_ABI}/libboost_program_options.a)
+ if(BOOST_INCLUDE_DIR)
+ file(STRINGS "${BOOST_INCLUDE_DIR}/boost/version.hpp" BOOST_VERSION_LINE REGEX "^#define BOOST_VERSION ")
+ string(REGEX REPLACE "^#define BOOST_VERSION ([0-9]+)" "\\1" BOOST_VERSION ${BOOST_VERSION_LINE})
+
+ if(${BOOST_VERSION} VERSION_LESS 108900)
+ list(APPEND ANDROID_MY_LIBS_LIBRARIES ${ANDROID_MY_LIBS}/lib/${ANDROID_ABI}/libboost_system.a)
+ endif()
+ endif()
+
set(OPENSSL_VERSION 1.1.1)
include_directories(${ANDROID_MY_LIBS}/include)
target_link_libraries(trojan ${ANDROID_MY_LIBS_LIBRARIES})
else()
- find_package(Boost 1.66.0 REQUIRED COMPONENTS system program_options)
+ find_package(Boost 1.66.0 REQUIRED)
+ if (Boost_MAJOR_VERSION LESS_EQUAL 1 AND Boost_MINOR_VERSION LESS 89)
+ find_package(Boost 1.66.0 REQUIRED COMPONENTS system program_options)
+ else()
+ find_package(Boost 1.66.0 REQUIRED COMPONENTS program_options)
+ endif()
include_directories(${Boost_INCLUDE_DIR})
target_link_libraries(trojan ${Boost_LIBRARIES})
if(MSVC)
add_definitions(-DBOOST_DATE_TIME_NO_LIB)
endif()
- find_package(OpenSSL 1.1.0 REQUIRED)
+ find_package(OpenSSL 1.1.1 REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIR})
target_link_libraries(trojan ${OPENSSL_LIBRARIES})
endif()