From 7e6c13630a9df6d62d5320eb14af64975d9eb112 Mon Sep 17 00:00:00 2001 From: elsid Date: Fri, 1 Jul 2022 14:05:17 +0000 Subject: [PATCH] Use target_precompile_headers for the most expensive headers --- CMakeLists.txt | 7 ++++- apps/benchmarks/CMakeLists.txt | 4 +++ apps/bsatool/CMakeLists.txt | 8 +++++ apps/bulletobjecttool/CMakeLists.txt | 7 +++++ apps/esmtool/CMakeLists.txt | 8 +++++ apps/essimporter/CMakeLists.txt | 10 ++++++ apps/launcher/CMakeLists.txt | 9 ++++++ apps/mwiniimporter/CMakeLists.txt | 9 ++++++ apps/navmeshtool/CMakeLists.txt | 9 ++++++ apps/niftest/CMakeLists.txt | 4 +++ apps/opencs/CMakeLists.txt | 15 +++++++++ apps/openmw/CMakeLists.txt | 29 +++++++++++++++-- apps/openmw/mwgui/messagebox.cpp | 2 -- apps/openmw/mwgui/messagebox.hpp | 2 -- apps/openmw/mwworld/weather.cpp | 4 +-- apps/openmw_test_suite/CMakeLists.txt | 17 ++++++++++ components/CMakeLists.txt | 33 ++++++++++++++++++-- components/files/windowspath.cpp | 6 ++++ extern/Base64/CMakeLists.txt | 6 +++- extern/CMakeLists.txt | 4 +++ extern/oics/CMakeLists.txt | 4 +++ extern/osg-ffmpeg-videoplayer/CMakeLists.txt | 10 ++++++ 22 files changed, 193 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 10edfb0f97..2450d0016f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -346,7 +346,12 @@ if (WIN32) add_definitions(-DSDL_MAIN_HANDLED) # Get rid of useless crud from windows.h - add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN) + add_definitions( + -DNOMINMAX # name conflict with std::min, std::max + -DWIN32_LEAN_AND_MEAN + -DNOMB # name conflict with MWGui::MessageBox + -DNOGDI # name conflict with osgAnimation::MorphGeometry::RELATIVE + ) endif() if(OPENMW_USE_SYSTEM_BULLET) diff --git a/apps/benchmarks/CMakeLists.txt b/apps/benchmarks/CMakeLists.txt index c96531a666..095a841742 100644 --- a/apps/benchmarks/CMakeLists.txt +++ b/apps/benchmarks/CMakeLists.txt @@ -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 ) +endif() diff --git a/apps/bsatool/CMakeLists.txt b/apps/bsatool/CMakeLists.txt index 85188dbe9f..6312c33aaf 100644 --- a/apps/bsatool/CMakeLists.txt +++ b/apps/bsatool/CMakeLists.txt @@ -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 + + + + ) +endif() diff --git a/apps/bulletobjecttool/CMakeLists.txt b/apps/bulletobjecttool/CMakeLists.txt index 6beb411e20..bc19a29e21 100644 --- a/apps/bulletobjecttool/CMakeLists.txt +++ b/apps/bulletobjecttool/CMakeLists.txt @@ -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 + + + ) +endif() diff --git a/apps/esmtool/CMakeLists.txt b/apps/esmtool/CMakeLists.txt index 914a40699e..841fb4b219 100644 --- a/apps/esmtool/CMakeLists.txt +++ b/apps/esmtool/CMakeLists.txt @@ -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 + + + + ) +endif() diff --git a/apps/essimporter/CMakeLists.txt b/apps/essimporter/CMakeLists.txt index 3dafba09ba..add5ad6d05 100644 --- a/apps/essimporter/CMakeLists.txt +++ b/apps/essimporter/CMakeLists.txt @@ -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 + + + + + + ) +endif() diff --git a/apps/launcher/CMakeLists.txt b/apps/launcher/CMakeLists.txt index e3256519c3..79a27094f2 100644 --- a/apps/launcher/CMakeLists.txt +++ b/apps/launcher/CMakeLists.txt @@ -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 + + + + + + ) +endif() diff --git a/apps/mwiniimporter/CMakeLists.txt b/apps/mwiniimporter/CMakeLists.txt index e83656708b..d35f4f4d33 100644 --- a/apps/mwiniimporter/CMakeLists.txt +++ b/apps/mwiniimporter/CMakeLists.txt @@ -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 + + + + + ) +endif() diff --git a/apps/navmeshtool/CMakeLists.txt b/apps/navmeshtool/CMakeLists.txt index 7df049af97..9f57d52a7e 100644 --- a/apps/navmeshtool/CMakeLists.txt +++ b/apps/navmeshtool/CMakeLists.txt @@ -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 + + + + + ) +endif() diff --git a/apps/niftest/CMakeLists.txt b/apps/niftest/CMakeLists.txt index 856404c1ce..2f0dcb59e3 100644 --- a/apps/niftest/CMakeLists.txt +++ b/apps/niftest/CMakeLists.txt @@ -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 ) +endif() diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index b3d405d1a3..8a3a41c824 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -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 + + + + + + + + + + + ) +endif() diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 24152d59ab..75d051c63b 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -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 + + + + + + + + + + + + + + + + + + + + + + + ) +endif() if (ANDROID) target_link_libraries(openmw EGL android log z) diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index 890406cd12..ccacdba108 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -13,8 +13,6 @@ #include "../mwbase/inputmanager.hpp" #include "../mwbase/windowmanager.hpp" -#undef MessageBox - namespace MWGui { diff --git a/apps/openmw/mwgui/messagebox.hpp b/apps/openmw/mwgui/messagebox.hpp index d46d31d938..59118ce6c2 100644 --- a/apps/openmw/mwgui/messagebox.hpp +++ b/apps/openmw/mwgui/messagebox.hpp @@ -3,8 +3,6 @@ #include "windowbase.hpp" -#undef MessageBox - namespace MyGUI { class Widget; diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 74cab7a461..062796e914 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -23,6 +23,8 @@ #include +namespace MWWorld +{ namespace { static const int invalidWeatherID = -1; @@ -53,8 +55,6 @@ namespace } } -namespace MWWorld -{ template T TimeOfDayInterpolator::getValue(const float gameHour, const TimeOfDaySettings& timeSettings, const std::string& prefix) const { diff --git a/apps/openmw_test_suite/CMakeLists.txt b/apps/openmw_test_suite/CMakeLists.txt index 739d3394b4..072514d0cc 100644 --- a/apps/openmw_test_suite/CMakeLists.txt +++ b/apps/openmw_test_suite/CMakeLists.txt @@ -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 + + + + + + + + + + + + + + ) + endif() endif() diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index a4e1d32e99..9a2295671e 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -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 + + + + + + + + + + + + + + + + + + + + + ) + + target_precompile_headers(components PRIVATE + + + + ) +endif() diff --git a/components/files/windowspath.cpp b/components/files/windowspath.cpp index 92d1a9ff09..8a17acec9d 100644 --- a/components/files/windowspath.cpp +++ b/components/files/windowspath.cpp @@ -4,10 +4,16 @@ #include +#define FAR +#define NEAR + #include #include #include +#undef NEAR +#undef FAR + #include namespace bconv = boost::locale::conv; diff --git a/extern/Base64/CMakeLists.txt b/extern/Base64/CMakeLists.txt index d1adf91bcb..4430d7648e 100644 --- a/extern/Base64/CMakeLists.txt +++ b/extern/Base64/CMakeLists.txt @@ -1,2 +1,6 @@ add_library(Base64 INTERFACE) -target_include_directories(Base64 INTERFACE .) \ No newline at end of file +target_include_directories(Base64 INTERFACE .) + +if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) + target_precompile_headers(Base64 INTERFACE ) +endif() diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index 898dfeffad..c183fe455b 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -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 ) + endif() endif() if (NOT OPENMW_USE_SYSTEM_ICU) diff --git a/extern/oics/CMakeLists.txt b/extern/oics/CMakeLists.txt index 00d77f52c6..585df5dd41 100644 --- a/extern/oics/CMakeLists.txt +++ b/extern/oics/CMakeLists.txt @@ -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 ) +endif() diff --git a/extern/osg-ffmpeg-videoplayer/CMakeLists.txt b/extern/osg-ffmpeg-videoplayer/CMakeLists.txt index ae19be8659..1bbe672d78 100644 --- a/extern/osg-ffmpeg-videoplayer/CMakeLists.txt +++ b/extern/osg-ffmpeg-videoplayer/CMakeLists.txt @@ -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 + + + + ) + + target_precompile_headers(${OSG_FFMPEG_VIDEOPLAYER_LIBRARY} PRIVATE ) +endif()