From e838136bced0c611e66eeac7bcebea2fbfff3e2b Mon Sep 17 00:00:00 2001 From: Mike Ravenelle Date: Sun, 24 Sep 2023 12:34:18 -0500 Subject: [PATCH 01/21] First test of SCM conan 2.0 --- conan/conanfile.py | 61 ++++++++++++++++++++ library/CMakeLists.txt | 125 +++++++++++++++++++++-------------------- 2 files changed, 126 insertions(+), 60 deletions(-) create mode 100644 conan/conanfile.py diff --git a/conan/conanfile.py b/conan/conanfile.py new file mode 100644 index 0000000000..3f1d7c7b08 --- /dev/null +++ b/conan/conanfile.py @@ -0,0 +1,61 @@ +from conan import ConanFile +from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps +from conan.tools.scm import Git +from conan.tools.files import load, update_conandata +1 +class DPPConan(ConanFile): + name = "dpp" + version = "0.1" + default_user = "brainboxdotcc" + default_channel = "testing" + license = "https://github.com/brainboxdotcc/DPP/blob/master/LICENSE" + url = "https://github.com/brainboxdotcc/DPP" + description = "D++ is a lightweight and efficient library for Discord" + topics = ("discord") + settings = "os", "compiler", "build_type", "arch" + options = {"shared": [True, False], "fPIC": [True, False]} + default_options = {"shared": False, "fPIC": True} + + def build_requirements(self): + self.tool_requires("nlohmann_json/3.11.2") + self.test_requires("openssl/3.1.2") + self.tool_requires("zlib/1.3") + self.test_requires("libsodium/cci.20220430") + self.test_requires("opus/1.4") + + def config_options(self): + if self.settings.os == "Windows": + self.options.rm_safe("fPIC") + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self) + + def export(self): + git = Git(self, self.recipe_folder) + scm_url, scm_commit = git.get_url_and_commit() + update_conandata(self, {"sources": {"commit": scm_commit, "url": scm_url}}) + + def source(self): + git = Git(self) + sources = self.conan_data["sources"] + git.clone(url=sources["url"], target=".") + git.checkout(commit=sources["commit"]) + + def generate(self): + deps = CMakeDeps(self) + deps.generate() + tc = CMakeToolchain(self) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() \ No newline at end of file diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 3879d10e2f..2ca4d6db24 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -1,4 +1,9 @@ # Check for various C functions +find_package(OpenSSL REQUIRED COMPONENTS SSL Crypto) +find_package(ZLIB REQUIRED) +find_package(libsodium REQUIRED) +find_package(Opus REQUIRED) + check_cxx_symbol_exists(prctl "sys/prctl.h" HAVE_PRCTL) check_cxx_symbol_exists(pthread_setname_np "pthread.h" HAVE_PTHREAD_SETNAME_NP) @@ -34,18 +39,18 @@ add_compile_options(${AVX_FLAG}) if(WIN32 AND NOT MINGW) if (NOT WINDOWS_32_BIT) message("-- Building for windows with precompiled packaged dependencies") - #set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) set(ZLIB_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib") set(ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../win32/include") set(OPENSSL_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../win32/include") set(OPENSSL_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib") #ADD_DEFINITIONS(/bigobj) - link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libssl.lib") - link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libcrypto.lib") - link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/zlib.lib") - link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libsodium.lib") - link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/opus.lib") + #link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libssl.lib") + #link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libcrypto.lib") + #link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/zlib.lib") + #link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libsodium.lib") + #link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/opus.lib") set(OPUS_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../win32/include") set(OPUS_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/opus.lib") @@ -113,36 +118,36 @@ endif() include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/colour.cmake") -if (BUILD_VOICE_SUPPORT) - if (MINGW OR NOT WIN32) - find_package(PkgConfig QUIET) - if(PKG_CONFIG_FOUND) - include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/FindSodium.cmake") - else() - message("-- Could not detect ${Green}libsodium${ColourReset} due to missing ${Green}pkgconfig${ColourReset}. VOICE support will be ${Red}disabled${ColourReset}") - endif() - include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/FindOpus.cmake") - endif() - - if(DEFINED OPUS_FOUND) - message("-- Found Opus ${Green}${OPUS_LIBRARIES}${ColourReset}") - if((WIN32 OR PKG_CONFIG_FOUND) AND DEFINED sodium_VERSION_STRING AND DEFINED sodium_LIBRARY_RELEASE) - add_compile_definitions(HAVE_VOICE) +# if (BUILD_VOICE_SUPPORT) +# if (MINGW OR NOT WIN32) +# find_package(PkgConfig QUIET) +# if(PKG_CONFIG_FOUND) +# include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/FindSodium.cmake") +# else() +# message("-- Could not detect ${Green}libsodium${ColourReset} due to missing ${Green}pkgconfig${ColourReset}. VOICE support will be ${Red}disabled${ColourReset}") +# endif() +# include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/FindOpus.cmake") +# endif() + +# if(DEFINED OPUS_FOUND) +# message("-- Found Opus ${Green}${OPUS_LIBRARIES}${ColourReset}") +# if((WIN32 OR PKG_CONFIG_FOUND) AND DEFINED sodium_VERSION_STRING AND DEFINED sodium_LIBRARY_RELEASE) +# add_compile_definitions(HAVE_VOICE) - message("-- Sodium ${Green}${sodium_VERSION_STRING}${ColourReset}") +# message("-- Sodium ${Green}${sodium_VERSION_STRING}${ColourReset}") set(HAVE_VOICE 1) - endif() - endif() - - if(HAVE_VOICE) - message("-- Detected ${Green}libsodium${ColourReset} and ${Green}libopus${ColourReset}. VOICE support will be ${Green}enabled${ColourReset}") - else(HAVE_VOICE) - message("-- Could not detect ${Green}libsodium${ColourReset} and/or ${Green}libopus${ColourReset}. VOICE support will be ${Red}disabled${ColourReset}") - endif(HAVE_VOICE) -else() - message("-- Voice support disabled by cmake option") -endif() +# endif() +# endif() + +# if(HAVE_VOICE) +# message("-- Detected ${Green}libsodium${ColourReset} and ${Green}libopus${ColourReset}. VOICE support will be ${Green}enabled${ColourReset}") +# else(HAVE_VOICE) +# message("-- Could not detect ${Green}libsodium${ColourReset} and/or ${Green}libopus${ColourReset}. VOICE support will be ${Red}disabled${ColourReset}") +# endif(HAVE_VOICE) +# else() +# message("-- Voice support disabled by cmake option") +# endif() string(ASCII 27 Esc) @@ -244,28 +249,28 @@ foreach (fullmodname ${subdirlist}) if (WIN32 AND NOT MINGW) if (NOT WINDOWS_32_BIT) - target_link_libraries(${modname} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libssl.lib" - "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libcrypto.lib" - "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libsodium.lib" - "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/opus.lib" - "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/zlib.lib") + target_link_libraries(${modname} PUBLIC openssl::openssl + libsodium::libsodium + Opus::opus + ZLIB::ZLIB) else() - target_link_libraries(${modname} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/lib/libssl.lib" - "${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/lib/libcrypto.lib" - "${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/lib/libsodium.lib" - "${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/lib/opus.lib" - "${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/lib/zlib.lib") + target_link_libraries(${modname} PUBLIC openssl::openssl + libsodium::libsodium + Opus::opus + ZLIB::ZLIB) endif() else() - target_link_libraries(${modname} PUBLIC ${OPENSSL_CRYPTO_LIBRARY} ${OPENSSL_SSL_LIBRARY} ${ZLIB_LIBRARIES}) + target_link_libraries(${modname} PUBLIC openssl::openssl + ZLIB::ZLIB) if (MINGW) target_link_libraries(${modname} PUBLIC wsock32 ws2_32 crypt32) endif () endif() if (HAVE_VOICE) - target_link_libraries(${modname} PUBLIC ${sodium_LIBRARY_RELEASE} ${OPUS_LIBRARIES}) + target_link_libraries(${modname} PUBLIC libsodium::libsodium + Opus::opus) include_directories(${OPUS_INCLUDE_DIRS} ${sodium_INCLUDE_DIR}) endif() @@ -370,21 +375,21 @@ if (DPP_BUILD_TEST) ) endif() -if(WIN32 AND NOT MINGW) - if (NOT WINDOWS_32_BIT) - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/zlib1.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/libcrypto-1_1-x64.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/libssl-1_1-x64.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/libsodium.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/opus.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) - else() - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/zlib1.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/libcrypto-1_1.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/libssl-1_1.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/libsodium.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/opus.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) - endif() -endif() +# if(WIN32 AND NOT MINGW) +# if (NOT WINDOWS_32_BIT) +# configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/zlib1.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) +# configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/libcrypto-1_1-x64.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) +# configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/libssl-1_1-x64.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) +# configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/libsodium.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) +# configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/opus.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) +# else() +# configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/zlib1.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) +# configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/libcrypto-1_1.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) +# configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/libssl-1_1.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) +# configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/libsodium.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) +# configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/opus.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) +# endif() +# endif() if(DPP_INSTALL) if(NOT WIN32) From 7277b21bf735d257b2afb46418d0b07bd0d3f139 Mon Sep 17 00:00:00 2001 From: mikeravenelle Date: Fri, 19 Jan 2024 11:01:52 -0600 Subject: [PATCH 02/21] Fixed requires --- conan/conanfile.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/conan/conanfile.py b/conan/conanfile.py index 3f1d7c7b08..e6084c668e 100644 --- a/conan/conanfile.py +++ b/conan/conanfile.py @@ -17,11 +17,11 @@ class DPPConan(ConanFile): default_options = {"shared": False, "fPIC": True} def build_requirements(self): - self.tool_requires("nlohmann_json/3.11.2") - self.test_requires("openssl/3.1.2") - self.tool_requires("zlib/1.3") - self.test_requires("libsodium/cci.20220430") - self.test_requires("opus/1.4") + self.requires("nlohmann_json/3.11.2", headers=True, libs=True) + self.requires("openssl/3.1.2", headers=True, libs=True) + self.requires("zlib/1.3", headers=True, libs=True) + self.requires("libsodium/cci.20220430", headers=True, libs=True) + self.requires("opus/1.4", headers=True, libs=True) def config_options(self): if self.settings.os == "Windows": From 60d31d46a86f086f0bf8a55fc0c24eae4cad1dd9 Mon Sep 17 00:00:00 2001 From: mikeravenelle Date: Fri, 19 Jan 2024 12:08:36 -0600 Subject: [PATCH 03/21] Added package info for libs --- conan/conanfile.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/conan/conanfile.py b/conan/conanfile.py index e6084c668e..bfc55157f0 100644 --- a/conan/conanfile.py +++ b/conan/conanfile.py @@ -58,4 +58,7 @@ def build(self): def package(self): cmake = CMake(self) - cmake.install() \ No newline at end of file + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["libdpp"] \ No newline at end of file From 5947864649b5d42da083dd43cfa0df24a12328e7 Mon Sep 17 00:00:00 2001 From: mikeravenelle Date: Fri, 19 Jan 2024 12:15:43 -0600 Subject: [PATCH 04/21] renamed libdpp to dpp --- conan/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conan/conanfile.py b/conan/conanfile.py index bfc55157f0..5c1e44098b 100644 --- a/conan/conanfile.py +++ b/conan/conanfile.py @@ -61,4 +61,4 @@ def package(self): cmake.install() def package_info(self): - self.cpp_info.libs = ["libdpp"] \ No newline at end of file + self.cpp_info.libs = ["dpp"] \ No newline at end of file From 25943bbcc02e79e3146201713b497880fbc1f3bc Mon Sep 17 00:00:00 2001 From: mikeravenelle Date: Fri, 19 Jan 2024 12:50:29 -0600 Subject: [PATCH 05/21] Made CmakeLists work for both conan and non conan users --- library/CMakeLists.txt | 189 ++++++++++++++++++++++++----------------- 1 file changed, 109 insertions(+), 80 deletions(-) diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 2ca4d6db24..b342458982 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -1,8 +1,17 @@ +# Check for the use of conan +if(EXISTS ${CMAKE_BINARY_DIR}/conan_toolchain.cmake) + message(STATUS "Conan toolchain found") + set(USING_CONAN TRUE) +endif() + +if(USING_CONAN) + find_package(OpenSSL REQUIRED COMPONENTS SSL Crypto) + find_package(ZLIB REQUIRED) + find_package(libsodium REQUIRED) + find_package(Opus REQUIRED) +endif() + # Check for various C functions -find_package(OpenSSL REQUIRED COMPONENTS SSL Crypto) -find_package(ZLIB REQUIRED) -find_package(libsodium REQUIRED) -find_package(Opus REQUIRED) check_cxx_symbol_exists(prctl "sys/prctl.h" HAVE_PRCTL) check_cxx_symbol_exists(pthread_setname_np "pthread.h" HAVE_PTHREAD_SETNAME_NP) @@ -39,29 +48,32 @@ add_compile_options(${AVX_FLAG}) if(WIN32 AND NOT MINGW) if (NOT WINDOWS_32_BIT) message("-- Building for windows with precompiled packaged dependencies") - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) - set(ZLIB_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib") - set(ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../win32/include") - set(OPENSSL_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../win32/include") - set(OPENSSL_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib") - #ADD_DEFINITIONS(/bigobj) - - #link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libssl.lib") - #link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libcrypto.lib") - #link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/zlib.lib") - #link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libsodium.lib") - #link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/opus.lib") - - set(OPUS_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../win32/include") - set(OPUS_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/opus.lib") - set(sodium_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../win32/include") - set(sodium_LIBRARY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libsodium.lib") - set(sodium_LIBRARY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libsodium.lib") - set(HAVE_OPUS_OPUS_H "${CMAKE_CURRENT_SOURCE_DIR}/../win32/include/opus/opus.h") - set(OPUS_FOUND 1) - SET(sodium_VERSION_STRING "win32 bundled") - - include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../win32/include") + if(USING_CONAN) + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) + else() + set(ZLIB_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib") + set(ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../win32/include") + set(OPENSSL_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../win32/include") + set(OPENSSL_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib") + ADD_DEFINITIONS(/bigobj) + + link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libssl.lib") + link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libcrypto.lib") + link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/zlib.lib") + link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libsodium.lib") + link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/opus.lib") + + set(OPUS_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../win32/include") + set(OPUS_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/opus.lib") + set(sodium_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../win32/include") + set(sodium_LIBRARY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libsodium.lib") + set(sodium_LIBRARY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libsodium.lib") + set(HAVE_OPUS_OPUS_H "${CMAKE_CURRENT_SOURCE_DIR}/../win32/include/opus/opus.h") + set(OPUS_FOUND 1) + SET(sodium_VERSION_STRING "win32 bundled") + + include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../win32/include") + endif() add_compile_options("/bigobj") add_compile_definitions(OPENSSL_SYS_WIN32) @@ -118,36 +130,38 @@ endif() include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/colour.cmake") -# if (BUILD_VOICE_SUPPORT) -# if (MINGW OR NOT WIN32) -# find_package(PkgConfig QUIET) -# if(PKG_CONFIG_FOUND) -# include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/FindSodium.cmake") -# else() -# message("-- Could not detect ${Green}libsodium${ColourReset} due to missing ${Green}pkgconfig${ColourReset}. VOICE support will be ${Red}disabled${ColourReset}") -# endif() -# include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/FindOpus.cmake") -# endif() - -# if(DEFINED OPUS_FOUND) -# message("-- Found Opus ${Green}${OPUS_LIBRARIES}${ColourReset}") -# if((WIN32 OR PKG_CONFIG_FOUND) AND DEFINED sodium_VERSION_STRING AND DEFINED sodium_LIBRARY_RELEASE) -# add_compile_definitions(HAVE_VOICE) + if (BUILD_VOICE_SUPPORT) + if(NOT USING_CONAN) + if (MINGW OR NOT WIN32) + find_package(PkgConfig QUIET) + if(PKG_CONFIG_FOUND) + include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/FindSodium.cmake") + else() + message("-- Could not detect ${Green}libsodium${ColourReset} due to missing ${Green}pkgconfig${ColourReset}. VOICE support will be ${Red}disabled${ColourReset}") + endif() + include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/FindOpus.cmake") + endif() + endif() + + if(DEFINED OPUS_FOUND OR USING_CONAN) + message("-- Found Opus ${Green}${OPUS_LIBRARIES}${ColourReset}") + if((WIN32 OR PKG_CONFIG_FOUND) AND DEFINED sodium_VERSION_STRING AND DEFINED sodium_LIBRARY_RELEASE) + add_compile_definitions(HAVE_VOICE) -# message("-- Sodium ${Green}${sodium_VERSION_STRING}${ColourReset}") + message("-- Sodium ${Green}${sodium_VERSION_STRING}${ColourReset}") set(HAVE_VOICE 1) -# endif() -# endif() - -# if(HAVE_VOICE) -# message("-- Detected ${Green}libsodium${ColourReset} and ${Green}libopus${ColourReset}. VOICE support will be ${Green}enabled${ColourReset}") -# else(HAVE_VOICE) -# message("-- Could not detect ${Green}libsodium${ColourReset} and/or ${Green}libopus${ColourReset}. VOICE support will be ${Red}disabled${ColourReset}") -# endif(HAVE_VOICE) -# else() -# message("-- Voice support disabled by cmake option") -# endif() + endif() + endif() + + if(HAVE_VOICE) + message("-- Detected ${Green}libsodium${ColourReset} and ${Green}libopus${ColourReset}. VOICE support will be ${Green}enabled${ColourReset}") + else(HAVE_VOICE) + message("-- Could not detect ${Green}libsodium${ColourReset} and/or ${Green}libopus${ColourReset}. VOICE support will be ${Red}disabled${ColourReset}") + endif(HAVE_VOICE) + else() + message("-- Voice support disabled by cmake option") + endif() string(ASCII 27 Esc) @@ -248,32 +262,45 @@ foreach (fullmodname ${subdirlist}) endif() if (WIN32 AND NOT MINGW) - if (NOT WINDOWS_32_BIT) + if(USING_CONAN) target_link_libraries(${modname} PUBLIC openssl::openssl libsodium::libsodium Opus::opus ZLIB::ZLIB) + elseif (NOT WINDOWS_32_BIT) + target_link_libraries(${modname} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libssl.lib" + "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libcrypto.lib" + "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libsodium.lib" + "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/opus.lib" + "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/zlib.lib") else() - target_link_libraries(${modname} PUBLIC openssl::openssl - libsodium::libsodium - Opus::opus - ZLIB::ZLIB) + target_link_libraries(${modname} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/lib/libssl.lib" + "${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/lib/libcrypto.lib" + "${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/lib/libsodium.lib" + "${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/lib/opus.lib" + "${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/lib/zlib.lib") endif() - else() - target_link_libraries(${modname} PUBLIC openssl::openssl - ZLIB::ZLIB) + if(USING_CONAN) + target_link_libraries(${modname} PUBLIC openssl::openssl ZLIB::ZLIB) + else() + target_link_libraries(${modname} PUBLIC ${OPENSSL_CRYPTO_LIBRARY} ${OPENSSL_SSL_LIBRARY} ${ZLIB_LIBRARIES}) + endif() if (MINGW) target_link_libraries(${modname} PUBLIC wsock32 ws2_32 crypt32) endif () endif() if (HAVE_VOICE) - target_link_libraries(${modname} PUBLIC libsodium::libsodium - Opus::opus) + if(USING_CONAN) + target_link_libraries(${modname} PUBLIC libsodium::libsodium Opus::opus) + else() + target_link_libraries(${modname} PUBLIC ${sodium_LIBRARY_RELEASE} ${OPUS_LIBRARIES}) + endif() include_directories(${OPUS_INCLUDE_DIRS} ${sodium_INCLUDE_DIR}) endif() + endforeach() target_compile_features(dpp PUBLIC cxx_std_17) @@ -374,22 +401,24 @@ if (DPP_BUILD_TEST) COMMAND unittest ) endif() - -# if(WIN32 AND NOT MINGW) -# if (NOT WINDOWS_32_BIT) -# configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/zlib1.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) -# configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/libcrypto-1_1-x64.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) -# configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/libssl-1_1-x64.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) -# configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/libsodium.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) -# configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/opus.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) -# else() -# configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/zlib1.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) -# configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/libcrypto-1_1.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) -# configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/libssl-1_1.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) -# configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/libsodium.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) -# configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/opus.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) -# endif() -# endif() + +if(NOT USING_CONAN) + if(WIN32 AND NOT MINGW) + if (NOT WINDOWS_32_BIT) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/zlib1.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/libcrypto-1_1-x64.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/libssl-1_1-x64.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/libsodium.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/opus.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) + else() + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/zlib1.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/libcrypto-1_1.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/libssl-1_1.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/libsodium.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/opus.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) + endif() + endif() +endif() if(DPP_INSTALL) if(NOT WIN32) From f7ee95b976460de1202f71032e96b786f35c794c Mon Sep 17 00:00:00 2001 From: mikeravenelle Date: Fri, 19 Jan 2024 17:24:41 -0600 Subject: [PATCH 06/21] Added documentation for using conan --- docpages/install/install-conan.md | 52 +++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 docpages/install/install-conan.md diff --git a/docpages/install/install-conan.md b/docpages/install/install-conan.md new file mode 100644 index 0000000000..a1ebba975a --- /dev/null +++ b/docpages/install/install-conan.md @@ -0,0 +1,52 @@ +\page install-conan Installing with Conan 2.0 + +To install D++ into a project using conan 2.0 and cmake: + +- Ensure conan is correctly installed the most popular method is with pip. +- Create a conanfile.txt in the root of the project. + +```conanfile.txt +[requires] +dpp/0.1 + +[generators] +CMakeDeps +CMakeToolchain +``` + +- You may now use the library within a `CMake` based project by adding instructions such as these to your `CMakeLists.txt`: + +```cmake +set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_LIST_DIR}/build") +find_package(dpp CONFIG REQUIRED) +target_link_libraries(${PROJECT_NAME} dpp::dpp) +``` + +- If you recieve any errors about CXX version you may need to set it + +``` +set(CMAKE_CXX_STANDARD 17) +``` + +- You will then also want to set your build type to match what you will be using in conan(Debug or Release) + +``` +set(CMAKE_BUILD_TYPE Debug) +``` + +OR + +``` +set(CMAKE_BUILD_TYPE Release) +``` + +- Now run the following commands + +``` +mkdir build && cd build +conan install .. --build=missing -of=. -s build_type=Release +cmake .. +make +``` + +- NOTE: build_type= needs to match whatever was set in your CMake or you will get linker issues. From 3abef91e889a379910d41f7bd95021003ff36ed0 Mon Sep 17 00:00:00 2001 From: mikeravenelle Date: Sat, 20 Jan 2024 10:56:33 -0600 Subject: [PATCH 07/21] Changed how conan detected and changed how opus is checked --- conan/conanfile.py | 1 + library/CMakeLists.txt | 30 +++++++++++++----------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/conan/conanfile.py b/conan/conanfile.py index 5c1e44098b..f072b25589 100644 --- a/conan/conanfile.py +++ b/conan/conanfile.py @@ -49,6 +49,7 @@ def generate(self): deps = CMakeDeps(self) deps.generate() tc = CMakeToolchain(self) + tc.cache_variables["CONAN_EXPORTED"] = True tc.generate() def build(self): diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index b342458982..1773e3bd43 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -1,14 +1,10 @@ # Check for the use of conan -if(EXISTS ${CMAKE_BINARY_DIR}/conan_toolchain.cmake) - message(STATUS "Conan toolchain found") - set(USING_CONAN TRUE) -endif() - -if(USING_CONAN) +if(CONAN_EXPORTED) + message("Conan in use... finding packages") find_package(OpenSSL REQUIRED COMPONENTS SSL Crypto) find_package(ZLIB REQUIRED) find_package(libsodium REQUIRED) - find_package(Opus REQUIRED) + find_package(Opus) endif() # Check for various C functions @@ -48,7 +44,7 @@ add_compile_options(${AVX_FLAG}) if(WIN32 AND NOT MINGW) if (NOT WINDOWS_32_BIT) message("-- Building for windows with precompiled packaged dependencies") - if(USING_CONAN) + if(CONAN_EXPORTED) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) else() set(ZLIB_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib") @@ -131,7 +127,7 @@ endif() include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/colour.cmake") if (BUILD_VOICE_SUPPORT) - if(NOT USING_CONAN) + if(NOT CONAN_EXPORTED) if (MINGW OR NOT WIN32) find_package(PkgConfig QUIET) if(PKG_CONFIG_FOUND) @@ -143,7 +139,7 @@ include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/colour.cmake") endif() endif() - if(DEFINED OPUS_FOUND OR USING_CONAN) + if(DEFINED OPUS_FOUND OR Opus_FOUND) message("-- Found Opus ${Green}${OPUS_LIBRARIES}${ColourReset}") if((WIN32 OR PKG_CONFIG_FOUND) AND DEFINED sodium_VERSION_STRING AND DEFINED sodium_LIBRARY_RELEASE) add_compile_definitions(HAVE_VOICE) @@ -262,8 +258,8 @@ foreach (fullmodname ${subdirlist}) endif() if (WIN32 AND NOT MINGW) - if(USING_CONAN) - target_link_libraries(${modname} PUBLIC openssl::openssl + if(CONAN_EXPORTED) + target_link_libraries(${modname} PRIVATE openssl::openssl libsodium::libsodium Opus::opus ZLIB::ZLIB) @@ -281,8 +277,8 @@ foreach (fullmodname ${subdirlist}) "${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/lib/zlib.lib") endif() else() - if(USING_CONAN) - target_link_libraries(${modname} PUBLIC openssl::openssl ZLIB::ZLIB) + if(CONAN_EXPORTED) + target_link_libraries(${modname} PRIVATE openssl::openssl ZLIB::ZLIB) else() target_link_libraries(${modname} PUBLIC ${OPENSSL_CRYPTO_LIBRARY} ${OPENSSL_SSL_LIBRARY} ${ZLIB_LIBRARIES}) endif() @@ -292,8 +288,8 @@ foreach (fullmodname ${subdirlist}) endif() if (HAVE_VOICE) - if(USING_CONAN) - target_link_libraries(${modname} PUBLIC libsodium::libsodium Opus::opus) + if(CONAN_EXPORTED) + target_link_libraries(${modname} PRIVATE libsodium::libsodium Opus::opus) else() target_link_libraries(${modname} PUBLIC ${sodium_LIBRARY_RELEASE} ${OPUS_LIBRARIES}) endif() @@ -402,7 +398,7 @@ if (DPP_BUILD_TEST) ) endif() -if(NOT USING_CONAN) +if(NOT CONAN_EXPORTED) if(WIN32 AND NOT MINGW) if (NOT WINDOWS_32_BIT) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/zlib1.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) From 857c4fc7fb5cfc1560ccb33082d7b103c6ed8a24 Mon Sep 17 00:00:00 2001 From: mikeravenelle Date: Sat, 20 Jan 2024 16:42:14 -0600 Subject: [PATCH 08/21] Added DPP_NO_CONAN to pipeline, moved conan cmake out of main library CMakeLists.txt, root CMakeLists now detects conan and uses its cmake if detected --- .github/workflows/ci.yml | 10 +- CMakeLists.txt | 11 +- library-conan/CMakeLists.txt | 360 +++++++++++++++++++++++++++++++++++ library/CMakeLists.txt | 154 ++++++--------- 4 files changed, 437 insertions(+), 98 deletions(-) create mode 100644 library-conan/CMakeLists.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e70f31207a..1fd18e25d1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,7 +67,7 @@ jobs: run: sudo sed -i 's/azure\.//' /etc/apt/sources.list && sudo apt update && sudo apt-get install -y ${{ matrix.cfg.package }} pkg-config libsodium-dev libopus-dev zlib1g-dev rpm - name: Generate CMake - run: mkdir build && cd build && cmake -DDPP_NO_VCPKG=ON -DAVX_TYPE=AVX0 -DCMAKE_BUILD_TYPE=Release ${{matrix.cfg.cmake-flags}} .. + run: mkdir build && cd build && cmake -DDPP_NO_VCPKG=ON -DDPP_NO_CONAN=ON -DAVX_TYPE=AVX0 -DCMAKE_BUILD_TYPE=Release ${{matrix.cfg.cmake-flags}} .. env: CXX: ${{matrix.cfg.cpp-version}} @@ -128,7 +128,7 @@ jobs: run: brew install cmake make libsodium opus openssl pkg-config - name: Generate CMake - run: mkdir build && cd build && cmake -DDPP_NO_VCPKG=ON -DCMAKE_BUILD_TYPE=Release -DDPP_CORO=ON -DAVX_TYPE=AVX0 .. + run: mkdir build && cd build && cmake -DDPP_NO_VCPKG=ON -DDPP_NO_CONAN=ON -DCMAKE_BUILD_TYPE=Release -DDPP_CORO=ON -DAVX_TYPE=AVX0 .. env: DONT_RUN_VCPKG: true @@ -183,13 +183,13 @@ jobs: - name: Generate CMake (x64) if: ${{ matrix.cfg.arch == 'x64' }} - run: mkdir main/build && cd main/build && cmake -G "Visual Studio ${{matrix.cfg.vsv}} ${{matrix.cfg.vs}}" -DDPP_NO_VCPKG=ON -DAVX_TYPE=AVX0 -DDPP_USE_PCH=on ${{matrix.cfg.options}} .. + run: mkdir main/build && cd main/build && cmake -G "Visual Studio ${{matrix.cfg.vsv}} ${{matrix.cfg.vs}}" -DDPP_NO_VCPKG=ON -DDPP_NO_CONAN=ON -DAVX_TYPE=AVX0 -DDPP_USE_PCH=on ${{matrix.cfg.options}} .. env: DONT_RUN_VCPKG: true - name: Generate CMake (x86) if: ${{ matrix.cfg.arch == 'x86' }} - run: mkdir main/build && cd main/build && cmake -DCMAKE_TOOLCHAIN_FILE="cmake\Win32Toolchain.cmake" -DDPP_NO_VCPKG=ON -DAVX_TYPE=AVX0 -DDPP_USE_PCH=on -G "Visual Studio ${{matrix.cfg.vsv}} ${{matrix.cfg.vs}}" -A Win32 ${{matrix.cfg.options}} .. + run: mkdir main/build && cd main/build && cmake -DCMAKE_TOOLCHAIN_FILE="cmake\Win32Toolchain.cmake" -DDPP_NO_VCPKG=ON -DDPP_NO_CONAN=ON -DAVX_TYPE=AVX0 -DDPP_USE_PCH=on -G "Visual Studio ${{matrix.cfg.vsv}} ${{matrix.cfg.vs}}" -A Win32 ${{matrix.cfg.options}} .. env: DONT_RUN_VCPKG: true @@ -242,7 +242,7 @@ jobs: run: sudo sed -i 's/azure\.//' /etc/apt/sources.list && sudo apt update && sudo apt-get install -y cmake rpm - name: Generate CMakeFiles - run: mkdir build && cd build && sudo cmake ${{matrix.cfg.cmake-options}} -DDPP_NO_VCPKG=ON -DCMAKE_BUILD_TYPE=Release -DAVX_TYPE=AVX0 .. + run: mkdir build && cd build && sudo cmake ${{matrix.cfg.cmake-options}} -DDPP_NO_VCPKG=ON -DDPP_NO_CONAN=ON -DCMAKE_BUILD_TYPE=Release -DAVX_TYPE=AVX0 .. - name: Compile Source run: cd build && sudo make -j2 diff --git a/CMakeLists.txt b/CMakeLists.txt index 025203badf..88cd8d311e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,12 @@ else() message("-- INFO: Using VCPKG if detected") endif() +if (DPP_NO_CONAN) + message("-- INFO: Explicitly disabling Conan as running inside the CI action.") +else() + message("-- INFO: Using Conan if detected") +endif() + if (WIN32 AND NOT MINGW AND BUILD_SHARED_LIBS) message("-- INFO: Configuring .rc resource script") configure_file("${DPP_ROOT_PATH}/src/dpp/dpp.rc.in" "${DPP_ROOT_PATH}/src/dpp/dpp.rc" NEWLINE_STYLE WIN32) @@ -99,7 +105,10 @@ else() enable_testing(${CMAKE_CURRENT_SOURCE_DIR}) endif() - add_subdirectory(library) + if(CONAN_EXPORTED AND NOT DPP_NO_CONAN) + add_subdirectory(library-conan) + else() + add_subdirectory(library) endif() if(DPP_USE_EXTERNAL_JSON) diff --git a/library-conan/CMakeLists.txt b/library-conan/CMakeLists.txt new file mode 100644 index 0000000000..f90fa07a1d --- /dev/null +++ b/library-conan/CMakeLists.txt @@ -0,0 +1,360 @@ +message("-- INFO: Conan detected... finding packages") +find_package(OpenSSL REQUIRED COMPONENTS SSL Crypto) +find_package(ZLIB REQUIRED) +find_package(libsodium REQUIRED) +find_package(Opus) + + +# Check for various C functions + +check_cxx_symbol_exists(prctl "sys/prctl.h" HAVE_PRCTL) +check_cxx_symbol_exists(pthread_setname_np "pthread.h" HAVE_PTHREAD_SETNAME_NP) + +# Go into more detail here and identify the valid signature of pthread_setname_np, +# because different systems have different forms of this function (ugh). +if (HAVE_PTHREAD_SETNAME_NP) + include(CheckCXXSourceCompiles) + check_cxx_source_compiles(" + #include + int main() { + pthread_setname_np(\"ThreadName\"); + return 0; + }" HAVE_SINGLE_PARAMETER_SETNAME_NP) + check_cxx_source_compiles(" + #include + int main() { + pthread_setname_np(pthread_self(), \"ThreadName\"); + return 0; + }" HAVE_TWO_PARAMETER_SETNAME_NP) +endif() + +add_compile_definitions(DPP_OS=${CMAKE_SYSTEM_NAME}) + +if(${AVX_TYPE} STREQUAL "OFF") + include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/DetectArchitecture.cmake") +else() + message("-- AVX type overridden by configuration: ${AVX_TYPE}") +endif() +STRING(REPLACE "AVX" "" AVX_TYPE ${AVX_TYPE}) +add_compile_definitions(AVX_TYPE=${AVX_TYPE}) +add_compile_options(${AVX_FLAG}) + +if(WIN32 AND NOT MINGW) + if (NOT WINDOWS_32_BIT) + message("-- Building for windows with precompiled packaged dependencies") + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) + add_compile_options("/bigobj") + add_compile_definitions(OPENSSL_SYS_WIN32) + add_compile_definitions(_WINSOCK_DEPRECATED_NO_WARNINGS) + add_compile_definitions(WIN32_LEAN_AND_MEAN) + add_compile_definitions(_CRT_SECURE_NO_WARNINGS) + add_compile_definitions(_CRT_NONSTDC_NO_DEPRECATE) + endif() +endif() + +if (UNIX) + message("-- Checking for ability to update autogenerated files") + execute_process( + COMMAND which php + RESULT_VARIABLE HAS_PHP + OUTPUT_QUIET + ) + + if (${HAS_PHP} STREQUAL "0") + message("-- Checking for update to autogenerated files") + # target for rebuild of cluster::*_sync() functions + execute_process( + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.." + COMMAND php buildtools/make_struct.php "\\Dpp\\Generator\\SyncGenerator" + ) + set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/../include/dpp/cluster_sync_calls.h" PROPERTIES GENERATED TRUE ) + # target for unicode_emojis.h + execute_process( + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.." + COMMAND php buildtools/emojis.php + ) + set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/../include/dpp/unicode_emojis.h" PROPERTIES GENERATED TRUE ) + else() + message("-- Autogeneration is not available") + endif() +endif() + +if(NOT BUILD_SHARED_LIBS) + if(UNIX) + message("-- Building static library.") + + if(UNIX AND NOT APPLE) + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") + endif() + + set(OPENSSL_USE_STATIC_LIBS ON) + set(sodium_USE_STATIC_LIBS ON) + set(OPUS_USE_STATIC_LIBS TRUE) + else() + message(WARNING "-- Building of static library not supported on non UNIX systems.") + endif() +endif() + +include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/colour.cmake") + + if (BUILD_VOICE_SUPPORT) + if(Opus_FOUND) + message("-- Found Opus ${Green}${OPUS_LIBRARIES}${ColourReset}") + if((WIN32 OR PKG_CONFIG_FOUND) AND DEFINED sodium_VERSION_STRING AND DEFINED sodium_LIBRARY_RELEASE) + add_compile_definitions(HAVE_VOICE) + + message("-- Sodium ${Green}${sodium_VERSION_STRING}${ColourReset}") + + set(HAVE_VOICE 1) + endif() + endif() + + if(HAVE_VOICE) + message("-- Detected ${Green}libsodium${ColourReset} and ${Green}libopus${ColourReset}. VOICE support will be ${Green}enabled${ColourReset}") + else(HAVE_VOICE) + message("-- Could not detect ${Green}libsodium${ColourReset} and/or ${Green}libopus${ColourReset}. VOICE support will be ${Red}disabled${ColourReset}") + endif(HAVE_VOICE) + else() + message("-- Voice support disabled by cmake option") + endif() + +string(ASCII 27 Esc) + +set(THREADS_PREFER_PTHREAD_FLAG ON) + +find_package(Threads REQUIRED) +if(MINGW OR NOT WIN32) + find_package(ZLIB REQUIRED) +endif(MINGW OR NOT WIN32) + +if(APPLE) + if(CMAKE_APPLE_SILICON_PROCESSOR EQUAL arm64) + set(OPENSSL_ROOT_DIR "/opt/homebrew/opt/openssl") + else() + set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl") + endif() + find_package(OpenSSL REQUIRED) +else() + if(MINGW OR NOT WIN32) + find_package(OpenSSL REQUIRED) + endif() +endif() + +include_directories(${OPENSSL_INCLUDE_DIR} ${ZLIB_INCLUDE_DIRS}) + +find_package(Git QUIET) + +if(NOT GIT_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../.git") + message(FATAL_ERROR "You are using a git version of D++ but do not have git installed. Install git (not 'gh') and try again.") +endif() + +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../.git") + message("-- Building ${Green}git${ColourReset} version. ${Green}Be aware git versions may be unstable!${ColourReset}") +else() + message("-- Building ${Green}stable${ColourReset} version ${Green}${DPP_VERSION}${ColourReset}") +endif() + +if(UNIX OR MSYS) + find_program(LDCONFIG_EXECUTABLE "ldconfig") +endif() + +if(MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /sdl /DFD_SETSIZE=1024") + if(CMAKE_BUILD_TYPE STREQUAL "Debug") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj /Od /DEBUG /Zi") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2 /Oi /Oy /Gy") + endif() + if(NOT DPP_CLANG_CL) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /Zc:preprocessor") + if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GL") + endif() + endif() + string(REGEX REPLACE "/W[1|2|3|4]" "/W3" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") +else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unused-private-field -Wno-psabi -Wempty-body -Wignored-qualifiers -Wimplicit-fallthrough -Wmissing-field-initializers -Wsign-compare -Wtype-limits -Wuninitialized -Wshift-negative-value -pthread") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og") + + if (NOT MINGW) + add_link_options("-rdynamic") + endif () +endif() + +set(modules_dir "../src") + +file(GLOB subdirlist ${modules_dir}/dpp) + +foreach (fullmodname ${subdirlist}) + get_filename_component(modname ${fullmodname} NAME) + set (modsrc "") + + file(GLOB modsrc "${modules_dir}/dpp/*.cpp" "${modules_dir}/dpp/events/*.cpp" "${modules_dir}/dpp/cluster/*.cpp" "${modules_dir}/dpp/*.rc") + + if(BUILD_SHARED_LIBS) + add_library(${modname} SHARED ${modsrc}) + else() + add_library(${modname} STATIC ${modsrc}) + endif() + set_target_properties(${modname} + PROPERTIES + VERSION ${CMAKE_PROJECT_VERSION} + SOVERSION ${CMAKE_PROJECT_VERSION} + POSITION_INDEPENDENT_CODE true + ) + target_include_directories(${modname} PUBLIC + $ + $ + ) + + if (DPP_USE_PCH) + target_precompile_headers(${modname} PRIVATE + "${CMAKE_CURRENT_SOURCE_DIR}/../include/dpp/cluster.h" + "${CMAKE_CURRENT_SOURCE_DIR}/../include/dpp/json.h" + "${CMAKE_CURRENT_SOURCE_DIR}/../include/dpp/utility.h" + "${CMAKE_CURRENT_SOURCE_DIR}/../include/dpp/restresults.h" + ) + endif() + + if (WIN32 AND NOT MINGW) + target_link_libraries(${modname} PRIVATE openssl::openssl + libsodium::libsodium + Opus::opus + ZLIB::ZLIB) + else() + target_link_libraries(${modname} PRIVATE openssl::openssl ZLIB::ZLIB) + if (MINGW) + target_link_libraries(${modname} PUBLIC wsock32 ws2_32 crypt32) + endif () + endif() + + if (HAVE_VOICE) + target_link_libraries(${modname} PRIVATE libsodium::libsodium Opus::opus) + include_directories(${OPUS_INCLUDE_DIRS} ${sodium_INCLUDE_DIR}) + endif() + +endforeach() + +target_compile_features(dpp PUBLIC cxx_std_17) +target_compile_features(dpp PRIVATE cxx_constexpr) +target_compile_features(dpp PRIVATE cxx_auto_type) +target_compile_features(dpp PRIVATE cxx_defaulted_functions) +target_compile_features(dpp PRIVATE cxx_deleted_functions) +target_compile_features(dpp PRIVATE cxx_final) +target_compile_features(dpp PRIVATE cxx_lambdas) +target_compile_features(dpp PRIVATE cxx_override) +target_compile_features(dpp PRIVATE cxx_thread_local) +target_compile_features(dpp PRIVATE cxx_variadic_templates) +target_compile_features(dpp PRIVATE cxx_attribute_deprecated) + +if(HAVE_PRCTL) + target_compile_definitions(dpp PRIVATE HAVE_PRCTL) +endif() +if(HAVE_PTHREAD_SETNAME_NP) + target_compile_definitions(dpp PRIVATE HAVE_PTHREAD_SETNAME_NP) +endif() + +if(DPP_CORO) + message("-- ${Yellow}Enabled experimental coroutine feature${ColourReset}") + set(CMAKE_CXX_STANDARD 20) + target_compile_features(dpp PUBLIC cxx_std_20) + if(WIN32 AND NOT MINGW AND NOT DPP_CLANG_CL) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /await:strict") # https://learn.microsoft.com/en-us/cpp/build/reference/await-enable-coroutine-support?view=msvc-170 + else() + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14.0.0) # clang >= 14 has native support + message("-- ${Yellow}Clang < 14 - attempting to detect if using libc++ or stdc++${ColourReset}") + check_cxx_source_compiles(" + #include + + int a = + #ifdef __GLIBCXX__ + 1; + #else + fgsfds; + #endif + + int main(int argc, char* argv[]) + { + return 0; + } + " IS_GLIBCXX) + if(IS_GLIBCXX) + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.0.0) + message(FATAL_ERROR "${BoldRed}Clang with stdc++ and coroutines requires version 12.0.0 or above${ColourReset}") + endif() + message("-- ${Yellow}Detected stdc++ - enabling mock std::experimental namespace${ColourReset}") + target_compile_definitions(dpp PUBLIC "STDCORO_GLIBCXX_COMPAT") + else() + message("-- ${Yellow}Detected libc++ - using ${ColourReset}") + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0.0) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcoroutines-ts") + endif() + endif() + message("-- ${Yellow}Note - coroutines in clang < 14 are experimental, upgrading is recommended${ColourReset}") + endif() + elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0) + message(FATAL_ERROR "${BoldRed}Coroutines with g++ require version 10 or above${ColourReset}") + elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11.0) + message("-- ${Yellow}Note - coroutines in g++10 are experimental, upgrading to g++11 or above is recommended${ColourReset}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcoroutines") + endif() + endif() + endif() + target_compile_definitions(dpp PUBLIC DPP_CORO) + execute_process(WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.." + COMMAND php buildtools/make_struct.php "\\Dpp\\Generator\\CoroGenerator") +endif() + +if (DPP_BUILD_TEST) + enable_testing(${CMAKE_CURRENT_SOURCE_DIR}/..) + file(GLOB testnamelist "${CMAKE_CURRENT_SOURCE_DIR}/../src/*") + foreach (fulltestname ${testnamelist}) + get_filename_component(testname ${fulltestname} NAME) + if (NOT "${testname}" STREQUAL "dpp") + message("-- Configuring test: ${Green}${testname}${ColourReset} with source: ${modules_dir}/${testname}/*.cpp") + set (testsrc "") + file(GLOB testsrc "${modules_dir}/${testname}/*.cpp") + add_executable(${testname} ${testsrc}) + if (DPP_CORO) + target_compile_features(${testname} PRIVATE cxx_std_20) + else() + target_compile_features(${testname} PRIVATE cxx_std_17) + endif() + if (MSVC) + target_compile_options(${testname} PRIVATE /utf-8) + endif() + target_link_libraries(${testname} PUBLIC ${modname}) + endif() + endforeach() + add_test( + NAME unittest + COMMAND unittest + ) +endif() + +if(DPP_INSTALL) + if(NOT WIN32) + # Installation + + include(GNUInstallDirs) + install(TARGETS dpp LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + message("Library install directory at ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") + install(DIRECTORY ../include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + message("Include files install directory at ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}") + install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -DRUN_LDCONFIG=${RUN_LDCONFIG} -DLDCONFIG_EXECUTABLE=${LDCONFIG_EXECUTABLE} -P ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/PostInstall.cmake)") + + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../dpp.pc.in" "${CMAKE_BINARY_DIR}/dpp.pc" @ONLY) + install(FILES "${CMAKE_BINARY_DIR}/dpp.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") + elseif(MINGW) + install(TARGETS dpp LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) + install(DIRECTORY ../include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include) + endif() + + # Setup information for packaging and distribution + include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/CPackSetup.cmake") + + # CPack initialization for distribution + include(CPack) +endif() diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 1773e3bd43..3879d10e2f 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -1,14 +1,4 @@ -# Check for the use of conan -if(CONAN_EXPORTED) - message("Conan in use... finding packages") - find_package(OpenSSL REQUIRED COMPONENTS SSL Crypto) - find_package(ZLIB REQUIRED) - find_package(libsodium REQUIRED) - find_package(Opus) -endif() - # Check for various C functions - check_cxx_symbol_exists(prctl "sys/prctl.h" HAVE_PRCTL) check_cxx_symbol_exists(pthread_setname_np "pthread.h" HAVE_PTHREAD_SETNAME_NP) @@ -44,32 +34,29 @@ add_compile_options(${AVX_FLAG}) if(WIN32 AND NOT MINGW) if (NOT WINDOWS_32_BIT) message("-- Building for windows with precompiled packaged dependencies") - if(CONAN_EXPORTED) - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) - else() - set(ZLIB_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib") - set(ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../win32/include") - set(OPENSSL_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../win32/include") - set(OPENSSL_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib") - ADD_DEFINITIONS(/bigobj) - - link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libssl.lib") - link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libcrypto.lib") - link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/zlib.lib") - link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libsodium.lib") - link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/opus.lib") - - set(OPUS_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../win32/include") - set(OPUS_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/opus.lib") - set(sodium_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../win32/include") - set(sodium_LIBRARY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libsodium.lib") - set(sodium_LIBRARY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libsodium.lib") - set(HAVE_OPUS_OPUS_H "${CMAKE_CURRENT_SOURCE_DIR}/../win32/include/opus/opus.h") - set(OPUS_FOUND 1) - SET(sodium_VERSION_STRING "win32 bundled") - - include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../win32/include") - endif() + #set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) + set(ZLIB_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib") + set(ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../win32/include") + set(OPENSSL_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../win32/include") + set(OPENSSL_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib") + #ADD_DEFINITIONS(/bigobj) + + link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libssl.lib") + link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libcrypto.lib") + link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/zlib.lib") + link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libsodium.lib") + link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/opus.lib") + + set(OPUS_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../win32/include") + set(OPUS_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/opus.lib") + set(sodium_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../win32/include") + set(sodium_LIBRARY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libsodium.lib") + set(sodium_LIBRARY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libsodium.lib") + set(HAVE_OPUS_OPUS_H "${CMAKE_CURRENT_SOURCE_DIR}/../win32/include/opus/opus.h") + set(OPUS_FOUND 1) + SET(sodium_VERSION_STRING "win32 bundled") + + include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../win32/include") add_compile_options("/bigobj") add_compile_definitions(OPENSSL_SYS_WIN32) @@ -126,38 +113,36 @@ endif() include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/colour.cmake") - if (BUILD_VOICE_SUPPORT) - if(NOT CONAN_EXPORTED) - if (MINGW OR NOT WIN32) - find_package(PkgConfig QUIET) - if(PKG_CONFIG_FOUND) - include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/FindSodium.cmake") - else() - message("-- Could not detect ${Green}libsodium${ColourReset} due to missing ${Green}pkgconfig${ColourReset}. VOICE support will be ${Red}disabled${ColourReset}") - endif() - include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/FindOpus.cmake") +if (BUILD_VOICE_SUPPORT) + if (MINGW OR NOT WIN32) + find_package(PkgConfig QUIET) + if(PKG_CONFIG_FOUND) + include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/FindSodium.cmake") + else() + message("-- Could not detect ${Green}libsodium${ColourReset} due to missing ${Green}pkgconfig${ColourReset}. VOICE support will be ${Red}disabled${ColourReset}") endif() + include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/FindOpus.cmake") endif() - if(DEFINED OPUS_FOUND OR Opus_FOUND) - message("-- Found Opus ${Green}${OPUS_LIBRARIES}${ColourReset}") - if((WIN32 OR PKG_CONFIG_FOUND) AND DEFINED sodium_VERSION_STRING AND DEFINED sodium_LIBRARY_RELEASE) - add_compile_definitions(HAVE_VOICE) + if(DEFINED OPUS_FOUND) + message("-- Found Opus ${Green}${OPUS_LIBRARIES}${ColourReset}") + if((WIN32 OR PKG_CONFIG_FOUND) AND DEFINED sodium_VERSION_STRING AND DEFINED sodium_LIBRARY_RELEASE) + add_compile_definitions(HAVE_VOICE) - message("-- Sodium ${Green}${sodium_VERSION_STRING}${ColourReset}") + message("-- Sodium ${Green}${sodium_VERSION_STRING}${ColourReset}") set(HAVE_VOICE 1) - endif() + endif() endif() - if(HAVE_VOICE) - message("-- Detected ${Green}libsodium${ColourReset} and ${Green}libopus${ColourReset}. VOICE support will be ${Green}enabled${ColourReset}") - else(HAVE_VOICE) - message("-- Could not detect ${Green}libsodium${ColourReset} and/or ${Green}libopus${ColourReset}. VOICE support will be ${Red}disabled${ColourReset}") - endif(HAVE_VOICE) - else() + if(HAVE_VOICE) + message("-- Detected ${Green}libsodium${ColourReset} and ${Green}libopus${ColourReset}. VOICE support will be ${Green}enabled${ColourReset}") + else(HAVE_VOICE) + message("-- Could not detect ${Green}libsodium${ColourReset} and/or ${Green}libopus${ColourReset}. VOICE support will be ${Red}disabled${ColourReset}") + endif(HAVE_VOICE) +else() message("-- Voice support disabled by cmake option") - endif() +endif() string(ASCII 27 Esc) @@ -258,12 +243,7 @@ foreach (fullmodname ${subdirlist}) endif() if (WIN32 AND NOT MINGW) - if(CONAN_EXPORTED) - target_link_libraries(${modname} PRIVATE openssl::openssl - libsodium::libsodium - Opus::opus - ZLIB::ZLIB) - elseif (NOT WINDOWS_32_BIT) + if (NOT WINDOWS_32_BIT) target_link_libraries(${modname} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libssl.lib" "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libcrypto.lib" "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libsodium.lib" @@ -276,27 +256,19 @@ foreach (fullmodname ${subdirlist}) "${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/lib/opus.lib" "${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/lib/zlib.lib") endif() + else() - if(CONAN_EXPORTED) - target_link_libraries(${modname} PRIVATE openssl::openssl ZLIB::ZLIB) - else() - target_link_libraries(${modname} PUBLIC ${OPENSSL_CRYPTO_LIBRARY} ${OPENSSL_SSL_LIBRARY} ${ZLIB_LIBRARIES}) - endif() + target_link_libraries(${modname} PUBLIC ${OPENSSL_CRYPTO_LIBRARY} ${OPENSSL_SSL_LIBRARY} ${ZLIB_LIBRARIES}) if (MINGW) target_link_libraries(${modname} PUBLIC wsock32 ws2_32 crypt32) endif () endif() if (HAVE_VOICE) - if(CONAN_EXPORTED) - target_link_libraries(${modname} PRIVATE libsodium::libsodium Opus::opus) - else() - target_link_libraries(${modname} PUBLIC ${sodium_LIBRARY_RELEASE} ${OPUS_LIBRARIES}) - endif() + target_link_libraries(${modname} PUBLIC ${sodium_LIBRARY_RELEASE} ${OPUS_LIBRARIES}) include_directories(${OPUS_INCLUDE_DIRS} ${sodium_INCLUDE_DIR}) endif() - endforeach() target_compile_features(dpp PUBLIC cxx_std_17) @@ -397,22 +369,20 @@ if (DPP_BUILD_TEST) COMMAND unittest ) endif() - -if(NOT CONAN_EXPORTED) - if(WIN32 AND NOT MINGW) - if (NOT WINDOWS_32_BIT) - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/zlib1.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/libcrypto-1_1-x64.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/libssl-1_1-x64.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/libsodium.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/opus.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) - else() - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/zlib1.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/libcrypto-1_1.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/libssl-1_1.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/libsodium.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/opus.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) - endif() + +if(WIN32 AND NOT MINGW) + if (NOT WINDOWS_32_BIT) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/zlib1.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/libcrypto-1_1-x64.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/libssl-1_1-x64.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/libsodium.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/opus.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) + else() + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/zlib1.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/libcrypto-1_1.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/libssl-1_1.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/libsodium.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/opus.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) endif() endif() From 0c5cbf07e2813292d90652280b81c5952e164587 Mon Sep 17 00:00:00 2001 From: mikeravenelle Date: Sat, 20 Jan 2024 16:43:13 -0600 Subject: [PATCH 09/21] Reset ci.yml since github wont let me commit --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1fd18e25d1..e70f31207a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,7 +67,7 @@ jobs: run: sudo sed -i 's/azure\.//' /etc/apt/sources.list && sudo apt update && sudo apt-get install -y ${{ matrix.cfg.package }} pkg-config libsodium-dev libopus-dev zlib1g-dev rpm - name: Generate CMake - run: mkdir build && cd build && cmake -DDPP_NO_VCPKG=ON -DDPP_NO_CONAN=ON -DAVX_TYPE=AVX0 -DCMAKE_BUILD_TYPE=Release ${{matrix.cfg.cmake-flags}} .. + run: mkdir build && cd build && cmake -DDPP_NO_VCPKG=ON -DAVX_TYPE=AVX0 -DCMAKE_BUILD_TYPE=Release ${{matrix.cfg.cmake-flags}} .. env: CXX: ${{matrix.cfg.cpp-version}} @@ -128,7 +128,7 @@ jobs: run: brew install cmake make libsodium opus openssl pkg-config - name: Generate CMake - run: mkdir build && cd build && cmake -DDPP_NO_VCPKG=ON -DDPP_NO_CONAN=ON -DCMAKE_BUILD_TYPE=Release -DDPP_CORO=ON -DAVX_TYPE=AVX0 .. + run: mkdir build && cd build && cmake -DDPP_NO_VCPKG=ON -DCMAKE_BUILD_TYPE=Release -DDPP_CORO=ON -DAVX_TYPE=AVX0 .. env: DONT_RUN_VCPKG: true @@ -183,13 +183,13 @@ jobs: - name: Generate CMake (x64) if: ${{ matrix.cfg.arch == 'x64' }} - run: mkdir main/build && cd main/build && cmake -G "Visual Studio ${{matrix.cfg.vsv}} ${{matrix.cfg.vs}}" -DDPP_NO_VCPKG=ON -DDPP_NO_CONAN=ON -DAVX_TYPE=AVX0 -DDPP_USE_PCH=on ${{matrix.cfg.options}} .. + run: mkdir main/build && cd main/build && cmake -G "Visual Studio ${{matrix.cfg.vsv}} ${{matrix.cfg.vs}}" -DDPP_NO_VCPKG=ON -DAVX_TYPE=AVX0 -DDPP_USE_PCH=on ${{matrix.cfg.options}} .. env: DONT_RUN_VCPKG: true - name: Generate CMake (x86) if: ${{ matrix.cfg.arch == 'x86' }} - run: mkdir main/build && cd main/build && cmake -DCMAKE_TOOLCHAIN_FILE="cmake\Win32Toolchain.cmake" -DDPP_NO_VCPKG=ON -DDPP_NO_CONAN=ON -DAVX_TYPE=AVX0 -DDPP_USE_PCH=on -G "Visual Studio ${{matrix.cfg.vsv}} ${{matrix.cfg.vs}}" -A Win32 ${{matrix.cfg.options}} .. + run: mkdir main/build && cd main/build && cmake -DCMAKE_TOOLCHAIN_FILE="cmake\Win32Toolchain.cmake" -DDPP_NO_VCPKG=ON -DAVX_TYPE=AVX0 -DDPP_USE_PCH=on -G "Visual Studio ${{matrix.cfg.vsv}} ${{matrix.cfg.vs}}" -A Win32 ${{matrix.cfg.options}} .. env: DONT_RUN_VCPKG: true @@ -242,7 +242,7 @@ jobs: run: sudo sed -i 's/azure\.//' /etc/apt/sources.list && sudo apt update && sudo apt-get install -y cmake rpm - name: Generate CMakeFiles - run: mkdir build && cd build && sudo cmake ${{matrix.cfg.cmake-options}} -DDPP_NO_VCPKG=ON -DDPP_NO_CONAN=ON -DCMAKE_BUILD_TYPE=Release -DAVX_TYPE=AVX0 .. + run: mkdir build && cd build && sudo cmake ${{matrix.cfg.cmake-options}} -DDPP_NO_VCPKG=ON -DCMAKE_BUILD_TYPE=Release -DAVX_TYPE=AVX0 .. - name: Compile Source run: cd build && sudo make -j2 From 84792c80aab87fc1ce103647d5625624ecf905a6 Mon Sep 17 00:00:00 2001 From: mikeravenelle Date: Sat, 20 Jan 2024 16:58:25 -0600 Subject: [PATCH 10/21] Fixed 1 error and tabbing --- conan/conanfile.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/conan/conanfile.py b/conan/conanfile.py index f072b25589..f5769350c0 100644 --- a/conan/conanfile.py +++ b/conan/conanfile.py @@ -2,7 +2,7 @@ from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps from conan.tools.scm import Git from conan.tools.files import load, update_conandata -1 + class DPPConan(ConanFile): name = "dpp" version = "0.1" @@ -17,11 +17,11 @@ class DPPConan(ConanFile): default_options = {"shared": False, "fPIC": True} def build_requirements(self): - self.requires("nlohmann_json/3.11.2", headers=True, libs=True) - self.requires("openssl/3.1.2", headers=True, libs=True) - self.requires("zlib/1.3", headers=True, libs=True) - self.requires("libsodium/cci.20220430", headers=True, libs=True) - self.requires("opus/1.4", headers=True, libs=True) + self.requires("nlohmann_json/3.11.2", headers=True, libs=True) + self.requires("openssl/3.1.2", headers=True, libs=True) + self.requires("zlib/1.3", headers=True, libs=True) + self.requires("libsodium/cci.20220430", headers=True, libs=True) + self.requires("opus/1.4", headers=True, libs=True) def config_options(self): if self.settings.os == "Windows": @@ -62,4 +62,4 @@ def package(self): cmake.install() def package_info(self): - self.cpp_info.libs = ["dpp"] \ No newline at end of file + self.cpp_info.libs = ["dpp"] \ No newline at end of file From d5dd3f63411ce3793bc4cf98737ecba2eb9a1c25 Mon Sep 17 00:00:00 2001 From: mikeravenelle Date: Sat, 20 Jan 2024 17:00:37 -0600 Subject: [PATCH 11/21] Added missing endif() --- CMakeLists.txt | 1 + conan/conanfile.py | 2 +- library-conan/CMakeLists.txt | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 88cd8d311e..a631292261 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,6 +109,7 @@ else() add_subdirectory(library-conan) else() add_subdirectory(library) + endif() endif() if(DPP_USE_EXTERNAL_JSON) diff --git a/conan/conanfile.py b/conan/conanfile.py index f5769350c0..41c5b57a09 100644 --- a/conan/conanfile.py +++ b/conan/conanfile.py @@ -2,7 +2,7 @@ from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps from conan.tools.scm import Git from conan.tools.files import load, update_conandata - + class DPPConan(ConanFile): name = "dpp" version = "0.1" diff --git a/library-conan/CMakeLists.txt b/library-conan/CMakeLists.txt index f90fa07a1d..a2710eac4e 100644 --- a/library-conan/CMakeLists.txt +++ b/library-conan/CMakeLists.txt @@ -3,7 +3,7 @@ find_package(OpenSSL REQUIRED COMPONENTS SSL Crypto) find_package(ZLIB REQUIRED) find_package(libsodium REQUIRED) find_package(Opus) - +message(STATUS "Opus_FOUND: ${Opus_FOUND}") # Check for various C functions From ffa9cd5e96ed2a10c9a9263d255a6fca51b745ba Mon Sep 17 00:00:00 2001 From: mikeravenelle Date: Sun, 21 Jan 2024 09:23:08 -0600 Subject: [PATCH 12/21] Added parent folder for commit instead of recipe folder and BUILD_VOICE_SUPPORT by default --- conan/conanfile.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/conan/conanfile.py b/conan/conanfile.py index 41c5b57a09..364371d7c1 100644 --- a/conan/conanfile.py +++ b/conan/conanfile.py @@ -1,8 +1,9 @@ +import os from conan import ConanFile from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps from conan.tools.scm import Git from conan.tools.files import load, update_conandata - + class DPPConan(ConanFile): name = "dpp" version = "0.1" @@ -35,7 +36,7 @@ def layout(self): cmake_layout(self) def export(self): - git = Git(self, self.recipe_folder) + git = Git(self, os.path.dirname(self.recipe_folder)) scm_url, scm_commit = git.get_url_and_commit() update_conandata(self, {"sources": {"commit": scm_commit, "url": scm_url}}) @@ -50,6 +51,7 @@ def generate(self): deps.generate() tc = CMakeToolchain(self) tc.cache_variables["CONAN_EXPORTED"] = True + tc.cache_variables["BUILD_VOICE_SUPPORT"] = True tc.generate() def build(self): From f4ecfc37b9020d2a53e83993019ea07b6a92f38c Mon Sep 17 00:00:00 2001 From: mikeravenelle Date: Sun, 21 Jan 2024 09:36:00 -0600 Subject: [PATCH 13/21] Fixed CMake variables for opus and libsodium --- library-conan/CMakeLists.txt | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/library-conan/CMakeLists.txt b/library-conan/CMakeLists.txt index a2710eac4e..c8d0fc6689 100644 --- a/library-conan/CMakeLists.txt +++ b/library-conan/CMakeLists.txt @@ -3,7 +3,6 @@ find_package(OpenSSL REQUIRED COMPONENTS SSL Crypto) find_package(ZLIB REQUIRED) find_package(libsodium REQUIRED) find_package(Opus) -message(STATUS "Opus_FOUND: ${Opus_FOUND}") # Check for various C functions @@ -96,17 +95,12 @@ if(NOT BUILD_SHARED_LIBS) endif() include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/colour.cmake") - if (BUILD_VOICE_SUPPORT) - if(Opus_FOUND) - message("-- Found Opus ${Green}${OPUS_LIBRARIES}${ColourReset}") - if((WIN32 OR PKG_CONFIG_FOUND) AND DEFINED sodium_VERSION_STRING AND DEFINED sodium_LIBRARY_RELEASE) - add_compile_definitions(HAVE_VOICE) - - message("-- Sodium ${Green}${sodium_VERSION_STRING}${ColourReset}") - - set(HAVE_VOICE 1) - endif() + if(Opus_FOUND AND libsodium_FOUND) + message("-- Found Opus ${Green}${Opus_VERSION}${ColourReset}") + add_compile_definitions(HAVE_VOICE) + message("-- Sodium ${Green}${libsodium_VERSION}${ColourReset}") + set(HAVE_VOICE 1) endif() if(HAVE_VOICE) From 68560d6907514d0187c84281e9d69d3ded68355f Mon Sep 17 00:00:00 2001 From: mikeravenelle Date: Mon, 22 Jan 2024 09:23:19 -0600 Subject: [PATCH 14/21] Removed load from conan.tools.files and moved conan recipe into library-conan folder --- {conan => library-conan}/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename {conan => library-conan}/conanfile.py (97%) diff --git a/conan/conanfile.py b/library-conan/conanfile.py similarity index 97% rename from conan/conanfile.py rename to library-conan/conanfile.py index 364371d7c1..3934fbc84c 100644 --- a/conan/conanfile.py +++ b/library-conan/conanfile.py @@ -2,7 +2,7 @@ from conan import ConanFile from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps from conan.tools.scm import Git -from conan.tools.files import load, update_conandata +from conan.tools.files import update_conandata class DPPConan(ConanFile): name = "dpp" From f37ce14c5f906151d756b9440300f705e4e2850f Mon Sep 17 00:00:00 2001 From: mikeravenelle Date: Thu, 25 Jan 2024 08:56:12 -0600 Subject: [PATCH 15/21] Updated the version number --- library-conan/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library-conan/conanfile.py b/library-conan/conanfile.py index 3934fbc84c..a10afff06b 100644 --- a/library-conan/conanfile.py +++ b/library-conan/conanfile.py @@ -6,7 +6,7 @@ class DPPConan(ConanFile): name = "dpp" - version = "0.1" + version = "10.0.29" default_user = "brainboxdotcc" default_channel = "testing" license = "https://github.com/brainboxdotcc/DPP/blob/master/LICENSE" From ea848838c423640019c6726b68750ee8a0009942 Mon Sep 17 00:00:00 2001 From: mikeravenelle Date: Fri, 26 Jan 2024 08:08:18 -0600 Subject: [PATCH 16/21] Remove docpage from branch so we can control docpage separately. --- docpages/install/install-conan.md | 52 ------------------------------- 1 file changed, 52 deletions(-) delete mode 100644 docpages/install/install-conan.md diff --git a/docpages/install/install-conan.md b/docpages/install/install-conan.md deleted file mode 100644 index a1ebba975a..0000000000 --- a/docpages/install/install-conan.md +++ /dev/null @@ -1,52 +0,0 @@ -\page install-conan Installing with Conan 2.0 - -To install D++ into a project using conan 2.0 and cmake: - -- Ensure conan is correctly installed the most popular method is with pip. -- Create a conanfile.txt in the root of the project. - -```conanfile.txt -[requires] -dpp/0.1 - -[generators] -CMakeDeps -CMakeToolchain -``` - -- You may now use the library within a `CMake` based project by adding instructions such as these to your `CMakeLists.txt`: - -```cmake -set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_LIST_DIR}/build") -find_package(dpp CONFIG REQUIRED) -target_link_libraries(${PROJECT_NAME} dpp::dpp) -``` - -- If you recieve any errors about CXX version you may need to set it - -``` -set(CMAKE_CXX_STANDARD 17) -``` - -- You will then also want to set your build type to match what you will be using in conan(Debug or Release) - -``` -set(CMAKE_BUILD_TYPE Debug) -``` - -OR - -``` -set(CMAKE_BUILD_TYPE Release) -``` - -- Now run the following commands - -``` -mkdir build && cd build -conan install .. --build=missing -of=. -s build_type=Release -cmake .. -make -``` - -- NOTE: build_type= needs to match whatever was set in your CMake or you will get linker issues. From 3b50591fbbb7dad3b16314feb2ec49cd35746bf7 Mon Sep 17 00:00:00 2001 From: mikeravenelle Date: Fri, 26 Jan 2024 11:35:05 -0600 Subject: [PATCH 17/21] Rearranged find_packages to top and removed include directories for OpenSSL and ZLIB since they are not needed with conan --- library-conan/CMakeLists.txt | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/library-conan/CMakeLists.txt b/library-conan/CMakeLists.txt index c8d0fc6689..c20af6c906 100644 --- a/library-conan/CMakeLists.txt +++ b/library-conan/CMakeLists.txt @@ -3,6 +3,8 @@ find_package(OpenSSL REQUIRED COMPONENTS SSL Crypto) find_package(ZLIB REQUIRED) find_package(libsodium REQUIRED) find_package(Opus) +find_package(Threads REQUIRED) +find_package(Git QUIET) # Check for various C functions @@ -116,28 +118,6 @@ string(ASCII 27 Esc) set(THREADS_PREFER_PTHREAD_FLAG ON) -find_package(Threads REQUIRED) -if(MINGW OR NOT WIN32) - find_package(ZLIB REQUIRED) -endif(MINGW OR NOT WIN32) - -if(APPLE) - if(CMAKE_APPLE_SILICON_PROCESSOR EQUAL arm64) - set(OPENSSL_ROOT_DIR "/opt/homebrew/opt/openssl") - else() - set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl") - endif() - find_package(OpenSSL REQUIRED) -else() - if(MINGW OR NOT WIN32) - find_package(OpenSSL REQUIRED) - endif() -endif() - -include_directories(${OPENSSL_INCLUDE_DIR} ${ZLIB_INCLUDE_DIRS}) - -find_package(Git QUIET) - if(NOT GIT_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../.git") message(FATAL_ERROR "You are using a git version of D++ but do not have git installed. Install git (not 'gh') and try again.") endif() From de0c141710ec9ced6f65b4a24f40e94ab94a7f41 Mon Sep 17 00:00:00 2001 From: Mike Ravenelle Date: Sun, 28 Jan 2024 15:31:22 -0600 Subject: [PATCH 18/21] Removed possibly uneeded windows flags and added exclusion for win32 folder --- library-conan/CMakeLists.txt | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/library-conan/CMakeLists.txt b/library-conan/CMakeLists.txt index c20af6c906..5e5894c656 100644 --- a/library-conan/CMakeLists.txt +++ b/library-conan/CMakeLists.txt @@ -42,10 +42,7 @@ add_compile_options(${AVX_FLAG}) if(WIN32 AND NOT MINGW) if (NOT WINDOWS_32_BIT) - message("-- Building for windows with precompiled packaged dependencies") - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) - add_compile_options("/bigobj") - add_compile_definitions(OPENSSL_SYS_WIN32) + message("-- Setting Windows flags") add_compile_definitions(_WINSOCK_DEPRECATED_NO_WARNINGS) add_compile_definitions(WIN32_LEAN_AND_MEAN) add_compile_definitions(_CRT_SECURE_NO_WARNINGS) @@ -80,22 +77,6 @@ if (UNIX) endif() endif() -if(NOT BUILD_SHARED_LIBS) - if(UNIX) - message("-- Building static library.") - - if(UNIX AND NOT APPLE) - set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") - endif() - - set(OPENSSL_USE_STATIC_LIBS ON) - set(sodium_USE_STATIC_LIBS ON) - set(OPUS_USE_STATIC_LIBS TRUE) - else() - message(WARNING "-- Building of static library not supported on non UNIX systems.") - endif() -endif() - include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/colour.cmake") if (BUILD_VOICE_SUPPORT) if(Opus_FOUND AND libsodium_FOUND) @@ -164,7 +145,7 @@ foreach (fullmodname ${subdirlist}) set (modsrc "") file(GLOB modsrc "${modules_dir}/dpp/*.cpp" "${modules_dir}/dpp/events/*.cpp" "${modules_dir}/dpp/cluster/*.cpp" "${modules_dir}/dpp/*.rc") - + if(BUILD_SHARED_LIBS) add_library(${modname} SHARED ${modsrc}) else() From 2f02ae723c636ab529b40e27724be7a487589982 Mon Sep 17 00:00:00 2001 From: Mike Ravenelle Date: Fri, 29 Mar 2024 08:07:48 -0500 Subject: [PATCH 19/21] Added flags for tests and BUILD_SHARED_LIBS --- library-conan/conanfile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library-conan/conanfile.py b/library-conan/conanfile.py index a10afff06b..de21255a8c 100644 --- a/library-conan/conanfile.py +++ b/library-conan/conanfile.py @@ -52,6 +52,8 @@ def generate(self): tc = CMakeToolchain(self) tc.cache_variables["CONAN_EXPORTED"] = True tc.cache_variables["BUILD_VOICE_SUPPORT"] = True + tc.cache_variables["DPP_BUILD_TEST"] = False + tc.cache_variables["BUILD_SHARED_LIBS"] = False tc.generate() def build(self): From 4ea4362a8716d13bf7544b99dc6cc116152d3b23 Mon Sep 17 00:00:00 2001 From: "Craig Edwards (Brain)" Date: Wed, 23 Oct 2024 22:02:12 +0100 Subject: [PATCH 20/21] Update library-conan/conanfile.py Co-authored-by: James --- library-conan/conanfile.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library-conan/conanfile.py b/library-conan/conanfile.py index de21255a8c..d8b20dec80 100644 --- a/library-conan/conanfile.py +++ b/library-conan/conanfile.py @@ -18,11 +18,11 @@ class DPPConan(ConanFile): default_options = {"shared": False, "fPIC": True} def build_requirements(self): - self.requires("nlohmann_json/3.11.2", headers=True, libs=True) - self.requires("openssl/3.1.2", headers=True, libs=True) - self.requires("zlib/1.3", headers=True, libs=True) - self.requires("libsodium/cci.20220430", headers=True, libs=True) - self.requires("opus/1.4", headers=True, libs=True) + self.requires("nlohmann_json/3.11.2") + self.requires("openssl/3.1.2") + self.requires("zlib/1.3") + self.requires("libsodium/cci.20220430") + self.requires("opus/1.4") def config_options(self): if self.settings.os == "Windows": From 6d1dbfacac177d1415e2b5a1ea65e2759a8b1cb8 Mon Sep 17 00:00:00 2001 From: "Craig Edwards (Brain)" Date: Wed, 23 Oct 2024 22:03:31 +0100 Subject: [PATCH 21/21] Update library-conan/conanfile.py Co-authored-by: James --- library-conan/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library-conan/conanfile.py b/library-conan/conanfile.py index d8b20dec80..d267f45c10 100644 --- a/library-conan/conanfile.py +++ b/library-conan/conanfile.py @@ -17,7 +17,7 @@ class DPPConan(ConanFile): options = {"shared": [True, False], "fPIC": [True, False]} default_options = {"shared": False, "fPIC": True} - def build_requirements(self): + def requirements(self): self.requires("nlohmann_json/3.11.2") self.requires("openssl/3.1.2") self.requires("zlib/1.3")