Hello,
I am using CLion on Windows 10 and am trying to create a project that depends on SFML 2.5.
CLion uses CMake and I want to setup my CMakeLists to automatically include SFML as a subdirectory, compile it, find the library and link it.
This is my current CMakeLists:
cmake_minimum_required(VERSION 3.16)
project(Renderer)
set(CMAKE_CXX_STANDARD 20)
add_library(${PROJECT_NAME})
add_subdirectory(src)
target_include_directories(${PROJECT_NAME} PUBLIC include)
add_subdirectory(lib/glm)
target_link_libraries(${PROJECT_NAME} PRIVATE glm)
add_definitions(-DGLEW_STATIC)
add_subdirectory(lib/glew)
target_link_libraries(${PROJECT_NAME} PRIVATE libglew_static)
# SFML
add_subdirectory(lib/SFML)
set(SFML_DIR ${CMAKE_CURRENT_BINARY_DIR}/dependencies/SFML)
find_package(SFML 2.5 COMPONENTS window audio REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE sfml-window sfml-audio)
And this is my folder structure. SFML is a git submodule.
The error I keep getting is
CMake Error at cmake-build-debug/lib/SFML/SFMLConfig.cmake:139 (message):
Requested SFML configuration (Shared) was not found
Call Stack (most recent call first):
CMakeLists.txt:23 (find_package)
CMake Error at CMakeLists.txt:23 (find_package):
Found package configuration file:
D:/Projects/C++/Renderer/cmake-build-debug/lib/SFML/SFMLConfig.cmake
but it set SFML_FOUND to FALSE so package "SFML" is considered to be NOT
FOUND.
It seems like the SFML library files are not being built, even though it is included as a subdirectory?
I am not a CMake expert and have no idea how to continue forward from here. Unfortunately all the tutorials online focus on older versions of SFML and use the FindSFML thing instead of the new find_package SFMLConfig way.
Any help is appreciated!