I am following this question. However my cmake
faces with error:
-- Configuring done
CMake Error at CMakeLists.txt:18 (add_executable):
Target "main" links to item "-L/usr/lib/x86_64-linux-gnu -lSDL2 " which has
leading or trailing whitespace. This is now an error according to policy
CMP0004.
-- Generating done
What is wrong with the cmake
list?
I do not think the slight cmake
version difference leads to such an error.
# CMakeLists.txt
cmake_minimum_required(VERSION 3.5.1)
project (main)
add_executable(main
main.cpp
)
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIRS})
target_link_libraries(main ${SDL2_LIBRARIES})
.
// main.cpp
int main()
{
return 0;
}
Update:
The content of
/usr/lib/x86_64-linux-gnu/cmake/SDL2/sdl2-config.cmake
is
# sdl2 cmake project-config input for ./configure scripts
set(prefix "/usr")
set(exec_prefix "${prefix}")
set(libdir "${prefix}/lib/x86_64-linux-gnu")
set(SDL2_PREFIX "/usr")
set(SDL2_EXEC_PREFIX "/usr")
set(SDL2_LIBDIR "${prefix}/lib/x86_64-linux-gnu")
set(SDL2_INCLUDE_DIRS "${prefix}/include/SDL2")
set(SDL2_LIBRARIES "-L${SDL2_LIBDIR} -lSDL2 ")