Skip to content

[vcpkg-cmake] Fix usage of CMAKE_CXX_COMPILER_TARGET#24101

Merged
strega-nil-ms merged 2 commits intomicrosoft:masterfrom
dg0yt:combined-flags
Apr 18, 2022
Merged

[vcpkg-cmake] Fix usage of CMAKE_CXX_COMPILER_TARGET#24101
strega-nil-ms merged 2 commits intomicrosoft:masterfrom
dg0yt:combined-flags

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:needs-maintainer-attention Lets the current 'on rotation' vcpkg maintainer know they need to look at this. 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:needs-maintainer-attention Lets the current 'on rotation' vcpkg maintainer know they need to look at this.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[boost-exception] build failure

5 participants