Merge pull request #5371 from OPM/unity-support

Add support for CMake Unity Build
This commit is contained in:
Magne Sjaastad 2020-01-23 14:29:01 +01:00 committed by GitHub
commit dc4d4e0fa2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 185 additions and 55 deletions

View File

@ -5,16 +5,15 @@ branches:
image: Visual Studio 2017 image: Visual Studio 2017
clone_depth: 1 clone_depth: 1
environment: environment:
QT5: C:\Qt\5.10.1\msvc2017_64 QT5: C:\Qt\5.13.2\msvc2017_64
configuration: Release
build_script: build_script:
- cmd: >- - cmd: >-
mkdir cmakebuild mkdir cmakebuild
cd cmakebuild cd cmakebuild
if exist "%QT5%" set Path=%QT5%\bin;%Path% if exist "%QT5%" set Path=%QT5%\bin;%Path%
cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Release -DRESINSIGHT_INCLUDE_APPLICATION_UNIT_TESTS=true -DRESINSIGHT_ENABLE_COTIRE=on "-DCMAKE_PREFIX_PATH=%QT5%" .. cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Release -DRESINSIGHT_ENABLE_UNITY_BUILD=on "-DCMAKE_PREFIX_PATH=%QT5%" ..
cmake --build . --target ResInsight_unity --config Release cmake --build . --target ResInsight --config Release

View File

@ -2,6 +2,12 @@ cmake_minimum_required (VERSION 2.8.12)
project (ApplicationCode) project (ApplicationCode)
if(RESINSIGHT_ENABLE_UNITY_BUILD)
message("Cmake Unity build is enabled on : ${PROJECT_NAME}")
set(CMAKE_UNITY_BUILD true)
endif()
if (CMAKE_COMPILER_IS_GNUCXX) if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wno-deprecated-declarations") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wno-deprecated-declarations")
endif() endif()
@ -455,40 +461,41 @@ target_link_libraries( ResInsight ${LINK_LIBRARIES} ${EXTERNAL_LINK_LIBRARIES})
############################################################################# #############################################################################
# cotire # cotire and unity builds
############################################################################# #############################################################################
set( UNITY_EXCLUDE_FILES
# forever is used as variable name, and this symbol is defined by Qt and used in precompiled headers
${ResInsight_SOURCE_DIR}/ThirdParty/gtest/gtest-all.cc
# multiple QRC files are not supported
qrc_cafAnimControl.cxx
qrc_ResInsight.cxx
# mix of cvf and Qt namespaces
ModelVisualization/GridBox/RivGridBoxGenerator.cpp
ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp
# exclude file using Eigen
ReservoirDataModel/RigCellGeometryTools.cpp
ReservoirDataModel/Completions/RigTransmissibilityCondenser.cpp
ReservoirDataModel/Completions/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp
ReservoirDataModel/Completions/RigEclipseToStimPlanCalculator.cpp
# exclude file using SolveSpace
Application/Tools/WellPathTools/RiaSCurveCalculator.cpp
# QT 5
qrc_cafAnimControl.cpp
qrc_ResInsight.cpp
qrc_cafCommandFeatures.cpp
ProjectDataModel/RimContourMapView.cpp
Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp
)
if(RESINSIGHT_ENABLE_COTIRE) if(RESINSIGHT_ENABLE_COTIRE)
set( COTIRE_EXCLUDE_FILES foreach (fileToExclude ${UNITY_EXCLUDE_FILES})
# forever is used as variable name, and this symbol is defined by Qt and used in precompiled headers
${ResInsight_SOURCE_DIR}/ThirdParty/gtest/gtest-all.cc
# multiple QRC files are not supported
qrc_cafAnimControl.cxx
qrc_ResInsight.cxx
# mix of cvf and Qt namespaces
ModelVisualization/GridBox/RivGridBoxGenerator.cpp
ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp
# exclude file using Eigen
ReservoirDataModel/RigCellGeometryTools.cpp
ReservoirDataModel/Completions/RigTransmissibilityCondenser.cpp
ReservoirDataModel/Completions/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp
ReservoirDataModel/Completions/RigEclipseToStimPlanCalculator.cpp
# exclude file using SolveSpace
Application/Tools/WellPathTools/RiaSCurveCalculator.cpp
# QT 5
qrc_cafAnimControl.cpp
qrc_ResInsight.cpp
qrc_cafCommandFeatures.cpp
ProjectDataModel/RimContourMapView.cpp
Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp
)
foreach (fileToExclude ${COTIRE_EXCLUDE_FILES})
set_source_files_properties (${fileToExclude} PROPERTIES COTIRE_EXCLUDED TRUE) set_source_files_properties (${fileToExclude} PROPERTIES COTIRE_EXCLUDED TRUE)
endforeach(fileToExclude) endforeach(fileToExclude)
@ -508,7 +515,11 @@ if(RESINSIGHT_ENABLE_COTIRE)
endif() endif()
if(RESINSIGHT_ENABLE_UNITY_BUILD)
foreach (fileToExclude ${UNITY_EXCLUDE_FILES})
set_source_files_properties (${fileToExclude} PROPERTIES SKIP_UNITY_BUILD_INCLUSION TRUE)
endforeach(fileToExclude)
endif()
############################################################################# #############################################################################
# Copy Dlls on MSVC # Copy Dlls on MSVC

