Skip to content

Conversation

@vrcomputing
Copy link
Owner

@vrcomputing vrcomputing commented Nov 24, 2024

What

Enable CMAKE_UNITY_BUILD accelerating total build time from 50s to 36s. 😮

This enables unity builds globally ( ⚠️ not recommended )

set(CMAKE_UNITY_BUILD ON)

This enables unity builds on a specific target

set_target_properties(${target} PROPERTIES UNITY_BUILD ON)

This excludes generated moc_* files from it

if(BUILD_UNITY)
    file(GLOB_RECURSE MOC_FILES
        ${CMAKE_CURRENT_BINARY_DIR}/moc_*.cpp
    )

    set_source_files_properties(${MOC_FILES} PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
endif()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants