Quellcode durchsuchen

Use CMake to do os-detection and option setting

Daniele Bartolini vor 13 Jahren
Ursprung
Commit
842bb99bb9
3 geänderte Dateien mit 27 neuen und 71 gelöschten Zeilen
  1. 22 0
      CMakeLists.txt
  2. 0 71
      src/Config.h
  3. 5 0
      src/Config.h.in

+ 22 - 0
CMakeLists.txt

@@ -32,6 +32,7 @@ set (INCLUDES
 include_directories(${INCLUDES})
 include_directories(${INCLUDES})
 add_definitions(-pipe -ansi -W -Wall -Wextra -Wno-long-long -pedantic -fPIC -g -pg)
 add_definitions(-pipe -ansi -W -Wall -Wextra -Wno-long-long -pedantic -fPIC -g -pg)
 
 
+# add build directories
 add_subdirectory(src)
 add_subdirectory(src)
 
 
 if (CROWN_BUILD_TOOLS)
 if (CROWN_BUILD_TOOLS)
@@ -45,3 +46,24 @@ endif (CROWN_BUILD_SAMPLES)
 if (CROWN_BUILD_TESTS)
 if (CROWN_BUILD_TESTS)
 add_subdirectory(tests)
 add_subdirectory(tests)
 endif (CROWN_BUILD_TESTS)
 endif (CROWN_BUILD_TESTS)
+
+# detect operating system
+if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+	set(LINUX 1)
+endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+
+if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
+	set (WINDOWS 1)
+endif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
+
+# set config options
+if (CROWN_BUILD_OPENGL)
+set(CROWN_USE_OPENGL 1)
+endif (CROWN_BUILD_OPENGL)
+
+if (CROWN_BUILD_OPENGLES)
+set(CROWN_USE_OPENGLES 1)
+endif (CROWN_BUILD_OPENGLES)
+
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/src/Config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/Config.h)
+

+ 0 - 71
src/Config.h

@@ -1,71 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-// Check operating system (code borrowed from Qt4)
-#if defined(WIN64) || defined(_WIN64) || defined(__WIN64__) || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
-	// The operating system is Windows
-	#define WINDOWS
-#elif defined(__linux__) || defined(__linux)
-	// The operating system is Linux
-	#define LINUX
-#else
-	#error "Can't detect operating system"
-#endif
-
-#ifdef WINDOWS
-#ifndef _CRT_SECURE_NO_WARNINGS
-#define _CRT_SECURE_NO_WARNINGS	//To suppress safe clr function warnings (Es: strcpy -> strcpy_s
-#endif
-#endif
-
-//#define CROWN_OS_ANDROID
-
-// Debug mode
-// #define DEBUG
-
-/*
-	Renderer settings.
-
-	Here you choose which renderer to use for drawing
-	things to screen. Uncomment your preferred renderer
-	to choose it.
-
-	Note that only _one_ renderer can be chosen at a time.
-
-	Note also that:
-	a) you can choose OpenGL if and only if you are on
-	   a Linux or Windows machine.
-	b) you can choose OpenGL|ES if and only if you are
-	   on a Linux or Android machine.
-*/
-#define CROWN_USE_OPENGL		//!< Whether to build with OpenGL
-//#define CROWN_USE_OPENGLES		//!< Whether to build with OpenGL|ES
-
-//#define CROWN_USE_WINDOWING	//!< Whether to build with windowing
-
-#define CROWN_USE_FLOAT
-

+ 5 - 0
src/Config.h.in

@@ -0,0 +1,5 @@
+#cmakedefine LINUX
+#cmakedefine WINDOWS
+#cmakedefine CROWN_USE_OPENGL
+#cmakedefine CROWN_USE_OPENGLES
+#cmakedefine CROWN_USE_FLOAT