Browse Source

Added CMake project (only tested on Linux with GNU make)
Added STATIC_LIB define to enable compilation as a static library
Fixed Linux compilation

Lloyd Weehuizen 15 years ago
parent
commit
f54fd9226e

+ 32 - 0
Build/CMakeLists.txt

@@ -0,0 +1,32 @@
+cmake_minimum_required(VERSION 2.6)
+
+project(libRocket)
+
+# Set up build options
+option(STATIC_LIB "Build the libRocket using static libraries." OFF)
+set(FREETYPE_INCLUDE "/usr/include/freetype2" CACHE STRING "Path to freetype")
+
+# Configure shared/static libraries
+if(STATIC_LIB)
+	set(LIBRARY_TYPE STATIC)
+	add_definitions(-DSTATIC_LIB)
+else(STATIC_LIB)
+	set(LIBRARY_TYPE SHARED)
+endif(STATIC_LIB)
+
+# Set up paths
+set(INCLUDE "../Include;${FREETYPE_INCLUDE}")
+set(SOURCE "../Source")
+set(LIBRARIES Core Controls Debugger)
+
+include_directories(${INCLUDE})
+
+# Build each library
+foreach(library ${LIBRARIES})
+	set(LIB_SOURCE_PATH "${SOURCE}/${library}")
+	set(NAME "Rocket${library}")
+	
+	aux_source_directory(${LIB_SOURCE_PATH} LIB_SOURCES)
+	add_library(${NAME} ${LIBRARY_TYPE} ${LIB_SOURCES})
+	set(LIB_SOURCES)
+endforeach(library)

+ 9 - 5
Include/Rocket/Controls/Header.h

@@ -30,14 +30,18 @@
 
 #include <Rocket/Core/Platform.h>
 
-#ifdef ROCKET_PLATFORM_WIN32
-	#ifdef RocketControls_EXPORTS
-		#define ROCKETCONTROLS_API __declspec(dllexport)
+#if !defined STATIC_LIB
+	#ifdef ROCKET_PLATFORM_WIN32
+		#ifdef RocketControls_EXPORTS
+			#define ROCKETCONTROLS_API __declspec(dllexport)
+		#else
+			#define ROCKETCONTROLS_API __declspec(dllimport)
+		#endif
 	#else
-		#define ROCKETCONTROLS_API __declspec(dllimport)
+		#define ROCKETCONTROLS_API __attribute__((visibility("default")))
 	#endif
 #else
-	#define ROCKETCONTROLS_API __attribute__((visibility("default")))
+	#define ROCKETCONTROLS_API
 #endif
 
 #endif

+ 9 - 5
Include/Rocket/Core/Header.h

@@ -30,14 +30,18 @@
 
 #include <Rocket/Core/Platform.h>
 
-#if defined ROCKET_PLATFORM_WIN32
-	#if defined RocketCore_EXPORTS
-		#define ROCKETCORE_API __declspec(dllexport)
+#if !defined STATIC_LIB
+	#if defined ROCKET_PLATFORM_WIN32
+		#if defined RocketCore_EXPORTS
+			#define ROCKETCORE_API __declspec(dllexport)
+		#else
+			#define ROCKETCORE_API __declspec(dllimport)
+		#endif
 	#else
-		#define ROCKETCORE_API __declspec(dllimport)
+		#define ROCKETCORE_API __attribute__((visibility("default")))
 	#endif
 #else
-	#define ROCKETCORE_API __attribute__((visibility("default")))
+	#define ROCKETCORE_API
 #endif
 
 #endif

+ 1 - 0
Include/Rocket/Core/String.h

@@ -31,6 +31,7 @@
 #include <Rocket/Core/Header.h>
 #include <Rocket/Core/StringBase.h>
 #include <stdarg.h>
+#include <string.h>
 #include <vector>
 
 namespace Rocket {

+ 1 - 0
Include/Rocket/Core/TypeConverter.h

@@ -33,6 +33,7 @@
 #include <Rocket/Core/Stream.h>
 #include <Rocket/Core/StringUtilities.h>
 #include <typeinfo>
+#include <stdlib.h>
 #include <stdio.h>
 
 namespace Rocket {

+ 9 - 5
Include/Rocket/Debugger/Header.h

@@ -30,14 +30,18 @@
 
 #include <Rocket/Core/Platform.h>
 
-#ifdef ROCKET_PLATFORM_WIN32
-	#ifdef RocketDebugger_EXPORTS
-		#define ROCKETDEBUGGER_API __declspec(dllexport)
+#if !defined STATIC_LIB
+	#ifdef ROCKET_PLATFORM_WIN32
+		#ifdef RocketDebugger_EXPORTS
+			#define ROCKETDEBUGGER_API __declspec(dllexport)
+		#else
+			#define ROCKETDEBUGGER_API __declspec(dllimport)
+		#endif
 	#else
-		#define ROCKETDEBUGGER_API __declspec(dllimport)
+		#define ROCKETDEBUGGER_API __attribute__((visibility("default")))
 	#endif
 #else
-	#define ROCKETDEBUGGER_API __attribute__((visibility("default")))
+	#define ROCKETDEBUGGER_API
 #endif
 
 #endif