Help: All resources failing to load upon building SFML project with CMake

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Help: All resources failing to load upon building SFML project with CMake

William Webster

This is my first time attempting to build/package my game with CMake, so apologies if this is a dumb questions/not the place to ask this. In short, i've been following the steps on this (https://github.com/SFML/SFML/wiki/Tutorial%3A-Build-your-SFML-project-with-CMake) tutorial up til now. However, once it came to the very final steps ("cmake CMakeLists.txt", "cmake --build .") my build appears to have failed loading any of my assets. This includes, pictures, sounds & fonts, while all SFML assets appear to be drawing as usual, I cant seem to figure it out. I've attempted to directly reference their file paths in the CMakeLists.txt file, in the hopes that even one variation of the different file paths would work, but no luck. It might go without saying, but run from within my IDE (CLion) the project runs perfectly. Just incase it's relevant (and as there's not really much code I can show here), I've included my CMakeLists.txt code, just incase that might help:

cmake_minimum_required(VERSION 3.8)

# Enable debug symbols by default
if(NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build (Debug or Release)" FORCE)
endif()

project(SK_IVER)

set(CMAKE_CXX_STANDARD 11)

# Set version information in a config.h file
set(SK_IVER_VERSION_MAJOR 1)
set(SK_IVER_VERSION_MINOR 0)
configure_file(
        "${PROJECT_SOURCE_DIR}/config.h.in"
        "${PROJECT_BINARY_DIR}/config.h"
)
include_directories("${PROJECT_BINARY_DIR}")


set(SOURCE_FILES
        main.cpp
        Diver.cpp
        Diver.h
        Ring.cpp Ring.h HandleEvents.cpp HandleEvents.h Background.cpp Background.h Particle.cpp Particle.h Particles.cpp Particles.h Game.cpp Game.h)

# Define sources and executable
set(EXECUTABLE_NAME "SK_IVER")
add_executable(${EXECUTABLE_NAME} ${SOURCE_FILES})

# Detect and add SFML
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})
find_package(SFML REQUIRED system window graphics network audio)
if (SFML_FOUND)
    include_directories(${SFML_INCLUDE_DIR})
    target_link_libraries(SK_IVER ${SFML_LIBRARIES})
endif()

# Install target
install(TARGETS ${EXECUTABLE_NAME} DESTINATION bin)

# CPack packaging
include(InstallRequiredSystemLibraries)
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
set(CPACK_PACKAGE_VERSION_MAJOR "${myproject_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${myproject_VERSION_MINOR}")
include(CPack)

I've been reading about symbolic links, and have considered that this might be what's needed, have had no luck with implement one up til now. All the files in my project, are stored in a 'Resources/' folder alongside the project files and are all directly referenced using relative paths within my code, such as:

if(!font.loadFromFile("Resources/Font/Arial_Unicode.ttf"))
    std::cout << "ERROR: Could not load font file." << std::endl;

(which loads and runs perfectly from within my IDE)

Thanks in advance for any help or pointers on the matter,
Will.



--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake