gpt4 book ai didi

c++ - CMake 无法确定目标的链接器语言 - C++

转载 作者:行者123 更新时间:2023-12-02 09:54:41 24 4
gpt4 key购买 nike

我正在尝试开发一个供私有(private)使用的引擎,我正在使用 CMake,因为我打算在未来让它成为多平台的,但是开始出现一个我以前从未遇到过的错误,我试图改变项目( IEngine) 到 project(IEngine CXX) 如堆栈溢出的其他问题中所述,但错误仍然存​​在,这是我的 CMakeLists

cmake_minimum_required(VERSION 3.16.2)

project(IEngine)

find_package(Vulkan REQUIRED)

file(GLOB_RECURSE SRC_RENDERER
"${IEngine_SOURCE_DIR}/src/Renderer/*.cpp"
"${IEngine_SOURCE_DIR}/src/Renderer/*.hpp"
"${IEngine_SOURCE_DIR}/src/Renderer/*.h")

source_group("Renderer" FILES ${SRC_RENDERER})

add_library(IEngine STATIC ${SRC_RENDERER})

if(WIN32)
target_compile_definitions(IEngine PRIVATE VK_USE_PLATFORM_WIN32_KHR)
endif()

target_include_directories(IEngine PRIVATE Vulkan::Vulkan)
target_link_libraries(IEngine Vulkan::Vulkan)

输出:

Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.18363.
The C compiler identification is MSVC 19.24.28315.0
The CXX compiler identification is MSVC 19.24.28315.0
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe - works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Detecting C compile features
Detecting C compile features - done
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe - works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
Found Vulkan: A:/VulkanSDK/1.2.131.1/Lib/vulkan-1.lib
Configuring done
CMake Error: CMake can not determine linker language for target: IEngine
Generating done

最佳答案

这个错误我遇到过很多次 :( 把这个添加到你的 CMakeLists.txt 中:

set_target_properties(IEngine PROPERTIES LINKER_LANGUAGE CXX)

关于c++ - CMake 无法确定目标的链接器语言 - C++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61235133/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com