# HG changeset patch # User Eris Caffee # Date 1287034975 18000 # Node ID 0aaa058b0994b80037a7d58e676d6b42fef78735 # Parent bacb3b7b582ef0064f239248e6507bf23f8c8692 Version with sdl and sdl_ttf functions. diff -r bacb3b7b582e -r 0aaa058b0994 .hgignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgignore Thu Oct 14 00:42:55 2010 -0500 @@ -0,0 +1,5 @@ +syntax: glob + +build*/* +*~ + diff -r bacb3b7b582e -r 0aaa058b0994 CMakeLists.txt --- a/CMakeLists.txt Sat Oct 09 02:35:16 2010 -0500 +++ b/CMakeLists.txt Thu Oct 14 00:42:55 2010 -0500 @@ -51,9 +51,13 @@ # system wide. + +# Probably not needed, but it may save someone else a headache someday. CMAKE_MINIMUM_REQUIRED (VERSION 2.6) + +# Name your program! SET (App_Name "check-sdl-version") IF (App_Name STREQUAL "") MESSAGE (FATAL_ERROR "You must set the App_Name variable!") @@ -63,6 +67,7 @@ #SET (CMAKE_VERBOSE_MAKEFILE ON) +# Every project must have a name. PROJECT (${App_Name}) @@ -83,20 +88,17 @@ 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 +# Set up the basic build environment +# A build type defines which options are passed to the compiler, and there are +# several that CMake defines by default. It does not set one by default, though +# so we need to set the build type manually here, and we are setting it to the +# generally useful "Release with debug info" IF (CMAKE_BUILD_TYPE STREQUAL "") - # CMake defaults to leaving CMAKE_BUILD_TYPE empty. This screws up + # CMake defaults to leaving CMAKE_BUILD_TYPE empty. This messes 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) + SET (CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE) ENDIF () @@ -106,110 +108,44 @@ FILE (GLOB SRCS src/*.c src/*.cpp) FILE (GLOB HDRS include/*.h include/*.hpp) +# The directories that contain the libraries we will be linking against. +# This must come before the ADD_EXECUTABLE directive. LINK_DIRECTORIES ( ) +# The directories that contain the include files our programs use. +# This must come before the ADD_EXECUTABLE directive. INCLUDE_DIRECTORIES ( ${PROJECT_SOURCE_DIR}/include ) +# Define the executable program file we are creating. We must list all of +# the source files. ADD_EXECUTABLE (${App_Name} ${SRCS} ${HDRS} ) +# Although we listed the library directories above, we also need to list the +# individual libraries we will be linking against. 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. +# extension libraries available as well. +# +# If any of the SDL libraries are not found automatically, you will need +# to set the appropriate environment variables and rerun cmake. You will +# need to remove the CMake cache before doing so. 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. @@ -306,77 +242,3 @@ ################################################################################ - -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 bacb3b7b582e -r 0aaa058b0994 src/main.c --- a/src/main.c Sat Oct 09 02:35:16 2010 -0500 +++ b/src/main.c Thu Oct 14 00:42:55 2010 -0500 @@ -3,6 +3,11 @@ // check-sdl-version // Copyright (c) 2010 Sarah Eris Horsley Caffee // +// Just a quick test program to verify SDL installation and to use as an +// example for learning to use CMake. +// +// This program may be freely copied, distributed, and used for any purpose. +// ******************************************************************************/ #include @@ -26,6 +31,6 @@ 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); + ttf_linked->major, ttf_linked->minor, ttf_linked->patch); }