Cmake 更改编译器选项

问题描述 投票:0回答:0

我想使用“-stdlib=libstdc++”,但 cmake(在 clion 中但我认为不重要)使用“-stdlib=libc++”。我该怎么做?

CmakeLists.txt:

cmake_minimum_required(VERSION 3.25)
project(provavcpkg)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20 -stdlib=libstdc++")
find_package(SFML COMPONENTS system window graphics CONFIG REQUIRED)
add_executable(provavcpkg main.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE sfml-system sfml-network sfml-graphics sfml-window)

建筑产出:

: && /opt/homebrew/bin/g++-12 -std=c++20 -O3 -DNDEBUG -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.1.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names  CMakeFiles/provavcpkg.dir/main.cpp.o -o provavcpkg  vcpkg_installed/arm64-osx/lib/libsfml-system-s.a  vcpkg_installed/arm64-osx/lib/libsfml-network-s.a  vcpkg_installed/arm64-osx/lib/libsfml-graphics-s.a  vcpkg_installed/arm64-osx/lib/libsfml-window-s.a  vcpkg_installed/arm64-osx/lib/libsfml-system-s.a  -lpthread  -ObjC  -framework Foundation  -framework AppKit  -framework IOKit  -framework Carbon  -stdlib=libc++  /Library/Developer/CommandLineTools/SDKs/MacOSX13.1.sdk/System/Library/Frameworks/OpenGL.framework/OpenGL.tbd  vcpkg_installed/arm64-osx/lib/libfreetype.a  vcpkg_installed/arm64-osx/lib/libbz2.a  vcpkg_installed/arm64-osx/lib/libpng16.a  vcpkg_installed/arm64-osx/lib/libz.a  vcpkg_installed/arm64-osx/lib/libbrotlidec-static.a  vcpkg_installed/arm64-osx/lib/libbrotlicommon-static.a
c++ cmake clion
© www.soinside.com 2019 - 2024. All rights reserved.