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

Author Topic: CMake - SFML dependency issues  (Read 1532 times)

0 Members and 1 Guest are viewing this topic.

Gamaray

  • Newbie
  • *
  • Posts: 6
    • View Profile
CMake - SFML dependency issues
« on: March 26, 2023, 12:38:16 pm »
I've started to word on the build scripts for one of my SFML projects - but I keep running into dependency problems with the modules: OpenAL, Vorbis and Flac - here is the error I get for a given dependency:

Code: [Select]
CMake Error at /usr/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:165 (message):
  Could NOT find FLAC (missing: FLAC_LIBRARY FLAC_INCLUDE_DIR)
Call Stack (most recent call first):
  /usr/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:458 (_FPHSA_FAILURE_MESSAGE)
  build/_deps/sfml-src/cmake/Modules/FindFLAC.cmake:16 (find_package_handle_standard_args)
  build/_deps/sfml-src/cmake/Macros.cmake:279 (find_package)
  build/_deps/sfml-src/src/SFML/Audio/CMakeLists.txt:71 (sfml_find_package)

To fix these I need to install the lib[module]-dev packages for each dependency with apt, but is there a way I could integrate the installation of such dependencies into the cmake build files. Here is a basic CMakeLists.txt file which should just compile a simple "hello world" SFML project, what could I add to resolve these problems? :

 1 cmake_minimum_required(VERSION 3.18)
 2 project(SfmlBasic VERSION 1.0)
 3 include(FetchContent)
 4 set(BUILD_SHARED_LIBS ON)
 5 FetchContent_Declare(
 6  SFML
 7  GIT_REPOSITORY https://github.com/SFML/SFML.git
 8  GIT_TAG 2.5.1
 9 )
10 FetchContent_MakeAvailable(SFML)
11 set(CMAKE_CXX_STANDARD 11)
12 set(CMAKE_CXX_STANDARD_REQUIRED true)
13 add_executable(
14  SfmlBasic
15  main.cpp
16 )
17 target_link_libraries(
18  SfmlBasic
19  sfml-graphics
20 )

« Last Edit: March 26, 2023, 03:39:21 pm by eXpl0it3r »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: CMake - SFML dependency issues
« Reply #1 on: March 26, 2023, 03:44:36 pm »
The script looks similar to what the SFML CMake template does. But neither script will build SFML's dependencies.
On Linux you're still required to install the necessary dependencies through your package manager.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Gamaray

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: CMake - SFML dependency issues
« Reply #2 on: March 26, 2023, 03:50:27 pm »
I see - so there is no way to omit this? It would be nice if people could just run the cmake script without any other steps - I could make a bash script I guess - would the CMAKE run fine on windows?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: CMake - SFML dependency issues
« Reply #3 on: March 26, 2023, 05:54:06 pm »
As Windows doesn't really have an established package manager, we ship the binaries, so it should fully build.

Keep in mind that you always need to install a graphics driver and other system libraries regardless :D
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything