Skip to content

Do not hardcode C++ runtime library on Darwin #163

@barracuda156

Description

@barracuda156

This is either redundant or breaking:

curlcpp/src/CMakeLists.txt

Lines 99 to 101 in fb07bb7

if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
target_compile_options(curlcpp PUBLIC -stdlib=libc++)
endif()

If a compiler does not know which C++ runtime to use, that should be fixed with compiler, not here. AFAIK, neither modern gcc nor modern clang has this issue. If a package manager uses non-default C++ runtime, it should pass the flag to handle it accordingly (MacPorts can do that).

Hardcoding just breaks the build, whenever libstdc++ should be used and not libc++:

[ 92%] Building CXX object src/CMakeFiles/curlcpp.dir/cookie_datetime.cpp.o
cd /opt/local/var/macports/build/curlcpp-db727ff1/work/build/src && /opt/local/bin/g++-mp-14 -Dcurlcpp_EXPORTS -I/opt/local/var/macports/build/curlcpp-db727ff1/work/curlcpp-fb07bb742b77b7ad8ed7176dbf1c6e82dd2e011e/src/../include -isystem /opt/local/include -pipe -Os -DNDEBUG -I/opt/local/include -D_GLIBCXX_USE_CXX11_ABI=0 -arch ppc -mmacosx-version-min=10.6 -fPIC -Wall -Wextra -Wpedantic -stdlib=libc++ -MD -MT src/CMakeFiles/curlcpp.dir/cookie_datetime.cpp.o -MF CMakeFiles/curlcpp.dir/cookie_datetime.cpp.o.d -o CMakeFiles/curlcpp.dir/cookie_datetime.cpp.o -c /opt/local/var/macports/build/curlcpp-db727ff1/work/curlcpp-fb07bb742b77b7ad8ed7176dbf1c6e82dd2e011e/src/cookie_datetime.cpp
[100%] Linking CXX shared library libcurlcpp.dylib
cd /opt/local/var/macports/build/curlcpp-db727ff1/work/build/src && /opt/local/bin/cmake -E cmake_link_script CMakeFiles/curlcpp.dir/link.txt --verbose=ON
Undefined symbols for architecture ppc:
  "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::compare(unsigned long, unsigned long, char const*, unsigned long) const", referenced from:
      curl::cookie::set_secure(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in cookie.cpp.o
  "std::__1::__vector_base_common<true>::__throw_length_error() const", referenced from:
      __ZNSt3__16vectorINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS4_IS6_EEE21__push_back_slow_pathIRKS6_EEvOT_ in curl_cookie.cpp.o
      curl::curl_exception::get_traceback() in curl_exception.cpp.o
. . .

Also gcc supports this flag only since 10.x, and even current release may be built without support for this flag being enabled. In that case the build will fail due to unsupported flag.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions