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

Author Topic: Problem with SFML_DIR in CMake  (Read 2658 times)

0 Members and 1 Guest are viewing this topic.

cheax

  • Newbie
  • *
  • Posts: 2
    • View Profile
Problem with SFML_DIR in CMake
« on: August 30, 2021, 05:44:12 pm »
So I have a project that uses SFML and it compiles fine when my CMakeLists.txt is like this:

    find_package(SFML 2.5.1
    COMPONENTS
    system window graphics network audio REQUIRED)

    target_link_libraries(Spark sfml-graphics sfml-audio)

Since I have SFML installed on my system (Ubuntu). But I'm trying to set it up using SFML_DIR, since I have SFML library included in the project structure in case the user doesnt have it installed on their system or if it's out of date. I tried this:

    set(SFML_DIR ${PROJECT_SOURCE_DIR}/libs/SFML/cmake/)
    target_include_directories(Spark PRIVATE ${PROJECT_SOURCE_DIR}/libs/SFML/include/)

However it got me an error message like this:

    undefined reference to symbol '_ZN2sf6Window9pollEventERNS_5EventE'

I also tried using both find_package() and set(SFML_DIR...) however the package always overwrote the SFML_DIR value. I tested it on another Windows 10 system where after set() and target_include_directories() (but find_package() commented out) still couldnt find 'sfml-graphics'.

How do I guarantee my included version of SFML is being used regardless of what system the project is being compiled on?


cheax

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Problem with SFML_DIR in CMake
« Reply #1 on: August 30, 2021, 09:41:12 pm »
never mind I needed to specify NO_DEFAULT_PATH

 

anything