Mercurial > check-sdl-version
changeset 0:bacb3b7b582e
initial import
author | Eris Caffee <discordia@eldalin.com> |
---|---|
date | Sat, 09 Oct 2010 02:35:16 -0500 |
parents | |
children | 0aaa058b0994 |
files | CMakeLists.txt src/main.c |
diffstat | 2 files changed, 413 insertions(+), 0 deletions(-) [+] |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/CMakeLists.txt Sat Oct 09 02:35:16 2010 -0500 1.3 @@ -0,0 +1,382 @@ 1.4 +############################################################################### 1.5 +# 1.6 +# A generalized cmake file for developing cross-platform games. 1.7 +# 1.8 +# (c) 2010 Sarah Eris Horsley Caffee 1.9 + 1.10 +# Instructions: 1.11 +# This cmake file assumes that your source files are laid in out in the 1.12 +# following manner: 1.13 +# 1.14 +# project_dir\ Top level directory of the project. 1.15 +# |---include\ Header files are here. 1.16 +# |---src\ Source files are here. 1.17 +# |---build\ Binaries/objects go here. Run cmake from here. 1.18 +# !---cmake\ 1.19 +# | |---modules\ Custom cmake include files, if any, go here. 1.20 +# |---CMakeLists.txt This file. 1.21 +# 1.22 +# You may have more directories, of course, but these are assumed. You probably 1.23 +# want more than one build directory. I normally have build-linux\ 1.24 +# and build-windows\ directories. 1.25 +# 1.26 +# Set the App_Name variable, below, to the name of your application and you 1.27 +# are ready to start. Run cmake, ccmake, or cmake-gui from within your build 1.28 +# directory, choose the options you need, such as enabling SDL or OGRE, 1.29 +# and you should be good to go. 1.30 +# 1.31 +# You can uncomment the "SET (CMAKE_VERBOSE_MAKEFILE ON) command if you 1.32 +# need to debug the actual makefile that is generated. 1.33 +# 1.34 +# On windows, you may need to modify some of the variables farther down in 1.35 +# this file so that cmake knows where SDL or other support libraries 1.36 +# and their header files can be found on the system. 1.37 +# 1.38 +# When writing path names on Windows, such as when manually specifiying a 1.39 +# file or directory name, either use unix-style forward slashes '/' in the 1.40 +# path names or use double backslashes. If you use a single backslash as the 1.41 +# path name seperator, then cmake will interpret it as an esacpe sequence. 1.42 +# Thus, write "C:/source" or "C:\\source" instead of "C:\source". It's 1.43 +# probably best to use forward slashes in case to ever have a situation 1.44 +# where cmake needs to do recursive processing: each level of cmake will 1.45 +# strip out one of the slashes, so if there are two lev3els of cmake you 1.46 +# need to write \\\, three levels requires \\\\, etc. 1.47 +# 1.48 +# 1.49 +# Note that some of the cmake support scripts that find libraries for you 1.50 +# can be controlled by environment variables. For example, you can set the 1.51 +# SDLDIR environment variable before running cmake in order to point to 1.52 +# a different version of SDL than your systems default copy. This is useful 1.53 +# for trying out cutting edge versions of libraries without installing them 1.54 +# system wide. 1.55 + 1.56 + 1.57 +CMAKE_MINIMUM_REQUIRED (VERSION 2.6) 1.58 + 1.59 + 1.60 +SET (App_Name "check-sdl-version") 1.61 +IF (App_Name STREQUAL "") 1.62 + MESSAGE (FATAL_ERROR "You must set the App_Name variable!") 1.63 +ENDIF () 1.64 + 1.65 + 1.66 +#SET (CMAKE_VERBOSE_MAKEFILE ON) 1.67 + 1.68 + 1.69 +PROJECT (${App_Name}) 1.70 + 1.71 + 1.72 +################################################################################ 1.73 +# Ensure that we are not building in our source directories. 1.74 + 1.75 +SET (Build_Dir_OK "TRUE") 1.76 +STRING (REGEX MATCH "^${CMAKE_SOURCE_DIR}" In_Sub_Dir ${CMAKE_BINARY_DIR}) 1.77 +IF (In_Sub_Dir) 1.78 + STRING (REGEX MATCH "^${CMAKE_SOURCE_DIR}/build" In_Build_Dir ${CMAKE_BINARY_DIR}) 1.79 + IF (NOT In_Build_Dir) 1.80 + SET (Build_Dir_OK "FALSE") 1.81 + ENDIF () 1.82 +ENDIF () 1.83 + 1.84 +IF (NOT Build_Dir_OK) 1.85 + MESSAGE (FATAL_ERROR "You must run cmake from a directory that is not in your source tree, or that is in a special subdirectory of the tree whose name begins with 'build'.") 1.86 +ENDIF () 1.87 + 1.88 + 1.89 +############################################################################### 1.90 +# If you have your own custom cmake modules that you want to include, put them 1.91 +# in the the cmake/modules subdirectory of your project. 1.92 + 1.93 +SET (CMAKE_MODULE_PATH ${${App_Name}_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH}) 1.94 + 1.95 + 1.96 +################################################################################ 1.97 +# Set up the basic build environment 1.98 + 1.99 +IF (CMAKE_BUILD_TYPE STREQUAL "") 1.100 + # CMake defaults to leaving CMAKE_BUILD_TYPE empty. This screws up 1.101 + # differentiation between debug and release builds. 1.102 + SET (CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: None (CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE) 1.103 +ENDIF () 1.104 + 1.105 + 1.106 +################################################################################ 1.107 +# The core project files 1.108 + 1.109 +FILE (GLOB SRCS src/*.c src/*.cpp) 1.110 +FILE (GLOB HDRS include/*.h include/*.hpp) 1.111 + 1.112 +LINK_DIRECTORIES ( 1.113 +) 1.114 + 1.115 +INCLUDE_DIRECTORIES ( 1.116 + ${PROJECT_SOURCE_DIR}/include 1.117 +) 1.118 + 1.119 +ADD_EXECUTABLE (${App_Name} 1.120 + ${SRCS} 1.121 + ${HDRS} 1.122 +) 1.123 + 1.124 +TARGET_LINK_LIBRARIES (${App_Name} 1.125 +) 1.126 + 1.127 + 1.128 +# # An example for a unix library named utils with a test driver program. 1.129 + 1.130 +# set (SRCS_utils 1.131 +# src/utils.cpp 1.132 +# include/utils.h 1.133 +# ) 1.134 + 1.135 +# INCLUDE_DIRECTORIES ( 1.136 +# ${PROJECT_SOURCE_DIR}/include 1.137 +# ) 1.138 + 1.139 +# # Build both static and shared libraries 1.140 +# # The target properties are needed because, by default, the output name 1.141 +# # will be the name in the add_library command, and we need to have different 1.142 +# # names in the two commands for the shared and static versions, even though 1.143 +# # we want the final files to have the same names with different extensions. 1.144 +# # 1.145 +# # The prefix is needed mostly in case we build on windows, which has no prefix 1.146 +# # by default. 1.147 +# # 1.148 +# # The clean_direct_output option makes sure that the two lib builds don't 1.149 +# # clobber each others temp files since they are being built from the same 1.150 +# # sources. 1.151 + 1.152 +# ADD_LIBRARY (utils SHARED 1.153 +# ${SRCS_utils} 1.154 +# ) 1.155 +# SET_TARGET_PROPERTIES (utils PROPERTIES OUTPUT_NAME "utils") 1.156 +# SET_TARGET_PROPERTIES (utils PROPERTIES PREFIX "lib") 1.157 +# SET_TARGET_PROPERTIES (utils PROPERTIES CLEAN_DIRECT_OUTPUT 1) 1.158 + 1.159 +# ADD_LIBRARY (utils-static STATIC 1.160 +# ${SRCS_utils} 1.161 +# ) 1.162 +# SET_TARGET_PROPERTIES (utils-static PROPERTIES OUTPUT_NAME "utils") 1.163 +# SET_TARGET_PROPERTIES (utils-static PROPERTIES PREFIX "lib") 1.164 +# SET_TARGET_PROPERTIES (utils-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) 1.165 + 1.166 + 1.167 + 1.168 +# # Build a test application. 1.169 + 1.170 +# ADD_EXECUTABLE (test 1.171 +# src/main.cpp 1.172 +# ) 1.173 + 1.174 +# TARGET_LINK_LIBRARIES (test 1.175 +# utils 1.176 +# ) 1.177 + 1.178 + 1.179 +################################################################################ 1.180 +# SDL Support 1.181 +# 1.182 +# Enabling SDL support enables several suboptions to make some common SDL 1.183 +# extension libraries available as well. On Windows, you will need to 1.184 +# specify the path of the directory where you have installed the headers and 1.185 +# libraries. See below. 1.186 + 1.187 +OPTION (Option_SDL_Dev "Build an SDL application." OFF) 1.188 + 1.189 +IF (Option_SDL_Dev) 1.190 + 1.191 + IF (WIN32) 1.192 + 1.193 + # Windows has no standard locations for include files and libraries, 1.194 + # so you need to specify them by hand. Each of the SDLDIR environment 1.195 + # variables below is used by the corresponding FIND_PACAKGE script 1.196 + # to locate the needed include files and libraries. Set each variable 1.197 + # to the directory containing the files. 1.198 + 1.199 + # Some of the sdl packages do not provide built in support for MinGW 1.200 + # compilation, and you will need to install the files appropriately by hand. 1.201 + # Each one needs 3 subdirectories under its top level: bin, include, and lib. 1.202 + # The bin directory is where you put the dll files, the include directory 1.203 + # holds the header files, and the lib directory holds the libSDL*.a files 1.204 + # needed by the mingw linker. Note that the dll's are not actually needed 1.205 + # for compilation, while the libs are, yet are run time the dlls are needed. 1.206 + # You will need to manually copy the dll's into an appropriate location, such 1.207 + # as the installation directory of your program. 1.208 + 1.209 + SET (ENV{SDLDIR} "C:/deps/SDL-1.2.14") 1.210 + SET (ENV{SDLTTFDIR} "C:/deps/SDL_ttf-2.0.10") 1.211 + SET (ENV{SDLIMAGEDIR} "C:/deps/SDL_image-1.2.10") 1.212 + SET (ENV{SDLMIXERDIR} "C:/deps/SDL_mixer-1.2.11") 1.213 + SET (ENV{SDLNETDIR} "C:/deps/SDL_net-1.2.7") 1.214 + ENDIF (WIN32) 1.215 + 1.216 + # SDL base package 1.217 + # To use a version of SDL other than your systems default, set the SDLDIR 1.218 + # environment variable to the installation location of your preferred version. 1.219 + FIND_PACKAGE (SDL) 1.220 + IF (NOT SDL_FOUND) 1.221 + MESSAGE (FATAL_ERROR "SDL not found!") 1.222 + ENDIF (NOT SDL_FOUND) 1.223 + INCLUDE_DIRECTORIES( 1.224 + ${SDL_INCLUDE_DIR} 1.225 + ${INCLUDE_DIRECTORIES} 1.226 + ) 1.227 + TARGET_LINK_LIBRARIES(${App_Name} 1.228 + ${SDL_LIBRARY} 1.229 + ${TARGET_LINK_LIBRARIES} 1.230 + ) 1.231 + 1.232 + # SDL_ttf 1.233 + # Environment variables SDLTTFDIR and SDLDIR will be checked in that order 1.234 + # and if set cmake will try to find SDL_ttf in the specified directory. 1.235 + OPTION(Option_SDL_Dev_SDL_ttf "Use SDL_ttf." OFF) 1.236 + IF (Option_SDL_Dev_SDL_ttf) 1.237 + FIND_PACKAGE (SDL_ttf) 1.238 + IF (NOT SDLTTF_FOUND) 1.239 + MESSAGE (FATAL_ERROR "SDL_ttf not found!") 1.240 + ENDIF (NOT SDLTTF_FOUND) 1.241 + INCLUDE_DIRECTORIES( 1.242 + ${SDLTTF_INCLUDE_DIR} 1.243 + ${INCLUDE_DIRECTORIES} 1.244 + ) 1.245 + TARGET_LINK_LIBRARIES(${App_Name} 1.246 + ${SDLTTF_LIBRARY} 1.247 + ${TARGET_LINK_LIBRARIES} 1.248 + ) 1.249 + ENDIF (Option_SDL_Dev_SDL_ttf) 1.250 + 1.251 + # SDL_image 1.252 + # Environment variables SDLIMAGEDIR and SDLDIR will be checked in that order 1.253 + # and if set cmake will try to find SDL_image in the specified directory. 1.254 + OPTION(Option_SDL_Dev_SDL_image "Use SDL_image." OFF) 1.255 + IF (Option_SDL_Dev_SDL_image) 1.256 + FIND_PACKAGE (SDL_image) 1.257 + IF (NOT SDLIMAGE_FOUND) 1.258 + MESSAGE (FATAL_ERROR "SDL_image not found!") 1.259 + ENDIF (NOT SDLIMAGE_FOUND) 1.260 + INCLUDE_DIRECTORIES( 1.261 + ${SDLIMAGE_INCLUDE_DIR} 1.262 + ${INCLUDE_DIRECTORIES} 1.263 + ) 1.264 + TARGET_LINK_LIBRARIES(${App_Name} 1.265 + ${SDLIMAGE_LIBRARY} 1.266 + ${TARGET_LINK_LIBRARIES} 1.267 + ) 1.268 + ENDIF (Option_SDL_Dev_SDL_image) 1.269 + 1.270 + # SDL_mixer 1.271 + # Environment variables SDLMIXERDIR and SDLDIR will be checked in that order 1.272 + # and if set cmake will try to find SDL_mixer in the specified directory. 1.273 + OPTION(Option_SDL_Dev_SDL_mixer "Use SDL_mixer." OFF) 1.274 + IF (Option_SDL_Dev_SDL_mixer) 1.275 + FIND_PACKAGE (SDL_mixer) 1.276 + IF (NOT SDLMIXER_FOUND) 1.277 + MESSAGE (FATAL_ERROR "SDL_mixer not found!") 1.278 + ENDIF (NOT SDLMIXER_FOUND) 1.279 + INCLUDE_DIRECTORIES( 1.280 + ${SDLMIXER_INCLUDE_DIR} 1.281 + ${INCLUDE_DIRECTORIES} 1.282 + ) 1.283 + TARGET_LINK_LIBRARIES(${App_Name} 1.284 + ${SDLMIXER_LIBRARY} 1.285 + ${TARGET_LINK_LIBRARIES} 1.286 + ) 1.287 + ENDIF (Option_SDL_Dev_SDL_mixer) 1.288 + 1.289 + # SDL_net 1.290 + # Environment variables SDLNETDIR and SDLDIR will be checked in that order 1.291 + # and if set cmake will try to find SDL_net in the specified directory. 1.292 + OPTION(Option_SDL_Dev_SDL_net "Use SDL_net." OFF) 1.293 + IF (Option_SDL_Dev_SDL_net) 1.294 + FIND_PACKAGE (SDL_net) 1.295 + IF (NOT SDLNET_FOUND) 1.296 + MESSAGE (FATAL_ERROR "SDL_net not found!") 1.297 + ENDIF (NOT SDLNET_FOUND) 1.298 + INCLUDE_DIRECTORIES( 1.299 + ${SDLNET_INCLUDE_DIR} 1.300 + ${INCLUDE_DIRECTORIES} 1.301 + ) 1.302 + TARGET_LINK_LIBRARIES(${App_Name} 1.303 + ${SDLNET_LIBRARY} 1.304 + ${TARGET_LINK_LIBRARIES} 1.305 + ) 1.306 + ENDIF (Option_SDL_Dev_SDL_net) 1.307 + 1.308 +ENDIF (Option_SDL_Dev) 1.309 + 1.310 + 1.311 +################################################################################ 1.312 + 1.313 +OPTION(Option_OGRE_Dev "Build with OGRE/OIS application." OFF) 1.314 + 1.315 +IF (Option_OGRE_Dev) 1.316 + set(CMAKE_MODULE_PATH 1.317 + /usr/local/lib/OGRE/cmake 1.318 + ${CMAKE_MODULE_PATH} 1.319 + ) 1.320 + 1.321 + FIND_PACKAGE(OGRE) 1.322 + FIND_PACKAGE(OIS) 1.323 + INCLUDE_DIRECTORIES( 1.324 + ${INCLUDE_DIRECTORIES} 1.325 + ${OGRE_INCLUDE_DIRS} 1.326 + ${OGRE_CEGUIRenderer_INCLUDE_DIRS} 1.327 + ${OIS_INCLUDE_DIRS} 1.328 + ) 1.329 + 1.330 + TARGET_LINK_LIBRARIES(${App_Name} 1.331 + ${TARGET_LINK_LIBRARIES} 1.332 + ${OGRE_LIBRARIES} 1.333 + ${OIS_LIBRARIES} 1.334 + ${TARGET_LINK_LIBRARIES} 1.335 + ) 1.336 +ENDIF (Option_OGRE_Dev) 1.337 + 1.338 + 1.339 +################################################################################ 1.340 +# ${OGRE_CEGUIRenderer_LIBRARIES} 1.341 + 1.342 + 1.343 + 1.344 +################################################################################ 1.345 + 1.346 +OPTION(Option_OpenAL_Dev "Build an OpenAL Application." OFF) 1.347 + 1.348 +IF (Option_OpenAL_Dev) 1.349 + FIND_PACKAGE(OpenAL) 1.350 + 1.351 + INCLUDE_DIRECTORIES( 1.352 + ${OpenAL_INCLUDE_DIR} 1.353 + ${INCLUDE_DIRECTORIES} 1.354 + ) 1.355 + 1.356 + TARGET_LINK_LIBRARIES(${App_Name} 1.357 + ${OpenAL_LIBRARIES} 1.358 + ${TARGET_LINK_LIBRARIES} 1.359 + ) 1.360 + 1.361 +ENDIF (Option_OpenAL_Dev) 1.362 + 1.363 + 1.364 + 1.365 +################################################################################ 1.366 + 1.367 +OPTION(Option_OpenGL_Dev "Build an OpenGL Application." OFF) 1.368 + 1.369 +IF (Option_OpenGL_Dev) 1.370 + 1.371 + FIND_PACKAGE(OpenGL) 1.372 + 1.373 + INCLUDE_DIRECTORIES( 1.374 + ${OpenGL_INCLUDE_DIR} 1.375 + ${INCLUDE_DIRECTORIES} 1.376 + ) 1.377 + 1.378 + TARGET_LINK_LIBRARIES(${App_Name} 1.379 + ${OpenGL_LIBRARIES} 1.380 + ${TARGET_LINK_LIBRARIES} 1.381 + ) 1.382 + 1.383 +ENDIF (Option_OpenGL_Dev) 1.384 + 1.385 +################################################################################
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/src/main.c Sat Oct 09 02:35:16 2010 -0500 2.3 @@ -0,0 +1,31 @@ 2.4 +/****************************************************************************** 2.5 +// 2.6 +// check-sdl-version 2.7 +// Copyright (c) 2010 Sarah Eris Horsley Caffee 2.8 +// 2.9 +******************************************************************************/ 2.10 + 2.11 +#include <stdio.h> 2.12 +#include <SDL.h> 2.13 +#include <SDL_ttf.h> 2.14 + 2.15 +int main(int argc, char **argv) 2.16 + { 2.17 + SDL_version compiled; 2.18 + const SDL_version * linked; 2.19 + SDL_version ttf_compiled; 2.20 + const SDL_version * ttf_linked; 2.21 + 2.22 + printf("\t\t\tCompiled\t\tLinked\n"); 2.23 + 2.24 + SDL_VERSION(&compiled); 2.25 + linked = SDL_Linked_Version(); 2.26 + printf("SDL version\t\t%d.%d.%d\t\t\t%d.%d.%d\n", compiled.major, compiled.minor, compiled.patch, 2.27 + linked->major, linked->minor, linked->patch); 2.28 + 2.29 + SDL_TTF_VERSION(&ttf_compiled); 2.30 + ttf_linked = TTF_Linked_Version(); 2.31 + printf("SDL_ttf version\t\t%d.%d.%d\t\t\t%d.%d.%d\n", ttf_compiled.major, ttf_compiled.minor, ttf_compiled.patch, 2.32 + ttf_linked->major, ttf_linked->minor, ttf_linked->patch); 2.33 + 2.34 + }