Fix conanfile.py/CMakeLists.txt for C consumers

The new configuration should make C consumers link to "stdc++" by
default, which should fix building with static libs for C programs.
This commit is contained in:
Stephen Seo 2024-07-13 22:41:16 +09:00
parent 83aacc3090
commit c3182cb127
4 changed files with 11 additions and 5 deletions

View file

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.7)
project(UDPC)
set(UDPC_VERSION 1.1)
set(UDPC_VERSION 1.2)
set(UDPC_SOVERSION 1)
set(UDPC_SOURCES
@ -42,6 +42,12 @@ find_package(libsodium REQUIRED)
target_compile_definitions(UDPC PUBLIC UDPC_LIBSODIUM_ENABLED)
target_link_libraries(UDPC PUBLIC libsodium::libsodium)
# Enforce linking with libstdc++ even with C targets.
# Doesn't affect conan, so conanfile.py was also modified for this.
set_target_properties(UDPC PROPERTIES
INTERFACE_LINK_LIBRARIES "stdc++"
)
if(CMAKE_BUILD_TYPE MATCHES "Debug")
set(UDPC_UnitTest_SOURCES
src/CXX11_shared_spin_lock.cpp

View file

@ -22,4 +22,4 @@ find_package(udpc CONFIG REQUIRED)
add_executable(UDPC_NetworkTest
${UDPC_NetworkTest_SOURCES}
)
target_link_libraries(UDPC_NetworkTest udpc::udpc stdc++)
target_link_libraries(UDPC_NetworkTest PUBLIC udpc::udpc)

View file

@ -1,5 +1,5 @@
[requires]
udpc/1.1
udpc/1.2
[generators]
CMakeDeps

View file

@ -5,7 +5,7 @@ import os
class udpcRecipe(ConanFile):
name = "udpc"
version = "1.1"
version = "1.2"
package_type = "library"
# Optional metadata
@ -54,4 +54,4 @@ class udpcRecipe(ConanFile):
def package_info(self):
self.cpp_info.libs = ["UDPC"]
self.cpp_info.system_libs = ["stdc++"]