From 07babdbd77f1978f8386791272b309949e56a09b Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 2 Jun 2023 18:20:19 -0400 Subject: [PATCH] use Conan for extra's dependencies on Windows conan install src\win32\conanfile.txt --build=missing cmake -B build . cmake --build build --config Release --target PACKAGE --- CMakeLists.txt | 4 ---- modules/CMakeLists.txt | 33 +++++++++++++++++++++++++++++++++ modules/extra/m_regex_pcre2.cpp | 2 +- modules/extra/m_ssl_openssl.cpp | 2 +- src/win32/conanfile.txt | 18 ++++++++++++++++++ 5 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 src/win32/conanfile.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 877dc204a..3b30374c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -502,10 +502,6 @@ if(WIN32) install(FILES ${Anope_SOURCE_DIR}/src/win32/anope.bat DESTINATION ${BIN_DIR} ) - - # Package any DLLs in src/win/ - file(GLOB EXTRA_DLLS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${Anope_SOURCE_DIR}/src/win32/*.dll") - install(FILES ${EXTRA_DLLS} DESTINATION ${BIN_DIR}) endif(WIN32) install(CODE "file(REMOVE_RECURSE \"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${LIB_DIR}/modules\")") diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index 4b0fd6eec..0553cad1c 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -3,6 +3,39 @@ if(WIN32) add_definitions(-DMODULE_COMPILE) endif(WIN32) +# enable extra modules if conan is used +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../conanbuildinfo.cmake") + include("${CMAKE_CURRENT_SOURCE_DIR}/../conanbuildinfo.cmake") + conan_basic_setup() + + function(enable_extra NAME PACKAGE) + if(DEFINED "CONAN_${PACKAGE}_ROOT") + 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}") + else() + message("Unable to enable the ${NAME} module (missing library)") + endif() + endfunction() + + function(copy_extra NAME) + file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/extra/${NAME}.cpp" DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}") + endfunction() + + enable_extra("m_mysql" "LIBMYSQLCLIENT") + enable_extra("m_regex_pcre2" "PCRE2") + enable_extra("m_sqlite" "SQLITE3") + enable_extra("m_ssl_openssl" "OPENSSL") + # these don't actually have extra dependencies, but require a module which does + copy_extra("m_sql_authentication") + copy_extra("m_sql_log") + copy_extra("m_sql_oper") + + # Package extra dlls + file(GLOB EXTRA_DLLS "${Anope_SOURCE_DIR}/extradll/bin/*.dll" "${Anope_SOURCE_DIR}/extradll/lib/*.dll") + install(FILES ${EXTRA_DLLS} DESTINATION ${BIN_DIR}) +endif() + macro(build_modules SRC) if(NOT ${SRC} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR} AND EXISTS "${SRC}/CMakeLists.txt") add_subdirectory("${SRC}") diff --git a/modules/extra/m_regex_pcre2.cpp b/modules/extra/m_regex_pcre2.cpp index b9db11c2c..5655c3324 100644 --- a/modules/extra/m_regex_pcre2.cpp +++ b/modules/extra/m_regex_pcre2.cpp @@ -7,7 +7,7 @@ */ /* RequiredLibraries: pcre2-8 */ -/* RequiredWindowsLibraries: libpcre2-8 */ +/* RequiredWindowsLibraries: pcre2-8 */ #include "module.h" diff --git a/modules/extra/m_ssl_openssl.cpp b/modules/extra/m_ssl_openssl.cpp index a73f144dd..26b47a330 100644 --- a/modules/extra/m_ssl_openssl.cpp +++ b/modules/extra/m_ssl_openssl.cpp @@ -7,7 +7,7 @@ */ /* RequiredLibraries: ssl,crypto */ -/* RequiredWindowsLibraries: ssleay32,libeay32 */ +/* RequiredWindowsLibraries: libssl,libcrypto */ #include "module.h" #include "modules/ssl.h" diff --git a/src/win32/conanfile.txt b/src/win32/conanfile.txt new file mode 100644 index 000000000..38b392415 --- /dev/null +++ b/src/win32/conanfile.txt @@ -0,0 +1,18 @@ +[requires] +libmysqlclient/8.0.31 +openssl/1.1.1t +pcre2/10.42 +sqlite3/3.41.1 + +[options] +libmysqlclient/*:shared=True +openssl/*:shared=True +pcre2/*:shared=True +sqlite3/*:shared=True + +[imports] +., *.dll -> extradll +., *.lib -> extralib + +[generators] +cmake \ No newline at end of file