Incorrect invocation of AppleClang compiler for detecting libcxx.
See original GitHub issueThe code
execute_process(
COMMAND ${CMAKE_COMMAND} -E echo "#include <string>"
COMMAND ${CMAKE_CXX_COMPILER} -x c++ ${compile_options} -E -dM -
OUTPUT_VARIABLE string_defines
)
causes the following output
-- Conan: Automatic detection of conan settings from cmake
In file included from <stdin>:1:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string:504:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string_view:175:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__string:57:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:641:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstring:60:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string.h:60:15: fatal error: 'string.h' file not found
#include_next <string.h>
^~~~~~~~~~
1 error generated.
-- Conan: Settings= -s;build_type=Debug;-s;compiler=apple-clang;-s;compiler.version=12.0;-s;compiler.libcxx=libc++
-isysroot
should be always specified for AppleClang, see also https://stackoverflow.com/a/63188875.
Fix:
if(${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL AppleClang)
set(compile_options -isysroot ${CMAKE_OSX_SYSROOT} ${compile_options})
endif()
execute_process(
COMMAND ${CMAKE_COMMAND} -E echo "#include <string>"
COMMAND ${CMAKE_CXX_COMPILER} -x c++ ${compile_options} -E -dM -
OUTPUT_VARIABLE string_defines
)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Problem installing ROOT 6.14.06 on mac 10.13.6 with libcxx ...
gcc 8.2 just installed compiling with support for objc++ on macos 10.13.6 with xcode 10.1. I'm not asking for an immediate solution, I...
Read more >Handling a version mismatch of the compiler version between ...
The first invocation has CMake think Apple-clang is my compiler while conan is configured to use the llvm version and on the second...
Read more >Changelog — conan 1.45.0 documentation
Fix: Added a visible warning about libcxx compatibility and the detected one for the default profile. Fix: Wrong detection of compiler in OSX...
Read more >Clang linking error MacOS Big Sur | Apple Developer Forums
Apple clang version 12.0.0 (clang-1200.0.32.27) ... clang: error: linker command failed with exit code 1 (use -v to see invocation).
Read more >Getting Started with the LLVM System
Hardware; Software; Host C++ Toolchain, both Compiler and Standard Library ... For example, to build LLVM, Clang, libcxx, and libcxxabi, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hmm… macOS reguires
CMAKE_OSX_SYSROOT
, so the patch isPatch for macOS and iOS: