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

Author Topic: SFML2 CMake - Project using only CMake  (Read 5563 times)

0 Members and 1 Guest are viewing this topic.

Klaim

  • Full Member
  • ***
  • Posts: 137
    • View Profile
SFML2 CMake - Project using only CMake
« on: April 28, 2012, 05:19:08 pm »
I want to test SFML2 with a CMake-only project, so I just write this:

cmake_minimum_required( VERSION 2.8 )


project( game )

add_subdirectory( sfml )

set( GAME_ALL_SOURCES
        main.cpp
)

add_executable( game ${GAME_ALL_SOURCES}  )
target_link_libraries( sfml-main sfml-system sfml-window sfml-graphics sfml-audio )
 

My sfml folder contain the current sfml git repository clone.
Without the last line I got no error, but with the last line I got:
CMake Error at CMakeLists.txt:13 (target_link_libraries):
  Attempt to add link library "sfml-system" to target "sfml-main" which is
  not built in this directory.


CMake Error at CMakeLists.txt:13 (target_link_libraries):
  Attempt to add link library "sfml-window" to target "sfml-main" which is
  not built in this directory.


CMake Error at CMakeLists.txt:13 (target_link_libraries):
  Attempt to add link library "sfml-graphics" to target "sfml-main" which is
  not built in this directory.


CMake Error at CMakeLists.txt:13 (target_link_libraries):
  Attempt to add link library "sfml-audio" to target "sfml-main" which is not
  built in this directory.

 

I'm  not sure what I'm doing wrong here... ?

It looks like the sfml projects can't refer to each other once I've included the projects this way.
I dont understand... is the problem from my CMake script, or from CMake or from the SFML CMake scripts?

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Re: SFML2 CMake - Project using only CMake
« Reply #1 on: April 28, 2012, 05:34:16 pm »
You either have to use add_subdirectory and then link to SFML's project name(s) or you search the libraries with find_library and SFML's FindSFML.cmake.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: SFML2 CMake - Project using only CMake
« Reply #2 on: April 28, 2012, 05:37:49 pm »
The first argument of target_link_libraries must be your own target. Here you're trying to link all SFML modules to... sfml-main ;)
Laurent Gomila - SFML developer

Klaim

  • Full Member
  • ***
  • Posts: 137
    • View Profile
Re: SFML2 CMake - Project using only CMake
« Reply #3 on: April 28, 2012, 05:44:49 pm »
The first argument of target_link_libraries must be your own target. Here you're trying to link all SFML modules to... sfml-main ;)


I was sure it was me being oblivious (but I can also blame the obscure CMake syntaxe!!!!.... ok ok it's my fault).

Also, I should stop creating new projects after midnight (I'm in japan right now).

Thanks.