Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake test project attempting to link with wrong file #945

Open
justofisker opened this issue Dec 3, 2022 · 1 comment
Open

CMake test project attempting to link with wrong file #945

justofisker opened this issue Dec 3, 2022 · 1 comment

Comments

@justofisker
Copy link

justofisker commented Dec 3, 2022

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.

@enetheru
Copy link
Contributor

I have a PR for modernising the cmake build scripts that I believe would resolve this issue.

The test project becomes a target of the main project and doesn't need to be configured separately.

Also for visual studio is a multi-config generator which means passing in CMAKE_BUILD_TYPE at the configure stage is ignored by visual studio always setting the config to the default which is Debug. The build configuration needs to be passed at the build command like so cmake --build . --config Release. With the current master both the config stage and build stage require to set the config type. but if my PR gets merged, then its only required at the build command for visual studio.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants