view CMakeLists.txt @ 14:3cf740339643

Removed executable permissions from CMakeLists.txt
author Eris Caffee <discordia@eldalin.com>
date Sat, 20 Nov 2010 02:12:01 -0600
parents 6fe9214af151
children bdfe3327f4ce
line source
1 ###############################################################################
2 #
3 # A generalized cmake file for developing cross-platform games.
4 #
5 # Copyright (C) 2010 Sarah Eris Horsley Caffee
6 #
7 # This file is part of Fracter.
8 #
9 # Fracter is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #
22 #
23 # Instructions:
24 # This cmake file assumes that your source files are laid in out in the
25 # following manner:
26 #
27 # project_dir\ Top level directory of the project.
28 # |---include\ Header files are here.
29 # |---src\ Source files are here.
30 # |---build\ Binaries/objects go here. Run cmake from here.
31 # !---cmake\
32 # | |---modules\ Custom cmake include files, if any, go here.
33 # |---CMakeLists.txt This file.
34 #
35 # You may have more directories, of course, but these are assumed. You probably
36 # want more than one build directory. I normally have build-linux\
37 # and build-windows\ directories.
38 #
39 # Set the App_Name variable, below, to the name of your application and you
40 # are ready to start. Run ccmake, or cmake-gui from within your build
41 # directory, choose the options you need, such as enabling SDL, and you
42 # should be good to go.
43 #
44 # You can uncomment the "SET (CMAKE_VERBOSE_MAKEFILE ON) command if you
45 # need to debug the actual makefile that is generated.
46 #
47 # On windows, you may need to set the SDLDIR environment variable to the location
48 # of your SDL installation before you run cmake-gui.
49 #
50 # When writing path names on Windows, such as when manually specifiying a
51 # file or directory name, either use unix-style forward slashes '/' in the
52 # path names or use double backslashes. If you use a single backslash as the
53 # path name seperator, then cmake will interpret it as an esacpe sequence.
54 # Thus, write "C:/source" or "C:\\source" instead of "C:\source". It's
55 # probably best to use forward slashes in case to ever have a situation
56 # where cmake needs to do recursive processing: each level of cmake will
57 # strip out one of the slashes, so if there are two lev3els of cmake you
58 # need to write \\\, three levels requires \\\\, etc.
59 #
60 # Note that some of the cmake support scripts that find libraries for you
61 # can be controlled by environment variables. For example, you can set the
62 # SDLDIR environment variable before running cmake in order to point to
63 # a different version of SDL than your systems default copy. This is useful
64 # for trying out cutting edge versions of libraries without installing them
65 # system wide.
67 cmake_minimum_required (VERSION 2.6 FATAL_ERROR)
68 #set (CMAKE_VERBOSE_MAKEFILE ON)
70 # Name your program!
71 set (App_Name "fracter")
72 if (App_Name STREQUAL "")
73 message (FATAL_ERROR "You must set the App_Name variable!")
74 endif ()
76 # Every project must have a name.
77 project (${App_Name})
80 ################################################################################
81 # Ensure that we are not building in our source directories.
83 set (Build_Dir_OK "TRUE")
84 string (REGEX MATCH "^${CMAKE_SOURCE_DIR}" In_Sub_Dir ${CMAKE_BINARY_DIR})
85 if (In_Sub_Dir)
86 string (REGEX MATCH "^${CMAKE_SOURCE_DIR}/build" In_Build_Dir ${CMAKE_BINARY_DIR})
87 if (NOT In_Build_Dir)
88 set (Build_Dir_OK "FALSE")
89 endif ()
90 endif ()
92 if (NOT Build_Dir_OK)
93 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'.")
94 endif ()
97 ################################################################################
98 # Set up the basic build environment
99 # A build type defines which options are passed to the compiler, and there are
100 # several that CMake defines by default. It does not set one by default, though
101 # so we need to set the build type manually here, and we are setting it to the
102 # generally useful "Release with debug info"
104 if (CMAKE_BUILD_TYPE STREQUAL "")
105 # CMake defaults to leaving CMAKE_BUILD_TYPE empty. This messes up
106 # differentiation between debug and release builds.
107 set (CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
108 endif ()
112 ################################################################################
113 # When using GCC turn on lots of warnings.
115 if (CMAKE_COMPILER_IS_GNUCXX)
116 add_definitions(-pedantic -Wall -Weffc++)
117 endif ()
120 ################################################################################
122 option(Option_Profile_Program "Build for gprof profiling." OFF)
123 if (Option_Profile_Program)
124 add_definitions(-pg)
125 set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
126 endif ()
129 ################################################################################
130 # The core project files
132 file (GLOB SRCS src/*.c src/*.cpp)
133 file (GLOB HDRS include/*.h include/*.hpp)
135 # The directories that contain the libraries we will be linking against.
136 # This must come before the ADD_EXECUTABLE directive.
137 link_directories (
138 )
140 # The directories that contain the include files our programs use.
141 # This must come before the ADD_EXECUTABLE directive.
142 include_directories (
143 ${CMAKE_SOURCE_DIR}/include
144 )
146 # Define the executable program file we are creating. We must list all of
147 # the source files.
148 if (WIN32)
149 add_executable (${App_Name} WIN32
150 ${SRCS}
151 ${HDRS}
152 )
153 else ()
154 add_executable (${App_Name}
155 ${SRCS}
156 ${HDRS}
157 )
158 endif ()
160 # Although we listed the library directories above, we also need to list the
161 # individual libraries we will be linking against.
162 target_link_libraries (${App_Name}
163 )
166 ################################################################################
167 # SDL Support
168 #
169 # Enabling SDL support enables several suboptions to make some common SDL
170 # extension libraries available as well.
171 #
172 # If any of the SDL libraries are not found automatically, you will need
173 # to set the appropriate environment variables and rerun cmake. You will
174 # need to remove the CMake cache before doing so.
176 # If you don't want to set actual environment variables before running
177 # CMake, then uncomment the if block below and put in the actual
178 # locations of your SDL installation.
180 if (WIN32)
181 set (ENV{SDLDIR} "c:/gamedev/deps/sdl/SDL-1.2.14")
182 endif ()
184 option(Option_SDL_Dev "Build an SDL application." ON)
186 if (Option_SDL_Dev)
188 # SDL base package
189 # To use a version of SDL other than your systems default, set the SDLDIR
190 # environment variable to the installation location of your preferred version.
191 find_package (SDL)
192 if (NOT SDL_FOUND)
193 message (FATAL_ERROR "SDL not found!")
194 endif (NOT SDL_FOUND)
195 include_directories(
196 ${SDL_INCLUDE_DIR}
197 ${INCLUDE_DIRECTORIES}
198 )
199 target_link_libraries(${App_Name}
200 ${SDL_LIBRARY}
201 ${TARGET_LINK_LIBRARIES}
202 )
204 endif (Option_SDL_Dev)
207 ################################################################################