feat(kcp): add LLAR formula for skywind3000/kcp - #420
MeteorsLiu wants to merge 2 commits into
Conversation
Translate Conan Center kcp 1.5 into skywind3000/kcp from 1.4, the first CMake-installing tag. Drive upstream CMake, publish relocatable kcp.pc, and cover the installed C API with a pkg-config consumer. Closes xgo-dev#224
There was a problem hiding this comment.
The formula is structurally consistent with the repository and the Linux/macOS paths are covered by the included consumer test. The Windows shared-library contract is incomplete, however: the Conan recipe explicitly enabled Windows symbol exports and adjusted DLL runtime lookup, while this formula does neither.
| binary := filepath.join(testDir, "consumer") | ||
| cc! consumer, "-o", binary, "@"+flagsFile | ||
|
|
||
| if target.options["shared"][0] == "ON" { |
There was a problem hiding this comment.
[P1] Add the Windows DLL directory to PATH
For a Windows shared build, CMake installs the DLL under ${CMAKE_INSTALL_BINDIR} (normally bin), but the test only sets LD_LIBRARY_PATH and DYLD_LIBRARY_PATH, neither of which Windows uses. The compiled consumer therefore fails at startup with a missing kcp.dll even after linking succeeds. In the shared=ON test path, prepend filepath.join(installDir, "bin") to PATH when target.require["os"] is Windows, matching the runtime setup required by the installed layout.
| c.define "CMAKE_POLICY_VERSION_MINIMUM", "3.5" | ||
| c.define "CMAKE_INSTALL_LIBDIR", "lib" | ||
| c.defineBool "BUILD_TESTING", false | ||
| c.defineBool "BUILD_SHARED_LIBS", shared |
There was a problem hiding this comment.
[P1] Enable Windows exports for shared builds
When shared=ON on Windows, the 1.4–1.7 sources are changed to add_library(kcp ikcp.c) but no symbols are exported from the resulting DLL. The Conan recipe sets CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS for this exact case, and the older upstream tags do not provide the explicit .def file added in 1.7.1. Consequently the installed import library has no usable KCP API symbols and a Windows consumer cannot link. Pass CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON (or otherwise provide the required exports) for the supported Windows shared configuration.
Translate Conan Center
kcpinto an idiomatic LLAR Formula.Closes #224
Formula
skywind3000/kcpfromVer:1.4(first upstream tag with CMake install; 1.0–1.3 are source-only)1.5(https://github.com/skywind3000/kcp/archive/1.5.tar.gz)shared(default OFF),fPIC(default ON, static only)Build
CMakeLists.txtthrough the cmake helper.add_library(kcp STATIC …)and add LIBRARY/RUNTIME install rules so shared builds work on 1.4–1.7 (Conan did the same).cmake_minimum_required(VERSION 4.0)to 3.5 so Ubuntu CI CMake can configure.lib/pkgconfig/kcp.pcviapkgconfig.new(Versionis thefromVerfloor).Tests
Local
llar test -von darwin/arm64:./skywind3000/kcp@1.5(Conan tag)./skywind3000/kcp@1.4(fromVer)./skywind3000/kcp@1.7,@1.7.1,@2.1.1@2.1.1)--option shared=ON--option fPIC=OFF@1.5,@1.5 shared=ON, and default@1.3rejected (no formula found)Conan
package_info()audit vs published.pc:cpp_info.libs = ["kcp"]→Libs: -L${libdir} -lkcp(match)system_libs/defines/ extra includedirs / components (none extra)