src/CMakeLists.txt: modernize CMake build system and fix package config#45
src/CMakeLists.txt: modernize CMake build system and fix package config#45luadebug wants to merge 15 commits intowinsoft666:masterfrom
Conversation
- Use CONFIG mode for find_package(CURL) with imported target CURL::libcurl - Simplify dependency linking to always use PRIVATE (transitive deps handled by imported targets) - Fix INSTALL_INTERFACE include path from ../include to include - Add proper package config file generation using configure_package_config_file - Rename export from zoeConfig to zoeTargets for CMake conventions - Simplify Windows platform check and library names - Remove redundant OpenSSL::Crypto (linked transitively via OpenSSL::SSL)
Add zoeConfig.cmake.in template that: - Uses CMakeFindDependencyMacro for transitive dependency resolution - Conditionally finds CURL and OpenSSL dependencies for static builds - Includes generated zoeTargets.cmake for exported target definitions This ensures consumers using find_package(zoe) get proper dependency propagation when linking against the static library.
…nd OpenSSL, and add pkg-config file for better integration
294f034 to
8db2f97
Compare
dg0yt
left a comment
There was a problem hiding this comment.
I was about to upstream my fixes from the vcpkg port. But there is overlap with this PR.
src/CMakeLists.txt
Outdated
| if(ZOE_BUILD_SHARED_LIBS) | ||
| set(ZOE_PRIVATE_LIBS "${ZOE_PRIVATE_LIBS} -lpthread") | ||
| else() | ||
| set(ZOE_LIBS "${ZOE_LIBS} -lpthread") |
There was a problem hiding this comment.
I guess this leads to the wrong result for MSVC.
There was a problem hiding this comment.
Sorry maybe I am missing something?
On MSVC, CMake's find_package(Threads) sets:
CMAKE_USE_WIN32_THREADS_INIT = TRUE
CMAKE_USE_PTHREADS_INIT = FALSE
There was a problem hiding this comment.
I see, CMAKE_USE_PTHREADS_INIT is a result variable. I tend to read this identifier wrong. So no problem with MSVC.
But IIRC -lpthread is also somewhat legacy vs. -pthread. (This is why CMake recommends THREADS_PREFER_PTHREAD_FLAG.)
There was a problem hiding this comment.
6f76eac
Is it good to go or there is better way to fix, LMK.
Co-authored-by: Kai Pastor <dg0yt@darc.de>
Co-authored-by: Kai Pastor <dg0yt@darc.de>
src/CMakeLists.txt
Outdated
| "${CMAKE_CURRENT_BINARY_DIR}/${ZOE_PC_NAME}.pc" | ||
| DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" |
There was a problem hiding this comment.
Wait, this is meant to generate different pc file names?
This is not common practice in pkgconfig and should be avoided IMO.
Co-authored-by: Kai Pastor <dg0yt@darc.de>
Co-authored-by: Kai Pastor <dg0yt@darc.de>
Add zoeConfig.cmake.in template that:
This ensures consumers using find_package(zoe) get proper dependency propagation when linking against the static library.
Enhance CMake configuration to support dynamic linking with libcurl and OpenSSL, and add pkg-config file for better integration