Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile error on configuration on MacOS #225

Closed
dforsten opened this issue Apr 26, 2020 · 2 comments · Fixed by #226
Closed

Compile error on configuration on MacOS #225

dforsten opened this issue Apr 26, 2020 · 2 comments · Fixed by #226

Comments

@dforsten
Copy link
Contributor

On MacOS I am getting these errors on executing conan_cmake_run

-- 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:56:
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.

The errors are caused by this command:

    execute_process(
        COMMAND ${CMAKE_COMMAND} -E echo "#include <string>"
        COMMAND ${CMAKE_CXX_COMPILER} -x c++ ${compile_options} -E -dM -
        OUTPUT_VARIABLE string_defines
    )

Where ${CMAKE_CXX_COMPILER} is expanding to /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++. Unlike for /usr/bin/c++ the sysroot is not set when executing that binary, but setting the sysroot manually fixes the compile issue:

    execute_process(
        COMMAND ${CMAKE_COMMAND} -E echo "#include <string>"
        COMMAND ${CMAKE_CXX_COMPILER} -x c++ --sysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk ${compile_options} -E -dM -
        OUTPUT_VARIABLE string_defines
    )
dforsten added a commit to dforsten/cmake-conan that referenced this issue Apr 26, 2020
…on on MacOS

The sysroot option is not set when using `/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++`, needs to be added explicitly.
@dforsten
Copy link
Contributor Author

Pull Request with a fix submitted.

dforsten added a commit to dforsten/cmake-conan that referenced this issue Apr 26, 2020
…on on MacOS

The sysroot option is not set when using `/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++`, needs to be added explicitly.
@dforsten
Copy link
Contributor Author

The compile error is present in the Travis CI logs for XCode 10 and 11 in builds before this fix.

The builds do not fail, but having to scroll past these compile errors on every CMake run on MacOS is definitely annoying.

czoido added a commit that referenced this issue Sep 3, 2020
Fix for cmake-conan issue #225 - Compile error on configuration on MacOS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant