help with cmake?

so if anyone remembers, im writing an irc bot. the source is getting pretty large, so i thought i would write a makefile. the only problem is, its getting quite big, so i turned to cmake to generate them. i have a good CMakeLists.txt file going, but i cant figure out how to do something. it links to sfml-system and sfml-network, but i cant figure out how to get cmake to look for those libraries. any help?
I thought Cmake ran off your computer's paths and settings of the person compiling. I've never used it personally though.
You can use the findSFML.cmake script in SFML root/cmake/modules then in CMakeLists.txt add something like:

find_package(SFML 2 REQUIRED network system)
if(SFML_FOUND)
    include_directories(${SFML_INCLUDE_DIR})
    link_directories(${SFML_ROOT}/lib)
else()
    message(FATAL_ERROR "SFML not found by find_package. Try specifying SFML_ROOT")
endif()
do i have to copy it into my projects folder that contains the List file?
It doesn't really matter where you copy it to, you just need to add the path to CMAKE_MODULE_PATH
a) i cant find the findSFML script
b) is that an environment variable or would i have to add it in my cmakeLists file
a) On linux it might be in /usr/share/SFML or /usr/local/share/SFML
b) Its a cmake variable, its already defined you just need to add your module directory
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})


EDIT: If you still can't find findSFML.cmake its also here https://github.com/LaurentGomila/SFML/blob/master/cmake/Modules/FindSFML.cmake
Last edited on
thanks! that worked great. just one last problem... ive tried googling it, but i cant find anything about this, and its generating lots of linker errors. so i have file foo.cpp and file bar.cpp (just an example). main.cpp uses both of those. how would i tell cmake to link to those? they are all in the same folder
Try
file(GLOB_RECURSE SOURCE "${SOURCE_DIR}*.cpp")

then
add_executable (ircbot ${SOURCE})
Topic archived. No new replies allowed.