From e7aa0cb5834983a74ede708807ceac9edae62d23 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sat, 7 Feb 2026 14:28:45 +0000 Subject: [PATCH] Migrate the Windows dependencies to Conan 2. [skip alpine ci] [skip ubuntu ci] --- .github/workflows/ci-windows.yml | 28 ++++++++++++++++------------ CMakeLists.txt | 11 ++++------- modules/CMakeLists.txt | 15 ++++++++------- modules/extra/enc_argon2.cpp | 3 ++- modules/extra/mysql.cpp | 3 ++- modules/extra/regex_pcre2.cpp | 3 ++- src/win32/conanfile.txt | 31 +++++++++++++++---------------- 7 files changed, 49 insertions(+), 45 deletions(-) diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml index 48ae9969c..bc52d0576 100644 --- a/.github/workflows/ci-windows.yml +++ b/.github/workflows/ci-windows.yml @@ -14,8 +14,7 @@ jobs: runs-on: windows-2025 env: BUILD_TYPE: ${{ github.event_name == 'release' && 'Release' || 'Debug' }} - CONAN_USER_HOME: ${{ github.workspace }}/win/build - CONAN_USER_HOME_SHORT: None + CONAN_HOME: ${{ github.workspace }}\build\conan steps: - uses: actions/checkout@v6 @@ -28,32 +27,37 @@ jobs: - name: Setup Conan uses: turtlebrowser/get-conan@v1.2 - with: - version: 1.66.0 + + - name: Create Conan profile + run: |- + conan profile detect + (Get-Content ${{ env.CONAN_HOME }}\profiles\default).replace('build_type=Release', 'build_type=${{ env.BUILD_TYPE }}') | Set-Content ${{ env.CONAN_HOME }}\profiles\default + (Get-Content ${{ env.CONAN_HOME }}\profiles\default).replace('compiler.cppstd=14', 'compiler.cppstd=17') | Set-Content ${{ env.CONAN_HOME }}\profiles\default + Write-Output 'core.sources:download_urls=["origin", "https://c3i.jfrog.io/artifactory/conan-center-backup-sources/"]' | Out-File -Append ${{ env.CONAN_HOME }}\global.conf - name: Try to restore libraries from the cache uses: actions/cache/restore@v5 id: library-cache with: - key: conan-${{ hashFiles('src/win32/conanfile.txt') }} - path: ${{ env.CONAN_USER_HOME }}/.conan + key: conan-${{ env.BUILD_TYPE }}-${{ hashFiles('src\win32\conanfile.txt') }} + path: ${{ env.CONAN_HOME }}\p - name: Install libraries run: | - conan install ${{ github.workspace }}\src\win32 --build=missing + (Get-Content ${{ github.workspace }}\src\win32\conanfile.txt).replace('##', '') | Set-Content ${{ github.workspace }}\src\win32\conanfile.txt + conan install ${{ github.workspace }}\src\win32 --build missing --deployer runtime_deploy --deployer-folder ${{ github.workspace }}\build\extradll --output-folder . - name: Save libraries to the cache if: ${{ steps.library-cache.outputs.cache-hit != 'true' }} uses: actions/cache/save@v5 with: - key: ${{ steps.library-cache.outputs.cache-primary-key }} - path: ${{ env.CONAN_USER_HOME }}/.conan + key: ${{ steps.library-cache.outputs.cache-primary-key }} + path: ${{ env.CONAN_HOME }}\p - name: Run CMake + working-directory: ${{ github.workspace }}\build run: | - mkdir ${{ github.workspace }}\build - cd ${{ github.workspace }}\build - cmake -A x64 -D "CMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}" -G "Visual Studio 17 2022" .. + cmake -A x64 -D "CMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}" -D CMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -G "Visual Studio 17 2022" .. - name: Build Anope working-directory: ${{ github.workspace }}\build diff --git a/CMakeLists.txt b/CMakeLists.txt index ee70fdbb8..62cd13d35 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,10 @@ include(CheckFunctionExists) include(CheckTypeSize) include(CheckLibraryExists) include(CheckCXXCompilerFlag) -include(FindPkgConfig) + +if(NOT WIN32) + include(FindPkgConfig) +endif() # If extra include directories were specified, tell cmake about them. if(EXTRA_INCLUDE) @@ -37,12 +40,6 @@ if(EXTRA_LIBS) link_directories(${EXTRA_LIBS}) endif() -# setup conan -if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/conanbuildinfo.cmake") - include("${CMAKE_CURRENT_SOURCE_DIR}/conanbuildinfo.cmake") - conan_basic_setup(TARGETS) -endif() - # Find gettext find_package(Gettext) find_package(Intl) diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index f1a562f75..7618ed6f9 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -4,9 +4,10 @@ if(WIN32) endif() # enable extra modules if conan is used -if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../conanbuildinfo.cmake") +if(WIN32 AND DEFINED CMAKE_TOOLCHAIN_FILE) function(enable_extra NAME PACKAGE) - if(DEFINED "CONAN_${PACKAGE}_ROOT") + find_package(${PACKAGE}) + if(${PACKAGE}_FOUND) message("Enabling the ${NAME} module") # copy the modules out of extra so it gets picked up by build_modules file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/extra/${NAME}.cpp" DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}") @@ -19,16 +20,16 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../conanbuildinfo.cmake") file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/extra/${NAME}.cpp" DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}") endfunction() - enable_extra("enc_argon2" "ARGON2") - enable_extra("mysql" "LIBMYSQLCLIENT") + enable_extra("enc_argon2" "argon2") + enable_extra("mysql" "libmysqlclient") enable_extra("regex_pcre2" "PCRE2") - enable_extra("sqlite" "SQLITE3") - enable_extra("ssl_openssl" "OPENSSL") + enable_extra("sqlite" "SQLite3") + enable_extra("ssl_openssl" "OpenSSL") # this uses Wldap so should always be available copy_extra("ldap") # Package extra dlls - file(GLOB EXTRA_DLLS "${Anope_SOURCE_DIR}/extradll/bin/*.dll" "${Anope_SOURCE_DIR}/extradll/lib/*.dll") + file(GLOB EXTRA_DLLS "${PROJECT_BINARY_DIR}/extradll/*.dll") install(FILES ${EXTRA_DLLS} DESTINATION ${BIN_DIR}) endif() diff --git a/modules/extra/enc_argon2.cpp b/modules/extra/enc_argon2.cpp index 47782f286..3829c3bb0 100644 --- a/modules/extra/enc_argon2.cpp +++ b/modules/extra/enc_argon2.cpp @@ -14,7 +14,8 @@ /// BEGIN CMAKE /// if(WIN32) -/// target_link_libraries(${SO} PRIVATE CONAN_PKG::argon2) +/// find_package("argon2" REQUIRED) +/// target_link_libraries(${SO} PRIVATE "argon2::argon2") /// else() /// pkg_check_modules("ARGON2" IMPORTED_TARGET REQUIRED "libargon2") /// target_link_libraries(${SO} PRIVATE PkgConfig::ARGON2) diff --git a/modules/extra/mysql.cpp b/modules/extra/mysql.cpp index 49ef925fe..8bc62ce28 100644 --- a/modules/extra/mysql.cpp +++ b/modules/extra/mysql.cpp @@ -14,7 +14,8 @@ /// BEGIN CMAKE /// if(WIN32) -/// target_link_libraries(${SO} PRIVATE CONAN_PKG::libmysqlclient) +/// find_package("libmysqlclient" REQUIRED) +/// target_link_libraries(${SO} PRIVATE "libmysqlclient::libmysqlclient") /// else() /// pkg_search_module("MYSQL" IMPORTED_TARGET REQUIRED "mysqlclient" "mariadb") /// target_link_libraries(${SO} PRIVATE PkgConfig::MYSQL) diff --git a/modules/extra/regex_pcre2.cpp b/modules/extra/regex_pcre2.cpp index 3e7987c86..04413c081 100644 --- a/modules/extra/regex_pcre2.cpp +++ b/modules/extra/regex_pcre2.cpp @@ -14,7 +14,8 @@ /// BEGIN CMAKE /// if(WIN32) -/// target_link_libraries(${SO} PRIVATE CONAN_PKG::pcre2) +/// find_package("PCRE2" REQUIRED) +/// target_link_libraries(${SO} PRIVATE "pcre2::pcre2") /// else() /// pkg_check_modules("PCRE2" IMPORTED_TARGET REQUIRED "libpcre2-8") /// target_link_libraries(${SO} PRIVATE PkgConfig::PCRE2) diff --git a/src/win32/conanfile.txt b/src/win32/conanfile.txt index d0ef69167..511970c0e 100644 --- a/src/win32/conanfile.txt +++ b/src/win32/conanfile.txt @@ -1,23 +1,22 @@ [requires] argon2/20190702 +gettext/0.26 +libgettext/0.26 libmysqlclient/8.1.0 -openssl/3.2.1 -pcre2/10.42 -sqlite3/3.45.1 -gettext/0.21 -libgettext/0.22 +openssl/3.6.1 +pcre2/10.44 +sqlite3/3.51.0 [options] -argon2/*:shared=True -libmysqlclient/*:shared=True -openssl/*:shared=True -pcre2/*:shared=True -sqlite3/*:shared=True -libgettext/*:shared=True - -[imports] -., *.dll -> extradll -., *.lib -> extralib +*/*:shared=True +libiconv/*:shared=False # Shared libiconv causes linker errors +openssl/*:no_apps=True +openssl/*:no_legacy=True +pcre2/*:build_pcre2_16=False +pcre2/*:build_pcre2_32=False +pcre2/*:build_pcre2grep=False +sqlite3/*:build_executable=False [generators] -cmake +CMakeDeps +CMakeToolchain