godot-cpp icon indicating copy to clipboard operation
godot-cpp copied to clipboard

CMake test project attempting to link with wrong file

Open justofisker opened this issue 2 years ago • 1 comments

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

https://github.com/godotengine/godot-cpp/blob/f1d501f97749fd70f590a3e82b81e55d6cf1d2d7/test/CMakeLists.txt#L138

and changing

https://github.com/godotengine/godot-cpp/blob/f1d501f97749fd70f590a3e82b81e55d6cf1d2d7/test/CMakeLists.txt#L112-L121

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.

justofisker avatar Dec 03 '22 05:12 justofisker