Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config mode compatibility + fix cmake warning #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions FindSDL2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ This module defines the following 'IMPORTED' targets:

::

SDL2::Core
SDL2::Core (for compatibility with older versions)
SDL2::SDL2 (compatibility with CONFIG mode)
The SDL2 library, if found.
Libraries should link to SDL2::Core
Libraries should link to SDL2::SDL2

SDL2::Main
SDL2::Main (for compatibility with older versions)
SDL2::SDL2main (compatibility with CONFIG mode)
The SDL2main library, if found.
Applications should link to SDL2::Main instead of SDL2::Core
Applications should link to SDL2::SDL2main instead of SDL2::SDL2



Expand Down Expand Up @@ -310,16 +312,14 @@ endif()

include(FindPackageHandleStandardArgs)

FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2
REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR
VERSION_VAR SDL2_VERSION_STRING)

set(SDL2_REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR)
if(SDL2MAIN_LIBRARY)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2main
REQUIRED_VARS SDL2MAIN_LIBRARY SDL2_INCLUDE_DIR
VERSION_VAR SDL2_VERSION_STRING)
list(APPEND SDL2_REQUIRED_VARS SDL2MAIN_LIBRARY SDL2_INCLUDE_DIR)
endif()

find_package_handle_standard_args(SDL2
REQUIRED_VARS ${SDL2_REQUIRED_VARS}
VERSION_VAR SDL2_VERSION_STRING)

mark_as_advanced(SDL2_PATH
SDL2_NO_DEFAULT_PATH
Expand Down Expand Up @@ -384,5 +384,9 @@ if(SDL2_FOUND)
INTERFACE_LINK_LIBRARIES SDL2::MainInternal)
endif()

# compatibility targets
add_library(SDL2::SDL2 ALIAS SDL2::Core)
add_library(SDL2::SDL2main ALIAS SDL2::Main)

endif()
endif()