diff --git a/CMakeLists.txt b/CMakeLists.txt index d6f7737..cd9ff49 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ project(QtShadowsocks LANGUAGES CXX) option(BUILD_SHARED_LIBS "Build ${PROJECT_NAME} as a shared library" ON) +option(USE_BOTAN2 "Build ${PROJECT_NAME} with Botan-2" OFF) set(LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib CACHE PATH "Installation directory for libraries") @@ -18,7 +19,15 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) find_package(Qt5Core) find_package(Qt5Network) find_package(PkgConfig) -pkg_search_module(BOTAN REQUIRED botan-1.10 botan-2) + +if (USE_BOTAN2) + pkg_check_modules(BOTAN REQUIRED botan-2>=2.2.0) +else() + pkg_check_modules(BOTAN REQUIRED botan-1.10) +endif() +find_library(BOTAN_LIBRARY_VAR + NAMES ${BOTAN_LIBRARIES} + HINTS ${BOTAN_LIBRARY_DIRS} ${BOTAN_LIBDIR}) if(NOT BUILD_SHARED_LIBS) add_definitions(-DQSS_STATIC) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index a83252d..bd466db 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -46,7 +46,7 @@ add_library(${LIBNAME} ${SOURCE}) target_link_libraries(${LIBNAME} PUBLIC Qt5::Core PUBLIC Qt5::Network - PRIVATE ${BOTAN_LIBRARIES}) + PRIVATE ${BOTAN_LIBRARY_VAR}) target_include_directories(${LIBNAME} PRIVATE ${BOTAN_INCLUDE_DIRS}) foreach(LIB Qt5Network Qt5Core ${BOTAN_LIBRARIES}) diff --git a/shadowsocks-libqss/CMakeLists.txt b/shadowsocks-libqss/CMakeLists.txt index 9897d47..ff7cb31 100644 --- a/shadowsocks-libqss/CMakeLists.txt +++ b/shadowsocks-libqss/CMakeLists.txt @@ -8,9 +8,8 @@ set(SOURCE add_executable(${TASK} ${SOURCE}) -target_link_libraries(${TASK} Qt5::Core Qt5::Network ${BOTAN_LIBRARIES} QtShadowsocks) +target_link_libraries(${TASK} Qt5::Core Qt5::Network QtShadowsocks) target_include_directories(${TASK} - PUBLIC ${BOTAN_INCLUDE_DIRS} PUBLIC ${PROJECT_SOURCE_DIR}/lib) install(TARGETS ${TASK} RUNTIME DESTINATION bin) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ac0c2db..e076ecc 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -12,7 +12,6 @@ set(SOURCE add_executable(${TASK} ${SOURCE}) find_package(Qt5Test) -target_link_libraries(${TASK} Qt5::Core Qt5::Network Qt5::Test ${BOTAN_LIBRARIES} QtShadowsocks) +target_link_libraries(${TASK} Qt5::Core Qt5::Network Qt5::Test QtShadowsocks) target_include_directories(${TASK} - PUBLIC ${BOTAN_INCLUDE_DIRS} PUBLIC ${PROJECT_SOURCE_DIR}/lib)