diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-02-19 14:32:48 -0500 |
|---|---|---|
| committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-02-19 14:32:48 -0500 |
| commit | 8f6b50132da371cbf66fd28b0bc1eefc2cb82135 (patch) | |
| tree | 3b90f3c82db698b6503659a2744e642c43eca0fe | |
| parent | 2aed9c0fbf000c1a57296ed3c957ac8387f7f2e8 (diff) | |
| download | mazeoflife-8f6b50132da371cbf66fd28b0bc1eefc2cb82135.tar.gz mazeoflife-8f6b50132da371cbf66fd28b0bc1eefc2cb82135.tar.bz2 mazeoflife-8f6b50132da371cbf66fd28b0bc1eefc2cb82135.zip | |
Switched to CMake build system
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | CMakeLists.txt | 17 | ||||
| -rw-r--r-- | Makefile.am | 8 | ||||
| -rw-r--r-- | acinclude.m4 | 202 | ||||
| -rw-r--r-- | cmake/FindSDL2.cmake | 163 | ||||
| -rw-r--r-- | cmake/FindSDL2_net.cmake | 73 | ||||
| -rw-r--r-- | cmake/FindSDL2_ttf.cmake | 156 | ||||
| -rw-r--r-- | configure.ac | 44 |
8 files changed, 410 insertions, 254 deletions
| diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..378eac2 --- /dev/null +++ b/.gitignore | |||
| @@ -0,0 +1 @@ | |||
| build | |||
| diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..ca45e19 --- /dev/null +++ b/CMakeLists.txt | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | cmake_minimum_required (VERSION 2.6) | ||
| 2 | project (mazeoflife) | ||
| 3 | |||
| 4 | set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) | ||
| 5 | |||
| 6 | find_package(SDL2 REQUIRED) | ||
| 7 | find_package(SDL2_ttf REQUIRED) | ||
| 8 | find_package(SDL2_net REQUIRED) | ||
| 9 | |||
| 10 | include_directories( | ||
| 11 | ${SDL2_INCLUDE_DIR} | ||
| 12 | ${SDL2_TTF_INCLUDE_DIR} | ||
| 13 | ${SDL2_NET_INCLUDE_DIRS} | ||
| 14 | ) | ||
| 15 | |||
| 16 | add_executable(mazeoflife highscore.cpp hslist.cpp mazeoflife.cpp util.cpp titlestate.cpp gamestate.cpp) | ||
| 17 | target_link_libraries(mazeoflife ${SDL2_LIBRARY} ${SDL2_TTF_LIBRARY} ${SDL2_NET_LIBRARIES}) | ||
| diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index f8b1425..0000000 --- a/Makefile.am +++ /dev/null | |||
| @@ -1,8 +0,0 @@ | |||
| 1 | AUTOMAKE_OPTIONS = subdir-objects | ||
| 2 | ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS} | ||
| 3 | |||
| 4 | bin_PROGRAMS = mazeoflife | ||
| 5 | mazeoflife_SOURCES = highscore.cpp highscore.h hslist.cpp hslist.h mazeoflife.cpp mazeoflife.h util.cpp util.h titlestate.cpp titlestate.h gamestate.cpp gamestate.h state.h | ||
| 6 | AM_CXXFLAGS = $(SDLTTF_CXXFLAGS) $(SDLNET_CXXFLAGS) | ||
| 7 | mazeoflife_LDADD = $(SDLTTF_LIBS) $(SDLNET_LIBS) | ||
| 8 | EXTRA_DIST = resources/chl.bmp resources/hlo_paartm.bmp resources/hlo_passartm.bmp resources/hlo_rtm.bmp resources/htp1.bmp resources/htp2.bmp resources/icon.bmp resources/mono.ttf resources/pointer.bmp resources/title.bmp | ||
| diff --git a/acinclude.m4 b/acinclude.m4 deleted file mode 100644 index a03b2d2..0000000 --- a/acinclude.m4 +++ /dev/null | |||
| @@ -1,202 +0,0 @@ | |||
| 1 | # Configure paths for SDL | ||
| 2 | # Sam Lantinga 9/21/99 | ||
| 3 | # stolen from Manish Singh | ||
| 4 | # stolen back from Frank Belew | ||
| 5 | # stolen from Manish Singh | ||
| 6 | # Shamelessly stolen from Owen Taylor | ||
| 7 | |||
| 8 | # serial 1 | ||
| 9 | |||
| 10 | dnl AM_PATH_SDL2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) | ||
| 11 | dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS | ||
| 12 | dnl | ||
| 13 | AC_DEFUN([AM_PATH_SDL2], | ||
| 14 | [dnl | ||
| 15 | dnl Get the cflags and libraries from the sdl2-config script | ||
| 16 | dnl | ||
| 17 | AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)], | ||
| 18 | sdl_prefix="$withval", sdl_prefix="") | ||
| 19 | AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)], | ||
| 20 | sdl_exec_prefix="$withval", sdl_exec_prefix="") | ||
| 21 | AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program], | ||
| 22 | , enable_sdltest=yes) | ||
| 23 | |||
| 24 | min_sdl_version=ifelse([$1], ,2.0.0,$1) | ||
| 25 | |||
| 26 | if test "x$sdl_prefix$sdl_exec_prefix" = x ; then | ||
| 27 | PKG_CHECK_MODULES([SDL], [sdl2 >= $min_sdl_version], | ||
| 28 | [sdl_pc=yes], | ||
| 29 | [sdl_pc=no]) | ||
| 30 | else | ||
| 31 | sdl_pc=no | ||
| 32 | if test x$sdl_exec_prefix != x ; then | ||
| 33 | sdl_config_args="$sdl_config_args --exec-prefix=$sdl_exec_prefix" | ||
| 34 | if test x${SDL2_CONFIG+set} != xset ; then | ||
| 35 | SDL2_CONFIG=$sdl_exec_prefix/bin/sdl2-config | ||
| 36 | fi | ||
| 37 | fi | ||
| 38 | if test x$sdl_prefix != x ; then | ||
| 39 | sdl_config_args="$sdl_config_args --prefix=$sdl_prefix" | ||
| 40 | if test x${SDL2_CONFIG+set} != xset ; then | ||
| 41 | SDL2_CONFIG=$sdl_prefix/bin/sdl2-config | ||
| 42 | fi | ||
| 43 | fi | ||
| 44 | fi | ||
| 45 | |||
| 46 | if test "x$sdl_pc" = xyes ; then | ||
| 47 | no_sdl="" | ||
| 48 | SDL2_CONFIG="pkg-config sdl2" | ||
| 49 | else | ||
| 50 | as_save_PATH="$PATH" | ||
| 51 | if test "x$prefix" != xNONE && test "$cross_compiling" != yes; then | ||
| 52 | PATH="$prefix/bin:$prefix/usr/bin:$PATH" | ||
| 53 | fi | ||
| 54 | AC_PATH_PROG(SDL2_CONFIG, sdl2-config, no, [$PATH]) | ||
| 55 | PATH="$as_save_PATH" | ||
| 56 | AC_MSG_CHECKING(for SDL - version >= $min_sdl_version) | ||
| 57 | no_sdl="" | ||
| 58 | |||
| 59 | if test "$SDL2_CONFIG" = "no" ; then | ||
| 60 | no_sdl=yes | ||
| 61 | else | ||
| 62 | SDL_CFLAGS=`$SDL2_CONFIG $sdl_config_args --cflags` | ||
| 63 | SDL_LIBS=`$SDL2_CONFIG $sdl_config_args --libs` | ||
| 64 | |||
| 65 | sdl_major_version=`$SDL2_CONFIG $sdl_config_args --version | \ | ||
| 66 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` | ||
| 67 | sdl_minor_version=`$SDL2_CONFIG $sdl_config_args --version | \ | ||
| 68 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` | ||
| 69 | sdl_micro_version=`$SDL2_CONFIG $sdl_config_args --version | \ | ||
| 70 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` | ||
| 71 | if test "x$enable_sdltest" = "xyes" ; then | ||
| 72 | ac_save_CFLAGS="$CFLAGS" | ||
| 73 | ac_save_CXXFLAGS="$CXXFLAGS" | ||
| 74 | ac_save_LIBS="$LIBS" | ||
| 75 | CFLAGS="$CFLAGS $SDL_CFLAGS" | ||
| 76 | CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" | ||
| 77 | LIBS="$LIBS $SDL_LIBS" | ||
| 78 | dnl | ||
| 79 | dnl Now check if the installed SDL is sufficiently new. (Also sanity | ||
| 80 | dnl checks the results of sdl2-config to some extent | ||
| 81 | dnl | ||
| 82 | rm -f conf.sdltest | ||
| 83 | AC_TRY_RUN([ | ||
| 84 | #include <stdio.h> | ||
| 85 | #include <stdlib.h> | ||
| 86 | #include <string.h> | ||
| 87 | #include "SDL.h" | ||
| 88 | |||
| 89 | char* | ||
| 90 | my_strdup (char *str) | ||
| 91 | { | ||
| 92 | char *new_str; | ||
| 93 | |||
| 94 | if (str) | ||
| 95 | { | ||
| 96 | new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); | ||
| 97 | strcpy (new_str, str); | ||
| 98 | } | ||
| 99 | else | ||
| 100 | new_str = NULL; | ||
| 101 | |||
| 102 | return new_str; | ||
| 103 | } | ||
| 104 | |||
| 105 | int main (int argc, char *argv[]) | ||
| 106 | { | ||
| 107 | int major, minor, micro; | ||
| 108 | char *tmp_version; | ||
| 109 | |||
| 110 | /* This hangs on some systems (?) | ||
| 111 | system ("touch conf.sdltest"); | ||
| 112 | */ | ||
| 113 | { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); } | ||
| 114 | |||
| 115 | /* HP/UX 9 (%@#!) writes to sscanf strings */ | ||
| 116 | tmp_version = my_strdup("$min_sdl_version"); | ||
| 117 | if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { | ||
| 118 | printf("%s, bad version string\n", "$min_sdl_version"); | ||
| 119 | exit(1); | ||
| 120 | } | ||
| 121 | |||
| 122 | if (($sdl_major_version > major) || | ||
| 123 | (($sdl_major_version == major) && ($sdl_minor_version > minor)) || | ||
| 124 | (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro))) | ||
| 125 | { | ||
| 126 | return 0; | ||
| 127 | } | ||
| 128 | else | ||
| 129 | { | ||
| 130 | printf("\n*** 'sdl2-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); | ||
| 131 | printf("*** of SDL required is %d.%d.%d. If sdl2-config is correct, then it is\n", major, minor, micro); | ||
| 132 | printf("*** best to upgrade to the required version.\n"); | ||
| 133 | printf("*** If sdl2-config was wrong, set the environment variable SDL2_CONFIG\n"); | ||
| 134 | printf("*** to point to the correct copy of sdl2-config, and remove the file\n"); | ||
| 135 | printf("*** config.cache before re-running configure\n"); | ||
| 136 | return 1; | ||
| 137 | } | ||
| 138 | } | ||
| 139 | |||
| 140 | ],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) | ||
| 141 | CFLAGS="$ac_save_CFLAGS" | ||
| 142 | CXXFLAGS="$ac_save_CXXFLAGS" | ||
| 143 | LIBS="$ac_save_LIBS" | ||
| 144 | fi | ||
| 145 | fi | ||
| 146 | if test "x$no_sdl" = x ; then | ||
| 147 | AC_MSG_RESULT(yes) | ||
| 148 | else | ||
| 149 | AC_MSG_RESULT(no) | ||
| 150 | fi | ||
| 151 | fi | ||
| 152 | if test "x$no_sdl" = x ; then | ||
| 153 | ifelse([$2], , :, [$2]) | ||
| 154 | else | ||
| 155 | if test "$SDL2_CONFIG" = "no" ; then | ||
| 156 | echo "*** The sdl2-config script installed by SDL could not be found" | ||
| 157 | echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" | ||
| 158 | echo "*** your path, or set the SDL2_CONFIG environment variable to the" | ||
| 159 | echo "*** full path to sdl2-config." | ||
| 160 | else | ||
| 161 | if test -f conf.sdltest ; then | ||
| 162 | : | ||
| 163 | else | ||
| 164 | echo "*** Could not run SDL test program, checking why..." | ||
| 165 | CFLAGS="$CFLAGS $SDL_CFLAGS" | ||
| 166 | CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" | ||
| 167 | LIBS="$LIBS $SDL_LIBS" | ||
| 168 | AC_TRY_LINK([ | ||
| 169 | #include <stdio.h> | ||
| 170 | #include "SDL.h" | ||
| 171 | |||
| 172 | int main(int argc, char *argv[]) | ||
| 173 | { return 0; } | ||
| 174 | #undef main | ||
| 175 | #define main K_and_R_C_main | ||
| 176 | ], [ return 0; ], | ||
| 177 | [ echo "*** The test program compiled, but did not run. This usually means" | ||
| 178 | echo "*** that the run-time linker is not finding SDL or finding the wrong" | ||
| 179 | echo "*** version of SDL. If it is not finding SDL, you'll need to set your" | ||
| 180 | echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" | ||
| 181 | echo "*** to the installed location Also, make sure you have run ldconfig if that" | ||
| 182 | echo "*** is required on your system" | ||
| 183 | echo "***" | ||
| 184 | echo "*** If you have an old version installed, it is best to remove it, although" | ||
| 185 | echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], | ||
| 186 | [ echo "*** The test program failed to compile or link. See the file config.log for the" | ||
| 187 | echo "*** exact error that occured. This usually means SDL was incorrectly installed" | ||
| 188 | echo "*** or that you have moved SDL since it was installed. In the latter case, you" | ||
| 189 | echo "*** may want to edit the sdl2-config script: $SDL2_CONFIG" ]) | ||
| 190 | CFLAGS="$ac_save_CFLAGS" | ||
| 191 | CXXFLAGS="$ac_save_CXXFLAGS" | ||
| 192 | LIBS="$ac_save_LIBS" | ||
| 193 | fi | ||
| 194 | fi | ||
| 195 | SDL_CFLAGS="" | ||
| 196 | SDL_LIBS="" | ||
| 197 | ifelse([$3], , :, [$3]) | ||
| 198 | fi | ||
| 199 | AC_SUBST(SDL_CFLAGS) | ||
| 200 | AC_SUBST(SDL_LIBS) | ||
| 201 | rm -f conf.sdltest | ||
| 202 | ]) | ||
| diff --git a/cmake/FindSDL2.cmake b/cmake/FindSDL2.cmake new file mode 100644 index 0000000..d94679c --- /dev/null +++ b/cmake/FindSDL2.cmake | |||
| @@ -0,0 +1,163 @@ | |||
| 1 | # Locate SDL2 library | ||
| 2 | # This module defines | ||
| 3 | # SDL2_LIBRARY, the name of the library to link against | ||
| 4 | # SDL2_FOUND, if false, do not try to link to SDL2 | ||
| 5 | # SDL2_INCLUDE_DIR, where to find SDL.h | ||
| 6 | # | ||
| 7 | # This module responds to the the flag: | ||
| 8 | # SDL2_BUILDING_LIBRARY | ||
| 9 | # If this is defined, then no SDL2main will be linked in because | ||
| 10 | # only applications need main(). | ||
| 11 | # Otherwise, it is assumed you are building an application and this | ||
| 12 | # module will attempt to locate and set the the proper link flags | ||
| 13 | # as part of the returned SDL2_LIBRARY variable. | ||
| 14 | # | ||
| 15 | # Don't forget to include SDLmain.h and SDLmain.m your project for the | ||
| 16 | # OS X framework based version. (Other versions link to -lSDL2main which | ||
| 17 | # this module will try to find on your behalf.) Also for OS X, this | ||
| 18 | # module will automatically add the -framework Cocoa on your behalf. | ||
| 19 | # | ||
| 20 | # | ||
| 21 | # Additional Note: If you see an empty SDL2_LIBRARY_TEMP in your configuration | ||
| 22 | # and no SDL2_LIBRARY, it means CMake did not find your SDL2 library | ||
| 23 | # (SDL2.dll, libsdl2.so, SDL2.framework, etc). | ||
| 24 | # Set SDL2_LIBRARY_TEMP to point to your SDL2 library, and configure again. | ||
| 25 | # Similarly, if you see an empty SDL2MAIN_LIBRARY, you should set this value | ||
| 26 | # as appropriate. These values are used to generate the final SDL2_LIBRARY | ||
| 27 | # variable, but when these values are unset, SDL2_LIBRARY does not get created. | ||
| 28 | # | ||
| 29 | # | ||
| 30 | # $SDL2DIR is an environment variable that would | ||
| 31 | # correspond to the ./configure --prefix=$SDL2DIR | ||
| 32 | # used in building SDL2. | ||
| 33 | # l.e.galup 9-20-02 | ||
| 34 | # | ||
| 35 | # Modified by Eric Wing. | ||
| 36 | # Added code to assist with automated building by using environmental variables | ||
| 37 | # and providing a more controlled/consistent search behavior. | ||
| 38 | # Added new modifications to recognize OS X frameworks and | ||
| 39 | # additional Unix paths (FreeBSD, etc). | ||
| 40 | # Also corrected the header search path to follow "proper" SDL guidelines. | ||
| 41 | # Added a search for SDL2main which is needed by some platforms. | ||
| 42 | # Added a search for threads which is needed by some platforms. | ||
| 43 | # Added needed compile switches for MinGW. | ||
| 44 | # | ||
| 45 | # On OSX, this will prefer the Framework version (if found) over others. | ||
| 46 | # People will have to manually change the cache values of | ||
| 47 | # SDL2_LIBRARY to override this selection or set the CMake environment | ||
| 48 | # CMAKE_INCLUDE_PATH to modify the search paths. | ||
| 49 | # | ||
| 50 | # Note that the header path has changed from SDL2/SDL.h to just SDL.h | ||
| 51 | # This needed to change because "proper" SDL convention | ||
| 52 | # is #include "SDL.h", not <SDL2/SDL.h>. This is done for portability | ||
| 53 | # reasons because not all systems place things in SDL2/ (see FreeBSD). | ||
| 54 | |||
| 55 | #============================================================================= | ||
| 56 | # Copyright 2003-2009 Kitware, Inc. | ||
| 57 | # | ||
| 58 | # Distributed under the OSI-approved BSD License (the "License"); | ||
| 59 | # see accompanying file Copyright.txt for details. | ||
| 60 | # | ||
| 61 | # This software is distributed WITHOUT ANY WARRANTY; without even the | ||
| 62 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
| 63 | # See the License for more information. | ||
| 64 | #============================================================================= | ||
| 65 | # (To distribute this file outside of CMake, substitute the full | ||
| 66 | # License text for the above reference.) | ||
| 67 | |||
| 68 | SET(SDL2_SEARCH_PATHS | ||
| 69 | ~/Library/Frameworks | ||
| 70 | /Library/Frameworks | ||
| 71 | /usr/local | ||
| 72 | /usr | ||
| 73 | /sw # Fink | ||
| 74 | /opt/local # DarwinPorts | ||
| 75 | /opt/csw # Blastwave | ||
| 76 | /opt | ||
| 77 | ) | ||
| 78 | |||
| 79 | FIND_PATH(SDL2_INCLUDE_DIR SDL.h | ||
| 80 | HINTS | ||
| 81 | $ENV{SDL2DIR} | ||
| 82 | PATH_SUFFIXES include/SDL2 include | ||
| 83 | PATHS ${SDL2_SEARCH_PATHS} | ||
| 84 | ) | ||
| 85 | |||
| 86 | FIND_LIBRARY(SDL2_LIBRARY_TEMP | ||
| 87 | NAMES SDL2 | ||
| 88 | HINTS | ||
| 89 | $ENV{SDL2DIR} | ||
| 90 | PATH_SUFFIXES lib64 lib | ||
| 91 | PATHS ${SDL2_SEARCH_PATHS} | ||
| 92 | ) | ||
| 93 | |||
| 94 | IF(NOT SDL2_BUILDING_LIBRARY) | ||
| 95 | IF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework") | ||
| 96 | # Non-OS X framework versions expect you to also dynamically link to | ||
| 97 | # SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms | ||
| 98 | # seem to provide SDL2main for compatibility even though they don't | ||
| 99 | # necessarily need it. | ||
| 100 | FIND_LIBRARY(SDL2MAIN_LIBRARY | ||
| 101 | NAMES SDL2main | ||
| 102 | HINTS | ||
| 103 | $ENV{SDL2DIR} | ||
| 104 | PATH_SUFFIXES lib64 lib | ||
| 105 | PATHS ${SDL2_SEARCH_PATHS} | ||
| 106 | ) | ||
| 107 | ENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework") | ||
| 108 | ENDIF(NOT SDL2_BUILDING_LIBRARY) | ||
| 109 | |||
| 110 | # SDL2 may require threads on your system. | ||
| 111 | # The Apple build may not need an explicit flag because one of the | ||
| 112 | # frameworks may already provide it. | ||
| 113 | # But for non-OSX systems, I will use the CMake Threads package. | ||
| 114 | IF(NOT APPLE) | ||
| 115 | FIND_PACKAGE(Threads) | ||
| 116 | ENDIF(NOT APPLE) | ||
| 117 | |||
| 118 | # MinGW needs an additional library, mwindows | ||
| 119 | # It's total link flags should look like -lmingw32 -lSDL2main -lSDL2 -lmwindows | ||
| 120 | # (Actually on second look, I think it only needs one of the m* libraries.) | ||
| 121 | IF(MINGW) | ||
| 122 | SET(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW") | ||
| 123 | ENDIF(MINGW) | ||
| 124 | |||
| 125 | IF(SDL2_LIBRARY_TEMP) | ||
| 126 | # For SDL2main | ||
| 127 | IF(NOT SDL2_BUILDING_LIBRARY) | ||
| 128 | IF(SDL2MAIN_LIBRARY) | ||
| 129 | SET(SDL2_LIBRARY_TEMP ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY_TEMP}) | ||
| 130 | ENDIF(SDL2MAIN_LIBRARY) | ||
| 131 | ENDIF(NOT SDL2_BUILDING_LIBRARY) | ||
| 132 | |||
| 133 | # For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa. | ||
| 134 | # CMake doesn't display the -framework Cocoa string in the UI even | ||
| 135 | # though it actually is there if I modify a pre-used variable. | ||
| 136 | # I think it has something to do with the CACHE STRING. | ||
| 137 | # So I use a temporary variable until the end so I can set the | ||
| 138 | # "real" variable in one-shot. | ||
| 139 | IF(APPLE) | ||
| 140 | SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa") | ||
| 141 | ENDIF(APPLE) | ||
| 142 | |||
| 143 | # For threads, as mentioned Apple doesn't need this. | ||
| 144 | # In fact, there seems to be a problem if I used the Threads package | ||
| 145 | # and try using this line, so I'm just skipping it entirely for OS X. | ||
| 146 | IF(NOT APPLE) | ||
| 147 | SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT}) | ||
| 148 | ENDIF(NOT APPLE) | ||
| 149 | |||
| 150 | # For MinGW library | ||
| 151 | IF(MINGW) | ||
| 152 | SET(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP}) | ||
| 153 | ENDIF(MINGW) | ||
| 154 | |||
| 155 | # Set the final string here so the GUI reflects the final state. | ||
| 156 | SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found") | ||
| 157 | # Set the temp variable to INTERNAL so it is not seen in the CMake GUI | ||
| 158 | SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "") | ||
| 159 | ENDIF(SDL2_LIBRARY_TEMP) | ||
| 160 | |||
| 161 | INCLUDE(FindPackageHandleStandardArgs) | ||
| 162 | |||
| 163 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR) \ No newline at end of file | ||
| diff --git a/cmake/FindSDL2_net.cmake b/cmake/FindSDL2_net.cmake new file mode 100644 index 0000000..31eae0a --- /dev/null +++ b/cmake/FindSDL2_net.cmake | |||
| @@ -0,0 +1,73 @@ | |||
| 1 | # - Find SDL2_net library and headers | ||
| 2 | # | ||
| 3 | # Find module for SDL_net 2.0 (http://www.libsdl.org/projects/SDL_net/). | ||
| 4 | # It defines the following variables: | ||
| 5 | # SDL2_NET_INCLUDE_DIRS - The location of the headers, e.g., SDL_net.h. | ||
| 6 | # SDL2_NET_LIBRARIES - The libraries to link against to use SDL2_net. | ||
| 7 | # SDL2_NET_FOUND - If false, do not try to use SDL2_net. | ||
| 8 | # SDL2_NET_VERSION_STRING | ||
| 9 | # Human-readable string containing the version of SDL2_net. | ||
| 10 | # | ||
| 11 | # Also defined, but not for general use are: | ||
| 12 | # SDL2_NET_INCLUDE_DIR - The directory that contains SDL_net.h. | ||
| 13 | # SDL2_NET_LIBRARY - The location of the SDL2_net library. | ||
| 14 | # | ||
| 15 | |||
| 16 | #============================================================================= | ||
| 17 | # Copyright 2013 Benjamin Eikel | ||
| 18 | # | ||
| 19 | # Distributed under the OSI-approved BSD License (the "License"); | ||
| 20 | # see accompanying file Copyright.txt for details. | ||
| 21 | # | ||
| 22 | # This software is distributed WITHOUT ANY WARRANTY; without even the | ||
| 23 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
| 24 | # See the License for more information. | ||
| 25 | #============================================================================= | ||
| 26 | # (To distribute this file outside of CMake, substitute the full | ||
| 27 | # License text for the above reference.) | ||
| 28 | |||
| 29 | find_package(PkgConfig QUIET) | ||
| 30 | pkg_check_modules(PC_SDL2_NET QUIET SDL2_net) | ||
| 31 | |||
| 32 | find_path(SDL2_NET_INCLUDE_DIR | ||
| 33 | NAMES SDL_net.h | ||
| 34 | HINTS | ||
| 35 | ${PC_SDL2_NET_INCLUDEDIR} | ||
| 36 | ${PC_SDL2_NET_INCLUDE_DIRS} | ||
| 37 | PATH_SUFFIXES SDL2 | ||
| 38 | ) | ||
| 39 | |||
| 40 | find_library(SDL2_NET_LIBRARY | ||
| 41 | NAMES SDL2_net | ||
| 42 | HINTS | ||
| 43 | ${PC_SDL2_NET_LIBDIR} | ||
| 44 | ${PC_SDL2_NET_LIBRARY_DIRS} | ||
| 45 | PATH_SUFFIXES x64 x86 | ||
| 46 | ) | ||
| 47 | |||
| 48 | if(SDL2_NET_INCLUDE_DIR AND EXISTS "${SDL2_NET_INCLUDE_DIR}/SDL_net.h") | ||
| 49 | file(STRINGS "${SDL2_NET_INCLUDE_DIR}/SDL_net.h" SDL2_NET_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_NET_MAJOR_VERSION[ \t]+[0-9]+$") | ||
| 50 | file(STRINGS "${SDL2_NET_INCLUDE_DIR}/SDL_net.h" SDL2_NET_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_NET_MINOR_VERSION[ \t]+[0-9]+$") | ||
| 51 | file(STRINGS "${SDL2_NET_INCLUDE_DIR}/SDL_net.h" SDL2_NET_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_NET_PATCHLEVEL[ \t]+[0-9]+$") | ||
| 52 | string(REGEX REPLACE "^#define[ \t]+SDL_NET_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_NET_VERSION_MAJOR "${SDL2_NET_VERSION_MAJOR_LINE}") | ||
| 53 | string(REGEX REPLACE "^#define[ \t]+SDL_NET_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_NET_VERSION_MINOR "${SDL2_NET_VERSION_MINOR_LINE}") | ||
| 54 | string(REGEX REPLACE "^#define[ \t]+SDL_NET_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_NET_VERSION_PATCH "${SDL2_NET_VERSION_PATCH_LINE}") | ||
| 55 | set(SDL2_NET_VERSION_STRING ${SDL2_NET_VERSION_MAJOR}.${SDL2_NET_VERSION_MINOR}.${SDL2_NET_VERSION_PATCH}) | ||
| 56 | unset(SDL2_NET_VERSION_MAJOR_LINE) | ||
| 57 | unset(SDL2_NET_VERSION_MINOR_LINE) | ||
| 58 | unset(SDL2_NET_VERSION_PATCH_LINE) | ||
| 59 | unset(SDL2_NET_VERSION_MAJOR) | ||
| 60 | unset(SDL2_NET_VERSION_MINOR) | ||
| 61 | unset(SDL2_NET_VERSION_PATCH) | ||
| 62 | endif() | ||
| 63 | |||
| 64 | set(SDL2_NET_INCLUDE_DIRS ${SDL2_NET_INCLUDE_DIR}) | ||
| 65 | set(SDL2_NET_LIBRARIES ${SDL2_NET_LIBRARY}) | ||
| 66 | |||
| 67 | include(FindPackageHandleStandardArgs) | ||
| 68 | |||
| 69 | find_package_handle_standard_args(SDL2_net | ||
| 70 | REQUIRED_VARS SDL2_NET_INCLUDE_DIRS SDL2_NET_LIBRARIES | ||
| 71 | VERSION_VAR SDL2_NET_VERSION_STRING) | ||
| 72 | |||
| 73 | mark_as_advanced(SDL2_NET_INCLUDE_DIR SDL2_NET_LIBRARY) \ No newline at end of file | ||
| diff --git a/cmake/FindSDL2_ttf.cmake b/cmake/FindSDL2_ttf.cmake new file mode 100644 index 0000000..72255a9 --- /dev/null +++ b/cmake/FindSDL2_ttf.cmake | |||
| @@ -0,0 +1,156 @@ | |||
| 1 | # Locate SDL2_ttf library | ||
| 2 | # This module defines | ||
| 3 | # SDL2_TTF_LIBRARY, the name of the library to link against | ||
| 4 | # SDL2_TTF_FOUND, if false, do not try to link to SDL2_ttf | ||
| 5 | # SDL2_TTF_INCLUDE_DIR, where to find SDL_image.h | ||
| 6 | # | ||
| 7 | # Additional Note: If you see an empty SDL2_TTF_LIBRARY_TEMP in your configuration | ||
| 8 | # and no SDL2_TTF_LIBRARY, it means CMake did not find your SDL2_Image library | ||
| 9 | # (SDL2_ttf.dll, libsdl2_image.so, SDL2_ttf.framework, etc). | ||
| 10 | # Set SDL2_TTF_LIBRARY_TEMP to point to your SDL2 library, and configure again. | ||
| 11 | # Similarly, if you see an empty SDL2MAIN_LIBRARY, you should set this value | ||
| 12 | # as appropriate. These values are used to generate the final SDL2_TTF_LIBRARY | ||
| 13 | # variable, but when these values are unset, SDL2_TTF_LIBRARY does not get created. | ||
| 14 | # | ||
| 15 | # $SDL2 is an environment variable that would | ||
| 16 | # correspond to the ./configure --prefix=$SDL2 | ||
| 17 | # used in building SDL2. | ||
| 18 | # l.e.galup 9-20-02 | ||
| 19 | # | ||
| 20 | # Modified by Eric Wing. | ||
| 21 | # Added code to assist with automated building by using environmental variables | ||
| 22 | # and providing a more controlled/consistent search behavior. | ||
| 23 | # Added new modifications to recognize OS X frameworks and | ||
| 24 | # additional Unix paths (FreeBSD, etc). | ||
| 25 | # Also corrected the header search path to follow "proper" SDL2 guidelines. | ||
| 26 | # Added a search for SDL2main which is needed by some platforms. | ||
| 27 | # Added a search for threads which is needed by some platforms. | ||
| 28 | # Added needed compile switches for MinGW. | ||
| 29 | # | ||
| 30 | # On OSX, this will prefer the Framework version (if found) over others. | ||
| 31 | # People will have to manually change the cache values of | ||
| 32 | # SDL2_TTF_LIBRARY to override this selection or set the CMake environment | ||
| 33 | # CMAKE_INCLUDE_PATH to modify the search paths. | ||
| 34 | # | ||
| 35 | # Note that the header path has changed from SDL2/SDL.h to just SDL.h | ||
| 36 | # This needed to change because "proper" SDL2 convention | ||
| 37 | # is #include "SDL.h", not <SDL2/SDL.h>. This is done for portability | ||
| 38 | # reasons because not all systems place things in SDL2/ (see FreeBSD). | ||
| 39 | # | ||
| 40 | # Ported by Johnny Patterson. This is a literal port for SDL2 of the FindSDL.cmake | ||
| 41 | # module with the minor edit of changing "SDL" to "SDL2" where necessary. This | ||
| 42 | # was not created for redistribution, and exists temporarily pending official | ||
| 43 | # SDL2 CMake modules. | ||
| 44 | # | ||
| 45 | # Note that on windows this will only search for the 32bit libraries, to search | ||
| 46 | # for 64bit change x86/i686-w64 to x64/x86_64-w64 | ||
| 47 | |||
| 48 | #============================================================================= | ||
| 49 | # Copyright 2003-2009 Kitware, Inc. | ||
| 50 | # | ||
| 51 | # CMake - Cross Platform Makefile Generator | ||
| 52 | # Copyright 2000-2014 Kitware, Inc. | ||
| 53 | # Copyright 2000-2011 Insight Software Consortium | ||
| 54 | # All rights reserved. | ||
| 55 | # | ||
| 56 | # Redistribution and use in source and binary forms, with or without | ||
| 57 | # modification, are permitted provided that the following conditions | ||
| 58 | # are met: | ||
| 59 | # | ||
| 60 | # * Redistributions of source code must retain the above copyright | ||
| 61 | # notice, this list of conditions and the following disclaimer. | ||
| 62 | # | ||
| 63 | # * Redistributions in binary form must reproduce the above copyright | ||
| 64 | # notice, this list of conditions and the following disclaimer in the | ||
| 65 | # documentation and/or other materials provided with the distribution. | ||
| 66 | # | ||
| 67 | # * Neither the names of Kitware, Inc., the Insight Software Consortium, | ||
| 68 | # nor the names of their contributors may be used to endorse or promote | ||
| 69 | # products derived from this software without specific prior written | ||
| 70 | # permission. | ||
| 71 | # | ||
| 72 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| 73 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| 74 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
| 75 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
| 76 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 77 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
| 78 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| 79 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| 80 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| 81 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| 82 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 83 | # | ||
| 84 | # This software is distributed WITHOUT ANY WARRANTY; without even the | ||
| 85 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
| 86 | # See the License for more information. | ||
| 87 | #============================================================================= | ||
| 88 | # (To distribute this file outside of CMake, substitute the full | ||
| 89 | # License text for the above reference.) | ||
| 90 | |||
| 91 | FIND_PATH(SDL2_TTF_INCLUDE_DIR SDL_ttf.h | ||
| 92 | HINTS | ||
| 93 | ${SDL2} | ||
| 94 | $ENV{SDL2} | ||
| 95 | $ENV{SDL2_TTF} | ||
| 96 | PATH_SUFFIXES include/SDL2 include SDL2 | ||
| 97 | i686-w64-mingw32/include/SDL2 | ||
| 98 | PATHS | ||
| 99 | ~/Library/Frameworks | ||
| 100 | /Library/Frameworks | ||
| 101 | /usr/local/include/SDL2 | ||
| 102 | /usr/include/SDL2 | ||
| 103 | /sw # Fink | ||
| 104 | /opt/local # DarwinPorts | ||
| 105 | /opt/csw # Blastwave | ||
| 106 | /opt | ||
| 107 | ) | ||
| 108 | |||
| 109 | # Lookup the 64 bit libs on x64 | ||
| 110 | IF(CMAKE_SIZEOF_VOID_P EQUAL 8) | ||
| 111 | FIND_LIBRARY(SDL2_TTF_LIBRARY_TEMP | ||
| 112 | NAMES SDL2_ttf | ||
| 113 | HINTS | ||
| 114 | ${SDL2} | ||
| 115 | $ENV{SDL2} | ||
| 116 | $ENV{SDL2_TTF} | ||
| 117 | PATH_SUFFIXES lib64 lib | ||
| 118 | lib/x64 | ||
| 119 | x86_64-w64-mingw32/lib | ||
| 120 | PATHS | ||
| 121 | /sw | ||
| 122 | /opt/local | ||
| 123 | /opt/csw | ||
| 124 | /opt | ||
| 125 | ) | ||
| 126 | # On 32bit build find the 32bit libs | ||
| 127 | ELSE(CMAKE_SIZEOF_VOID_P EQUAL 8) | ||
| 128 | FIND_LIBRARY(SDL2_TTF_LIBRARY_TEMP | ||
| 129 | NAMES SDL2_ttf | ||
| 130 | HINTS | ||
| 131 | ${SDL2} | ||
| 132 | $ENV{SDL2} | ||
| 133 | $ENV{SDL2_TTF} | ||
| 134 | PATH_SUFFIXES lib | ||
| 135 | lib/x86 | ||
| 136 | i686-w64-mingw32/lib | ||
| 137 | PATHS | ||
| 138 | /sw | ||
| 139 | /opt/local | ||
| 140 | /opt/csw | ||
| 141 | /opt | ||
| 142 | ) | ||
| 143 | ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8) | ||
| 144 | |||
| 145 | SET(SDL2_TTF_FOUND "NO") | ||
| 146 | IF(SDL2_TTF_LIBRARY_TEMP) | ||
| 147 | # Set the final string here so the GUI reflects the final state. | ||
| 148 | SET(SDL2_TTF_LIBRARY ${SDL2_TTF_LIBRARY_TEMP} CACHE STRING "Where the SDL2_ttf Library can be found") | ||
| 149 | # Set the temp variable to INTERNAL so it is not seen in the CMake GUI | ||
| 150 | SET(SDL2_TTF_LIBRARY_TEMP "${SDL2_TTF_LIBRARY_TEMP}" CACHE INTERNAL "") | ||
| 151 | SET(SDL2_TTF_FOUND "YES") | ||
| 152 | ENDIF(SDL2_TTF_LIBRARY_TEMP) | ||
| 153 | |||
| 154 | INCLUDE(FindPackageHandleStandardArgs) | ||
| 155 | |||
| 156 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_TTF REQUIRED_VARS SDL2_TTF_LIBRARY SDL2_TTF_INCLUDE_DIR) | ||
| diff --git a/configure.ac b/configure.ac deleted file mode 100644 index da0bd69..0000000 --- a/configure.ac +++ /dev/null | |||
| @@ -1,44 +0,0 @@ | |||
| 1 | AC_INIT(mazeoflife, version-3.0) | ||
| 2 | AC_PREREQ([2.59]) | ||
| 3 | AM_INIT_AUTOMAKE([1.10 no-define foreign]) | ||
| 4 | AC_PROG_CXX | ||
| 5 | AC_CONFIG_FILES([Makefile]) | ||
| 6 | |||
| 7 | dnl Check for SDL | ||
| 8 | SDL_VERSION=2.0.0 | ||
| 9 | AM_PATH_SDL2($SDL_VERSION, | ||
| 10 | :, | ||
| 11 | AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!]) | ||
| 12 | ) | ||
| 13 | CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" | ||
| 14 | LIBS="$LIBS $SDL_LIBS" | ||
| 15 | |||
| 16 | dnl Check for SDL2_ttf | ||
| 17 | AC_ARG_WITH([sdl-ttf2-include-path], | ||
| 18 | [AS_HELP_STRING([--with-sdl2-ttf-include-path], | ||
| 19 | [location of the SDL2_ttf headers, defaults to /usr/include/SDL2])], | ||
| 20 | [SDLTTF_CXXFLAGS="-I$withval"], | ||
| 21 | [SDLTTF_CXXFLAGS="-I/usr/include/SDL2"]) | ||
| 22 | AC_SUBST([SDLTTF_CXXFLAGS]) | ||
| 23 | |||
| 24 | AC_ARG_WITH([sdl2-ttf-lib-path], | ||
| 25 | [AS_HELP_STRING([--with-sdl2-ttf-lib-path], [location of the SDL2_ttf library])], | ||
| 26 | [SDLTTF_LIBS="-L$withval -lSDL2_ttf"], | ||
| 27 | [SDLTTF_LIBS="-lSDL2_ttf"]) | ||
| 28 | AC_SUBST([SDLTTF_LIBS]) | ||
| 29 | |||
| 30 | dnl Check for SDL2_net | ||
| 31 | AC_ARG_WITH([sdl2-net-include-path], | ||
| 32 | [AS_HELP_STRING([--with-sdl2-net-include-path], | ||
| 33 | [location of the SDL2_net headers, defaults to /usr/include/SDL2])], | ||
| 34 | [SDLNET_CXXFLAGS="-I$withval"], | ||
| 35 | [SDLNET_CXXFLAGS="-I/usr/include/SDL2"]) | ||
| 36 | AC_SUBST([SDLNET_CXXFLAGS]) | ||
| 37 | |||
| 38 | AC_ARG_WITH([sdl2-net-lib-path], | ||
| 39 | [AS_HELP_STRING([--with-sdl2-net-lib-path], [location of the SDL2_net library])], | ||
| 40 | [SDLNET_LIBS="-L$withval -lSDL2_net"], | ||
| 41 | [SDLNET_LIBS="-lSDL2_net"]) | ||
| 42 | AC_SUBST([SDLNET_LIBS]) | ||
| 43 | |||
| 44 | AC_OUTPUT | ||
