Use target_precompile_headers for the most expensive headers

Only for MSVC. Ccache doesn't work out of the box with precompiled headers but
usually gives less build time for Clang and GCC. Also GCC builds code slower
with precompiled headers for unknown reason.
precompile_headers
elsid 2 years ago
parent 5ad2ae04ce
commit 921a22fb73
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -9,3 +9,7 @@ target_link_libraries(openmw_detournavigator_navmeshtilescache_benchmark benchma
if (UNIX AND NOT APPLE) if (UNIX AND NOT APPLE)
target_link_libraries(openmw_detournavigator_navmeshtilescache_benchmark ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(openmw_detournavigator_navmeshtilescache_benchmark ${CMAKE_THREAD_LIBS_INIT})
endif() endif()
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)
target_precompile_headers(openmw_detournavigator_navmeshtilescache_benchmark PRIVATE <algorithm>)
endif()

@ -17,3 +17,11 @@ if (BUILD_WITH_CODE_COVERAGE)
add_definitions (--coverage) add_definitions (--coverage)
target_link_libraries(bsatool gcov) target_link_libraries(bsatool gcov)
endif() endif()
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)
target_precompile_headers(bsatool PRIVATE
<filesystem>
<fstream>
<vector>
)
endif()

@ -18,3 +18,10 @@ endif()
if (WIN32) if (WIN32)
install(TARGETS openmw-bulletobjecttool RUNTIME DESTINATION ".") install(TARGETS openmw-bulletobjecttool RUNTIME DESTINATION ".")
endif() endif()
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)
target_precompile_headers(openmw-bulletobjecttool PRIVATE
<string>
<vector>
)
endif()

@ -24,3 +24,11 @@ if (BUILD_WITH_CODE_COVERAGE)
add_definitions (--coverage) add_definitions (--coverage)
target_link_libraries(esmtool gcov) target_link_libraries(esmtool gcov)
endif() endif()
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)
target_precompile_headers(esmtool PRIVATE
<fstream>
<string>
<vector>
)
endif()

@ -47,3 +47,13 @@ endif()
if (WIN32) if (WIN32)
INSTALL(TARGETS openmw-essimporter RUNTIME DESTINATION ".") INSTALL(TARGETS openmw-essimporter RUNTIME DESTINATION ".")
endif(WIN32) endif(WIN32)
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)
target_precompile_headers(openmw-essimporter PRIVATE
<algorithm>
<filesystem>
<fstream>
<string>
<vector>
)
endif()

@ -96,3 +96,12 @@ if(USE_QT)
set_property(TARGET openmw-launcher PROPERTY AUTOMOC ON) set_property(TARGET openmw-launcher PROPERTY AUTOMOC ON)
endif(USE_QT) endif(USE_QT)
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)
target_precompile_headers(openmw-launcher PRIVATE
<boost/program_options/options_description.hpp>
<algorithm>
<string>
<vector>
)
endif()

@ -33,3 +33,12 @@ if (BUILD_WITH_CODE_COVERAGE)
add_definitions (--coverage) add_definitions (--coverage)
target_link_libraries(openmw-iniimporter gcov) target_link_libraries(openmw-iniimporter gcov)
endif() endif()
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)
target_precompile_headers(openmw-iniimporter PRIVATE
<boost/filesystem.hpp>
<string>
<vector>
)
endif()

@ -20,3 +20,12 @@ endif()
if (WIN32) if (WIN32)
install(TARGETS openmw-navmeshtool RUNTIME DESTINATION ".") install(TARGETS openmw-navmeshtool RUNTIME DESTINATION ".")
endif() endif()
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)
target_precompile_headers(openmw-navmeshtool PRIVATE
<algorithm>
<memory>
<string>
<vector>
)
endif()

@ -16,3 +16,7 @@ if (BUILD_WITH_CODE_COVERAGE)
add_definitions (--coverage) add_definitions (--coverage)
target_link_libraries(niftest gcov) target_link_libraries(niftest gcov)
endif() endif()
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)
target_precompile_headers(niftest PRIVATE <filesystem>)
endif()

@ -261,3 +261,18 @@ endif()
if(USE_QT) if(USE_QT)
set_property(TARGET openmw-cs PROPERTY AUTOMOC ON) set_property(TARGET openmw-cs PROPERTY AUTOMOC ON)
endif(USE_QT) endif(USE_QT)
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)
target_precompile_headers(openmw-cs PRIVATE
<boost/filesystem.hpp>
<boost/program_options/options_description.hpp>
<algorithm>
<fstream>
<functional>
<ostream>
<string>
<string_view>
<vector>
)
endif()

