I'm working on a project, so I have to have somekind of building platform.
So I choose CMake.
I found the FindSFML.cmake module here:
https://github.com/SFML/SFML/blob/master/cmake/Modules/FindSFML.cmake.
And I found this:
http://www.cmake.org/Wiki/CMake:How_To_Find_Libraries to use the module.
But the problem is, I don't know how to use the module, I tried it with the standard way listed on the page, but it gave an undefined resource error.
code:
CMakeLists.txt:
cmake_minimum_required (VERSION 2.6)
project (hello)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
find_package(SFML REQUIRED)
include_directories(${SFML_INCLUDE_DIR})
set(LIBS ${LIBS} ${SFML_SYSTEM_LIBRARY})
add_executable (hello hello.cxx)
target_link_libraries(hello ${LIBS})
hello.cxx:
#include <iostream>
#include <SFML/System.hpp>
int main()
{
/*sf::Clock Clock;
while (Clock.GetElapsedTime() < 5.f)
{
std::cout << Clock.GetElapsedTime() << std::endl;
sf::Sleep(0.5f);
}*/
return 0;
}
Console output:
[stijn@vaio bin]$ cmake ..
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
Found SFML: /usr/include
-- Configuring done
-- Generating done
-- Build files have been written to: /home/stijn/devel/cmaketest/bin
[stijn@vaio bin]$ make
Scanning dependencies of target hello
[100%] Building CXX object CMakeFiles/hello.dir/hello.cxx.o
Linking CXX executable hello
CMakeFiles/hello.dir/hello.cxx.o: In function `main':
hello.cxx:(.text+0x10): undefined reference to `sf::Clock::Clock()'
hello.cxx:(.text+0x1e): undefined reference to `sf::Clock::GetElapsedTime() const'
hello.cxx:(.text+0x42): undefined reference to `sf::Sleep(float)'
hello.cxx:(.text+0x4e): undefined reference to `sf::Clock::GetElapsedTime() const'
collect2: ld gaf exit-status 1 terug
make[2]: *** [hello] Fout 1
make[1]: *** [CMakeFiles/hello.dir/all] Fout 2
make: *** [all] Fout 2
Sorry for it being half in dutch, and yes it's a Sony VAIO.
CMake says everything is perfect. But when I use make to actually compile it, it gives the undefined resource error.
Platform info:
Fedora Linux 16 x64
CMake
GNU Make
And g++
Sorry for being such a noob!