Skip to content

CMake test project attempting to link with wrong file #945

Closed
@justofisker

Description

@justofisker

Issue description

When attempting to build the test project for this using CMake it fails do to looking for the godot-cpp library file

Output when attempting to build test project using VSCode's CMake extension:

[main] Building folder: test 
[build] Starting build
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --build c:/Users/bea/Desktop/godot-cpp/test/build --config Debug --target godot-cpp-test -j 26 --
[build] MSBuild version 17.4.0+18d5aef85 for .NET Framework
[build]   Checking Build System
[build]   Building Custom Rule C:/Users/bea/Desktop/godot-cpp/test/CMakeLists.txt
[build]   example.cpp
[build]   register_types.cpp
[build]   Generating Code...
[build] LINK : fatal error LNK1104: cannot open file 'godot-cpp.windows.release.64.lib' [C:\Users\bea\Desktop\godot-cpp\test\build\godot-cpp-test.vcxproj]
[proc] The command: "C:\Program Files\CMake\bin\cmake.EXE" --build c:/Users/bea/Desktop/godot-cpp/test/build --config Debug --target godot-cpp-test -j 26 -- exited with code: 1 and signal: null
[build] Build finished with exit code 1

My workaround

The current way I am working around this is adding "lib" to the beginning of this filename

godot-cpp.${SYSTEM_NAME}.${BUILD_TYPE}$<$<NOT:$<PLATFORM_ID:Android>>:.${BITS}>

and changing

set(BITS 32)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(BITS 64)
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(GODOT_CPP_BUILD_TYPE Debug)
else()
set(GODOT_CPP_BUILD_TYPE Release)
endif()

to

 set(BITS x86_32) 
 if(CMAKE_SIZEOF_VOID_P EQUAL 8) 
 	set(BITS x86_64) 
 endif(CMAKE_SIZEOF_VOID_P EQUAL 8)

if(CMAKE_BUILD_TYPE MATCHES Debug)
	set(GODOT_CPP_BUILD_TYPE Template_Debug)
else()
	set(GODOT_CPP_BUILD_TYPE Template_Release)
endif()

Issues with my workaround

There are two problems with this second change. Firstly, for non x86 platforms the x86_ prefix in not valid. Secondly, while the only release binary build type is template_release, both template_debug and editor are valid build types for a debug builds and can both be used by the editor if linked against, but this change only checks for template_debug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions