*.o
doxygen_out/
/tags
+
+CMakeUserPresets.json
endif()
endif()
-if(UDPC_DISABLE_LIBSODIUM)
- message(STATUS "libsodium disabled")
-elseif(DEFINED M_LIBSODIUM_LIBRARIES AND DEFINED M_LIBSODIUM_INCLUDE_DIRS)
- message(STATUS "libsodium manual paths detected, using them")
- target_compile_definitions(UDPC PUBLIC UDPC_LIBSODIUM_ENABLED)
- target_link_libraries(UDPC PUBLIC ${M_LIBSODIUM_LIBRARIES})
- target_include_directories(UDPC PUBLIC ${M_LIBSODIUM_INCLUDE_DIRS})
-else()
- find_package(PkgConfig REQUIRED)
- pkg_check_modules(LIBSODIUM QUIET libsodium)
- if(LIBSODIUM_FOUND)
- target_compile_definitions(UDPC PUBLIC UDPC_LIBSODIUM_ENABLED)
- target_link_libraries(UDPC PUBLIC ${LIBSODIUM_LIBRARIES})
- target_include_directories(UDPC PUBLIC ${LIBSODIUM_INCLUDE_DIRS})
- target_compile_options(UDPC PUBLIC ${LIBSODIUM_CFLAGS_OTHER})
- message(STATUS "libsodium enabled")
- else()
- message(STATUS "libsodium not found, UDPC will be compiled without libsodium support")
- endif()
-endif()
+find_package(libsodium REQUIRED)
+target_compile_definitions(UDPC PUBLIC UDPC_LIBSODIUM_ENABLED)
+target_link_libraries(UDPC PUBLIC libsodium::libsodium)
if(CMAKE_BUILD_TYPE MATCHES "Debug")
set(UDPC_UnitTest_SOURCES
--- /dev/null
+from conan import ConanFile
+from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps
+import os
+
+
+class udpcRecipe(ConanFile):
+ name = "udpc"
+ version = "1.0"
+ package_type = "library"
+
+ # Optional metadata
+ license = "MIT"
+ author = "Stephen Seo stephen@seodisparate.com"
+ url = "https://git.seodisparate.com/stephenseo/UDPConnection"
+ description = "Implements a connection over UDP"
+ topics = ("UDPC", "UDP", "Network", "Network Connection")
+
+ # Binary configuration
+ settings = "os", "compiler", "build_type", "arch"
+ options = {"shared": [True, False], "fPIC": [True, False]}
+ default_options = {"shared": False, "fPIC": True}
+
+ # Sources are located in the same place as this recipe, copy them to the recipe
+ exports_sources = "CMakeLists.txt", "src/*"
+
+ 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 requirements(self):
+ self.requires("libsodium/cci.20220430")
+
+ 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()
+
+ def package_info(self):
+ self.cpp_info.libs = ["UDPC"]
+
--- /dev/null
+cmake_minimum_required(VERSION 3.15)
+project(PackageTest CXX)
+
+find_package(udpc CONFIG REQUIRED)
+
+add_executable(example src/test.cpp)
+target_link_libraries(example udpc::udpc)
--- /dev/null
+import os
+
+from conan import ConanFile
+from conan.tools.cmake import CMake, cmake_layout
+from conan.tools.build import can_run
+
+
+class udpcTestConan(ConanFile):
+ settings = "os", "compiler", "build_type", "arch"
+ generators = "CMakeDeps", "CMakeToolchain"
+
+ def requirements(self):
+ self.requires(self.tested_reference_str)
+
+ def build(self):
+ cmake = CMake(self)
+ cmake.configure()
+ cmake.build()
+
+ def layout(self):
+ cmake_layout(self)
+
+ def test(self):
+ if can_run(self):
+ cmd = os.path.join(self.cpp.build.bindir, "example")
+ self.run(cmd, env="conanrun")
--- /dev/null
+#include "UDPC.h"
+
+int main() {
+ auto ctx = UDPC_init(UDPC_create_id_easy("127.0.0.1", 0), 1, 1);
+ if (UDPC_is_valid_context(ctx) == 0) {
+ return 1;
+ }
+ UDPC_destroy(ctx);
+ return 0;
+}