From 45be0e6d6d7a4a756c4944d456d5e2b7a5dd9c4b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 11 Aug 2023 12:41:40 +0200 Subject: [PATCH] Use precompiled headers to speed up build * Add precompiled headers to Commands, and improve usage * Use precompiled headers on github action --- .github/workflows/ResInsightWithCache.yml | 1 + ApplicationLibCode/Commands/CMakeLists.txt | 5 ++++ ApplicationLibCode/Commands/pch.h | 33 ++++++++++++++++++++++ ApplicationLibCode/pch.h | 18 +++++++++++- 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 ApplicationLibCode/Commands/pch.h diff --git a/.github/workflows/ResInsightWithCache.yml b/.github/workflows/ResInsightWithCache.yml index 6df5751a7e..9c290822c1 100644 --- a/.github/workflows/ResInsightWithCache.yml +++ b/.github/workflows/ResInsightWithCache.yml @@ -196,6 +196,7 @@ jobs: -D RESINSIGHT_BUNDLE_OPENSSL=true -D RESINSIGHT_INCLUDE_APPLICATION_UNIT_TESTS=true -D RESINSIGHT_TREAT_WARNINGS_AS_ERRORS=true + -D RESINSIGHT_ENABLE_PRECOMPILED_HEADERS=true -D RESINSIGHT_ENABLE_UNITY_BUILD=${{ matrix.config.unity-build }} -D RESINSIGHT_ENABLE_GRPC=${{ matrix.config.build-python-module }} -D RESINSIGHT_GRPC_PYTHON_EXECUTABLE=${{ steps.python-path.outputs.PYTHON_EXECUTABLE }} diff --git a/ApplicationLibCode/Commands/CMakeLists.txt b/ApplicationLibCode/Commands/CMakeLists.txt index 509e4cc40e..d0aa8eeaf1 100644 --- a/ApplicationLibCode/Commands/CMakeLists.txt +++ b/ApplicationLibCode/Commands/CMakeLists.txt @@ -59,6 +59,11 @@ add_library( ${COMMAND_MOC_SOURCE_FILES} ) +if(RESINSIGHT_ENABLE_PRECOMPILED_HEADERS) + message("Precompiled Headers is enabled on : ${PROJECT_NAME}") + target_precompile_headers(Commands PRIVATE pch.h) +endif() + target_include_directories( ${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/EclipseCommands diff --git a/ApplicationLibCode/Commands/pch.h b/ApplicationLibCode/Commands/pch.h new file mode 100644 index 0000000000..64892045ab --- /dev/null +++ b/ApplicationLibCode/Commands/pch.h @@ -0,0 +1,33 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2023 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "cafAssert.h" +#include "cafCmdFeature.h" +#include "cafFactory.h" +#include "cafPdmChildArrayField.h" +#include "cafPdmObject.h" +#include "cafPdmPtrArrayField.h" +#include "cafPdmPtrField.h" +#include "cafPdmUiOrdering.h" + +#include + +#include "RiaApplication.h" +#include "RimPlotCurve.h" +#include "RiuMainWindow.h" +#include "RiuPlotMainWindow.h" diff --git a/ApplicationLibCode/pch.h b/ApplicationLibCode/pch.h index 3141cc55c2..e1f0453cd5 100644 --- a/ApplicationLibCode/pch.h +++ b/ApplicationLibCode/pch.h @@ -1,6 +1,6 @@ //////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2019- Equinor ASA +// Copyright (C) 2023 Equinor ASA // // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -20,18 +20,34 @@ #include "cvfVector3.h" #include "cafAppEnum.h" +#include "cafAssert.h" #include "cafCmdFeature.h" +#include "cafFactory.h" +#include "cafPdmChildArrayField.h" #include "cafPdmField.h" +#include "cafPdmFieldScriptingCapability.h" #include "cafPdmObject.h" +#include "cafPdmPtrArrayField.h" +#include "cafPdmPtrField.h" +#include "cafPdmUiOrdering.h" #include "cafSelectionManager.h" #include +#include #include +#include #include #include #include "RiaApplication.h" #include "RiaPreferences.h" +#include "RimPlotCurve.h" #include "RiuMainWindow.h" #include "RiuPlotMainWindow.h" + +// These files are reported as candidates for PCH file, but including them breaks the Unity build +// #include "cafViewer.h" +// #include "RiuViewer.h" +// #include "cafOpenGLWidget.h" +// #include