我正在尝试开发供私有(private)使用的引擎,我正在使用CMake,因为我打算在将来使其跨平台使用,但是出现了一个以前从未遇到过的错误,我尝试将project(IEngine)更改为项目(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/