forked from quickshell/quickshell
		
	build: greatly speed up build times using pch
This commit is contained in:
		
							parent
							
								
									3480707e99
								
							
						
					
					
						commit
						c44041653c
					
				
					 10 changed files with 51 additions and 8 deletions
				
			
		| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
cmake_minimum_required(VERSION 3.20)
 | 
					cmake_minimum_required(VERSION 3.20)
 | 
				
			||||||
project(quickshell VERSION "0.1.0")
 | 
					project(quickshell VERSION "0.1.0" LANGUAGES CXX C)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
set(QT_MIN_VERSION "6.6.0")
 | 
					set(QT_MIN_VERSION "6.6.0")
 | 
				
			||||||
set(CMAKE_CXX_STANDARD 20)
 | 
					set(CMAKE_CXX_STANDARD 20)
 | 
				
			||||||
| 
						 | 
					@ -65,6 +65,28 @@ find_package(Qt6 REQUIRED COMPONENTS ${QT_FPDEPS})
 | 
				
			||||||
qt_standard_project_setup(REQUIRES 6.6)
 | 
					qt_standard_project_setup(REQUIRES 6.6)
 | 
				
			||||||
set(QT_QML_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/qml_modules)
 | 
					set(QT_QML_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/qml_modules)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					file(GENERATE
 | 
				
			||||||
 | 
						OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pchstub.cpp
 | 
				
			||||||
 | 
						CONTENT ""
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					add_library(qt-pch ${CMAKE_CURRENT_BINARY_DIR}/pchstub.cpp)
 | 
				
			||||||
 | 
					target_link_libraries(qt-pch PRIVATE ${QT_DEPS})
 | 
				
			||||||
 | 
					target_precompile_headers(qt-pch PUBLIC
 | 
				
			||||||
 | 
						<memory>
 | 
				
			||||||
 | 
						<qobject.h>
 | 
				
			||||||
 | 
						<qqmlengine.h>
 | 
				
			||||||
 | 
						<qlist.h>
 | 
				
			||||||
 | 
						<qcolor.h>
 | 
				
			||||||
 | 
						<qquickitem.h>
 | 
				
			||||||
 | 
						<qevent.h>
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function (qs_pch target)
 | 
				
			||||||
 | 
						target_precompile_headers(${target} REUSE_FROM qt-pch)
 | 
				
			||||||
 | 
						target_link_libraries(${target} PRIVATE ${QT_DEPS}) # required for gcc to accept the pch on plugin targets
 | 
				
			||||||
 | 
					endfunction()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
add_subdirectory(src/core)
 | 
					add_subdirectory(src/core)
 | 
				
			||||||
add_subdirectory(src/io)
 | 
					add_subdirectory(src/io)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -47,6 +47,8 @@ This repo has a nix flake you can use to install the package directly:
 | 
				
			||||||
Quickshell's binary is available at `quickshell.packages.<system>.default` to be added to
 | 
					Quickshell's binary is available at `quickshell.packages.<system>.default` to be added to
 | 
				
			||||||
lists such as `environment.systemPackages` or `home.packages`.
 | 
					lists such as `environment.systemPackages` or `home.packages`.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Note: by default this package is built with clang as it is significantly faster.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Manual
 | 
					## Manual
 | 
				
			||||||
 | 
					
 | 
				
			||||||
If not using nix, you'll have to build from source.
 | 
					If not using nix, you'll have to build from source.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,7 +3,7 @@
 | 
				
			||||||
  nix-gitignore,
 | 
					  nix-gitignore,
 | 
				
			||||||
  pkgs,
 | 
					  pkgs,
 | 
				
			||||||
  keepDebugInfo,
 | 
					  keepDebugInfo,
 | 
				
			||||||
  stdenv ? (keepDebugInfo pkgs.stdenv),
 | 
					  buildStdenv ? pkgs.clang17Stdenv,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  cmake,
 | 
					  cmake,
 | 
				
			||||||
  ninja,
 | 
					  ninja,
 | 
				
			||||||
| 
						 | 
					@ -23,7 +23,7 @@
 | 
				
			||||||
     else "unknown"),
 | 
					     else "unknown"),
 | 
				
			||||||
  debug ? false,
 | 
					  debug ? false,
 | 
				
			||||||
  enableWayland ? true,
 | 
					  enableWayland ? true,
 | 
				
			||||||
}: stdenv.mkDerivation {
 | 
					}: buildStdenv.mkDerivation {
 | 
				
			||||||
  pname = "quickshell${lib.optionalString debug "-debug"}";
 | 
					  pname = "quickshell${lib.optionalString debug "-debug"}";
 | 
				
			||||||
  version = "0.1.0";
 | 
					  version = "0.1.0";
 | 
				
			||||||
  src = nix-gitignore.gitignoreSource "/docs\n/examples\n" ./.;
 | 
					  src = nix-gitignore.gitignoreSource "/docs\n/examples\n" ./.;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										2
									
								
								docs
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								docs
									
										
									
									
									
								
							| 
						 | 
					@ -1 +1 @@
 | 
				
			||||||
Subproject commit 2d0b15bbd52ea61bd79880b89fae0a589010d1f3
 | 
					Subproject commit b4587482d7835818e78f8a84b29057b88c35c567
 | 
				
			||||||
| 
						 | 
					@ -10,7 +10,7 @@
 | 
				
			||||||
    rev = "1f062cc198d1112d13e5128fa1f2ee3dbffe613b";
 | 
					    rev = "1f062cc198d1112d13e5128fa1f2ee3dbffe613b";
 | 
				
			||||||
    sha256 = "kbt0Zc1qHE5fhqBkKz8iue+B+ZANjF1AR/RdgmX1r0I=";
 | 
					    sha256 = "kbt0Zc1qHE5fhqBkKz8iue+B+ZANjF1AR/RdgmX1r0I=";
 | 
				
			||||||
  }) { inherit pkgs; };
 | 
					  }) { inherit pkgs; };
 | 
				
			||||||
