Closed DanDucky closed 4 months ago
Thanks for the detailed report.
I don't know much about CLion, but I think the issue is that the cmake build system only installs a Release version of the dependencies that are not found on the system (or the one forced using FORCE_LOCAL
options) and assumes they are compatible with the currently used config. I haven't used a Debug config in years as at one point it was too slow and ended up time out the connection quite often. I usually use a RelWithDebInfo
configuration as a result.
Anyway, I'll try to see if I can install CLion and give it a try to see if I can fix it for next monthly release. In the meantime, you could try installing a debug version of openssl (and zlib ?) manually and set OPENSSL_ROOT_DIR to the right path with the hope that cmake finds it properly.
Ok yeah I think you're right, the build system only configures dependencies as release configs. I just reproduced the error without CLion as well with the following commands:
cmake -DCMAKE_BUILD_TYPE=Debug ..
cmake --build . --config Debug
# works so far, builds exe
nvim ../CMakeLists.txt
# add a simple message("TEST") to CMakeLists.txt
cmake -DCMAKE_BUILD_TYPE=Debug ..
TEST
-- Selected game version: 1.20.4 || Protocol: 765
-- Configuring done (0.1s)
CMake Error in 3rdparty/Botcraft/CMakeLists.txt:
IMPORTED_LOCATION not set for imported target "OpenSSL::SSL" configuration
"Debug".
CMake Error in 3rdparty/Botcraft/CMakeLists.txt:
IMPORTED_LOCATION not set for imported target "OpenSSL::Crypto"
configuration "Debug".
CMake Error in 3rdparty/Botcraft/botcraft/CMakeLists.txt:
Imported target "OpenSSL::SSL" includes non-existent path
"/install/include"
in its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:
* The path was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and references files it does not
provide.
CMake Error in 3rdparty/Botcraft/CMakeLists.txt:
IMPORTED_LOCATION not set for imported target "OpenSSL::SSL" configuration
"Debug".
CMake Error in 3rdparty/Botcraft/CMakeLists.txt:
IMPORTED_LOCATION not set for imported target "OpenSSL::Crypto"
configuration "Debug".
-- Generating done (0.1s)
CMake Generate step failed. Build files cannot be regenerated correctly.
I took a bit of time to look around and I think I found the issue. It was in fact not related to CLion or Debug config. It was just a cmake-variable-scope issue for local openssl. Will push the fix in the next release, here is the diff in the meantime:
diff --git a/cmake/openssl.cmake b/cmake/openssl.cmake
index 335103e5..887709b7 100644
--- a/cmake/openssl.cmake
+++ b/cmake/openssl.cmake
@@ -8,7 +8,7 @@ endif()
# If not found, build from sources
if(NOT OPENSSL_FOUND)
set(OPENSSL_SRC_PATH "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/openssl/")
- set(OPENSSL_BUILD_PATH "${CMAKE_CURRENT_BINARY_DIR}/3rdparty/openssl")
+ set(OPENSSL_BUILD_PATH "${CMAKE_CURRENT_BINARY_DIR}/3rdparty/openssl" CACHE INTERNAL "Local OpenSSL build path")
file(GLOB RESULT "${OPENSSL_BUILD_PATH}/install")
list(LENGTH RESULT RES_LEN)
Also, as the code is almost never tested with CLion/MinGW feel free to report any bug or weird compilation stuff either here or in the discord.
When my IDE (CLion) re-runs the cmake build command on my cmake-build-debug config, it fails with the following errors:
I'm compiling Botcraft with these settings to make it build statically:
I've narrowed down the issue to a simpler CMakeLists.txt and settings. With this CMakeLists the error occurs if you configure and build, change the CMakeLists, then configure and build again then it fails.
I don't believe the issue is related to the static build, because removing any static options changes nothing. However the issue does not persist when I remove the BOTCRAFT_FORCELOCAL* options, so it should be related to how botcraft adds these libraries. The build does work with the CMakeLists above, but only if the CMakeLists does not change. As soon as you change the CMakeLists and update the config and build again, the build fails.
I don't really know how else to describe this issue because I don't know that much about cmake. The last thing I can really describe about this project is the structure:
|-3rdParty | |-Botcraft | | |-CMakeLists.txt |-src | |-main.cpp |-CMakeLists.txt