Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Cmake building SFML 3.0 with WSL2  (Read 96 times)

0 Members and 2 Guests are viewing this topic.

Aidymouse

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Cmake building SFML 3.0 with WSL2
« on: December 22, 2024, 12:54:33 pm »
Hi all,

Trying to build SFML using Cmake in WSL2 and having some success except that it can't find X11?

I've seen a lot of other posts about getting X11 apps to work, and it's not that. I can get X11 apps to run, but I can't build because it's apparently missing.

My CMakeLists.txt looks like

Code: [Select]
cmake_minimum_required(VERSION 3.28)

project(EvilPikmin LANGUAGES CXX VERSION 0.0.1)

set(CMAKE_EXPORT_COMPILE_COMMANDS true)

add_executable(EvilPikmin src/main.cpp)

include_directories(include)
add_subdirectory(src)

#SFML
set(SFML_USE_DRM false) # Disables need for X11
#set(EGL_CONTEXT_CLIENT_VERSION 2)

include(FetchContent)
FetchContent_Declare(SFML
    GIT_REPOSITORY https://github.com/SFML/SFML.git
    GIT_TAG 3.0.0
    GIT_SHALLOW ON
    EXCLUDE_FROM_ALL
    SYSTEM)
FetchContent_MakeAvailable(SFML)

target_link_libraries(EvilPikmin PRIVATE SFML::Graphics)

I'm getting an error like
Code: [Select]
CMake Error at /snap/cmake/1435/share/cmake-3.31/Modules/FindPackageHandleStandardArgs.cmake:233 (message):
  Could NOT find X11 (missing: Xi)
Call Stack (most recent call first):
  /snap/cmake/1435/share/cmake-3.31/Modules/FindPackageHandleStandardArgs.cmake:603 (_FPHSA_FAILURE_MESSAGE)
  /snap/cmake/1435/share/cmake-3.31/Modules/FindX11.cmake:676 (find_package_handle_standard_args)
  build/_deps/sfml-src/src/SFML/Window/CMakeLists.txt:279 (find_package)

Any ideas?

Thanks



Aidymouse

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: Cmake building SFML 3.0 with WSL2
« Reply #1 on: Today at 10:51:03 am »
Alright, the problem is that I'm really dumb. I had to install the package it said was missing
Code: [Select]
sudo apt get libxi-dev
and set display to 0
Code: [Select]
export DISPLAY=:0
and then it worked.