1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
|
Origin: https://github.com/JACoders/OpenJK/commit/52030235f052772008d99e6ccb16de48e7ddb688
Remove FindSDL2 find-module, use sdl2-config.cmake instead
This requires SDL >= 2.0.4.
Since <https://bugzilla.libsdl.org/show_bug.cgi?id=2464> was fixed in
SDL 2.0.4, SDL behaves as a CMake "config-file package", even if it was
not itself built using CMake: it installs a sdl2-config.cmake file to
${libdir}/cmake/SDL2, which tells CMake where to find SDL's headers and
library, analogous to a pkg-config .pc file.
As a result, we no longer need to copy/paste a "find-module package"
to be able to find a system copy of SDL >= 2.0.4 with find_package(SDL2).
Find-module packages are now discouraged by the CMake developers, in
favour of having upstream projects behave as config-file packages.
This results in a small API change: FindSDL2 used to set SDL2_INCLUDE_DIR
and SDL2_LIBRARY, but the standard behaviour for config-file packages is
to set <name>_INCLUDE_DIRS and <name>_LIBRARIES. Use the CONFIG keyword
to make sure we search in config-file package mode, and will not find a
FindSDL2.cmake in some other directory that implements the old interface.
In addition to deleting redundant code, this avoids some assumptions in
FindSDL2 about the layout of a SDL installation. The current libsdl2-dev
package in Debian breaks those assumptions; this is considered a bug
and will hopefully be fixed soon, but it illustrates how fragile these
assumptions can be. We can be more robust against different installation
layouts by relying on SDL's own CMake integration.
When linking to a copy of CMake in a non-standard location, users can
now set the SDL2_DIR or CMAKE_PREFIX_PATH environment variable to point
to it; previously, these users would have used the SDL2DIR environment
variable. This continues to be unnecessary if using matching system-wide
installations of CMake and SDL2, for example both from Debian.
Mitigates: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=951087
Signed-off-by: Simon McVittie <smcv@debian.org>
--- hedgewars-1.0.0.orig/QTfrontend/CMakeLists.txt
+++ hedgewars-1.0.0/QTfrontend/CMakeLists.txt
@@ -13,9 +13,9 @@ include_directories(${Qt5Core_PRIVATE_INCLUDE_DIRS})
include(CheckLibraryExists)
-find_package(SDL2 REQUIRED)
+find_package(SDL2 REQUIRED CONFIG)
find_package(SDL2_mixer 2 REQUIRED) #audio in SDLInteraction
-include_directories(${SDL2_INCLUDE_DIR})
+include_directories(${SDL2_INCLUDE_DIRS})
include_directories(${SDL2_MIXER_INCLUDE_DIRS})
if(LIBAV_FOUND)
@@ -230,12 +230,12 @@ list(APPEND HW_LINK_LIBS
)
list(APPEND HW_LINK_LIBS
- ${SDL2_LIBRARY}
+ ${SDL2_LIBRARIES}
${SDL2_MIXER_LIBRARIES}
)
if(WIN32 AND NOT UNIX)
- if(NOT SDL2_LIBRARY)
+ if(NOT SDL2_LIBRARIES)
list(APPEND HW_LINK_LIBS SDL2)
endif()
--- hedgewars-1.0.0.orig/hedgewars/CMakeLists.txt
+++ hedgewars-1.0.0/hedgewars/CMakeLists.txt
@@ -1,6 +1,6 @@
enable_language(Pascal)
-find_package(SDL2 REQUIRED)
+find_package(SDL2 REQUIRED CONFIG)
find_package(SDL2_image 2 REQUIRED)
find_package(SDL2_net 2 REQUIRED)
find_package(SDL2_ttf 2 REQUIRED)
@@ -130,7 +130,7 @@ if(APPLE AND (NOT BUILD_ENGINE_LIBRARY))
add_flag_append(CMAKE_Pascal_FLAGS "-k-framework -kOpenGL")
#set the correct library or framework style depending on the main SDL
- string(FIND "${SDL2_LIBRARY}" "dylib" sdl_framework)
+ string(FIND "${SDL2_LIBRARIES}" "dylib" sdl_framework)
if(${sdl_framework} GREATER -1)
add_flag_append(CMAKE_Pascal_FLAGS "-k-lsdl2 -k-lsdl2_image -k-lsdl2_mixer -k-lsdl2_ttf -k-lsdl2_net")
else()
--- hedgewars-1.0.0.orig/misc/libphyslayer/CMakeLists.txt
+++ hedgewars-1.0.0/misc/libphyslayer/CMakeLists.txt
@@ -1,6 +1,6 @@
-find_package(SDL2 REQUIRED)
+find_package(SDL2 REQUIRED CONFIG)
-include_directories(${SDL2_INCLUDE_DIR})
+include_directories(${SDL2_INCLUDE_DIRS})
include_directories(${PHYSFS_INCLUDE_DIR})
include_directories(${LUA_INCLUDE_DIR})
@@ -17,7 +17,7 @@ add_library (physlayer ${PHYSLAYER_SRCS}
set_target_properties(physlayer PROPERTIES
VERSION 1.0
SOVERSION 1.0)
-target_link_libraries(physlayer ${SDL2_LIBRARY} lua physfs)
+target_link_libraries(physlayer ${SDL2_LIBRARIES} lua physfs)
install(TARGETS physlayer RUNTIME DESTINATION ${target_binary_install_dir}
LIBRARY DESTINATION ${target_library_install_dir}
ARCHIVE DESTINATION ${target_library_install_dir})
--- hedgewars-1.0.0.orig/project_files/hwc/CMakeLists.txt
+++ hedgewars-1.0.0/project_files/hwc/CMakeLists.txt
@@ -1,6 +1,6 @@
#the usual set of dependencies
find_package(OpenGL REQUIRED)
-find_package(SDL2 REQUIRED)
+find_package(SDL2 REQUIRED CONFIG)
find_package(SDL2_mixer 2 REQUIRED)
find_package(SDL2_net 2 REQUIRED)
find_package(SDL2_image 2 REQUIRED)
@@ -111,7 +111,7 @@ endif()
target_link_libraries(hwengine fpcrtl
${LUA_LIBRARY}
${OPENGL_LIBRARY}
- ${SDL2_LIBRARY}
+ ${SDL2_LIBRARIES}
${SDL2_MIXER_LIBRARIES}
${SDL2_NET_LIBRARIES}
${SDL2_IMAGE_LIBRARIES}
--- hedgewars-1.0.0.orig/tools/CMakeLists.txt
+++ hedgewars-1.0.0/tools/CMakeLists.txt
@@ -8,7 +8,7 @@ endif()
if(APPLE AND NOT SKIPBUNDLE)
find_package(Qt5 REQUIRED QUIET COMPONENTS Core Widgets Gui Network)
- find_package(SDL2 REQUIRED)
+ find_package(SDL2 REQUIRED CONFIG)
find_package(SDL2_image 2 REQUIRED)
find_package(SDL2_net 2 REQUIRED)
find_package(SDL2_ttf 2 REQUIRED)
@@ -26,9 +26,9 @@ if(APPLE AND NOT SKIPBUNDLE)
endif()
endif()
- #remove the ";-framework Cocoa" from the SDL2_LIBRARY variable
- string(REGEX REPLACE "(.*);-.*" "\\1" sdl_library_only "${SDL2_LIBRARY}")
- #remove the "libSDLmain.a" from the SDL2_LIBRARY variable
+ #remove the ";-framework Cocoa" from the SDL2_LIBRARIES variable
+ string(REGEX REPLACE "(.*);-.*" "\\1" sdl_library_only "${SDL2_LIBRARIES}")
+ #remove the "libSDLmain.a" from the SDL2_LIBRARIES variable
string(REGEX REPLACE ".*;(.*)" "\\1" sdl_library_only "${sdl_library_only}")
#get the neme of the library (harmelss if it is static)
diff --git a/cmake_modules/FindSDL2.cmake b/cmake_modules/FindSDL2.cmake
deleted file mode 100644
index a572ff15..00000000
--- a/cmake_modules/FindSDL2.cmake
+++ /dev/null
@@ -1,169 +0,0 @@
-# Locate SDL2 library
-# This module defines
-# SDL2_LIBRARY, the name of the library to link against
-# SDL2_FOUND, if false, do not try to link to SDL2
-# SDL2_INCLUDE_DIR, where to find SDL.h
-#
-# This module responds to the the flag:
-# SDL2_BUILDING_LIBRARY
-# If this is defined, then no SDL2main will be linked in because
-# only applications need main().
-# Otherwise, it is assumed you are building an application and this
-# module will attempt to locate and set the the proper link flags
-# as part of the returned SDL2_LIBRARY variable.
-#
-# Don't forget to include SDLmain.h and SDLmain.m your project for the
-# OS X framework based version. (Other versions link to -lSDL2main which
-# this module will try to find on your behalf.) Also for OS X, this
-# module will automatically add the -framework Cocoa on your behalf.
-#
-#
-# Additional Note: If you see an empty SDL2_LIBRARY_TEMP in your configuration
-# and no SDL2_LIBRARY, it means CMake did not find your SDL2 library
-# (SDL2.dll, libsdl2.so, SDL2.framework, etc).
-# Set SDL2_LIBRARY_TEMP to point to your SDL2 library, and configure again.
-# Similarly, if you see an empty SDL2MAIN_LIBRARY, you should set this value
-# as appropriate. These values are used to generate the final SDL2_LIBRARY
-# variable, but when these values are unset, SDL2_LIBRARY does not get created.
-#
-#
-# $SDL2DIR is an environment variable that would
-# correspond to the ./configure --prefix=$SDL2DIR
-# used in building SDL2.
-# l.e.galup 9-20-02
-#
-# Modified by Eric Wing.
-# Added code to assist with automated building by using environmental variables
-# and providing a more controlled/consistent search behavior.
-# Added new modifications to recognize OS X frameworks and
-# additional Unix paths (FreeBSD, etc).
-# Also corrected the header search path to follow "proper" SDL guidelines.
-# Added a search for SDL2main which is needed by some platforms.
-# Added a search for threads which is needed by some platforms.
-# Added needed compile switches for MinGW.
-#
-# On OSX, this will prefer the Framework version (if found) over others.
-# People will have to manually change the cache values of
-# SDL2_LIBRARY to override this selection or set the CMake environment
-# CMAKE_INCLUDE_PATH to modify the search paths.
-#
-# Note that the header path has changed from SDL2/SDL.h to just SDL.h
-# This needed to change because "proper" SDL convention
-# is #include "SDL.h", not <SDL2/SDL.h>. This is done for portability
-# reasons because not all systems place things in SDL2/ (see FreeBSD).
-
-#=============================================================================
-# Copyright 2003-2009 Kitware, Inc.
-#
-# Distributed under the OSI-approved BSD License (the "License");
-# see accompanying file Copyright.txt for details.
-#
-# This software is distributed WITHOUT ANY WARRANTY; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the License for more information.
-#=============================================================================
-# (To distribute this file outside of CMake, substitute the full
-# License text for the above reference.)
-
-SET(SDL2_SEARCH_PATHS
- ~/Library/Frameworks
- /Library/Frameworks
- /usr/local
- /usr
- /sw # Fink
- /opt/local # DarwinPorts
- /opt/csw # Blastwave
- /opt
-)
-
-FIND_PATH(SDL2_INCLUDE_DIR SDL.h
- HINTS
- $ENV{SDL2DIR}
- PATH_SUFFIXES include/SDL2 include
- PATHS ${SDL2_SEARCH_PATHS}
-)
-
-FIND_LIBRARY(SDL2_LIBRARY_TEMP
- NAMES SDL2
- HINTS
- $ENV{SDL2DIR}
- PATH_SUFFIXES lib64 lib
- PATHS ${SDL2_SEARCH_PATHS}
-)
-
-IF(NOT SDL2_BUILDING_LIBRARY)
- IF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
- # Non-OS X framework versions expect you to also dynamically link to
- # SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms
- # seem to provide SDL2main for compatibility even though they don't
- # necessarily need it.
- FIND_LIBRARY(SDL2MAIN_LIBRARY
- NAMES SDL2main
- HINTS
- $ENV{SDL2DIR}
- PATH_SUFFIXES lib64 lib
- PATHS ${SDL2_SEARCH_PATHS}
- )
- ENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
-ENDIF(NOT SDL2_BUILDING_LIBRARY)
-
-# SDL2 may require threads on your system.
-# The Apple build may not need an explicit flag because one of the
-# frameworks may already provide it.
-# But for non-OSX systems, I will use the CMake Threads package.
-IF(NOT APPLE)
- FIND_PACKAGE(Threads)
-ENDIF(NOT APPLE)
-
-# MinGW needs an additional library, mwindows
-# It's total link flags should look like -lmingw32 -lSDL2main -lSDL2 -lmwindows
-# (Actually on second look, I think it only needs one of the m* libraries.)
-IF(MINGW)
- SET(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW")
-ENDIF(MINGW)
-
-IF(SDL2_LIBRARY_TEMP)
- # For SDL2main
- IF(NOT SDL2_BUILDING_LIBRARY)
- IF(SDL2MAIN_LIBRARY)
- SET(SDL2_LIBRARY_TEMP ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY_TEMP})
- ENDIF(SDL2MAIN_LIBRARY)
- ENDIF(NOT SDL2_BUILDING_LIBRARY)
-
- # For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa.
- # CMake doesn't display the -framework Cocoa string in the UI even
- # though it actually is there if I modify a pre-used variable.
- # I think it has something to do with the CACHE STRING.
- # So I use a temporary variable until the end so I can set the
- # "real" variable in one-shot.
- IF(APPLE)
- SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa")
- ENDIF(APPLE)
-
- # For threads, as mentioned Apple doesn't need this.
- # In fact, there seems to be a problem if I used the Threads package
- # and try using this line, so I'm just skipping it entirely for OS X.
- IF(NOT APPLE)
- SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
- ENDIF(NOT APPLE)
-
- # For MinGW library
- IF(MINGW)
- SET(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP})
- ENDIF(MINGW)
-
- # Set the final string here so the GUI reflects the final state.
- SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found")
- # Set the temp variable to INTERNAL so it is not seen in the CMake GUI
- SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "")
-ENDIF(SDL2_LIBRARY_TEMP)
-
-if(BUILD_ENGINE_JS)
- set(SDL2_LIBRARY "sdl2_emscripten_internal" CACHE STRING "emscripten override" FORCE)
- set(SDL2_INCLUDE_DIR "${CMAKE_SYSTEM_INCLUDE_PATH}/SDL" CACHE STRING "emscripten override" FORCE)
-endif()
-
-INCLUDE(FindPackageHandleStandardArgs)
-
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR)
-
|