Mercurial > solar_system
changeset 0:6b163267bd3e
Initial import
author | Eris Caffee <discordia@eldalin.com> |
---|---|
date | Wed, 29 Dec 2010 02:43:17 -0600 |
parents | |
children | 9c54994a2635 |
files | .hgignore CMakeLists.txt |
diffstat | 2 files changed, 445 insertions(+), 0 deletions(-) [+] |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/.hgignore Wed Dec 29 02:43:17 2010 -0600 1.3 @@ -0,0 +1,5 @@ 1.4 +syntax: glob 1.5 + 1.6 +build*/* 1.7 +*~ 1.8 +
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/CMakeLists.txt Wed Dec 29 02:43:17 2010 -0600 2.3 @@ -0,0 +1,440 @@ 2.4 +############################################################################### 2.5 +# 2.6 +# A generalized cmake file for developing cross-platform games. 2.7 +# 2.8 +# Copyright (C) 2010 Sarah Eris Horsley Caffee 2.9 +# 2.10 +# This is free software: you can redistribute it and/or modify 2.11 +# it under the terms of the GNU General Public License as published by 2.12 +# the Free Software Foundation, either version 3 of the License, or 2.13 +# (at your option) any later version. 2.14 +# 2.15 +# This program is distributed in the hope that it will be useful, 2.16 +# but WITHOUT ANY WARRANTY; without even the implied warranty of 2.17 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 2.18 +# GNU General Public License for more details. 2.19 +# 2.20 +# You should have received a copy of the GNU General Public License 2.21 +# along with this program. If not, see <http://www.gnu.org/licenses/>. 2.22 +# 2.23 +# 2.24 +# Instructions: 2.25 +# This cmake file assumes that your source files are laid in out in the 2.26 +# following manner: 2.27 +# 2.28 +# project_dir\ Top level directory of the project. 2.29 +# |---include\ Header files are here. 2.30 +# |---src\ Source files are here. 2.31 +# |---build\ Binaries/objects go here. Run cmake from here. 2.32 +# !---cmake\ 2.33 +# | |---modules\ Custom cmake include files, if any, go here. 2.34 +# |---CMakeLists.txt This file. 2.35 +# 2.36 +# You may have more directories, of course, but these are assumed. You probably 2.37 +# want more than one build directory. I normally have build-linux\ 2.38 +# and build-windows\ directories. 2.39 +# 2.40 +# Set the App_Name variable, below, to the name of your application and you 2.41 +# are ready to start. Run ccmake, or cmake-gui from within your build 2.42 +# directory, choose the options you need, such as enabling SDL, and you 2.43 +# should be good to go. 2.44 +# 2.45 +# You can uncomment the "SET (CMAKE_VERBOSE_MAKEFILE ON) command if you 2.46 +# need to debug the actual makefile that is generated. 2.47 +# 2.48 +# On windows, you may need to set the SDLDIR environment variable to the location 2.49 +# of your SDL installation before you run cmake-gui. 2.50 +# 2.51 +# When writing path names on Windows, such as when manually specifiying a 2.52 +# file or directory name, either use unix-style forward slashes '/' in the 2.53 +# path names or use double backslashes. If you use a single backslash as the 2.54 +# path name seperator, then cmake will interpret it as an esacpe sequence. 2.55 +# Thus, write "C:/source" or "C:\\source" instead of "C:\source". It's 2.56 +# probably best to use forward slashes in case to ever have a situation 2.57 +# where cmake needs to do recursive processing: each level of cmake will 2.58 +# strip out one of the slashes, so if there are two lev3els of cmake you 2.59 +# need to write \\\, three levels requires \\\\, etc. 2.60 +# 2.61 +# Note that some of the cmake support scripts that find libraries for you 2.62 +# can be controlled by environment variables. For example, you can set the 2.63 +# SDLDIR environment variable before running cmake in order to point to 2.64 +# a different version of SDL than your systems default copy. This is useful 2.65 +# for trying out cutting edge versions of libraries without installing them 2.66 +# system wide. 2.67 + 2.68 +cmake_minimum_required (VERSION 2.6 FATAL_ERROR) 2.69 +#set (CMAKE_VERBOSE_MAKEFILE ON) 2.70 + 2.71 +# Name your program! 2.72 +set (App_Name "") 2.73 +if (App_Name STREQUAL "") 2.74 + message (FATAL_ERROR "You must set the App_Name variable!") 2.75 +endif () 2.76 + 2.77 +# Every project must have a name. 2.78 +project (${App_Name}) 2.79 + 2.80 + 2.81 +################################################################################ 2.82 +# Special options 2.83 + 2.84 + 2.85 +################################################################################ 2.86 +# Ensure that we are not building in our source directories. 2.87 + 2.88 +set (Build_Dir_OK "TRUE") 2.89 +string (REGEX MATCH "^${CMAKE_SOURCE_DIR}" In_Sub_Dir ${CMAKE_BINARY_DIR}) 2.90 +if (In_Sub_Dir) 2.91 + string (REGEX MATCH "^${CMAKE_SOURCE_DIR}/build" In_Build_Dir ${CMAKE_BINARY_DIR}) 2.92 + if (NOT In_Build_Dir) 2.93 + set (Build_Dir_OK "FALSE") 2.94 + endif () 2.95 +endif () 2.96 + 2.97 +if (NOT Build_Dir_OK) 2.98 + 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'.") 2.99 +endif () 2.100 + 2.101 + 2.102 +################################################################################ 2.103 +# Set up the basic build environment 2.104 +# A build type defines which options are passed to the compiler, and there are 2.105 +# several that CMake defines by default. It does not set one by default, though 2.106 +# so we need to set the build type manually here, and we are setting it to the 2.107 +# generally useful "Release with debug info" 2.108 + 2.109 +if (CMAKE_BUILD_TYPE STREQUAL "") 2.110 + # CMake defaults to leaving CMAKE_BUILD_TYPE empty. This messes up 2.111 + # differentiation between debug and release builds. 2.112 + set (CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE) 2.113 +endif () 2.114 + 2.115 + 2.116 +################################################################################ 2.117 +# When using GCC turn on lots of warnings. 2.118 +# Some other options to consider: 2.119 +# C++ -Weffc++ 2.120 +# C -std=gnu99 -std=c99 2.121 + 2.122 +if (CMAKE_COMPILER_IS_GNUCXX) 2.123 + add_definitions(-pedantic -Wall) 2.124 +endif () 2.125 + 2.126 + 2.127 +################################################################################ 2.128 + 2.129 +option(Option_Profile_Program "Build for gprof profiling." OFF) 2.130 +if (Option_Profile_Program) 2.131 + add_definitions(-pg) 2.132 + set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg") 2.133 +endif () 2.134 + 2.135 + 2.136 +################################################################################ 2.137 +# The core project files 2.138 + 2.139 +file (GLOB SRCS src/*.c src/*.cpp) 2.140 +file (GLOB HDRS include/*.h include/*.hpp) 2.141 + 2.142 +# The directories that contain the libraries we will be linking against. 2.143 +# This must come before the ADD_EXECUTABLE directive. 2.144 +link_directories ( 2.145 + ) 2.146 + 2.147 +# The directories that contain the include files our programs use. 2.148 +# This must come before the ADD_EXECUTABLE directive. 2.149 +include_directories ( 2.150 + ${CMAKE_SOURCE_DIR}/include 2.151 + ) 2.152 + 2.153 +# Define the executable program file we are creating. We must list all of 2.154 +# the source files. 2.155 +if (WIN32) 2.156 + add_executable (${App_Name} WIN32 2.157 + ${SRCS} 2.158 + ${HDRS} 2.159 + ) 2.160 +else () 2.161 + add_executable (${App_Name} 2.162 + ${SRCS} 2.163 + ${HDRS} 2.164 + ) 2.165 +endif () 2.166 + 2.167 +# Although we listed the library directories above, we also need to list the 2.168 +# individual libraries we will be linking against. 2.169 +target_link_libraries (${App_Name} 2.170 +) 2.171 + 2.172 + 2.173 +# # An example for a unix library named utils with a test driver program. 2.174 + 2.175 +# set (SRCS_utils 2.176 +# src/utils.cpp 2.177 +# include/utils.h 2.178 +# ) 2.179 + 2.180 +# include_directories ( 2.181 +# ${PROJECT_SOURCE_DIR}/include 2.182 +# ) 2.183 + 2.184 +# # Build both static and shared libraries 2.185 +# # The target properties are needed because, by default, the output name 2.186 +# # will be the name in the add_library command, and we need to have different 2.187 +# # names in the two commands for the shared and static versions, even though 2.188 +# # we want the final files to have the same names with different extensions. 2.189 +# # 2.190 +# # The prefix is needed mostly in case we build on windows, which has no prefix 2.191 +# # by default. 2.192 +# # 2.193 +# # The clean_direct_output option makes sure that the two lib builds don't 2.194 +# # clobber each others temp files since they are being built from the same 2.195 +# # sources. 2.196 + 2.197 +# add_library (utils SHARED 2.198 +# ${SRCS_utils} 2.199 +# ) 2.200 +# set_target_properties (utils PROPERTIES OUTPUT_NAME "utils") 2.201 +# set_target_properties (utils PROPERTIES PREFIX "lib") 2.202 +# set_target_properties (utils PROPERTIES CLEAN_DIRECT_OUTPUT 1) 2.203 + 2.204 +# add_library (utils-static STATIC 2.205 +# ${SRCS_utils} 2.206 +# ) 2.207 +# set_target_properties (utils-static PROPERTIES OUTPUT_NAME "utils") 2.208 +# set_target_properties (utils-static PROPERTIES PREFIX "lib") 2.209 +# set_target_properties (utils-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) 2.210 + 2.211 +# # Build a test application. 2.212 + 2.213 +# add_executable (test 2.214 +# src/main.cpp 2.215 +# ) 2.216 + 2.217 +# target_link_libraries (test 2.218 +# utils 2.219 +# ) 2.220 + 2.221 + 2.222 +################################################################################ 2.223 +# X11 2.224 +# 2.225 +# Note that the FindX11.cmake package does _not_ include most X extensions 2.226 +# in the X11_LIBRARIES variable, although it does pick up their header files 2.227 +# in the X11_INCLUDE_DIR variable. 2.228 +# 2.229 +# To link a program with extensions, such as Xrandr, or Xv, you must manually 2.230 +# update the target_link_libraries to include the appropriate library variable. 2.231 +# ${X11_Xrandr_LIB} is an example. See the FindX11.cmake file for a complete 2.232 +# list of availble variables. 2.233 +# 2.234 + 2.235 +option(Option_X11_Dev "Build an X11 Application." OFF) 2.236 + 2.237 +if (Option_X11_Dev) 2.238 + 2.239 + option(Option_Xrandr "Use Xrandr" OFF) 2.240 + option(Option_Xinerama "Use Xinerama" OFF) 2.241 + 2.242 + 2.243 + ######################################## 2.244 + find_package(X11) 2.245 + if (NOT X11_FOUND) 2.246 + message (FATAL_ERROR "X11 not found!") 2.247 + endif () 2.248 + 2.249 + include_directories( 2.250 + ${X11_INCLUDE_DIR} 2.251 + ${INCLUDE_DIRECTORIES} 2.252 + ) 2.253 + 2.254 + target_link_libraries(${App_Name} 2.255 + ${X11_LIBRARIES} 2.256 + ${TARGET_LINK_LIBRARIES} 2.257 + ) 2.258 + 2.259 + ######################################## 2.260 + if (Option_Xrandr) 2.261 + if (NOT X11_Xrandr_FOUND) 2.262 + message (FATAL_ERRO "Xrandr not found!") 2.263 + endif () 2.264 + target_link_libraries(${App_Name} 2.265 + ${X11_Xrandr_LIB} 2.266 + ${TARGET_LINK_LIBRARIES} 2.267 + ) 2.268 + endif () 2.269 + 2.270 + ######################################## 2.271 + if (Option_Xinerama) 2.272 + if (NOT X11_Xinerama_FOUND) 2.273 + message (FATAL_ERRO "Xinerama not found!") 2.274 + endif () 2.275 + target_link_libraries(${App_Name} 2.276 + ${X11_Xinerama_LIB} 2.277 + ${TARGET_LINK_LIBRARIES} 2.278 + ) 2.279 + endif () 2.280 + 2.281 +endif () 2.282 + 2.283 +################################################################################ 2.284 +# SDL 2.285 +# 2.286 +# Enabling SDL support enables several suboptions to make some common SDL 2.287 +# extension libraries available as well. 2.288 +# 2.289 +# If any of the SDL libraries are not found automatically, you will need 2.290 +# to set the appropriate environment variables and rerun cmake. You will 2.291 +# need to remove the CMake cache before doing so. 2.292 + 2.293 +# If you don't want to set actual environment variables before running 2.294 +# CMake, then uncomment the if block below and put in the actual 2.295 +# locations of your SDL installation. 2.296 + 2.297 +option(Option_SDL_Dev "Build an SDL application." OFF) 2.298 + 2.299 +if (Option_SDL_Dev) 2.300 + 2.301 + # # Force SDL 1.3 only 2.302 + # if (WIN32) 2.303 + # set (ENV{SDLDIR} "c:/gamedev/deps/sdl/SDL-build") 2.304 + # else () 2.305 + # set (ENV{SDLDIR} "/home/eris/gamedev/deps/sdl/SDL-build") 2.306 + # endif () 2.307 + # add_definitions(-DSDL_NO_COMPAT) 2.308 + 2.309 + # SDL base package 2.310 + # To use a version of SDL other than your systems default, set the SDLDIR 2.311 + # environment variable to the installation location of your preferred version. 2.312 + find_package (SDL) 2.313 + if (NOT SDL_FOUND) 2.314 + message (FATAL_ERROR "SDL not found!") 2.315 + endif (NOT SDL_FOUND) 2.316 + include_directories( 2.317 + ${SDL_INCLUDE_DIR} 2.318 + ${INCLUDE_DIRECTORIES} 2.319 + ) 2.320 + target_link_libraries(${App_Name} 2.321 + ${SDL_LIBRARY} 2.322 + ${TARGET_LINK_LIBRARIES} 2.323 + ) 2.324 + 2.325 + # SDL_ttf 2.326 + # Environment variables SDLTTFDIR and SDLDIR will be checked in that order 2.327 + # and if set cmake will try to find SDL_ttf in the specified directory. 2.328 + option(Option_SDL_Dev_SDL_ttf "Use SDL_ttf." OFF) 2.329 + if (Option_SDL_Dev_SDL_ttf) 2.330 + find_package (SDL_ttf) 2.331 + if (NOT SDLTTF_FOUND) 2.332 + message (FATAL_ERROR "SDL_ttf not found!") 2.333 + endif (NOT SDLTTF_FOUND) 2.334 + include_directories( 2.335 + ${SDLTTF_INCLUDE_DIR} 2.336 + ${INCLUDE_DIRECTORIES} 2.337 + ) 2.338 + target_link_libraries(${App_Name} 2.339 + ${SDLTTF_LIBRARY} 2.340 + ${TARGET_LINK_LIBRARIES} 2.341 + ) 2.342 + endif () 2.343 + 2.344 + # SDL_image 2.345 + # Environment variables SDLIMAGEDIR and SDLDIR will be checked in that order 2.346 + # and if set cmake will try to find SDL_image in the specified directory. 2.347 + option(Option_SDL_Dev_SDL_image "Use SDL_image." OFF) 2.348 + if (Option_SDL_Dev_SDL_image) 2.349 + find_package (SDL_image) 2.350 + if (NOT SDLIMAGE_FOUND) 2.351 + message (FATAL_ERROR "SDL_image not found!") 2.352 + endif (NOT SDLIMAGE_FOUND) 2.353 + include_directories( 2.354 + ${SDLIMAGE_INCLUDE_DIR} 2.355 + ${INCLUDE_DIRECTORIES} 2.356 + ) 2.357 + target_link_libraries(${App_Name} 2.358 + ${SDLIMAGE_LIBRARY} 2.359 + ${TARGET_LINK_LIBRARIES} 2.360 + ) 2.361 + endif () 2.362 + 2.363 + # SDL_mixer 2.364 + # Environment variables SDLMIXERDIR and SDLDIR will be checked in that order 2.365 + # and if set cmake will try to find SDL_mixer in the specified directory. 2.366 + option(Option_SDL_Dev_SDL_mixer "Use SDL_mixer." OFF) 2.367 + if (Option_SDL_Dev_SDL_mixer) 2.368 + find_package (SDL_mixer) 2.369 + if (NOT SDLMIXER_FOUND) 2.370 + message (FATAL_ERROR "SDL_mixer not found!") 2.371 + endif (NOT SDLMIXER_FOUND) 2.372 + include_directories( 2.373 + ${SDLMIXER_INCLUDE_DIR} 2.374 + ${INCLUDE_DIRECTORIES} 2.375 + ) 2.376 + target_link_libraries(${App_Name} 2.377 + ${SDLMIXER_LIBRARY} 2.378 + ${TARGET_LINK_LIBRARIES} 2.379 + ) 2.380 + endif () 2.381 + 2.382 + # SDL_net 2.383 + # Environment variables SDLNETDIR and SDLDIR will be checked in that order 2.384 + # and if set cmake will try to find SDL_net in the specified directory. 2.385 + option(Option_SDL_Dev_SDL_net "Use SDL_net." OFF) 2.386 + if (Option_SDL_Dev_SDL_net) 2.387 + find_package (SDL_net) 2.388 + if (NOT SDLNET_FOUND) 2.389 + message (FATAL_ERROR "SDL_net not found!") 2.390 + endif (NOT SDLNET_FOUND) 2.391 + include_directories( 2.392 + ${SDLNET_INCLUDE_DIR} 2.393 + ${INCLUDE_DIRECTORIES} 2.394 + ) 2.395 + target_link_libraries(${App_Name} 2.396 + ${SDLNET_LIBRARY} 2.397 + ${TARGET_LINK_LIBRARIES} 2.398 + ) 2.399 + endif () 2.400 + 2.401 +endif (Option_SDL_Dev) 2.402 + 2.403 + 2.404 +################################################################################ 2.405 + 2.406 +option(Option_OpenGL_Dev "Build an OpenGL Application." OFF) 2.407 + 2.408 +if (Option_OpenGL_Dev) 2.409 + 2.410 + find_package(OpenGL) 2.411 + 2.412 + include_directories( 2.413 + ${OpenGL_INCLUDE_DIR} 2.414 + ${INCLUDE_DIRECTORIES} 2.415 + ) 2.416 + 2.417 + target_link_libraries(${App_Name} 2.418 + ${OpenGL_LIBRARIES} 2.419 + ${TARGET_LINK_LIBRARIES} 2.420 + ) 2.421 + 2.422 +endif () 2.423 + 2.424 +################################################################################ 2.425 + 2.426 +option(Option_OpenAL_Dev "Build an OpenAL Application." OFF) 2.427 + 2.428 +if (Option_OpenAL_Dev) 2.429 + find_package(OpenAL) 2.430 + 2.431 + include_directories( 2.432 + ${OpenAL_INCLUDE_DIR} 2.433 + ${INCLUDE_DIRECTORIES} 2.434 + ) 2.435 + 2.436 + target_link_libraries(${App_Name} 2.437 + ${OpenAL_LIBRARIES} 2.438 + ${TARGET_LINK_LIBRARIES} 2.439 + ) 2.440 + 2.441 +endif () 2.442 + 2.443 +################################################################################