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

Author Topic: Trouble creating an SFML 2.0 CodeBlocks project file in Cmake  (Read 3329 times)

0 Members and 1 Guest are viewing this topic.

gws923

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Hello all.  I have read through a bunch of threads on this forum that talked about similar problems and I made a lot of progress, but there is something weird which is happening that none of those threads quite addressed.  So forgive me if this has been asked a million times.

I'm currently getting the following error when trying to configure:
CMake Error at cmake/Modules/FindSFML.cmake:199 (message):
  SFML found but version too low (requested: 2.0, found: 1.x)
Call Stack (most recent call first):
  CMakeLists.txt:25 (find_package)

I am quite definitely using SFML 2.0.  I even redownloaded the release candidate to make sure.

To help give some context, right before receiving this error, I had gotten an error saying CMake could not find SFML (I dunno what's up with the FindSFML.make or what I did to get that message).  I fixed it by added an SFMLDIR path to C:/Program Files(x86)/SFML 2.0 where I have it installed.  That let me continue on until I encountered the error above.  Any ideas?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Trouble creating an SFML 2.0 CodeBlocks project file in Cmake
« Reply #1 on: January 29, 2013, 06:13:07 pm »
As the message says, it somehow seems to find SFML 1.x (probably 1.6), but it needs SFML 2.
Are you sure, you don't have SFML 1.6 somewhere lying around where CMake could potentially find it?

Btw are you trying to build SFML or are you writing your own CMake file for your project?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

gws923

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: Trouble creating an SFML 2.0 CodeBlocks project file in Cmake
« Reply #2 on: January 29, 2013, 06:26:32 pm »
I probably do have 1.6 around somewhere.  Would deleting it (I don't need it for anything) fix the problem?  It just seems strange that I specified the path to my 2.0 folder and then it's giving me this problem.

My friend wrote the cmake file, which I only sort of maybe a little bit understand.  I'm pretty new to programming, and especially to my worst enemy, Cmake.  We do have a line in the file requiring SFML 2.0.  I tried changing it to just SFML (which will accept any version, right?) and then it gave me the error of not being able to find the SFML libraries again.

We started programming a library in Linux and are now trying to get the project onto Windows (MinGW) so we're having to go through this.  Unfortunately, my friend doesn't have Windows so he can't reproduce the problem and help very much.


gws923

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: Trouble creating an SFML 2.0 CodeBlocks project file in Cmake
« Reply #3 on: January 29, 2013, 06:34:44 pm »
Deleted my 1.6 folder.  Nothing seemed to change :/

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Trouble creating an SFML 2.0 CodeBlocks project file in Cmake
« Reply #4 on: January 29, 2013, 06:44:12 pm »
I tried changing it to just SFML (which will accept any version, right?) and then it gave me the error of not being able to find the SFML libraries again.
You tried to change what?

Here's an example CMake script for building a library that links against the Graphics, Window and System module and gives an option to build a shared or a static library.

cmake_minimum_required( VERSION 2.8 )
project( MyLib )

set( MYLIB_BUILD_SHARED_LIBS TRUE CACHE BOOL "Build shared libraries." )
set( MYLIB_SKIP_INSTALL FALSE CACHE BOOL "Do not run install target." )

if( MYLIB_BUILD_SHARED_LIBS )
        set( LIB_TYPE SHARED )
else()
        set( LIB_TYPE STATIC )
endif()

find_package( SFML 2.0 REQUIRED GRAPHICS WINDOW SYSTEM )

set( SRC_DIR "src" )
set( INC_DIR "include" )

set(
        SOURCES
        ${INC_DIR}/MyLib/Header1.hpp
        ${INC_DIR}/MyLib/Header2.hpp
        ${SRC_DIR}/Source1.cpp
        ${SRC_DIR}/Source2.cpp
)

include_directories( ${INC_DIR} )
include_directories( ${SFML_INCLUDE_DIR} )

add_library( MyLib ${LIB_TYPE} ${SOURCES} )

target_link_libraries( MyLib ${SFML_GRAPHICS_LIBRARY} )
target_link_libraries( MyLib ${SFML_WINDOW_LIBRARY} )
target_link_libraries( MyLib ${SFML_SYSTEM_LIBRARY} )

if( MYLIB_BUILD_SHARED_LIBS )
        set_target_properties( MyLib PROPERTIES DEBUG_POSTFIX -d )
else()
        set_target_properties( MyLib PROPERTIES DEBUG_POSTFIX -s-d )
        set_target_properties( MyLib PROPERTIES RELEASE_POSTFIX -s )
        set_target_properties( MyLib PROPERTIES MINSIZEREL_POSTFIX -s )
endif()

if( NOT MYLIB_SKIP_INSTALL )
        install(
                TARGETS MyLib
                RUNTIME DESTINATION bin COMPONENT bin
                LIBRARY DESTINATION lib COMPONENT bin
                ARCHIVE DESTINATION lib COMPONENT dev
        )

        install(
                DIRECTORY include/MyLib
                DESTINATION include
        )
endif()
 

Deleted my 1.6 folder.  Nothing seemed to change :/
Well you need to give some more information on your setup and what you're doing, otherwise it's impossible for us to make some guesses...
« Last Edit: January 29, 2013, 06:49:23 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

gws923

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: Trouble creating an SFML 2.0 CodeBlocks project file in Cmake
« Reply #5 on: January 29, 2013, 07:08:43 pm »
Sorry, when I said I changed SFML 2.0 to SFML I meant in the Cmake file.  Here is our cmake file:
project(JollyLava CXX)
cmake_minimum_required( VERSION 2.6 )

# Set version information in a config.h file
set(myproject_VERSION_MAJOR 0)
set(myproject_VERSION_MINOR 1)

# Name of this library.
set(LIBRARY_NAME "JollyLava")

#
# --- User options
#
set(JOLLYLAVA_BUILD_EXAMPLES FALSE CACHE BOOL
    "Build sandbox targets that try out the various classes.")
set(JOLLYLAVA_BUILD_DOC FALSE CACHE BOOL
    "Create API documentation (requires Doxygen).")

#
# --- Dependencies
#
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules" ${CMAKE_MODULE_PATH})

# SFML
find_package(SFML 2.0 REQUIRED system window graphics network audio)

# Box2D
find_package(Box2D REQUIRED)
include_directories("${BOX2D_INCLUDE_DIR}")

# Include headers.
include_directories(${CMAKE_SOURCE_DIR}/include)

# C++ source code.
add_subdirectory(src)

# Example executables.
if(JOLLYLAVA_BUILD_EXAMPLES)
    add_subdirectory(examples)
endif(JOLLYLAVA_BUILD_EXAMPLES)

# Doxygen API documentation
if(JOLLYLAVA_BUILD_DOC)
    find_package(Doxygen REQUIRED)
    if(DOXYGEN_FOUND)
        configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile
            ${CMAKE_CURRENT_BINARY_DIR}/doc/Doxyfile @ONLY)
        add_custom_target(doc ALL
            ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doc/Doxyfile
            WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
            COMMENT "Generating API documentation with Doxygen" VERBATIM)
    endif(DOXYGEN_FOUND)
endif(JOLLYLAVA_BUILD_DOC)

# http://www.dlyr.fr/stuff/2012/03/release-and-debug-with-cmake-and-qtcreator/
#if(CMAKE_BUILD_TYPE STREQUAL "debug")
#    set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib-debug)
#    set(LIB_INSTALL_DIR ${CMAKE_SOURCE_DIR}/lib-debug)
#    set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin-dbg)
#else()
#    set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
#    set(LIB_INSTALL_DIR ${CMAKE_SOURCE_DIR}/lib)
#    set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin)
#endif()

# Install target
#install(TARGETS ${EXECUTABLE_NAME} DESTINATION bin)


# CPack packaging
#include(InstallRequiredSystemLibraries)
#set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE.txt")
#set(CPACK_PACKAGE_VERSION_MAJOR "${myproject_VERSION_MAJOR}")
#set(CPACK_PACKAGE_VERSION_MINOR "${myproject_VERSION_MINOR}")
#include(CPack)

#${UIS} ${RSCS} ${TRS} ${MOCS} )
 

gws923

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: Trouble creating an SFML 2.0 CodeBlocks project file in Cmake
« Reply #6 on: January 29, 2013, 07:35:38 pm »
Ok, after some work I have gotten Cmake to finally work.  I just had to take out the required version in the cmake file and then respecify the paths to the .a files.  So, I have it working, but still a little curious what might have happened.  Thanks for your help, Exploiter.