3

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)

The output:

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
Ives TI
  • 137
  • 2
  • 9
  • CMake determines linker language according to the **source files**. It seems that your library has no source files. (Read: `SRC_RENDERER` variable is **empty**). This could be start point in your debugging process. You can always print the variable's value with `message()`. – Tsyvarev Apr 15 '20 at 18:46

1 Answers1

10

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

set_target_properties(IEngine PROPERTIES LINKER_LANGUAGE CXX)
theWiseBro
  • 1,439
  • 12
  • 11