Browse Source

Enable precompiled header for shell project. Make a separate include file for Windows.h for consistent definitions.

Michael Ragazzon 5 years ago
parent
commit
a18a5b7e7c

+ 2 - 0
CMake/SampleFileList.cmake

@@ -1,6 +1,7 @@
 # This file was auto-generated with gen_samplelists.sh
 
 set(shell_HDR_FILES
+    ${PROJECT_SOURCE_DIR}/Samples/shell/src/precompiled.h
     ${PROJECT_SOURCE_DIR}/Samples/shell/include/Input.h
     ${PROJECT_SOURCE_DIR}/Samples/shell/include/Shell.h
     ${PROJECT_SOURCE_DIR}/Samples/shell/include/ShellFileInterface.h
@@ -258,6 +259,7 @@ if(WIN32)
        )
        list(APPEND shell_HDR_FILES
                ${PROJECT_SOURCE_DIR}/Samples/shell/include/win32/InputWin32.h
+               ${PROJECT_SOURCE_DIR}/Samples/shell/include/win32/IncludeWindows.h
        )
 elseif(APPLE)
        list(APPEND shell_SRC_FILES

+ 1 - 0
CMake/gen_samplelists.sh

@@ -42,6 +42,7 @@ echo '               ${PROJECT_SOURCE_DIR}/Samples/shell/src/win32/ShellRenderIn
 echo '       )' >> $file
 echo '       list(APPEND shell_HDR_FILES' >> $file
 echo '               ${PROJECT_SOURCE_DIR}/Samples/shell/include/win32/InputWin32.h' >> $file
+echo '               ${PROJECT_SOURCE_DIR}/Samples/shell/include/win32/IncludeWindows.h' >> $file
 echo '       )' >> $file
 echo 'elseif(APPLE)' >> $file
 echo '       list(APPEND shell_SRC_FILES' >> $file

+ 4 - 0
CMakeLists.txt

@@ -498,6 +498,10 @@ endif(NOT BUILD_FRAMEWORK)
 	add_library(shell STATIC ${shell_SRC_FILES} ${shell_HDR_FILES})
 	set_property(TARGET shell PROPERTY CXX_STANDARD 14)
 	set_property(TARGET shell PROPERTY CXX_STANDARD_REQUIRED ON)
+	
+	if (CMAKE_VERSION VERSION_GREATER 3.16.0)
+		target_precompile_headers(shell PRIVATE ${PROJECT_SOURCE_DIR}/Samples/shell/src/precompiled.h)
+	endif()
 
 	# Build and install the basic samples
 	foreach(sample ${samples})

+ 1 - 1
Samples/shell/include/Shell.h

@@ -64,7 +64,7 @@ public:
 	static void* GetWindowHandle();
 
 	/// Run the event loop, calling the idle function every frame.
-	typedef void (*ShellIdleFunction)();
+	using ShellIdleFunction = void(*)();
 	static void EventLoop(ShellIdleFunction idle_function);
 	static void RequestExit();
 

+ 1 - 2
Samples/shell/include/ShellOpenGL.h

@@ -32,8 +32,7 @@
 #include <RmlUi/Core/Platform.h>
 
 #if defined RMLUI_PLATFORM_WIN32
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
+#include <win32/IncludeWindows.h>
 #include <gl/Gl.h>
 #include <gl/Glu.h>
 #elif defined RMLUI_PLATFORM_MACOSX

+ 42 - 0
Samples/shell/include/win32/IncludeWindows.h

@@ -0,0 +1,42 @@
+/*
+ * This source file is part of RmlUi, the HTML/CSS Interface Middleware
+ *
+ * For the latest information, see http://github.com/mikke89/RmlUi
+ *
+ * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
+ * Copyright (c) 2019 The RmlUi Team, and contributors
+ *
+ * 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.
+ *
+ */
+
+#ifndef RMLUIINCLUDEWINDOWS_H
+#define RMLUIINCLUDEWINDOWS_H
+
+#if !defined _WIN32_WINNT || _WIN32_WINNT < 0x0501
+#undef _WIN32_WINNT
+#define _WIN32_WINNT 0x0501
+#endif
+#define UNICODE
+#define _UNICODE
+#define WIN32_LEAN_AND_MEAN
+
+#include <windows.h>
+
+#endif

+ 1 - 7
Samples/shell/include/win32/InputWin32.h

@@ -30,13 +30,7 @@
 #define RMLUIINPUTWIN32_H
 
 #include <Input.h>
-#if !defined _WIN32_WINNT || _WIN32_WINNT < 0x0501
-#undef _WIN32_WINNT
-#define _WIN32_WINNT 0x0501
-#endif
-#define UNICODE
-#define _UNICODE
-#include <windows.h>
+#include <win32/IncludeWindows.h>
 
 /**
 	Processes Windows input events and passes them through to RmlUi. Feel free to take this class and integrate it

+ 36 - 0
Samples/shell/src/precompiled.h

@@ -0,0 +1,36 @@
+/*
+ * This source file is part of RmlUi, the HTML/CSS Interface Middleware
+ *
+ * For the latest information, see http://github.com/mikke89/RmlUi
+ *
+ * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
+ * Copyright (c) 2019 The RmlUi Team, and contributors
+ *
+ * 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.
+ *
+ */
+
+#ifndef RMLUISHELLPRECOMPILED_H
+#define RMLUISHELLPRECOMPILED_H
+
+#include <RmlUi/Core/Core.h>
+#include <Shell.h>
+#include <ShellOpenGL.h>
+
+#endif

+ 1 - 1
Samples/shell/src/win32/ShellRenderInterfaceExtensionsOpenGL_Win32.cpp

@@ -28,7 +28,7 @@
 
 #include <ShellRenderInterfaceExtensions.h>
 #include <ShellRenderInterfaceOpenGL.h>
-#include <windows.h>
+#include <win32/IncludeWindows.h>
 #include <RmlUi/Core.h>
 #include <RmlUi/Core/Platform.h>
 #include <Shell.h>