From d3ef6905ff3f17b6e67aefc7d6672d39debe190b Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 25 Jul 2018 20:17:11 +0200 Subject: [PATCH] + add option to switch off precompiled header --- CMakeLists.txt | 1 + src/App/CMakeLists.txt | 4 ++-- src/App/ColorModel.h | 1 + src/App/PreCompiled.h | 8 ++++++-- src/App/PropertyContainer.cpp | 1 + src/Base/CMakeLists.txt | 8 ++++---- src/Base/Quantity.cpp | 5 ++++- src/Gui/CMakeLists.txt | 8 +++++--- src/Gui/NavigationStyle.cpp | 1 + src/Gui/PreCompiled.h | 9 ++++++--- src/Mod/Drawing/App/CMakeLists.txt | 4 ++-- src/Mod/Drawing/Gui/CMakeLists.txt | 4 ++-- src/Mod/Measure/App/CMakeLists.txt | 4 ++-- src/Mod/Measure/App/PreCompiled.h | 7 ++++++- src/Mod/Mesh/App/CMakeLists.txt | 4 ++-- src/Mod/TechDraw/App/CMakeLists.txt | 4 ++-- src/Mod/TechDraw/Gui/CMakeLists.txt | 4 ++-- 17 files changed, 49 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ac4c97e0e0..2446e27624 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -182,6 +182,7 @@ if(MSVC) OPTION(FREECAD_LIBPACK_USE "Use the LibPack to Build FreeCAD (only Win32 so far)." ON) OPTION(FREECAD_LIBPACK_USEPYSIDE "Use PySide in LibPack rather to PyQt and Swig." ON) set(FREECAD_LIBPACK_DIR ${CMAKE_SOURCE_DIR} CACHE PATH "Directory of the FreeCAD LibPack") + OPTION(BUILD_USE_PCH "Activate precompiled headers where it's used." ON) else(MSVC) OPTION(FREECAD_LIBPACK_USE "Use the LibPack to Build FreeCAD (only Win32 so far)." OFF) set(FREECAD_LIBPACK_DIR "" CACHE PATH "Directory of the FreeCAD LibPack") diff --git a/src/App/CMakeLists.txt b/src/App/CMakeLists.txt index 7c6906793b..a712c75e94 100644 --- a/src/App/CMakeLists.txt +++ b/src/App/CMakeLists.txt @@ -266,10 +266,10 @@ SET(FreeCADApp_SRCS PreCompiled.h ) -if(MSVC) +if(BUILD_USE_PCH) add_definitions(-D_PreComp_) ADD_MSVC_PRECOMPILED_HEADER(FreeCADApp PreCompiled.h PreCompiled.cpp FreeCADApp_CPP_SRCS) -endif(MSVC) +endif(BUILD_USE_PCH) add_library(FreeCADApp SHARED ${FreeCADApp_SRCS}) diff --git a/src/App/ColorModel.h b/src/App/ColorModel.h index 458e9000a6..535047c7d2 100644 --- a/src/App/ColorModel.h +++ b/src/App/ColorModel.h @@ -26,6 +26,7 @@ #include "Material.h" +#include #include #include #include diff --git a/src/App/PreCompiled.h b/src/App/PreCompiled.h index 6cd3a881eb..2b3ff8558d 100644 --- a/src/App/PreCompiled.h +++ b/src/App/PreCompiled.h @@ -31,11 +31,17 @@ #pragma warning( disable : 4251 ) #pragma warning( disable : 4273 ) #pragma warning( disable : 4275 ) +#pragma warning( disable : 4482 ) // nonstandard extension used: enum 'App::ObjectStatus' used in qualified name #pragma warning( disable : 4503 ) #pragma warning( disable : 4786 ) // specifier longer then 255 chars #endif +#ifdef FC_OS_WIN32 +#define WIN32_LEAN_AND_MEAN +#define NOMINMAX +#endif + #ifdef _PreComp_ // standard @@ -46,8 +52,6 @@ #ifdef FC_OS_WIN32 #include -#define WIN32_LEAN_AND_MEAN -#define NOMINMAX #include #include #endif diff --git a/src/App/PropertyContainer.cpp b/src/App/PropertyContainer.cpp index 2ca7f95d1b..5b3d208812 100644 --- a/src/App/PropertyContainer.cpp +++ b/src/App/PropertyContainer.cpp @@ -26,6 +26,7 @@ #ifndef _PreComp_ # include # include +# include #endif /// Here the FreeCAD includes sorted by Base,App,Gui...... diff --git a/src/Base/CMakeLists.txt b/src/Base/CMakeLists.txt index 8e14465872..d2bc36cdd6 100644 --- a/src/Base/CMakeLists.txt +++ b/src/Base/CMakeLists.txt @@ -370,10 +370,10 @@ else(FREECAD_USE_EXTERNAL_ZIPIOS) endif(FREECAD_USE_EXTERNAL_ZIPIOS) -if(MSVC) -add_definitions(-D_PreComp_) -ADD_MSVC_PRECOMPILED_HEADER(FreeCADBase PreCompiled.h PreCompiled.cpp FreeCADBase_CPP_SRCS) -endif(MSVC) +if(BUILD_USE_PCH) + add_definitions(-D_PreComp_) + ADD_MSVC_PRECOMPILED_HEADER(FreeCADBase PreCompiled.h PreCompiled.cpp FreeCADBase_CPP_SRCS) +endif(BUILD_USE_PCH) add_library(FreeCADBase SHARED ${FreeCADBase_SRCS}) diff --git a/src/Base/Quantity.cpp b/src/Base/Quantity.cpp index d98e23afda..aab28e5c25 100644 --- a/src/Base/Quantity.cpp +++ b/src/Base/Quantity.cpp @@ -23,9 +23,12 @@ #include "PreCompiled.h" #ifndef _PreComp_ # include +# ifdef FC_OS_WIN32 +# define _USE_MATH_DEFINES +# endif // FC_OS_WIN32 +# include #endif -#include #include "Quantity.h" #include "Exception.h" #include "UnitsApi.h" diff --git a/src/Gui/CMakeLists.txt b/src/Gui/CMakeLists.txt index 5e102d2273..a37188eefa 100644 --- a/src/Gui/CMakeLists.txt +++ b/src/Gui/CMakeLists.txt @@ -1171,7 +1171,6 @@ SET(FreeCADGui_SRCS ) if(MSVC) - add_definitions(-D_PreComp_) SET(FreeCADGui_CPP_SRCS Language/Translator.cpp propertyeditor/PropertyEditor.cpp @@ -1196,15 +1195,18 @@ if(MSVC) ${Workbench_CPP_SRCS} ${FreeCADGui_CPP_SRCS} ) - ADD_MSVC_PRECOMPILED_HEADER(FreeCADGui PreCompiled.h PreCompiled.cpp FreeCADGui_CPP_SRCS) endif(MSVC) -add_library(FreeCADGui SHARED ${FreeCADGui_SRCS}) +if (BUILD_USE_PCH) + add_definitions(-D_PreComp_) + ADD_MSVC_PRECOMPILED_HEADER(FreeCADGui PreCompiled.h PreCompiled.cpp FreeCADGui_CPP_SRCS) +endif(BUILD_USE_PCH) if (FREECAD_USE_QT_FILEDIALOG) set_source_files_properties(FileDialog.cpp PROPERTIES COMPILE_FLAGS -DUSE_QT_FILEDIALOG) endif() +add_library(FreeCADGui SHARED ${FreeCADGui_SRCS}) target_link_libraries(FreeCADGui ${FreeCADGui_LIBS}) SET_BIN_DIR(FreeCADGui FreeCADGui) diff --git a/src/Gui/NavigationStyle.cpp b/src/Gui/NavigationStyle.cpp index c65da1c2df..d239035a27 100644 --- a/src/Gui/NavigationStyle.cpp +++ b/src/Gui/NavigationStyle.cpp @@ -23,6 +23,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ +# include # include # include "InventorAll.h" # include diff --git a/src/Gui/PreCompiled.h b/src/Gui/PreCompiled.h index 33afc7351d..8b41562a24 100644 --- a/src/Gui/PreCompiled.h +++ b/src/Gui/PreCompiled.h @@ -26,7 +26,10 @@ #include -#ifdef _PreComp_ +#ifdef FC_OS_WIN32 +#define WIN32_LEAN_AND_MEAN +#define NOMINMAX +#endif // here get the warnings of too long specifiers disabled (needed for VC6) #ifdef _MSC_VER @@ -37,6 +40,8 @@ #pragma warning( disable : 4786 ) // specifier longer then 255 chars #endif +#ifdef _PreComp_ + // standard #include #include @@ -47,8 +52,6 @@ #include #ifdef FC_OS_WIN32 -#define WIN32_LEAN_AND_MEAN -#define NOMINMAX #include #include #include diff --git a/src/Mod/Drawing/App/CMakeLists.txt b/src/Mod/Drawing/App/CMakeLists.txt index 8455550a4e..9148b8126a 100644 --- a/src/Mod/Drawing/App/CMakeLists.txt +++ b/src/Mod/Drawing/App/CMakeLists.txt @@ -80,11 +80,11 @@ SET(Drawing_Templates Templates/A4_Portrait_plain.svg ) -if(MSVC) +if(BUILD_USE_PCH) #add_definitions(-D_PreComp_) #GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" Drawing_CPP_SRCS ${Drawing_SRCS} ${Features_SRCS} ${DrawingAlgos_SRCS}) #ADD_MSVC_PRECOMPILED_HEADER(Drawing PreCompiled.h PreCompiled.cpp Drawing_CPP_SRCS) -endif(MSVC) +endif(BUILD_USE_PCH) add_library(Drawing SHARED ${Drawing_SRCS} ${Features_SRCS} ${DrawingAlgos_SRCS}) target_link_libraries(Drawing ${Drawing_LIBS}) diff --git a/src/Mod/Drawing/Gui/CMakeLists.txt b/src/Mod/Drawing/Gui/CMakeLists.txt index 7b78b1e63a..5bb01e9749 100644 --- a/src/Mod/Drawing/Gui/CMakeLists.txt +++ b/src/Mod/Drawing/Gui/CMakeLists.txt @@ -83,11 +83,11 @@ SET(DrawingGuiTaskDlgs_SRCS ) SOURCE_GROUP("TaskDialogs" FILES ${DrawingGuiTaskDlgs_SRCS}) -if(MSVC) +if(BUILD_USE_PCH) #add_definitions(-D_PreComp_) #GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${DrawingGui_SRCS} ${DrawingGuiView_SRCS} ${DrawingGuiViewProvider_SRCS}) #ADD_MSVC_PRECOMPILED_HEADER(DrawingGui PreCompiled.h PreCompiled.cpp PCH_SRCS) -endif(MSVC) +endif(BUILD_USE_PCH) add_library(DrawingGui SHARED ${DrawingGui_SRCS} ${DrawingGuiView_SRCS} ${DrawingGuiViewProvider_SRCS}) target_link_libraries(DrawingGui ${DrawingGui_LIBS}) diff --git a/src/Mod/Measure/App/CMakeLists.txt b/src/Mod/Measure/App/CMakeLists.txt index 795a64a1a2..2f3a26f734 100644 --- a/src/Mod/Measure/App/CMakeLists.txt +++ b/src/Mod/Measure/App/CMakeLists.txt @@ -47,11 +47,11 @@ SET(Measure_SRCS ${Python_SRCS} ) -if(MSVC) +if(BUILD_USE_PCH) add_definitions(-D_PreComp_) GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" Measure_CPP_SRCS ${Measure_SRCS}) ADD_MSVC_PRECOMPILED_HEADER(Measure PreCompiled.h PreCompiled.cpp Measure_CPP_SRCS) -endif(MSVC) +endif(BUILD_USE_PCH) # Set special compiler flag to convert a SIGSEV into an exception # to handle issue #0000478. diff --git a/src/Mod/Measure/App/PreCompiled.h b/src/Mod/Measure/App/PreCompiled.h index 6af53da620..aede0035ad 100644 --- a/src/Mod/Measure/App/PreCompiled.h +++ b/src/Mod/Measure/App/PreCompiled.h @@ -37,6 +37,11 @@ # define MeshExport #endif +#ifdef FC_OS_WIN32 +#define WIN32_LEAN_AND_MEAN +#define NOMINMAX +#endif + #ifdef _PreComp_ // standard @@ -63,4 +68,4 @@ #elif defined(FC_OS_WIN32) #include #endif // _PreComp_ -#endif \ No newline at end of file +#endif diff --git a/src/Mod/Mesh/App/CMakeLists.txt b/src/Mod/Mesh/App/CMakeLists.txt index 2d3e1eb85c..1f64c340c4 100644 --- a/src/Mod/Mesh/App/CMakeLists.txt +++ b/src/Mod/Mesh/App/CMakeLists.txt @@ -361,11 +361,11 @@ SET(Mesh_SRCS Segment.h ) -if(MSVC) +if(BUILD_USE_PCH) add_definitions(-D_PreComp_) GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${Core_SRCS} ${Mesh_SRCS}) ADD_MSVC_PRECOMPILED_HEADER(Mesh PreCompiled.h PreCompiled.cpp PCH_SRCS) -endif(MSVC) +endif(BUILD_USE_PCH) add_library(Mesh SHARED ${Core_SRCS} ${WildMagic4_SRCS} ${Mesh_SRCS}) target_link_libraries(Mesh ${Mesh_LIBS}) diff --git a/src/Mod/TechDraw/App/CMakeLists.txt b/src/Mod/TechDraw/App/CMakeLists.txt index 7d23ed636a..1e3d8e964c 100644 --- a/src/Mod/TechDraw/App/CMakeLists.txt +++ b/src/Mod/TechDraw/App/CMakeLists.txt @@ -162,11 +162,11 @@ SET(TechDraw_LineGroupFile LineGroup/LineGroup.csv ) -if(MSVC) +if(BUILD_USE_PCH) #add_definitions(-D_PreComp_) #GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" TechDrawCPP_SRCS ${TechDraw_SRCS} ${Draw_SRCS} ) #ADD_MSVC_PRECOMPILED_HEADER(TechDraw PreCompiled.h PreCompiled.cpp TechDrawCPP_SRCS) -endif(MSVC) +endif(BUILD_USE_PCH) add_library(TechDraw SHARED ${TechDraw_SRCS} ${Draw_SRCS} ${TechDrawAlgos_SRCS} ${Geometry_SRCS} ${Python_SRCS}) diff --git a/src/Mod/TechDraw/Gui/CMakeLists.txt b/src/Mod/TechDraw/Gui/CMakeLists.txt index 2acd0a770e..7900902594 100644 --- a/src/Mod/TechDraw/Gui/CMakeLists.txt +++ b/src/Mod/TechDraw/Gui/CMakeLists.txt @@ -226,11 +226,11 @@ SET(TechDrawGuiTaskDlgs_SRCS ) SOURCE_GROUP("TaskDialogs" FILES ${TechDrawGuiTaskDlgs_SRCS}) -if(MSVC) +if(BUILD_USE_PCH) #add_definitions(-D_PreComp_) #GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${TechDrawGui_SRCS} ${TechDrawGuiView_SRCS} ${TechDrawGuiViewProvider_SRCS}) #ADD_MSVC_PRECOMPILED_HEADER(TechDrawGui PreCompiled.h PreCompiled.cpp PCH_SRCS) -endif(MSVC) +endif(BUILD_USE_PCH) add_library(TechDrawGui SHARED ${TechDrawGui_SRCS} ${TechDrawGuiView_SRCS} ${TechDrawGuiViewProvider_SRCS}) target_link_libraries(TechDrawGui ${TechDrawGui_LIBS})