Digamos que usei find_package(SDL REQUIRED) agora preciso vincular essa biblioteca através de target_link_libraries qual seria o nome da variável a passar para target_link_libraries? Em geral, existe uma maneira de encontrar essas variáveis além de adivinhar heuristicamente? Eu tentei SDL_LIBRARY, SDL2_LIBRARY e SDL_LIBRARIES. Eu tenho o sdl2 instalado.
Eu esperava que isso funcionasse, mas não funcionou:
cmake_minimum_required(VERSION 3.10)
project(someProject)
# Find SDL2
find_package(SDL REQUIRED)
find_package(SDL_image REQUIRED)
# Include directories
include_directories(${SDL2_INCLUDE_DIRS} ${SDL2_IMAGE_INCLUDE_DIRS})
# Set source files
set(SOURCES main.cpp)
# Set executable
add_executable(someProject ${SOURCES})
# Link libraries
target_link_libraries(someProject ${SDL2_LIBRARIES} ${SDL2_IMAGE_LIBRARIES})
> CMake Error at
> /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230
> (message): Could NOT find SDL (missing: SDL_LIBRARY SDL_INCLUDE_DIR)
> Call Stack (most recent call first):
> /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:600
> (_FPHSA_FAILURE_MESSAGE) /usr/share/cmake/Modules/FindSDL.cmake:224
> (FIND_PACKAGE_HANDLE_STANDARD_ARGS) CMakeLists.txt:5 (find_package)
>
>
> -- Configuring incomplete, errors occurred!