I'm trying to use sdl on ubuntu. According to this instruction(https://gist.github.com/BoredBored/3187339a99f7786c25075d4d9c80fad5) i installed sdl2, sdl image and sdl mixer. Now I have to link them while building. Example how should I do it below.
g++ myProgram.cpp -o myProgram `sdl2-config --cflags --libs` -lSDL2 -lSDL2_mixer -lSDL2_image -lSDL2_ttf I'm using Cmake and I have no idea how to link them...
Below it's code done just for testing sdl working or not.
//MAIN #include <iostream> #include <SDL2/SDL.h> #include <SDL2/SDL_image.h> #include <SDL2/SDL_mixer.h> #include <SDL2/SDL_ttf.h> int main(int argc, char*args[]) { SDL_Init(SDL_INIT_EVERYTHING); } CMakeList below
# Set the minimum version of CMake that can be used # To find the cmake version run # $ cmake --version cmake_minimum_required(VERSION 3.5) # Set the project name project (sdl) # Create a sources variable with a link to all cpp files to compile set(SOURCES src/main.cpp ) # Add an executable with the above sources add_executable(${PROJECT_NAME} ${SOURCES}) # Set the directories that should be included in the build command for this target # when running g++ these will be included as -I/directory/path/ target_include_directories(sdl PRIVATE ${PROJECT_SOURCE_DIR}/inc ) How can I link them in Cmake? Thanks for your time.