Botcraft icon indicating copy to clipboard operation
Botcraft copied to clipboard

Build Failure On Multiple Builds

Open DanDucky opened this issue 2 months ago • 3 comments

When my IDE (CLion) re-runs the cmake build command on my cmake-build-debug config, it fails with the following errors:

CMake Error in cmake-build-debug/_deps/botcraft-src/CMakeLists.txt:
  IMPORTED_LOCATION not set for imported target "OpenSSL::SSL" configuration
  "Debug".


CMake Error in cmake-build-debug/_deps/botcraft-src/CMakeLists.txt:
  IMPORTED_LOCATION not set for imported target "OpenSSL::Crypto"
  configuration "Debug".


CMake Error in cmake-build-debug/_deps/botcraft-src/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 cmake-build-debug/_deps/botcraft-src/CMakeLists.txt:
  IMPORTED_LOCATION not set for imported target "OpenSSL::SSL" configuration
  "Debug".


CMake Error in cmake-build-debug/_deps/botcraft-src/CMakeLists.txt:
  IMPORTED_LOCATION not set for imported target "OpenSSL::Crypto"
  configuration "Debug".

I'm compiling Botcraft with these settings to make it build statically:

            "BOTCRAFT_BUILD_EXAMPLES OFF"
            "BOTCRAFT_BUILD_DOC OFF"
            "BOTCRAFT_GAME_VERSION 1.20.4"
            "BOTCRAFT_STATIC ON"
            "PROTOCOLCRAFT_STATIC ON"
            "BOTCRAFT_FORCE_LOCAL_ZLIB ON"
            "BOTCRAFT_FORCE_LOCAL_OPENSSL ON"
            "BUILD_SHARED_LIBS OFF"

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.

cmake_minimum_required(VERSION 3.20)
project(TheHand)

set(CMAKE_CXX_STANDARD 23)


#include(cmake/botcraft.cmake)
set(BOTCRAFT_BUILD_EXAMPLES OFF)
set(BOTCRAFT_BUILD_DOC OFF)
set(BOTCRAFT_GAME_VERSION 1.20.4)
set(BOTCRAFT_STATIC ON)
set(PROTOCOLCRAFT_STATIC ON)
set(BOTCRAFT_FORCE_LOCAL_ZLIB ON)
set(BOTCRAFT_FORCE_LOCAL_OPENSSL ON)
set(BUILD_SHARED_LIBS OFF)

add_subdirectory(3rdparty/Botcraft)

add_executable(TheHand src/main.cpp)

target_include_directories(TheHand PUBLIC 3rdparty/botcraft/include)

target_link_libraries(TheHand m botcraft)
set(CMAKE_CXX_FLAGS "-static")

install(TARGETS TheHand)

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_FORCE_LOCAL_* 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

DanDucky avatar Apr 22 '24 20:04 DanDucky