0

I was trying to compile Cmake with SFML and try several things from different sites, but no result.

This same code is from my teammate that works for him in Fedora 29 while me for Ubuntu doesn't work, and I have no idea what to try more.

cmake_minimum_required(VERSION 3.16)
project(indie)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_FLAGS "-W -Wall -Wextra -I./$(INCLUDE_PATH) -Wno-long-long -lsfml-graphics -lsfml-window -lsfml-system -lIrrlicht")

include_directories(src
        include)

add_executable(indie
        src/Indie.cpp
        include/Indie.hpp
        src/Player.cpp
        include/Game.hpp
        include/Player.hpp
        src/Game.cpp
        include/Menu.hpp
        src/Menu.cpp
        include/Structures.hpp
        src/Structures.cpp
        include/Macros.hpp
        main.cpp)
Kevin
  • 16,549
  • 8
  • 60
  • 74
Jonathan Gómez
  • 403
  • 1
  • 6
  • 19
  • 3
    What do you mean by "*doesn't work*"? Please provide any **error messages** you are seeing. Also, using the `-l` flag in the `CMAKE_CXX_FLAGS` variable probably won't have the effect you expect, as these are *compilation* flags, and not for the linker. Instead, use `target_link_libraries(indie PRIVATE sfml-graphics sfml-window sfml-system Irrlicht)` – Kevin May 26 '20 at 17:06
  • Sorry, I'm a newbie, and now using the target_link_libraries you suggest, now works! :) – Jonathan Gómez May 26 '20 at 17:14
  • 1
    "trying to compile Cmake with SFML" - I think you got that backwards. You don't seem to be trying to compile CMake. You seem to be trying to compile a project that uses SFML with CMake as your meta build system. – Jesper Juhl May 26 '20 at 17:19
  • I don't if it could be in this question but now I have this error when I execute it `X Error of failed request: GLXBadContextTag Major opcode of failed request: 152 (GLX) Minor opcode of failed request: 16 (X_GLXVendorPrivate) Serial number of failed request: 714 Current serial number in output stream: 715` – Jonathan Gómez May 26 '20 at 17:28
  • Search for that error. – drescherjm May 26 '20 at 17:35
  • @drescherjm I search it but didn't find the solution for my case – Jonathan Gómez May 26 '20 at 17:41
  • 1
    I think this is an OS issue related to your opengl and/or graphics drivers. – drescherjm May 26 '20 at 17:43
  • 1
    If you're using CMake 3.16 there's no reason to ever use directory-level commands like `include_directories`. Use the equivalent target commands, like `target_include_directories`, instead. – Alex Reinking May 26 '20 at 18:29
  • 1
    Also _never_ set `CMAKE_CXX_FLAGS` from inside the CMakeLists.txt. Use `target_compile_options`, `target_link_libraries`, `target_compile_definitions`, instead. – Alex Reinking May 26 '20 at 18:31
  • @drescherjm you were right, it was an OS problem, I had to update to the new Ubuntu version, thanks :) – Jonathan Gómez May 27 '20 at 11:11

0 Answers0