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

[vcpkg-cmake] Fix usage of CMAKE_CXX_COMPILER_TARGET #24101

Merged
merged 2 commits into from
Apr 18, 2022

Conversation

dg0yt
Copy link
Contributor

@dg0yt dg0yt commented Apr 12, 2022

@dg0yt
Copy link
Contributor Author

dg0yt commented Apr 12, 2022

For mingw gcc, we get CMAKE_CXX_COMPILER_TARGET (value x86_64-windows-gnu) but not CMAKE_CXX_COMPILE_OPTIONS_TARGET. This leads to boost exception compiling command lines and errors like

    "D:/msys64/mingw64/bin/x86_64-w64-mingw32-g++.exe"   -g "x86_64-windows-gnu" -m64 -mthreads -O0 -fno-inline -Wall -g  -DBOOST_ALL_NO_LIB=1  -I"..\include" -I"D:\msys64\home\Darer\vcpkg\installed\x64-mingw-static\include"  -c -o "D:\msys64\home\Darer\vcpkg\buildtrees\boost-exception\x64-mingw-static-dbg\boost\build\7bca12b6b2cf72a95198e22cff26ec25\clone_current_exception_non_intrusive.o" "..\src\clone_current_exception_non_intrusive.cpp"

x86_64-w64-mingw32-g++.exe: warning: x86_64-windows-gnu: linker input file unused because linking not done
x86_64-w64-mingw32-g++.exe: error: x86_64-windows-gnu: linker input file not found: No such file or directory

due the stand-alone "x86_64-windows-gnu".

Before #23001, this didn't happen because CMAKE_CXX_COMPILER_TARGET was never used without CMAKE_CXX_COMPILE_OPTIONS_TARGET:

if(CMAKE_CXX_COMPILER_TARGET AND CMAKE_CXX_COMPILE_OPTIONS_TARGET)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
string(APPEND CXXFLAGS " <compileflags>${CMAKE_CXX_COMPILE_OPTIONS_TARGET}${CMAKE_CXX_COMPILER_TARGET}")
string(APPEND LDFLAGS " <linkflags>${CMAKE_CXX_COMPILE_OPTIONS_TARGET}${CMAKE_CXX_COMPILER_TARGET}")
else()
string(APPEND CXXFLAGS " <compileflags>${CMAKE_CXX_COMPILE_OPTIONS_TARGET} <compileflags>${CMAKE_CXX_COMPILER_TARGET}")
string(APPEND LDFLAGS " <linkflags>${CMAKE_CXX_COMPILE_OPTIONS_TARGET} <linkflags>${CMAKE_CXX_COMPILER_TARGET}")
endif()
endif()

AFAIU Clang always takes that parameter, so I didn't restore the guard before that line.

@JackBoosY JackBoosY added the category:vcpkg-bug The issue is with the vcpkg system (including helper scripts in `scripts/cmake/`) label Apr 13, 2022
@Masaiki
Copy link
Contributor

Masaiki commented Apr 17, 2022

@LilyWangLL request for a review.

@LilyWangLL LilyWangLL added the info:reviewed Pull Request changes follow basic guidelines label Apr 18, 2022
@strega-nil-ms
Copy link
Contributor

Thanks!

@strega-nil-ms strega-nil-ms merged commit 97b723c into microsoft:master Apr 18, 2022
@dg0yt dg0yt deleted the combined-flags branch April 20, 2022 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:vcpkg-bug The issue is with the vcpkg system (including helper scripts in `scripts/cmake/`) info:reviewed Pull Request changes follow basic guidelines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[boost-exception] build failure
5 participants