View File

@ -2,6 +2,12 @@ cmake_minimum_required (VERSION 2.8.12)
project (RigGeoMechDataModel) project (RigGeoMechDataModel)
# Unity Build
if (RESINSIGHT_ENABLE_UNITY_BUILD)
message("Cmake Unity build is enabled on : ${PROJECT_NAME}")
set(CMAKE_UNITY_BUILD true)
endif()
add_library( ${PROJECT_NAME} add_library( ${PROJECT_NAME}
RigFemPart.h RigFemPart.h
RigFemPart.cpp RigFemPart.cpp
@ -26,10 +32,10 @@ add_library( ${PROJECT_NAME}
RigFemPartGrid.cpp RigFemPartGrid.cpp
RigFemResultAddress.h RigFemResultAddress.h
RigFemResultPosEnum.h RigFemResultPosEnum.h
RimFemResultObserver.h RimFemResultObserver.h
RimFemResultObserver.cpp RimFemResultObserver.cpp
RimGeoMechGeometrySelectionItem.h RimGeoMechGeometrySelectionItem.h
RimGeoMechGeometrySelectionItem.cpp RimGeoMechGeometrySelectionItem.cpp
) )
target_include_directories(${PROJECT_NAME} target_include_directories(${PROJECT_NAME}

View File

@ -2,6 +2,12 @@ cmake_minimum_required (VERSION 2.8.12)
project (RifOdbReader) project (RifOdbReader)
# Unity Build
if (RESINSIGHT_ENABLE_UNITY_BUILD)
message("Cmake Unity build is enabled on : ${PROJECT_NAME}")
set(CMAKE_UNITY_BUILD true)
endif()
if (MSVC) if (MSVC)
add_definitions(-DHKS_NT) add_definitions(-DHKS_NT)
add_definitions(-DABQ_WIN86_64) add_definitions(-DABQ_WIN86_64)

View File

@ -59,11 +59,19 @@ include (ResInsightVersion.cmake)
find_package(Octave) find_package(Octave)
################################################################################ ################################################################################
# cotire # cotire and CMake Unity Build
# Fully automated CMake module for build speedup # Fully automated CMake module for build speedup
# https://github.com/sakra/cotire # https://github.com/sakra/cotire
################################################################################ ################################################################################
# CMAKE_UNITY_BUILD was introduced in CMake 3.16.2
option(RESINSIGHT_ENABLE_UNITY_BUILD "Experimental speedup of compilation using CMake Unity Build" OFF)
mark_as_advanced(FORCE RESINSIGHT_ENABLE_UNITY_BUILD)
if(RESINSIGHT_ENABLE_UNITY_BUILD)
set(CAF_ENABLE_UNITY_BUILD true)
set(CVF_ENABLE_UNITY_BUILD true)
endif()
option(RESINSIGHT_ENABLE_COTIRE "Experimental speedup of compilation using cotire" OFF) option(RESINSIGHT_ENABLE_COTIRE "Experimental speedup of compilation using cotire" OFF)
mark_as_advanced(FORCE RESINSIGHT_ENABLE_COTIRE) mark_as_advanced(FORCE RESINSIGHT_ENABLE_COTIRE)
if(RESINSIGHT_ENABLE_COTIRE) if(RESINSIGHT_ENABLE_COTIRE)

View File

@ -2,6 +2,12 @@ cmake_minimum_required (VERSION 2.8.12)
project (CommonCode) project (CommonCode)
# Unity Build
if (CAF_ENABLE_UNITY_BUILD)
message("Cmake Unity build is enabled on : ${PROJECT_NAME}")
set(CMAKE_UNITY_BUILD true)
endif()
# Open GL # Open GL
find_package( OpenGL ) find_package( OpenGL )

View File

@ -2,6 +2,12 @@ cmake_minimum_required (VERSION 2.8.12)
project (cafAnimControl) project (cafAnimControl)
# Unity Build
if (CAF_ENABLE_UNITY_BUILD)
message("Cmake Unity build is enabled on : ${PROJECT_NAME}")
set(CMAKE_UNITY_BUILD true)
endif()
# Qt # Qt
set( MOC_HEADER_FILES set( MOC_HEADER_FILES
cafFrameAnimationControl.h cafFrameAnimationControl.h

View File

@ -2,6 +2,11 @@ cmake_minimum_required (VERSION 2.8.12)
project (cafCommand) project (cafCommand)
# Unity Build
if (CAF_ENABLE_UNITY_BUILD)
message("Cmake Unity build is enabled on : ${PROJECT_NAME}")
set(CMAKE_UNITY_BUILD true)
endif()
# These headers need to go through Qt's MOC compiler # These headers need to go through Qt's MOC compiler
set (MOC_HEADER_FILES set (MOC_HEADER_FILES

View File

@ -2,6 +2,11 @@ cmake_minimum_required (VERSION 2.8.12)
project (cafCommandFeatures) project (cafCommandFeatures)
# Unity Build
if (CAF_ENABLE_UNITY_BUILD)
message("Cmake Unity build is enabled on : ${PROJECT_NAME}")
set(CMAKE_UNITY_BUILD true)
endif()
# These headers need to go through Qt's MOC compiler # These headers need to go through Qt's MOC compiler
set (MOC_HEADER_FILES set (MOC_HEADER_FILES

View File

@ -2,6 +2,12 @@ cmake_minimum_required (VERSION 2.8.12)
project (cafPdmCvf) project (cafPdmCvf)
# Unity Build
if (CAF_ENABLE_UNITY_BUILD)
message("Cmake Unity build is enabled on : ${PROJECT_NAME}")
set(CMAKE_UNITY_BUILD true)
endif()
# Qt # Qt
if (CEE_USE_QT5) if (CEE_USE_QT5)
find_package(Qt5 COMPONENTS REQUIRED Core Gui Widgets) find_package(Qt5 COMPONENTS REQUIRED Core Gui Widgets)

View File

@ -2,6 +2,12 @@ cmake_minimum_required (VERSION 2.8.12)
project (cafProjectDataModel) project (cafProjectDataModel)
# Unity Build
if (CAF_ENABLE_UNITY_BUILD)
message("Cmake Unity build is enabled on : ${PROJECT_NAME}")
set(CMAKE_UNITY_BUILD true)
endif()
# Qt # Qt
if (CEE_USE_QT5) if (CEE_USE_QT5)
find_package(Qt5 COMPONENTS REQUIRED Core Gui Widgets) find_package(Qt5 COMPONENTS REQUIRED Core Gui Widgets)

View File

@ -1,6 +1,13 @@
cmake_minimum_required (VERSION 2.8.12) cmake_minimum_required (VERSION 2.8.12)
project (cafPdmCore) project (cafPdmCore)
# Unity Build
if (CAF_ENABLE_UNITY_BUILD)
message("Cmake Unity build is enabled on : ${PROJECT_NAME}")
set(CMAKE_UNITY_BUILD true)
endif()
# Qt # Qt
option(CEE_USE_QT5 "Use Qt 5 instead of Qt 4" true) option(CEE_USE_QT5 "Use Qt 5 instead of Qt 4" true)

View File

@ -2,6 +2,12 @@ cmake_minimum_required (VERSION 2.8.12)
project (cafPdmUiCore) project (cafPdmUiCore)
# Unity Build
if (CAF_ENABLE_UNITY_BUILD)
message("Cmake Unity build is enabled on : ${PROJECT_NAME}")
set(CMAKE_UNITY_BUILD true)
endif()
# These headers need to go through Qt's MOC compiler # These headers need to go through Qt's MOC compiler
set (MOC_HEADER_FILES set (MOC_HEADER_FILES
cafPdmUiEditorHandle.h cafPdmUiEditorHandle.h

View File

@ -2,6 +2,12 @@ cmake_minimum_required (VERSION 2.8.12)
project (cafPdmXml) project (cafPdmXml)
# Unity Build
if (CAF_ENABLE_UNITY_BUILD)
message("Cmake Unity build is enabled on : ${PROJECT_NAME}")
set(CMAKE_UNITY_BUILD true)
endif()
# Qt # Qt
if (CEE_USE_QT5) if (CEE_USE_QT5)
find_package(Qt5 COMPONENTS REQUIRED Core Xml) find_package(Qt5 COMPONENTS REQUIRED Core Xml)

View File

@ -2,6 +2,12 @@ cmake_minimum_required (VERSION 2.8.12)
project (cafUserInterface) project (cafUserInterface)
# Unity Build
if (CAF_ENABLE_UNITY_BUILD)
message("Cmake Unity build is enabled on : ${PROJECT_NAME}")
set(CMAKE_UNITY_BUILD true)
endif()
if (MSVC) if (MSVC)
# Define this one to tell windows.h to not define min() and max() as macros # Define this one to tell windows.h to not define min() and max() as macros
add_definitions(-DNOMINMAX) add_definitions(-DNOMINMAX)

View File

@ -2,6 +2,12 @@ cmake_minimum_required (VERSION 2.8.12)
project (cafViewer) project (cafViewer)
# Unity Build
if (CAF_ENABLE_UNITY_BUILD)
message("Cmake Unity build is enabled on : ${PROJECT_NAME}")
set(CMAKE_UNITY_BUILD true)
endif()
# Qt # Qt
# These headers need to go through Qt's MOC compiler # These headers need to go through Qt's MOC compiler

View File

@ -2,6 +2,12 @@ cmake_minimum_required (VERSION 2.8.12)
project (cafVizExtensions) project (cafVizExtensions)
# Unity Build
if (CAF_ENABLE_UNITY_BUILD)
message("Cmake Unity build is enabled on : ${PROJECT_NAME}")
set(CMAKE_UNITY_BUILD true)
endif()
# Open GL # Open GL
find_package( OpenGL ) find_package( OpenGL )

View File

@ -2,6 +2,11 @@ cmake_minimum_required(VERSION 2.8)
project(LibCore) project(LibCore)
# CMake Unity Build
if (CVF_ENABLE_UNITY_BUILD)
message("Cmake Unity build is enabled on : ${PROJECT_NAME}")
set(CMAKE_UNITY_BUILD true)
endif()
# Use our strict compile flags # Use our strict compile flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CEE_STRICT_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CEE_STRICT_CXX_FLAGS}")

View File

@ -2,6 +2,11 @@ cmake_minimum_required(VERSION 2.8)
project(LibGeometry) project(LibGeometry)
# CMake Unity Build
if (CVF_ENABLE_UNITY_BUILD)
message("Cmake Unity build is enabled on : ${PROJECT_NAME}")
set(CMAKE_UNITY_BUILD true)
endif()
# Use our strict compile flags # Use our strict compile flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CEE_STRICT_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CEE_STRICT_CXX_FLAGS}")

View File

@ -2,6 +2,12 @@ cmake_minimum_required(VERSION 2.8.12)
project(LibGuiQt) project(LibGuiQt)
# CMake Unity Build
if (CVF_ENABLE_UNITY_BUILD)
message("Cmake Unity build is enabled on : ${PROJECT_NAME}")
set(CMAKE_UNITY_BUILD true)
endif()
# We're getting too much trouble from Qt using strict # We're getting too much trouble from Qt using strict
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CEE_BASE_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CEE_BASE_CXX_FLAGS}")
@ -60,8 +66,8 @@ target_link_libraries ( ${PROJECT_NAME}
set(PROJECT_FILES ${CEE_HEADER_FILES} ${CEE_SOURCE_FILES}) set(PROJECT_FILES ${CEE_HEADER_FILES} ${CEE_SOURCE_FILES})
source_group("" FILES ${PROJECT_FILES}) source_group("" FILES ${PROJECT_FILES})
#if (COMMAND ri_apply_cotire) # Unity Build
# set_source_files_properties (cvfqtOpenGLWidget.cpp PROPERTIES COTIRE_EXCLUDED TRUE) if (CMAKE_UNITY_BUILD)
# set_source_files_properties (cvfqtOpenGLContext.cpp PROPERTIES COTIRE_EXCLUDED TRUE) set_source_files_properties (cvfqtOpenGLWidget.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION TRUE)
# ri_apply_cotire() set_source_files_properties (cvfqtOpenGLContext.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION TRUE)
#endif() endif()

View File

@ -2,6 +2,11 @@ cmake_minimum_required(VERSION 2.8)
project(LibRender) project(LibRender)
# Unity Build
if (CVF_ENABLE_UNITY_BUILD)
message("Cmake Unity build is enabled on : ${PROJECT_NAME}")
set(CMAKE_UNITY_BUILD true)
endif()
# Use our strict compile flags # Use our strict compile flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CEE_STRICT_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CEE_STRICT_CXX_FLAGS}")
@ -191,11 +196,8 @@ target_link_libraries ( ${PROJECT_NAME}
set(PROJECT_FILES ${CEE_HEADER_FILES} ${CEE_SOURCE_FILES}) set(PROJECT_FILES ${CEE_HEADER_FILES} ${CEE_SOURCE_FILES})
source_group("" FILES ${PROJECT_FILES}) source_group("" FILES ${PROJECT_FILES})
#if (COMMAND ri_apply_cotire) # Unity Build
# set_source_files_properties (cvfOpenGLCapabilities.cpp PROPERTIES COTIRE_EXCLUDED TRUE) if (CMAKE_UNITY_BUILD)
# set_source_files_properties (cvfOpenGLContext.cpp PROPERTIES COTIRE_EXCLUDED TRUE) set_source_files_properties (cvfOpenGL.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION TRUE)
# set_source_files_properties (cvfOpenGLContextGroup.cpp PROPERTIES COTIRE_EXCLUDED TRUE) set_source_files_properties (cvfOpenGLContextGroup.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION TRUE)
# set_source_files_properties (cvfOpenGLResourceManager.cpp PROPERTIES COTIRE_EXCLUDED TRUE) endif()
# set_source_files_properties (cvfOpenGL.cpp PROPERTIES COTIRE_EXCLUDED TRUE)
# ri_apply_cotire()
#endif()

View File

@ -2,6 +2,11 @@ cmake_minimum_required(VERSION 2.8)
project(LibViewing) project(LibViewing)
# CMake Unity Build
if (CVF_ENABLE_UNITY_BUILD)
message("Cmake Unity build is enabled on : ${PROJECT_NAME}")
set(CMAKE_UNITY_BUILD true)
endif()
# Use our strict compile flags # Use our strict compile flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CEE_STRICT_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CEE_STRICT_CXX_FLAGS}")

View File

@ -2,6 +2,12 @@ cmake_minimum_required(VERSION 2.8.12)
project(Qwt) project(Qwt)
# Unity Build
if (RESINSIGHT_ENABLE_UNITY_BUILD)
message("Cmake Unity build is enabled on : ${PROJECT_NAME}")
set(CMAKE_UNITY_BUILD true)
endif()
if (MSVC) if (MSVC)
# Disable some annoying warnings (relative to warning level 3) # Disable some annoying warnings (relative to warning level 3)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267")