Skip to content

Instantly share code, notes, and snippets.

@yatima1460
Last active September 27, 2019 01:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yatima1460/7ec6ec563c5871335064b63e2c1a5127 to your computer and use it in GitHub Desktop.
Save yatima1460/7ec6ec563c5871335064b63e2c1a5127 to your computer and use it in GitHub Desktop.
Load SDL2 on Arch with CMake
# Load SDL2
find_program(LSB_RELEASE_EXEC lsb_release)
execute_process(COMMAND ${LSB_RELEASE_EXEC} -is OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT OUTPUT_STRIP_TRAILING_WHITESPACE)
message("Your distro is ${LSB_RELEASE_ID_SHORT}")
find_package(SDL2 REQUIRED)
if ("${LSB_RELEASE_ID_SHORT}" STREQUAL "Arch")
message("Arch distro detected, using Arch CMake linkage")
target_link_libraries(ProjectName SDL2::SDL2)
else ()
message("Non-Arch distro detected, using normal linkage")
string(STRIP ${SDL2_LIBRARIES} SDL2_LIBRARIES) # Fix because CMake is stupid, remove trailing spaces
include_directories(ProjectName ${SDL2_INCLUDE_DIRS})
target_link_libraries(ProjectName ${SDL2_LIBRARIES})
endif ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment