diff --git a/CMakeLists.txt b/CMakeLists.txt index 244bb160f..3ff126686 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,16 +50,17 @@ endif() set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/build/cmake") find_package(PkgConfig) -pkg_search_module(SDL2 REQUIRED sdl2) -pkg_search_module(SDL2_IMAGE REQUIRED SDL2_image) -pkg_search_module(SDL2_MIXER REQUIRED SDL2_mixer) -if(NOT ${SDL2_FOUND}) +pkg_search_module(SDL2 sdl2) +pkg_search_module(SDL2_IMAGE SDL2_image) +pkg_search_module(SDL2_MIXER SDL2_mixer) +if(NOT "${SDL2_FOUND}") + message("looking for SDL2") find_package(SDL2 REQUIRED) endif() -if(NOT ${SDL2_IMAGE_FOUND}) +if(NOT "${SDL2_IMAGE_FOUND}") find_package(SDL2_image REQUIRED) endif() -if(NOT ${SDL2_MIXER_FOUND}) +if(NOT "${SDL2_MIXER_FOUND}") find_package(SDL2_mixer REQUIRED) endif() link_directories(${SDL2_LIBRARY_DIRS} ${SDL2_IMAGE_LIBRARY_DIRS} ${SDL2_MIXER_LIBRARY_DIRS}) diff --git a/build/cmake/FindSDL2.cmake b/build/cmake/FindSDL2.cmake index 252e4806f..334cd6e5d 100644 --- a/build/cmake/FindSDL2.cmake +++ b/build/cmake/FindSDL2.cmake @@ -2,7 +2,7 @@ # This module defines # SDL2_LIBRARY, the name of the library to link against # SDL2_FOUND, if false, do not try to link to SDL -# SDL2_INCLUDE_DIR, where to find SDL.h +# SDL2_INCLUDE_DIRS, where to find SDL.h # SDL2_VERSION_STRING, human-readable string containing the version of SDL2 # # This module responds to the the flag: @@ -38,7 +38,7 @@ # See the License for more information. #============================================================================= -find_path(SDL2_INCLUDE_DIR SDL.h +find_path(SDL2_INCLUDE_DIRS SDL.h HINTS ENV SDLDIR PATH_SUFFIXES include/SDL2 include @@ -52,7 +52,7 @@ find_library(SDL2_LIBRARY_TEMP ) if(NOT SDL2_BUILDING_LIBRARY) - if(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework") + if(NOT ${SDL2_INCLUDE_DIRS} MATCHES ".framework") # Non-OS X framework versions expect you to also dynamically link to # SDLmain. This is mainly for Windows and OS X. Other (Unix) platforms # seem to provide SDLmain for compatibility even though they don't @@ -124,10 +124,10 @@ if(SDL2_LIBRARY_TEMP) set(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "") endif() -if(SDL2_INCLUDE_DIR AND EXISTS "${SDL2_INCLUDE_DIR}/SDL_version.h") - file(STRINGS "${SDL2_INCLUDE_DIR}/SDL_version.h" SDL2_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+[0-9]+$") - file(STRINGS "${SDL2_INCLUDE_DIR}/SDL_version.h" SDL2_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_MINOR_VERSION[ \t]+[0-9]+$") - file(STRINGS "${SDL2_INCLUDE_DIR}/SDL_version.h" SDL2_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_PATCHLEVEL[ \t]+[0-9]+$") +if(SDL2_INCLUDE_DIRS AND EXISTS "${SDL2_INCLUDE_DIRS}/SDL_version.h") + file(STRINGS "${SDL2_INCLUDE_DIRS}/SDL_version.h" SDL2_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+[0-9]+$") + file(STRINGS "${SDL2_INCLUDE_DIRS}/SDL_version.h" SDL2_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_MINOR_VERSION[ \t]+[0-9]+$") + file(STRINGS "${SDL2_INCLUDE_DIRS}/SDL_version.h" SDL2_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_PATCHLEVEL[ \t]+[0-9]+$") string(REGEX REPLACE "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_MAJOR "${SDL2_VERSION_MAJOR_LINE}") string(REGEX REPLACE "^#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_MINOR "${SDL2_VERSION_MINOR_LINE}") string(REGEX REPLACE "^#define[ \t]+SDL_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_PATCH "${SDL2_VERSION_PATCH_LINE}") @@ -143,5 +143,5 @@ endif() include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 - REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR + REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIRS VERSION_VAR SDL2_VERSION_STRING) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 17994167d..dac6ed195 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -include_directories(. ${SDL2_INCLUDE_DIR} ${SDL2_INCLUDE_DIRS}) +include_directories(. ${SDL2_INCLUDE_DIRS}) add_subdirectory(cdogs) add_subdirectory(cdogsed) diff --git a/src/cdogs/CMakeLists.txt b/src/cdogs/CMakeLists.txt index 02322acb4..6b25e67c6 100644 --- a/src/cdogs/CMakeLists.txt +++ b/src/cdogs/CMakeLists.txt @@ -1,4 +1,4 @@ -include_directories(${SDL2_INCLUDE_DIR} ${SDL2_INCLUDE_DIRS}) +include_directories(${SDL2_INCLUDE_DIRS}) add_definitions(-DSTATIC) set(CDOGS_SOURCES actor_placement.c