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

Author Topic: Cmake problem  (Read 5143 times)

0 Members and 1 Guest are viewing this topic.

torenf

  • Newbie
  • *
  • Posts: 29
    • View Profile
    • Email
Cmake problem
« on: October 14, 2014, 04:22:25 pm »
Hey,
Iam working with QT and i want to make a SFML Project with Cmake.I built my Libs etc. but i have an error in my List's.Ive pushed the includes and libs in my project folder and he finds the includes but not my Libs.I think he doesnt even search.My Lists is a Attach.

Code:
Quote
#include <SFML/Graphics.hpp>



int main()
{
    // create the window
    sf::RenderWindow window(sf::VideoMode(800, 600), "My window");

    // run the program as long as the window is open
    while (window.isOpen())
    {
        // check all the window's events that were triggered since the last iteration of the loop
        sf::Event event;
        while (window.pollEvent(event))
        {
            // "close requested" event: we close the window
            if (event.type == sf::Event::Closed)
                window.close();
        }

        // clear the window with black color
        window.clear(sf::Color::Black);

        // draw everything here...
        // window.draw(...);

        // end the current frame
        window.display();
    }

    return 0;
}

I hope u can help me :)
Toren
« Last Edit: October 14, 2014, 04:32:44 pm by torenf »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10895
    • View Profile
    • development blog
    • Email
Re: Cmake problem
« Reply #1 on: October 14, 2014, 04:33:42 pm »
It's sfml-graphics, sfml-window and sfml-system, meaning, don't add the "-2".
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

torenf

  • Newbie
  • *
  • Posts: 29
    • View Profile
    • Email
Re: Cmake problem
« Reply #2 on: October 14, 2014, 05:11:00 pm »
I tried it,same error :(

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Cmake problem
« Reply #3 on: October 14, 2014, 05:22:23 pm »
Read the following thread and post full output.

http://en.sfml-dev.org/forums/index.php?topic=12552.0
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

torenf

  • Newbie
  • *
  • Posts: 29
    • View Profile
    • Email
Re: Cmake problem
« Reply #4 on: October 14, 2014, 06:24:04 pm »
Again i use Qt.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Cmake problem
« Reply #5 on: October 14, 2014, 08:17:09 pm »
"lib" is a link directory, not an include directory.
Laurent Gomila - SFML developer

torenf

  • Newbie
  • *
  • Posts: 29
    • View Profile
    • Email
Re: Cmake problem
« Reply #6 on: October 15, 2014, 05:13:03 pm »
I dont include it ^^
I search the directory then i link it.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Cmake problem
« Reply #7 on: October 15, 2014, 05:33:48 pm »
I dont include it ^^
Yes, you do. There is an include_directories(lib) in your CMake script, see what that command means here :)

What you want is link_directories.
« Last Edit: October 15, 2014, 05:35:43 pm by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

torenf

  • Newbie
  • *
  • Posts: 29
    • View Profile
    • Email
Re: Cmake problem
« Reply #8 on: October 15, 2014, 06:19:32 pm »
Hm okay ure right :D
Ok now ive wrote

Quote
link_directories(sfml-graphics;sfml-window;sfml-sytem)

But again errors and i dont know why....

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Cmake problem
« Reply #9 on: October 15, 2014, 08:58:33 pm »
Hmm... what about spending a little more time learning the syntax of CMake?

include_directories(include)
link_directories(lib)
target_link_libraries(${PROJECT_NAME}
    DEBUG sfml-graphics-d sfml-window-d sfml-system-d
    OPTIMIZED sfml-graphics sfml-window sfml-system)

(once you understand what's going on in your CMake file, use the FindSFML.cmake module to simplify it)
Laurent Gomila - SFML developer

torenf

  • Newbie
  • *
  • Posts: 29
    • View Profile
    • Email
Re: Cmake problem
« Reply #10 on: October 16, 2014, 01:51:35 pm »
Sorry for my stupidity... :D
I didnt saw that it was link_DIRECTORY and not link_libary or something like that.Thanks for
ure help :)
but i have one more problem now...Why he cant find the libs and debug/optimized?!
« Last Edit: October 16, 2014, 04:24:26 pm by torenf »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10895
    • View Profile
    • development blog
    • Email
AW: Cmake problem
« Reply #11 on: October 16, 2014, 06:53:49 pm »
As said before, learn CMake. This has nothing to do with SFML.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

torenf

  • Newbie
  • *
  • Posts: 29
    • View Profile
    • Email
Re: Cmake problem
« Reply #12 on: October 16, 2014, 07:55:09 pm »
^^

torenf

  • Newbie
  • *
  • Posts: 29
    • View Profile
    • Email
Re: Cmake problem
« Reply #13 on: October 16, 2014, 08:14:41 pm »
One last question.I think i have the problem.

Error:
CMake Error at CMakeLists.txt:8 (target_link_libraries):
Cannot specify link libraries for target
"C:/Programiersachen/QT/SFML-Cmake/SFML/lib}" which is not built by this
project.
 
I dont understand the error... Its precompiled so i dont understand why he says that error.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Cmake problem
« Reply #14 on: October 16, 2014, 10:10:51 pm »
The first argument of target_link_libraries is probably wrong. It must be the same as the first argument of add_executable (ie. the target name).
Laurent Gomila - SFML developer