1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-07 00:15:34 +00:00

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.
This commit is contained in:
elsid 2022-06-28 08:38:27 +02:00
parent 5ad2ae04ce
commit 921a22fb73
No known key found for this signature in database
GPG key ID: 4DE04C198CBA7625
17 changed files with 179 additions and 7 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -96,3 +96,12 @@ if(USE_QT)
set_property(TARGET openmw-launcher PROPERTY AUTOMOC ON)
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()

View file

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

View file

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

View file

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

View file

@ -261,3 +261,18 @@ endif()
if(USE_QT)
set_property(TARGET openmw-cs PROPERTY AUTOMOC ON)
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()

View file

@ -157,9 +157,32 @@ target_link_libraries(openmw
components
)
if (MSVC AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.16)
target_precompile_headers(openmw PRIVATE ${SOL_INCLUDE_DIR}/sol/sol.hpp)
endif ()
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)
target_precompile_headers(openmw PRIVATE
<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)
target_link_libraries(openmw EGL android log z)

View file

@ -110,4 +110,21 @@ if (GTEST_FOUND AND GMOCK_FOUND)
PRIVATE OPENMW_DATA_DIR="${CMAKE_CURRENT_BINARY_DIR}/data"
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()

View file

@ -498,6 +498,33 @@ if(USE_QT)
set_property(TARGET components_qt PROPERTY AUTOMOC ON)
endif(USE_QT)
if (MSVC AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.16)
target_precompile_headers(components PRIVATE ${SOL_INCLUDE_DIR}/sol/sol.hpp)
endif ()
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)
target_precompile_headers(components PUBLIC
<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()

View file

@ -1,2 +1,6 @@
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()

View file

@ -241,6 +241,10 @@ if (NOT OPENMW_USE_SYSTEM_YAML_CPP)
SOURCE_DIR fetched/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()
if (NOT OPENMW_USE_SYSTEM_ICU)

View file

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

View file

@ -16,3 +16,13 @@ target_link_libraries(${OSG_FFMPEG_VIDEOPLAYER_LIBRARY} ${FFmpeg_LIBRARIES})
target_link_libraries(${OSG_FFMPEG_VIDEOPLAYER_LIBRARY} ${OSG_LIBRARIES})
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()