Mercurial > molko
annotate cmake/FindSDL2.cmake @ 316:1a6125ffebff
misc: fix many warnings and build on macOS
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 22 Sep 2021 12:57:55 +0200 |
parents | 3bfaaf5342a9 |
children |
rev | line source |
---|---|
116
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
1 # FindSDL2 |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
2 # -------- |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
3 # |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
4 # Find SDL2 library and components, this modules defines: |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
5 # |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
6 # SDL2_LIBRARY, the name of the library to link against. |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
7 # SDL2_MAIN_LIBRARY, for SDL2main (if present). |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
8 # SDL2_LIBRARIES, alias to SDL2_LIBRARY. |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
9 # SDL2_FOUND, true if found. |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
10 # SDL2_INCLUDE_DIR, where to find SDL.h. |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
11 # |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
12 # The following imported targets will be defined: |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
13 # |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
14 # SDL2::SDL2 |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
15 # SDL2::SDL2main (if present) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
16 # |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
17 # This module also handle the following official SDL addons: |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
18 # |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
19 # - image |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
20 # - mixer |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
21 # - net |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
22 # - ttf |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
23 # |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
24 # And thus, variables SDL2_<C>_LIBRARY, SDL2_<C>_INCLUDE_DIRS and SDL2::<C> |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
25 # imported targets will be defined if they are found. |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
26 # |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
27 |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
28 include(FindPackageHandleStandardArgs) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
29 |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
30 # The official include convention is <SDL.h> not <SDL/SDL.h>. |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
31 find_path( |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
32 SDL2_INCLUDE_DIR |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
33 NAMES SDL.h |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
34 PATH_SUFFIXES include/SDL2 include |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
35 ) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
36 |
315
3bfaaf5342a9
cmake: add support for Visual Studio 2019
David Demelier <markand@malikania.fr>
parents:
116
diff
changeset
|
37 find_library(SDL2_LIBRARY NAMES SDL2 libSDL2 SDL2d libSDL2d) |
3bfaaf5342a9
cmake: add support for Visual Studio 2019
David Demelier <markand@malikania.fr>
parents:
116
diff
changeset
|
38 find_library(SDL2_MAIN_LIBRARY NAMES SDL2main libSDL2main SDL2maind libSDL2maind) |
116
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
39 |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
40 # Standard components. |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
41 foreach (c ${SDL2_FIND_COMPONENTS}) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
42 find_path( |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
43 SDL2_${c}_INCLUDE_DIR |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
44 NAMES SDL.h |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
45 PATH_SUFFIXES include/SDL2 include |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
46 ) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
47 |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
48 find_library( |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
49 SDL2_${c}_LIBRARY |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
50 NAMES SDL2_${c} libSDL2_${c} |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
51 ) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
52 |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
53 if (NOT TARGET SDL2::${c} AND SDL2_${c}_LIBRARY) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
54 set(SDL2_${c}_FOUND TRUE) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
55 add_library(SDL2::${c} UNKNOWN IMPORTED) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
56 set_target_properties( |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
57 SDL2::${c} |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
58 PROPERTIES |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
59 IMPORTED_LINK_INTERFACE_LANGUAGES "C" |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
60 IMPORTED_LOCATION "${SDL2_${c}_LIBRARY}" |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
61 INTERFACE_INCLUDE_DIRECTORIES "${SDL2_${c}_INCLUDE_DIRS}" |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
62 ) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
63 endif () |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
64 |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
65 mark_as_advanced(SDL2_${c}_INCLUDE_DIR SDL2_${c}_LIBRARY) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
66 endforeach () |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
67 |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
68 find_package_handle_standard_args( |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
69 SDL2 |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
70 REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
71 HANDLE_COMPONENTS |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
72 ) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
73 |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
74 if (SDL2_FOUND) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
75 set(SDL2_LIBRARIES ${SDL2_LIBRARY}) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
76 set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIR}) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
77 |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
78 if (NOT TARGET SDL2::SDL2) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
79 add_library(SDL2::SDL2 UNKNOWN IMPORTED) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
80 set_target_properties( |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
81 SDL2::SDL2 |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
82 PROPERTIES |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
83 IMPORTED_LINK_INTERFACE_LANGUAGES "C" |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
84 IMPORTED_LOCATION "${SDL2_LIBRARY}" |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
85 INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}" |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
86 ) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
87 endif () |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
88 |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
89 if (NOT TARGET SDL2::main AND SDL2_MAIN_LIBRARY) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
90 add_library(SDL2::main UNKNOWN IMPORTED) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
91 set_target_properties( |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
92 SDL2::main |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
93 PROPERTIES |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
94 IMPORTED_LINK_INTERFACE_LANGUAGES "C" |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
95 IMPORTED_LOCATION "${SDL2_MAIN_LIBRARY}" |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
96 INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}" |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
97 ) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
98 endif () |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
99 endif () |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
100 |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
101 mark_as_advanced(SDL2_INCLUDE_DIR SDL2_LIBRARY) |