Last active
September 27, 2019 01:52
-
-
Save yatima1460/7ec6ec563c5871335064b63e2c1a5127 to your computer and use it in GitHub Desktop.
Load SDL2 on Arch with CMake
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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