CMake 无法确定目标的链接器语言 - C++ [英] CMake can not determine linker language for target - C++

查看:75
本文介绍了CMake 无法确定目标的链接器语言 - C++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to develop an engine for private use, I'm using CMake because I intend to make it multiplatform in the future, but an error started to appear that I never came across before, I tried to change project(IEngine) to project(IEngine CXX) as said in other questions from stack overflow, but the error persists, here's my 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 中:

I've had this error many times :( Add this to your CMakeLists.txt:

set_target_properties(IEngine PROPERTIES LINKER_LANGUAGE CXX)

这篇关于CMake 无法确定目标的链接器语言 - C++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