@ -157,9 +157,32 @@ target_link_libraries(openmw
components components
) )
if (MSVC AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.16) if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)
target_precompile_headers(openmw PRIVATE ${SOL_INCLUDE_DIR}/sol/sol.hpp) target_precompile_headers(openmw PRIVATE
endif () <boost/filesystem.hpp>
<boost/program_options/options_description.hpp>
<sol/sol.hpp>
<osg/StateSet>
<osg/Node>
<osg/Drawable>
<osg/Camera>
<osgViewer/Viewer>
<MyGUI_Widget.h>
<algorithm>
<filesystem>
<fstream>
<functional>
<memory>
<string>
<string_view>
<vector>
)
endif()
if (ANDROID) if (ANDROID)
target_link_libraries(openmw EGL android log z) target_link_libraries(openmw EGL android log z)

@ -110,4 +110,21 @@ if (GTEST_FOUND AND GMOCK_FOUND)
PRIVATE OPENMW_DATA_DIR="${CMAKE_CURRENT_BINARY_DIR}/data" PRIVATE OPENMW_DATA_DIR="${CMAKE_CURRENT_BINARY_DIR}/data"
OPENMW_TEST_SUITE_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}") OPENMW_TEST_SUITE_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)
target_precompile_headers(openmw_test_suite PRIVATE
<boost/program_options/options_description.hpp>
<gtest/gtest.h>
<sol/sol.hpp>
<algorithm>
<filesystem>
<fstream>
<functional>
<memory>
<string>
<vector>
)
endif()
endif() endif()

@ -498,6 +498,33 @@ if(USE_QT)
set_property(TARGET components_qt PROPERTY AUTOMOC ON) set_property(TARGET components_qt PROPERTY AUTOMOC ON)
endif(USE_QT) endif(USE_QT)
if (MSVC AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.16) if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)
target_precompile_headers(components PRIVATE ${SOL_INCLUDE_DIR}/sol/sol.hpp) target_precompile_headers(components PUBLIC
endif () <sol/sol.hpp>
<osg/State>
<osg/StateSet>
<osg/Node>
<osg/Drawable>
<osg/Camera>
<MyGUI_Widget.h>
<boost/filesystem.hpp>
<algorithm>
<filesystem>
<fstream>
<functional>
<memory>
<ostream>
<string>
<vector>
)
target_precompile_headers(components PRIVATE
<osgViewer/Viewer>
<boost/program_options/options_description.hpp>
)
endif()

@ -1,2 +1,6 @@
add_library(Base64 INTERFACE) add_library(Base64 INTERFACE)
target_include_directories(Base64 INTERFACE .) target_include_directories(Base64 INTERFACE .)
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)
target_precompile_headers(Base64 INTERFACE <string>)
endif()

@ -241,6 +241,10 @@ if (NOT OPENMW_USE_SYSTEM_YAML_CPP)
SOURCE_DIR fetched/yaml-cpp SOURCE_DIR fetched/yaml-cpp
) )
FetchContent_MakeAvailableExcludeFromAll(yaml-cpp) FetchContent_MakeAvailableExcludeFromAll(yaml-cpp)
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)
target_precompile_headers(yaml-cpp PRIVATE <algorithm>)
endif()
endif() endif()
if (NOT OPENMW_USE_SYSTEM_ICU) if (NOT OPENMW_USE_SYSTEM_ICU)

@ -19,3 +19,7 @@ else()
) )
target_link_libraries(oics local_tinyxml) target_link_libraries(oics local_tinyxml)
endif() endif()
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)
target_precompile_headers(oics PUBLIC <algorithm> <string>)
endif()

@ -16,3 +16,13 @@ target_link_libraries(${OSG_FFMPEG_VIDEOPLAYER_LIBRARY} ${FFmpeg_LIBRARIES})
target_link_libraries(${OSG_FFMPEG_VIDEOPLAYER_LIBRARY} ${OSG_LIBRARIES}) target_link_libraries(${OSG_FFMPEG_VIDEOPLAYER_LIBRARY} ${OSG_LIBRARIES})
link_directories(${CMAKE_CURRENT_BINARY_DIR}) link_directories(${CMAKE_CURRENT_BINARY_DIR})
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)
target_precompile_headers(${OSG_FFMPEG_VIDEOPLAYER_LIBRARY} PUBLIC
<memory>
<string>
<vector>
)
target_precompile_headers(${OSG_FFMPEG_VIDEOPLAYER_LIBRARY} PRIVATE <algorithm>)
endif()

Loading…
Cancel
Save