nomlib
Loading...
Searching...
No Matches
config.hpp
1/******************************************************************************
2
3 nomlib - C++11 cross-platform game engine
4
5Copyright (c) 2013, 2014 Jeffrey Carpenter <i8degrees@gmail.com>
6All rights reserved.
7
8Redistribution and use in source and binary forms, with or without
9modification, are permitted provided that the following conditions are met:
10
111. Redistributions of source code must retain the above copyright notice, this
12 list of conditions and the following disclaimer.
132. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation
15 and/or other materials provided with the distribution.
16
17THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28******************************************************************************/
29
30// This file is auto-generated by CMake at build time; modifications to this
31// file *MUST* be done to config.hpp.in, located in the project's cmake
32// templates directory.
33//
34// Any modifications made to this file will be replaced upon a project
35// rebuild -- anytime CMake re-generates our project files.
36
37#ifndef NOMLIB_CORE_CONFIG_HPP
38#define NOMLIB_CORE_CONFIG_HPP
39
40// Debugging
41#include <iostream>
42#include <string.h> // __FILE__ macro post-processing
43
44// Shortened __FILE__ utility macro
45//
46// TODO: I'd like to see this integrated into the SDL2Logger interface!
47#define NOM_FILE \
48 ( strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__ )
49
51#define NOM_USE_SDL2_ASSERT
52
53// Include SDL2's enhanced assert facility if enabled, otherwise fall-back to
54// standard C assert facility.
55#if defined( NOM_USE_SDL2_ASSERT ) // See cmake/platform.cmake
56 #include <SDL_assert.h>
57#else
58 #include <cassert>
59#endif
60
61// nomlib's platform detection
62#include "nomlib/platforms.hpp"
63
64// nomlib's standard integer types
65#include "nomlib/types.hpp"
66
67#include "nomlib/core/SDL2Logger.hpp"
68
69// nomlib's general-purpose macros
70#include "nomlib/macros.hpp"
71
85#define NOM_LOG_MESSAGE( cat, prio, ... ) \
86 { nom::SDL2Logger( cat, prio ).write( __VA_ARGS__ ); }
87
94#if defined( NOM_DEBUG )
95 #define NOM_LOG_VERBOSE( cat, ... ) \
96 NOM_LOG_MESSAGE( cat, nom::LogPriority::NOM_LOG_PRIORITY_VERBOSE, "[", NOM_FILE, ":", __LINE__, "]", __VA_ARGS__ );
97#else
98 #define NOM_LOG_VERBOSE( cat, ... ) \
99 NOM_LOG_MESSAGE( cat, nom::LogPriority::NOM_LOG_PRIORITY_VERBOSE, __VA_ARGS__ );
100#endif
101
108#if defined( NOM_DEBUG )
109 #define NOM_LOG_DEBUG( cat, ... ) \
110 NOM_LOG_MESSAGE( cat, nom::LogPriority::NOM_LOG_PRIORITY_DEBUG, "[", NOM_FILE, ":", __LINE__, "]", __VA_ARGS__ );
111#else
112 #define NOM_LOG_DEBUG( cat, ... ) \
113 NOM_LOG_MESSAGE( cat, nom::LogPriority::NOM_LOG_PRIORITY_DEBUG, __VA_ARGS__ );
114#endif
115
122#define NOM_LOG_INFO( cat, ... ) \
123 NOM_LOG_MESSAGE( cat, nom::LogPriority::NOM_LOG_PRIORITY_INFO, __VA_ARGS__ );
124
131#if defined( NOM_DEBUG )
132 #define NOM_LOG_WARN( cat, ... ) \
133 NOM_LOG_MESSAGE( cat, nom::LogPriority::NOM_LOG_PRIORITY_WARN, "[", NOM_FILE, ":", __LINE__, "]", __VA_ARGS__ );
134#else
135 #define NOM_LOG_WARN( cat, ... ) \
136 NOM_LOG_MESSAGE( cat, nom::LogPriority::NOM_LOG_PRIORITY_WARN, __VA_ARGS__ );
137#endif
138
145#if defined( NOM_DEBUG )
146 #define NOM_LOG_ERR( cat, ... ) \
147 NOM_LOG_MESSAGE( cat, nom::LogPriority::NOM_LOG_PRIORITY_ERROR, "[", NOM_FILE, ":", __LINE__, "]", __VA_ARGS__ );
148#else
149 #define NOM_LOG_ERR( cat, ... ) \
150 NOM_LOG_MESSAGE( cat, nom::LogPriority::NOM_LOG_PRIORITY_ERROR, __VA_ARGS__ );
151#endif
152
159#if defined( NOM_DEBUG )
160 #define NOM_LOG_CRIT( cat, ... ) \
161 NOM_LOG_MESSAGE( cat, nom::LogPriority::NOM_LOG_PRIORITY_CRITICAL, "[", NOM_FILE, ":", __LINE__, "]", __VA_ARGS__ );
162#else
163 #define NOM_LOG_CRIT( cat, ... ) \
164 NOM_LOG_MESSAGE( cat, nom::LogPriority::NOM_LOG_PRIORITY_CRITICAL, __VA_ARGS__ );
165#endif
166
173#define NOM_DUMP( var ) \
174 NOM_LOG_MESSAGE( NOM, nom::LogPriority::NOM_LOG_PRIORITY_DEBUG, "[", NOM_FILE, ":", __LINE__, "]", #var, ":", var );
175
184#define NOM_DUMP_VAR( cat, ... ) \
185 NOM_LOG_MESSAGE( cat, nom::LogPriority::NOM_LOG_PRIORITY_DEBUG, "[", NOM_FILE, ":", __LINE__, "]", __VA_ARGS__ );
186
191#define NOM_LOG_TRACE( cat ) \
192 NOM_LOG_MESSAGE( cat, nom::LogPriority::NOM_LOG_PRIORITY_DEBUG, NOM_FUNC );
193
201#define NOM_LOG_TRACE_PRIO( cat, prio ) \
202 NOM_LOG_MESSAGE( cat, prio, NOM_FUNC );
203
204#define NOM_STUBBED( cat ) \
205 NOM_LOG_MESSAGE( cat, nom::LogPriority::NOM_LOG_PRIORITY_INFO, "Stubbed function", NOM_FUNC, "was called" );
206
207#ifdef NOM_DEBUG_ASSERT // -D NOM_DEBUG_ASSERT=on
208
209 // Use SDL2's enhanced assert macro if available, otherwise fall-back to
210 // standard C assert.
211 #if defined( NOM_USE_SDL2_ASSERT )
212 #define NOM_ASSERT(expression) SDL_assert(expression)
213 #else
214 #define NOM_ASSERT(expression) \
215 ( assert (expression) )
216 #endif // defined( NOM_USE_SDL2_ASSERT )
217
218#else // Do not add any overhead
219 #define NOM_ASSERT(expression) // NO-OP
220#endif // defined( NOM_DEBUG_ASSERT )
221
222#define NOM_ASSERT_INVALID_PATH(reserved) \
223 NOM_ASSERT(!"Invalid execution path assertion triggered")
224
225#if defined(NOM_COMPILER_CLANG)
226 // SOURCE: http://clang.llvm.org/docs/UsersManual.html#controlling-diagnostics-via-pragmas
227 #define NOM_PRAGMA_STR(msg) #msg
228 #define NOM_PRAGMA_DEFER(arg, ...) arg(__VA_ARGS__)
229 #define NOM_PRAGMA_ERROR(msg) \
230 _Pragma(NOM_PRAGMA_STR(GCC error(msg " in " \
231 NOM_PRAGMA_DEFER(NOM_PRAGMA_STR, __FILE__) \
232 ":" NOM_PRAGMA_DEFER(NOM_PRAGMA_STR,__LINE__) )))
233#else
234 // NO OPCODE defined
235 #define NOM_PRAGMA_STR(msg)
236 #define NOM_PRAGMA_DEFER(arg, ...)
237 #define NOM_PRAGMA_ERROR(msg)
238#endif
239
240#ifndef __cplusplus
241 NOM_PRAGMA_ERROR("nomlib requires a C++11 capable compiler.")
242#endif
243
249#if defined(NOM_DEBUG) && defined(NOM_COMPILER_CLANG)
250
260 #define NOM_IGNORED_VARS(expr) \
261 _Pragma("clang diagnostic push") \
262 _Pragma("clang diagnostic ignored \"-Wunused\"" )
263
265 #define NOM_IGNORED_VARS_ENDL(expr) \
266 _Pragma("clang diagnostic pop")
267
269 #define NOM_IGNORED_ENDL(expr) NOM_IGNORED_VARS_ENDL(expr)
270
271#else // Ignoring of compiler generated warning messages is not supported
272
273 #define NOM_IGNORED_VARS()
274 #define NOM_IGNORED_ENDL()
275 #define NOM_IGNORED_VARS_ENDL()
276
277#endif // defined(NOM_DEBUG) && defined(NOM_COMPILER_CLANG)
278
279// NOTE(jeff): See src/CMakeLists.txt for declarations
280
281// Image loader
282#define NOM_USE_SDL2_IMAGE TRUE
283
284// Font loader
285#define NOM_USE_SDL2_TTF TRUE
286
287// Audio
288/* #undef NOM_USE_CREATIVE_OPENAL */
289/* #undef NOM_USE_APPLE_OPENAL */
290/* #undef NOM_USE_OPENAL_SOFT */
291
292#if defined(NOM_USE_CREATIVE_OPENAL) || defined(NOM_USE_APPLE_OPENAL) || \
293 defined(NOM_USE_OPENAL_SOFT)
294 #define NOM_USE_OPENAL
295#endif
296
297#if defined NOM_BUILD_AUDIO_UNIT
298 #ifndef NOM_USE_OPENAL
299 // One of the above variables must be set in src/CMakeLists.txt
300 NOM_PRAGMA_ERROR("Audio Unit: One of the OpenAL audio engines must be selected")
301 #endif
302#endif
303
304/* #undef NOM_USE_LIBSNDFILE */
305
306// High-quality rescaling algorithms for low-resolution sprites
307// (i.e.: pixel art)
308#define NOM_USE_SCALEX TRUE
309#define NOM_USE_HQX TRUE
310
311#define NOM_USE_LIBROCKET TRUE
312/* #undef NOM_USE_LIBROCKET_LUA */
313
314#endif // include guard defined