in pkgs.mkShell {
 | 
					in pkgs.mkShell.override { stdenv = quickshell.stdenv; } {
 | 
				
			||||||
  inputsFrom = [ quickshell ];
 | 
					  inputsFrom = [ quickshell ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  nativeBuildInputs = with pkgs; [
 | 
					  nativeBuildInputs = with pkgs; [
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,6 +22,7 @@ set_source_files_properties(main.cpp PROPERTIES COMPILE_DEFINITIONS GIT_REVISION
 | 
				
			||||||
qt_add_qml_module(quickshell URI Quickshell VERSION 0.1)
 | 
					qt_add_qml_module(quickshell URI Quickshell VERSION 0.1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
target_link_libraries(quickshell PRIVATE ${QT_DEPS})
 | 
					target_link_libraries(quickshell PRIVATE ${QT_DEPS})
 | 
				
			||||||
 | 
					qs_pch(quickshell)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if (BUILD_TESTING)
 | 
					if (BUILD_TESTING)
 | 
				
			||||||
	add_subdirectory(test)
 | 
						add_subdirectory(test)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,6 +16,10 @@ target_link_libraries(quickshell-io-init PRIVATE ${QT_DEPS})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
target_link_libraries(quickshell PRIVATE quickshell-ioplugin quickshell-io-init)
 | 
					target_link_libraries(quickshell PRIVATE quickshell-ioplugin quickshell-io-init)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					qs_pch(quickshell-io)
 | 
				
			||||||
 | 
					qs_pch(quickshell-ioplugin)
 | 
				
			||||||
 | 
					qs_pch(quickshell-io-init)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if (BUILD_TESTING)
 | 
					if (BUILD_TESTING)
 | 
				
			||||||
	add_subdirectory(test)
 | 
						add_subdirectory(test)
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -37,9 +37,15 @@ function (wl_proto target name path)
 | 
				
			||||||
	execute_process(COMMAND ${qtwaylandscanner} client-header ${path} OUTPUT_FILE ${PROTO_BUILD_PATH}/qwayland-${name}.h)
 | 
						execute_process(COMMAND ${qtwaylandscanner} client-header ${path} OUTPUT_FILE ${PROTO_BUILD_PATH}/qwayland-${name}.h)
 | 
				
			||||||
	execute_process(COMMAND ${qtwaylandscanner} client-code ${path} OUTPUT_FILE ${PROTO_BUILD_PATH}/qwayland-${name}.cpp)
 | 
						execute_process(COMMAND ${qtwaylandscanner} client-code ${path} OUTPUT_FILE ${PROTO_BUILD_PATH}/qwayland-${name}.cpp)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	target_sources(${target} PRIVATE ${PROTO_BUILD_PATH}/wayland-${name}.c)
 | 
						add_library(wl-proto-${name}
 | 
				
			||||||
	target_sources(${target} PRIVATE ${PROTO_BUILD_PATH}/qwayland-${name}.cpp)
 | 
							${PROTO_BUILD_PATH}/wayland-${name}.c
 | 
				
			||||||
	target_include_directories(${target} PRIVATE ${PROTO_BUILD_PATH})
 | 
							${PROTO_BUILD_PATH}/qwayland-${name}.cpp
 | 
				
			||||||
 | 
						)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						target_include_directories(wl-proto-${name} INTERFACE ${PROTO_BUILD_PATH})
 | 
				
			||||||
 | 
						target_link_libraries(wl-proto-${name} Qt6::WaylandClient Qt6::WaylandClientPrivate)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						target_link_libraries(${target} PRIVATE wl-proto-${name})
 | 
				
			||||||
endfunction()
 | 
					endfunction()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# -----
 | 
					# -----
 | 
				
			||||||
| 
						 | 
					@ -65,4 +71,8 @@ endif()
 | 
				
			||||||
target_link_libraries(quickshell-wayland PRIVATE ${QT_DEPS})
 | 
					target_link_libraries(quickshell-wayland PRIVATE ${QT_DEPS})
 | 
				
			||||||
target_link_libraries(quickshell-wayland-init PRIVATE ${QT_DEPS})
 | 
					target_link_libraries(quickshell-wayland-init PRIVATE ${QT_DEPS})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					qs_pch(quickshell-wayland)
 | 
				
			||||||
 | 
					qs_pch(quickshell-waylandplugin)
 | 
				
			||||||
 | 
					qs_pch(quickshell-wayland-init)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
target_link_libraries(quickshell PRIVATE quickshell-waylandplugin quickshell-wayland-init)
 | 
					target_link_libraries(quickshell PRIVATE quickshell-waylandplugin quickshell-wayland-init)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,5 +8,6 @@ qt_add_library(quickshell-wayland-sessionlock STATIC
 | 
				
			||||||
 | 
					
 | 
				
			||||||
wl_proto(quickshell-wayland-sessionlock ext-session-lock-v1 "${WAYLAND_PROTOCOLS}/staging/ext-session-lock/ext-session-lock-v1.xml")
 | 
					wl_proto(quickshell-wayland-sessionlock ext-session-lock-v1 "${WAYLAND_PROTOCOLS}/staging/ext-session-lock/ext-session-lock-v1.xml")
 | 
				
			||||||
target_link_libraries(quickshell-wayland-sessionlock PRIVATE ${QT_DEPS} wayland-client)
 | 
					target_link_libraries(quickshell-wayland-sessionlock PRIVATE ${QT_DEPS} wayland-client)
 | 
				
			||||||
 | 
					qs_pch(quickshell-wayland-sessionlock)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
target_link_libraries(quickshell-wayland PRIVATE quickshell-wayland-sessionlock)
 | 
					target_link_libraries(quickshell-wayland PRIVATE quickshell-wayland-sessionlock)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,4 +9,7 @@ qt_add_qml_module(quickshell-wayland-layershell URI Quickshell.Wayland._WlrLayer
 | 
				
			||||||
wl_proto(quickshell-wayland-layershell wlr-layer-shell-unstable-v1 "${CMAKE_CURRENT_SOURCE_DIR}/wlr-layer-shell-unstable-v1.xml")
 | 
					wl_proto(quickshell-wayland-layershell wlr-layer-shell-unstable-v1 "${CMAKE_CURRENT_SOURCE_DIR}/wlr-layer-shell-unstable-v1.xml")
 | 
				
			||||||
target_link_libraries(quickshell-wayland-layershell PRIVATE ${QT_DEPS} wayland-client)
 | 
					target_link_libraries(quickshell-wayland-layershell PRIVATE ${QT_DEPS} wayland-client)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					qs_pch(quickshell-wayland-layershell)
 | 
				
			||||||
 | 
					qs_pch(quickshell-wayland-layershellplugin)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
target_link_libraries(quickshell-wayland PRIVATE quickshell-wayland-layershellplugin)
 | 
					target_link_libraries(quickshell-wayland PRIVATE quickshell-wayland-layershellplugin)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue