diff --git a/CMakeLists.txt b/CMakeLists.txt index 057857b..5d195bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,12 @@ PROJECT(meandmyshadow) CMAKE_MINIMUM_REQUIRED(VERSION 2.6) - +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") Find_Package(SDL REQUIRED) Find_Package(SDL_ttf REQUIRED) Find_Package(SDL_image REQUIRED) Find_Package(SDL_mixer REQUIRED) -Set(SDLGFX_LIBRARY SDL_gfx) -Set(SDLGFX_INCLUDE_DIR ${SDL_INCLUDE_DIR}/SDL_gfx) +Find_Package(SDL_gfx REQUIRED) Find_Package(CURL REQUIRED) Find_Package(LibArchive REQUIRED) @@ -31,6 +30,10 @@ if ( NOT SDLMIXER_FOUND ) message(FATAL_ERROR "SDL_mixer not found !") endif ( NOT SDLMIXER_FOUND ) +if ( NOT SDLGFX_FOUND ) + message(FATAL_ERROR "SDL_gfx not found !") +endif ( NOT SDLGFX_FOUND ) + if ( NOT CURL_FOUND ) message(FATAL_ERROR "CURL not found !") endif ( NOT CURL_FOUND ) diff --git a/cmake/Modules/FindLibArchive.cmake b/cmake/Modules/FindLibArchive.cmake new file mode 100644 index 0000000..cedcd24 --- /dev/null +++ b/cmake/Modules/FindLibArchive.cmake @@ -0,0 +1,66 @@ +# - Find libarchive library and headers +# The module defines the following variables: +# +# LibArchive_FOUND - true if libarchive was found +# LibArchive_INCLUDE_DIRS - include search path +# LibArchive_LIBRARIES - libraries to link +# LibArchive_VERSION - libarchive 3-component version number + +#============================================================================= +# Copyright 2010 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.) + +find_path(LibArchive_INCLUDE_DIR + NAMES archive.h + PATHS + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\LibArchive;InstallPath]/include" + ) + +find_library(LibArchive_LIBRARY + NAMES archive libarchive + PATHS + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\LibArchive;InstallPath]/lib" + ) + +mark_as_advanced(LibArchive_INCLUDE_DIR LibArchive_LIBRARY) + +# Extract the version number from the header. +if(LibArchive_INCLUDE_DIR AND EXISTS "${LibArchive_INCLUDE_DIR}/archive.h") + # The version string appears in one of two known formats in the header: + # #define ARCHIVE_LIBRARY_VERSION "libarchive 2.4.12" + # #define ARCHIVE_VERSION_STRING "libarchive 2.8.4" + # Match either format. + set(_LibArchive_VERSION_REGEX "^#define[ \t]+ARCHIVE[_A-Z]+VERSION[_A-Z]*[ \t]+\"libarchive +([0-9]+)\\.([0-9]+)\\.([0-9]+)[^\"]*\".*$") + file(STRINGS "${LibArchive_INCLUDE_DIR}/archive.h" _LibArchive_VERSION_STRING LIMIT_COUNT 1 REGEX "${_LibArchive_VERSION_REGEX}") + if(_LibArchive_VERSION_STRING) + string(REGEX REPLACE "${_LibArchive_VERSION_REGEX}" "\\1.\\2.\\3" LibArchive_VERSION "${_LibArchive_VERSION_STRING}") + endif() + unset(_LibArchive_VERSION_REGEX) + unset(_LibArchive_VERSION_STRING) +endif() + +# Handle the QUIETLY and REQUIRED arguments and set LIBARCHIVE_FOUND +# to TRUE if all listed variables are TRUE. +# (Use ${CMAKE_ROOT}/Modules instead of ${CMAKE_CURRENT_LIST_DIR} because CMake +# itself includes this FindLibArchive when built with an older CMake that does +# not provide it. The older CMake also does not have CMAKE_CURRENT_LIST_DIR.) +include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) +find_package_handle_standard_args(LibArchive DEFAULT_MSG + LibArchive_LIBRARY LibArchive_INCLUDE_DIR + ) +set(LibArchive_FOUND ${LIBARCHIVE_FOUND}) +unset(LIBARCHIVE_FOUND) + +if(LibArchive_FOUND) + set(LibArchive_INCLUDE_DIRS ${LibArchive_INCLUDE_DIR}) + set(LibArchive_LIBRARIES ${LibArchive_LIBRARY}) +endif() diff --git a/cmake/Modules/FindSDL_gfx.cmake b/cmake/Modules/FindSDL_gfx.cmake new file mode 100644 index 0000000..13e37f5 --- /dev/null +++ b/cmake/Modules/FindSDL_gfx.cmake @@ -0,0 +1,102 @@ +# Locate SDL_mixer library +# This module defines +# SDLGFX_LIBRARY, the name of the library to link against +# SDLGFX_FOUND, if false, do not try to link to SDL +# SDLGFX_INCLUDE_DIR, where to find SDL/SDL.h +# +# $SDLDIR is an environment variable that would +# correspond to the ./configure --prefix=$SDLDIR +# used in building SDL. +# +# Created by Guillaume Chevallereau. This was influenced by the FindSDL.cmake +# module. + +#============================================================================= +# Copyright 2005-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.) + +FIND_PATH(SDLGFX_INCLUDE_DIR SDL_gfx.h + HINTS + $ENV{SDLGFXDIR} + $ENV{SDLDIR} + PATH_SUFFIXES include + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local/include/SDL + /usr/include/SDL + /usr/local/include/SDL12 + /usr/local/include/SDL11 # FreeBSD ports + /usr/include/SDL12 + /usr/include/SDL11 + /usr/local/include + /usr/include + /sw/include/SDL # Fink + /sw/include + /opt/local/include/SDL # DarwinPorts + /opt/local/include + /opt/csw/include/SDL # Blastwave + /opt/csw/include + /opt/include/SDL + /opt/include +) + +FIND_LIBRARY(SDLGFX_LIBRARY + NAMES SDL_gfx + HINTS + $ENV{SDLGFXDIR} + $ENV{SDLDIR} + PATH_SUFFIXES lib64 lib + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw + /opt/local + /opt/csw + /opt +) + +IF(NOT SDLGFX_INCLUDE_DIR) + FIND_PATH(SDLGFX_INCLUDE_DIR SDL_gfxPrimitives.h + HINTS + $ENV{SDLGFXDIR} + $ENV{SDLDIR} + PATH_SUFFIXES include + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local/include/SDL + /usr/include/SDL + /usr/local/include/SDL12 + /usr/local/include/SDL11 # FreeBSD ports + /usr/include/SDL12 + /usr/include/SDL11 + /usr/local/include + /usr/include + /sw/include/SDL # Fink + /sw/include + /opt/local/include/SDL # DarwinPorts + /opt/local/include + /opt/csw/include/SDL # Blastwave + /opt/csw/include + /opt/include/SDL + /opt/include +) +endif(NOT SDLGFX_INCLUDE_DIR) + +SET(SDLGFX_FOUND "NO") + +IF(SDLGFX_LIBRARY AND SDLGFX_INCLUDE_DIR) + SET(SDLGFX_FOUND "YES") +ENDIF(SDLGFX_LIBRARY AND SDLGFX_INCLUDE_DIR) \ No newline at end of file