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,8 +5,7 @@ branches:
image: Visual Studio 2017
clone_depth: 1
environment:
QT5: C:\Qt\5.10.1\msvc2017_64
configuration: Release
QT5: C:\Qt\5.13.2\msvc2017_64
build_script:
- cmd: >-
mkdir cmakebuild
@ -15,6 +14,6 @@ build_script:
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)
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)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wno-deprecated-declarations")
endif()
@ -455,11 +461,10 @@ target_link_libraries( ResInsight ${LINK_LIBRARIES} ${EXTERNAL_LINK_LIBRARIES})
#############################################################################
# cotire
# cotire and unity builds
#############################################################################
if(RESINSIGHT_ENABLE_COTIRE)
set( COTIRE_EXCLUDE_FILES
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
@ -486,9 +491,11 @@ if(RESINSIGHT_ENABLE_COTIRE)
qrc_cafCommandFeatures.cpp
ProjectDataModel/RimContourMapView.cpp
Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp
)
)
foreach (fileToExclude ${COTIRE_EXCLUDE_FILES})
if(RESINSIGHT_ENABLE_COTIRE)
foreach (fileToExclude ${UNITY_EXCLUDE_FILES})
set_source_files_properties (${fileToExclude} PROPERTIES COTIRE_EXCLUDED TRUE)
endforeach(fileToExclude)
@ -508,7 +515,11 @@ if(RESINSIGHT_ENABLE_COTIRE)
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

View File

@ -2,6 +2,12 @@ cmake_minimum_required (VERSION 2.8.12)
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}
RigFemPart.h
RigFemPart.cpp

View File

@ -2,6 +2,12 @@ cmake_minimum_required (VERSION 2.8.12)
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)
add_definitions(-DHKS_NT)
add_definitions(-DABQ_WIN86_64)

View File

@ -59,11 +59,19 @@ include (ResInsightVersion.cmake)
find_package(Octave)
################################################################################
# cotire
# cotire and CMake Unity Build
# Fully automated CMake module for build speedup
# 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)
mark_as_advanced(FORCE RESINSIGHT_ENABLE_COTIRE)
if(RESINSIGHT_ENABLE_COTIRE)

View File

@ -2,6 +2,12 @@ cmake_minimum_required (VERSION 2.8.12)
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
find_package( OpenGL )

View File

@ -2,6 +2,12 @@ cmake_minimum_required (VERSION 2.8.12)
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
set( MOC_HEADER_FILES
cafFrameAnimationControl.h

View File

@ -2,6 +2,11 @@ cmake_minimum_required (VERSION 2.8.12)
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
set (MOC_HEADER_FILES

View File

@ -2,6 +2,11 @@ cmake_minimum_required (VERSION 2.8.12)
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
set (MOC_HEADER_FILES

View File

@ -2,6 +2,12 @@ cmake_minimum_required (VERSION 2.8.12)
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
if (CEE_USE_QT5)
find_package(Qt5 COMPONENTS REQUIRED Core Gui Widgets)

View File

@ -2,6 +2,12 @@ cmake_minimum_required (VERSION 2.8.12)
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
if (CEE_USE_QT5)
find_package(Qt5 COMPONENTS REQUIRED Core Gui Widgets)

View File

@ -1,6 +1,13 @@
cmake_minimum_required (VERSION 2.8.12)
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
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)
# 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
set (MOC_HEADER_FILES
cafPdmUiEditorHandle.h

View File

@ -2,6 +2,12 @@ cmake_minimum_required (VERSION 2.8.12)
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
if (CEE_USE_QT5)
find_package(Qt5 COMPONENTS REQUIRED Core Xml)

View File

@ -2,6 +2,12 @@ cmake_minimum_required (VERSION 2.8.12)
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)
# Define this one to tell windows.h to not define min() and max() as macros
add_definitions(-DNOMINMAX)

View File

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

View File

@ -2,6 +2,11 @@ cmake_minimum_required(VERSION 2.8)
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
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)
# 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
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)
# 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
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})
source_group("" FILES ${PROJECT_FILES})
#if (COMMAND ri_apply_cotire)
# set_source_files_properties (cvfqtOpenGLWidget.cpp PROPERTIES COTIRE_EXCLUDED TRUE)
# set_source_files_properties (cvfqtOpenGLContext.cpp PROPERTIES COTIRE_EXCLUDED TRUE)
# ri_apply_cotire()
#endif()
# Unity Build
if (CMAKE_UNITY_BUILD)
set_source_files_properties (cvfqtOpenGLWidget.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION TRUE)
set_source_files_properties (cvfqtOpenGLContext.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION TRUE)
endif()

View File

@ -2,6 +2,11 @@ cmake_minimum_required(VERSION 2.8)
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
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})
source_group("" FILES ${PROJECT_FILES})
#if (COMMAND ri_apply_cotire)
# set_source_files_properties (cvfOpenGLCapabilities.cpp PROPERTIES COTIRE_EXCLUDED TRUE)
# set_source_files_properties (cvfOpenGLContext.cpp PROPERTIES COTIRE_EXCLUDED TRUE)
# set_source_files_properties (cvfOpenGLContextGroup.cpp PROPERTIES COTIRE_EXCLUDED TRUE)
# set_source_files_properties (cvfOpenGLResourceManager.cpp PROPERTIES COTIRE_EXCLUDED TRUE)
# set_source_files_properties (cvfOpenGL.cpp PROPERTIES COTIRE_EXCLUDED TRUE)
# ri_apply_cotire()
#endif()
# Unity Build
if (CMAKE_UNITY_BUILD)
set_source_files_properties (cvfOpenGL.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION TRUE)
set_source_files_properties (cvfOpenGLContextGroup.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION TRUE)
endif()

View File

@ -2,6 +2,11 @@ cmake_minimum_required(VERSION 2.8)
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
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)
# Unity Build
if (RESINSIGHT_ENABLE_UNITY_BUILD)
message("Cmake Unity build is enabled on : ${PROJECT_NAME}")
set(CMAKE_UNITY_BUILD true)
endif()
if (MSVC)
# Disable some annoying warnings (relative to warning level 3)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267")