# HG changeset patch # User Eris Caffee # Date 1286609716 18000 # Node ID bacb3b7b582ef0064f239248e6507bf23f8c8692 initial import diff -r 000000000000 -r bacb3b7b582e CMakeLists.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CMakeLists.txt Sat Oct 09 02:35:16 2010 -0500 @@ -0,0 +1,382 @@ +############################################################################### +# +# A generalized cmake file for developing cross-platform games. +# +# (c) 2010 Sarah Eris Horsley Caffee + +# Instructions: +# This cmake file assumes that your source files are laid in out in the +# following manner: +# +# project_dir\ Top level directory of the project. +# |---include\ Header files are here. +# |---src\ Source files are here. +# |---build\ Binaries/objects go here. Run cmake from here. +# !---cmake\ +# | |---modules\ Custom cmake include files, if any, go here. +# |---CMakeLists.txt This file. +# +# You may have more directories, of course, but these are assumed. You probably +# want more than one build directory. I normally have build-linux\ +# and build-windows\ directories. +# +# Set the App_Name variable, below, to the name of your application and you +# are ready to start. Run cmake, ccmake, or cmake-gui from within your build +# directory, choose the options you need, such as enabling SDL or OGRE, +# and you should be good to go. +# +# You can uncomment the "SET (CMAKE_VERBOSE_MAKEFILE ON) command if you +# need to debug the actual makefile that is generated. +# +# On windows, you may need to modify some of the variables farther down in +# this file so that cmake knows where SDL or other support libraries +# and their header files can be found on the system. +# +# When writing path names on Windows, such as when manually specifiying a +# file or directory name, either use unix-style forward slashes '/' in the +# path names or use double backslashes. If you use a single backslash as the +# path name seperator, then cmake will interpret it as an esacpe sequence. +# Thus, write "C:/source" or "C:\\source" instead of "C:\source". It's +# probably best to use forward slashes in case to ever have a situation +# where cmake needs to do recursive processing: each level of cmake will +# strip out one of the slashes, so if there are two lev3els of cmake you +# need to write \\\, three levels requires \\\\, etc. +# +# +# Note that some of the cmake support scripts that find libraries for you +# can be controlled by environment variables. For example, you can set the +# SDLDIR environment variable before running cmake in order to point to +# a different version of SDL than your systems default copy. This is useful +# for trying out cutting edge versions of libraries without installing them +# system wide. + + +CMAKE_MINIMUM_REQUIRED (VERSION 2.6) + + +SET (App_Name "check-sdl-version") +IF (App_Name STREQUAL "") + MESSAGE (FATAL_ERROR "You must set the App_Name variable!") +ENDIF () + + +#SET (CMAKE_VERBOSE_MAKEFILE ON) + + +PROJECT (${App_Name}) + + +################################################################################ +# Ensure that we are not building in our source directories. + +SET (Build_Dir_OK "TRUE") +STRING (REGEX MATCH "^${CMAKE_SOURCE_DIR}" In_Sub_Dir ${CMAKE_BINARY_DIR}) +IF (In_Sub_Dir) + STRING (REGEX MATCH "^${CMAKE_SOURCE_DIR}/build" In_Build_Dir ${CMAKE_BINARY_DIR}) + IF (NOT In_Build_Dir) + SET (Build_Dir_OK "FALSE") + ENDIF () +ENDIF () + +IF (NOT Build_Dir_OK) + 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'.") +ENDIF () + + +############################################################################### +# If you have your own custom cmake modules that you want to include, put them +# in the the cmake/modules subdirectory of your project. + +SET (CMAKE_MODULE_PATH ${${App_Name}_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH}) + + +################################################################################ +# Set up the basic build environment + +IF (CMAKE_BUILD_TYPE STREQUAL "") + # CMake defaults to leaving CMAKE_BUILD_TYPE empty. This screws up + # differentiation between debug and release builds. + 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) +ENDIF () + + +################################################################################ +# The core project files + +FILE (GLOB SRCS src/*.c src/*.cpp) +FILE (GLOB HDRS include/*.h include/*.hpp) + +LINK_DIRECTORIES ( +) + +INCLUDE_DIRECTORIES ( + ${PROJECT_SOURCE_DIR}/include +) + +ADD_EXECUTABLE (${App_Name} + ${SRCS} + ${HDRS} +) + +TARGET_LINK_LIBRARIES (${App_Name} +) + + +# # An example for a unix library named utils with a test driver program. + +# set (SRCS_utils +# src/utils.cpp +# include/utils.h +# ) + +# INCLUDE_DIRECTORIES ( +# ${PROJECT_SOURCE_DIR}/include +# ) + +# # Build both static and shared libraries +# # The target properties are needed because, by default, the output name +# # will be the name in the add_library command, and we need to have different +# # names in the two commands for the shared and static versions, even though +# # we want the final files to have the same names with different extensions. +# # +# # The prefix is needed mostly in case we build on windows, which has no prefix +# # by default. +# # +# # The clean_direct_output option makes sure that the two lib builds don't +# # clobber each others temp files since they are being built from the same +# # sources. + +# ADD_LIBRARY (utils SHARED +# ${SRCS_utils} +# ) +# SET_TARGET_PROPERTIES (utils PROPERTIES OUTPUT_NAME "utils") +# SET_TARGET_PROPERTIES (utils PROPERTIES PREFIX "lib") +# SET_TARGET_PROPERTIES (utils PROPERTIES CLEAN_DIRECT_OUTPUT 1) + +# ADD_LIBRARY (utils-static STATIC +# ${SRCS_utils} +# ) +# SET_TARGET_PROPERTIES (utils-static PROPERTIES OUTPUT_NAME "utils") +# SET_TARGET_PROPERTIES (utils-static PROPERTIES PREFIX "lib") +# SET_TARGET_PROPERTIES (utils-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) + + + +# # Build a test application. + +# ADD_EXECUTABLE (test +# src/main.cpp +# ) + +# TARGET_LINK_LIBRARIES (test +# utils +# ) + + +################################################################################ +# SDL Support +# +# Enabling SDL support enables several suboptions to make some common SDL +# extension libraries available as well. On Windows, you will need to +# specify the path of the directory where you have installed the headers and +# libraries. See below. + +OPTION (Option_SDL_Dev "Build an SDL application." OFF) + +IF (Option_SDL_Dev) + + IF (WIN32) + + # Windows has no standard locations for include files and libraries, + # so you need to specify them by hand. Each of the SDLDIR environment + # variables below is used by the corresponding FIND_PACAKGE script + # to locate the needed include files and libraries. Set each variable + # to the directory containing the files. + + # Some of the sdl packages do not provide built in support for MinGW + # compilation, and you will need to install the files appropriately by hand. + # Each one needs 3 subdirectories under its top level: bin, include, and lib. + # The bin directory is where you put the dll files, the include directory + # holds the header files, and the lib directory holds the libSDL*.a files + # needed by the mingw linker. Note that the dll's are not actually needed + # for compilation, while the libs are, yet are run time the dlls are needed. + # You will need to manually copy the dll's into an appropriate location, such + # as the installation directory of your program. + + SET (ENV{SDLDIR} "C:/deps/SDL-1.2.14") + SET (ENV{SDLTTFDIR} "C:/deps/SDL_ttf-2.0.10") + SET (ENV{SDLIMAGEDIR} "C:/deps/SDL_image-1.2.10") + SET (ENV{SDLMIXERDIR} "C:/deps/SDL_mixer-1.2.11") + SET (ENV{SDLNETDIR} "C:/deps/SDL_net-1.2.7") + ENDIF (WIN32) + + # SDL base package + # To use a version of SDL other than your systems default, set the SDLDIR + # environment variable to the installation location of your preferred version. + FIND_PACKAGE (SDL) + IF (NOT SDL_FOUND) + MESSAGE (FATAL_ERROR "SDL not found!") + ENDIF (NOT SDL_FOUND) + INCLUDE_DIRECTORIES( + ${SDL_INCLUDE_DIR} + ${INCLUDE_DIRECTORIES} + ) + TARGET_LINK_LIBRARIES(${App_Name} + ${SDL_LIBRARY} + ${TARGET_LINK_LIBRARIES} + ) + + # SDL_ttf + # Environment variables SDLTTFDIR and SDLDIR will be checked in that order + # and if set cmake will try to find SDL_ttf in the specified directory. + OPTION(Option_SDL_Dev_SDL_ttf "Use SDL_ttf." OFF) + IF (Option_SDL_Dev_SDL_ttf) + FIND_PACKAGE (SDL_ttf) + IF (NOT SDLTTF_FOUND) + MESSAGE (FATAL_ERROR "SDL_ttf not found!") + ENDIF (NOT SDLTTF_FOUND) + INCLUDE_DIRECTORIES( + ${SDLTTF_INCLUDE_DIR} + ${INCLUDE_DIRECTORIES} + ) + TARGET_LINK_LIBRARIES(${App_Name} + ${SDLTTF_LIBRARY} + ${TARGET_LINK_LIBRARIES} + ) + ENDIF (Option_SDL_Dev_SDL_ttf) + + # SDL_image + # Environment variables SDLIMAGEDIR and SDLDIR will be checked in that order + # and if set cmake will try to find SDL_image in the specified directory. + OPTION(Option_SDL_Dev_SDL_image "Use SDL_image." OFF) + IF (Option_SDL_Dev_SDL_image) + FIND_PACKAGE (SDL_image) + IF (NOT SDLIMAGE_FOUND) + MESSAGE (FATAL_ERROR "SDL_image not found!") + ENDIF (NOT SDLIMAGE_FOUND) + INCLUDE_DIRECTORIES( + ${SDLIMAGE_INCLUDE_DIR} + ${INCLUDE_DIRECTORIES} + ) + TARGET_LINK_LIBRARIES(${App_Name} + ${SDLIMAGE_LIBRARY} + ${TARGET_LINK_LIBRARIES} + ) + ENDIF (Option_SDL_Dev_SDL_image) + + # SDL_mixer + # Environment variables SDLMIXERDIR and SDLDIR will be checked in that order + # and if set cmake will try to find SDL_mixer in the specified directory. + OPTION(Option_SDL_Dev_SDL_mixer "Use SDL_mixer." OFF) + IF (Option_SDL_Dev_SDL_mixer) + FIND_PACKAGE (SDL_mixer) + IF (NOT SDLMIXER_FOUND) + MESSAGE (FATAL_ERROR "SDL_mixer not found!") + ENDIF (NOT SDLMIXER_FOUND) + INCLUDE_DIRECTORIES( + ${SDLMIXER_INCLUDE_DIR} + ${INCLUDE_DIRECTORIES} + ) + TARGET_LINK_LIBRARIES(${App_Name} + ${SDLMIXER_LIBRARY} + ${TARGET_LINK_LIBRARIES} + ) + ENDIF (Option_SDL_Dev_SDL_mixer) + + # SDL_net + # Environment variables SDLNETDIR and SDLDIR will be checked in that order + # and if set cmake will try to find SDL_net in the specified directory. + OPTION(Option_SDL_Dev_SDL_net "Use SDL_net." OFF) + IF (Option_SDL_Dev_SDL_net) + FIND_PACKAGE (SDL_net) + IF (NOT SDLNET_FOUND) + MESSAGE (FATAL_ERROR "SDL_net not found!") + ENDIF (NOT SDLNET_FOUND) + INCLUDE_DIRECTORIES( + ${SDLNET_INCLUDE_DIR} + ${INCLUDE_DIRECTORIES} + ) + TARGET_LINK_LIBRARIES(${App_Name} + ${SDLNET_LIBRARY} + ${TARGET_LINK_LIBRARIES} + ) + ENDIF (Option_SDL_Dev_SDL_net) + +ENDIF (Option_SDL_Dev) + + +################################################################################ + +OPTION(Option_OGRE_Dev "Build with OGRE/OIS application." OFF) + +IF (Option_OGRE_Dev) + set(CMAKE_MODULE_PATH + /usr/local/lib/OGRE/cmake + ${CMAKE_MODULE_PATH} + ) + + FIND_PACKAGE(OGRE) + FIND_PACKAGE(OIS) + INCLUDE_DIRECTORIES( + ${INCLUDE_DIRECTORIES} + ${OGRE_INCLUDE_DIRS} + ${OGRE_CEGUIRenderer_INCLUDE_DIRS} + ${OIS_INCLUDE_DIRS} + ) + + TARGET_LINK_LIBRARIES(${App_Name} + ${TARGET_LINK_LIBRARIES} + ${OGRE_LIBRARIES} + ${OIS_LIBRARIES} + ${TARGET_LINK_LIBRARIES} + ) +ENDIF (Option_OGRE_Dev) + + +################################################################################ +# ${OGRE_CEGUIRenderer_LIBRARIES} + + + +################################################################################ + +OPTION(Option_OpenAL_Dev "Build an OpenAL Application." OFF) + +IF (Option_OpenAL_Dev) + FIND_PACKAGE(OpenAL) + + INCLUDE_DIRECTORIES( + ${OpenAL_INCLUDE_DIR} + ${INCLUDE_DIRECTORIES} + ) + + TARGET_LINK_LIBRARIES(${App_Name} + ${OpenAL_LIBRARIES} + ${TARGET_LINK_LIBRARIES} + ) + +ENDIF (Option_OpenAL_Dev) + + + +################################################################################ + +OPTION(Option_OpenGL_Dev "Build an OpenGL Application." OFF) + +IF (Option_OpenGL_Dev) + + FIND_PACKAGE(OpenGL) + + INCLUDE_DIRECTORIES( + ${OpenGL_INCLUDE_DIR} + ${INCLUDE_DIRECTORIES} + ) + + TARGET_LINK_LIBRARIES(${App_Name} + ${OpenGL_LIBRARIES} + ${TARGET_LINK_LIBRARIES} + ) + +ENDIF (Option_OpenGL_Dev) + +################################################################################ diff -r 000000000000 -r bacb3b7b582e src/main.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main.c Sat Oct 09 02:35:16 2010 -0500 @@ -0,0 +1,31 @@ +/****************************************************************************** +// +// check-sdl-version +// Copyright (c) 2010 Sarah Eris Horsley Caffee +// +******************************************************************************/ + +#include +#include +#include + +int main(int argc, char **argv) + { + SDL_version compiled; + const SDL_version * linked; + SDL_version ttf_compiled; + const SDL_version * ttf_linked; + + printf("\t\t\tCompiled\t\tLinked\n"); + + SDL_VERSION(&compiled); + linked = SDL_Linked_Version(); + printf("SDL version\t\t%d.%d.%d\t\t\t%d.%d.%d\n", compiled.major, compiled.minor, compiled.patch, + linked->major, linked->minor, linked->patch); + + SDL_TTF_VERSION(&ttf_compiled); + ttf_linked = TTF_Linked_Version(); + 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, + ttf_linked->major, ttf_linked->minor, ttf_linked->patch); + + }