I'm trying CMake for the first time. When I run cmake from the command line everything seems ok:
alex@mileena:~/Projects/SDLTutorial/_build$ cmake ..
-- Configuring done
-- Generating done
-- Build files have been written to: /home/alex/Projects/SDLTutorial/_build
But when I run make, I get undefined references to all SDL functions. I've included SDL.h.
alex@mileena:~/Projects/SDLTutorial/_build$ make
Linking CXX executable SDLTutorial
CMakeFiles/SDLTutorial.dir/main.cpp.o: In function `main':
main.cpp:(.text+0x15): undefined reference to `SDL_Init'
main.cpp:(.text+0x43): undefined reference to `SDL_CreateWindow'
main.cpp:(.text+0x6f): undefined reference to `SDL_CreateRenderer'
main.cpp:(.text+0xa3): undefined reference to `SDL_SetRenderDrawColor'
main.cpp:(.text+0xb2): undefined reference to `SDL_RenderClear'
main.cpp:(.text+0xc1): undefined reference to `SDL_RenderPresent'
main.cpp:(.text+0xcb): undefined reference to `SDL_Delay'
main.cpp:(.text+0xd0): undefined reference to `SDL_Quit'
collect2: error: ld returned 1 exit status
CMakeFiles/SDLTutorial.dir/build.make:85: recipe for target 'SDLTutorial' failed
make[2]: *** [SDLTutorial] Error 1
These are the contents of CMakeLists.txt. Am I including the library correctly?
cmake_minimum_required(VERSION 2.8)
project(SDLTutorial)
add_executable(SDLTutorial main.cpp)
find_library(SDL REQUIRED)
if (SDL_FOUND)
include_directories(${SDL_INCLUDE_DIR})
target_link_libraries(SDLTutorial ${SDL_LIBRARY})
endif (SDL_FOUND)
install(TARGETS SDLTutorial DESTINATION bin)