mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 08:28:11 +00:00
Meta: Add an option to precompile some very common AK headers
Until we get the goodness that C++ modules are supposed to be, let's try to shave off some parse time using precompiled headers. This commit only adds some very common AK headers, only to binaries, libraries and the kernel (tests are not covered due to incompatibility with AK/TestSuite.h). This option is on by default, but can be disabled by passing `-DPRECOMPILE_COMMON_HEADERS=OFF` to cmake, which will disable all header precompilations. This makes the build about 30 seconds faster on my machine (about 7%).
This commit is contained in:
parent
c4f682606a
commit
468ac11f29
5 changed files with 63 additions and 0 deletions
9
Meta/CMake/precompile-headers.cmake
Normal file
9
Meta/CMake/precompile-headers.cmake
Normal file
|
@ -0,0 +1,9 @@
|
|||
function(serenity_add_precompiled_header_to_target target header)
|
||||
if (PRECOMPILE_COMMON_HEADERS AND COMMAND target_precompile_headers)
|
||||
target_precompile_headers(${target} PRIVATE ${header})
|
||||
endif ()
|
||||
endfunction()
|
||||
|
||||
function(serenity_add_ak_precompiled_headers_to_target target)
|
||||
serenity_add_precompiled_header_to_target(${target} ${CMAKE_SOURCE_DIR}/Meta/Precompile/AK.h)
|
||||
endfunction()
|
|
@ -1,3 +1,5 @@
|
|||
include(${CMAKE_SOURCE_DIR}/Meta/CMake/precompile-headers.cmake)
|
||||
|
||||
function(serenity_install_headers target_name)
|
||||
file(GLOB_RECURSE headers RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
|
||||
foreach(header ${headers})
|
||||
|
@ -31,6 +33,7 @@ function(serenity_lib target_name fs_name)
|
|||
add_library(${target_name} SHARED ${SOURCES} ${GENERATED_SOURCES})
|
||||
install(TARGETS ${target_name} DESTINATION usr/lib)
|
||||
set_target_properties(${target_name} PROPERTIES OUTPUT_NAME ${fs_name})
|
||||
serenity_add_ak_precompiled_headers_to_target(${target_name})
|
||||
serenity_generated_sources(${target_name})
|
||||
endfunction()
|
||||
|
||||
|
@ -67,6 +70,7 @@ endfunction()
|
|||
function(serenity_bin target_name)
|
||||
add_executable(${target_name} ${SOURCES})
|
||||
install(TARGETS ${target_name} RUNTIME DESTINATION bin)
|
||||
serenity_add_ak_precompiled_headers_to_target(${target_name})
|
||||
serenity_generated_sources(${target_name})
|
||||
endfunction()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue