Skip to content

Commit

Permalink
Coding - PCH improvements #160
Browse files Browse the repository at this point in the history
Refactor precompiled headers and improve Windows compatibility.
Extend TKernel, TKMath and TKBRep pch with more usage headers.
Implement PCH for TKDEIGES, TKDESTEP, TKMesh, and TKXSBase.
  • Loading branch information
dpasukhi committed Nov 17, 2024
1 parent 4ebc468 commit ac5a612
Show file tree
Hide file tree
Showing 17 changed files with 123 additions and 63 deletions.
8 changes: 6 additions & 2 deletions adm/cmake/occt_macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -456,11 +456,15 @@ function (COLLECT_AND_INSTALL_OCCT_HEADER_FILES THE_ROOT_TARGET_OCCT_DIR THE_OCC
install (FILES ${OCCT_HEADER_FILES_COMPLETE} DESTINATION "${INSTALL_DIR}/${THE_OCCT_INSTALL_DIR_PREFIX}")
endfunction()

function(ADD_PRECOMPILED_HEADER INPUT_TARGET PRECOMPILED_HEADER)
function(ADD_PRECOMPILED_HEADER INPUT_TARGET PRECOMPILED_HEADER THE_IS_PRIVATE)
if (NOT BUILD_USE_PCH)
return()
endif()
target_precompile_headers(${INPUT_TARGET} PUBLIC "$<$<COMPILE_LANGUAGE:CXX>:${PRECOMPILED_HEADER}>")
if (${THE_IS_PRIVATE})
target_precompile_headers(${INPUT_TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${PRECOMPILED_HEADER}>")
else()
target_precompile_headers(${INPUT_TARGET} PUBLIC "$<$<COMPILE_LANGUAGE:CXX>:${PRECOMPILED_HEADER}>")
endif()
endfunction()

macro (OCCT_COPY_FILE_OR_DIR BEING_COPIED_OBJECT DESTINATION_PATH)
Expand Down
2 changes: 1 addition & 1 deletion src/TKBRep/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ project(TKBRep)
OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)

# Add the precompiled header
ADD_PRECOMPILED_HEADER(TKBRep "${CMAKE_CURRENT_SOURCE_DIR}/TKBRep_pch.hxx")
ADD_PRECOMPILED_HEADER(TKBRep "${CMAKE_CURRENT_SOURCE_DIR}/TKBRep_pch.hxx" FALSE)
30 changes: 8 additions & 22 deletions src/TKBRep/TKBRep_pch.hxx
Original file line number Diff line number Diff line change
@@ -1,33 +1,19 @@
#ifndef TKBRep_HXX
#define TKBRep_HXX

// Windows-specific headers (for MSVC)
#ifdef _WIN32
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <windows.h> // For Windows API functions like WideCharToMultiByte
#include <tchar.h> // For Unicode/MBCS mappings
#ifdef GetObject
#undef GetObject
#endif
#endif

#include <TopoDS_Shape.hxx>
#include <TopoDS_Solid.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Builder.hxx>
#include <TopoDS_CompSolid.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Builder.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Solid.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Wire.hxx>

#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>

#include <BRepTools.hxx>

#endif // TKBRep_HXX
3 changes: 3 additions & 0 deletions src/TKDEIGES/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
project(TKDEIGES)

OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)

# Add the precompiled header
ADD_PRECOMPILED_HEADER(TKDEIGES "${CMAKE_CURRENT_SOURCE_DIR}/TKDEIGES_pch.hxx" TRUE)
9 changes: 9 additions & 0 deletions src/TKDEIGES/TKDEIGES_pch.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef TKDEIGES_PCH_H
#define TKDEIGES_PCH_H

#include <IGESData_HArray1OfIGESEntity.hxx>
#include <IGESData_IGESEntity.hxx>
#include <IGESData_IGESReaderData.hxx>
#include <IGESData_ParamReader.hxx>

#endif // TKDEIGES_PCH_H
3 changes: 3 additions & 0 deletions src/TKDESTEP/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ project(TKDESTEP)

OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)

# Add the precompiled header
ADD_PRECOMPILED_HEADER(TKDESTEP "${CMAKE_CURRENT_SOURCE_DIR}/TKDESTEP_pch.hxx" TRUE)

FLEX_AND_BISON_TARGET_APPLY ("StepFile" src)
11 changes: 11 additions & 0 deletions src/TKDESTEP/TKDESTEP_pch.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef TKDESTEP_PCH_H
#define TKDESTEP_PCH_H

#include <StepData_StepReaderData.hxx>
#include <StepData_StepWriter.hxx>
#include <StepGeom_GeometricRepresentationItem.hxx>
#include <StepKinematics_KinematicPair.hxx>
#include <StepRepr_Representation.hxx>
#include <StepRepr_RepresentationItem.hxx>

#endif // TKDESTEP_PCH_H
2 changes: 1 addition & 1 deletion src/TKMath/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ project(TKMath)
OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)

# Add the precompiled header
ADD_PRECOMPILED_HEADER(TKMath "${CMAKE_CURRENT_SOURCE_DIR}/TKMath_pch.hxx")
ADD_PRECOMPILED_HEADER(TKMath "${CMAKE_CURRENT_SOURCE_DIR}/TKMath_pch.hxx" FALSE)
33 changes: 14 additions & 19 deletions src/TKMath/TKMath_pch.hxx
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
#ifndef TKMATH_PCH_H
#define TKMATH_PCH_H

// Standard library headers
#include <type_traits>

// Windows-specific headers (for MSVC)
#ifdef _WIN32
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <windows.h> // For Windows API functions like WideCharToMultiByte
#include <tchar.h> // For Unicode/MBCS mappings
#ifdef GetObject
#undef GetObject
#endif
#endif

#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <gp_Dir.hxx>
#include <gp_Ax1.hxx>
#include <gp_Ax2.hxx>
#include <gp_Trsf.hxx>
#include <gp_Ax3.hxx>
#include <gp_Circ.hxx>
#include <gp_Dir.hxx>
#include <gp_Elips.hxx>
#include <gp_Hypr.hxx>
#include <gp_Lin.hxx>
#include <gp_Lin2d.hxx>
#include <gp_Pnt.hxx>
#include <gp_Quaternion.hxx>
#include <gp_Trsf.hxx>
#include <gp_Vec.hxx>

#include <PLib.hxx>

#include <BSplCLib.hxx>

#include <TopLoc_Location.hxx>

Expand Down
3 changes: 3 additions & 0 deletions src/TKMesh/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
project(TKMesh)

OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)

# Add the precompiled header
ADD_PRECOMPILED_HEADER(TKMesh "${CMAKE_CURRENT_SOURCE_DIR}/TKMesh_pch.hxx" TRUE)
6 changes: 6 additions & 0 deletions src/TKMesh/TKMesh_pch.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef TKMESH_PCH_H
#define TKMESH_PCH_H

#include <IMeshData_Types.hxx>

#endif // TKMESH_PCH_H
3 changes: 3 additions & 0 deletions src/TKV3d/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
project(TKV3d)

OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)

# Add the precompiled header
ADD_PRECOMPILED_HEADER(TKV3d "${CMAKE_CURRENT_SOURCE_DIR}/TKV3d_pch.hxx" TRUE)
9 changes: 9 additions & 0 deletions src/TKV3d/TKV3d_pch.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef TKTKV3d_PCH_H
#define TKTKV3d_PCH_H

#include <AIS_InteractiveObject.hxx>
#include <PrsMgr_PresentableObject.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_SelectableObject.hxx>

#endif // TKTKV3d_PCH_H
3 changes: 3 additions & 0 deletions src/TKXSBase/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
project(TKXSBase)

OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)

# Add the precompiled header
ADD_PRECOMPILED_HEADER(TKXSBase "${CMAKE_CURRENT_SOURCE_DIR}/TKXSBase_pch.hxx" TRUE)
10 changes: 10 additions & 0 deletions src/TKXSBase/TKXSBase_pch.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef TKXSBASE_PCH_H
#define TKXSBASE_PCH_H

#include <Interface_Check.hxx>
#include <Interface_CheckIterator.hxx>
#include <Interface_EntityIterator.hxx>
#include <Interface_FileReaderData.hxx>
#include <Interface_Graph.hxx>

#endif // TKXSBASE_PCH_H
2 changes: 1 addition & 1 deletion src/TKernel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ else ()
endif()

# Add the precompiled header
ADD_PRECOMPILED_HEADER(TKernel "${CMAKE_CURRENT_SOURCE_DIR}/TKernel_pch.hxx")
ADD_PRECOMPILED_HEADER(TKernel "${CMAKE_CURRENT_SOURCE_DIR}/TKernel_pch.hxx" FALSE)
49 changes: 32 additions & 17 deletions src/TKernel/TKernel_pch.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,65 @@
#define TKERNEL_PCH_H

// Standard library headers
#include <atomic>
#include <iostream>
#include <limits>
#include <ostream>
#include <random>
#include <sstream>
#include <string>
#include <type_traits>

// Windows-specific headers (for MSVC)
#ifdef _WIN32
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <windows.h> // For Windows API functions like WideCharToMultiByte
#include <tchar.h> // For Unicode/MBCS mappings
#ifdef GetObject
#undef GetObject
#endif
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <tchar.h> // For Unicode/MBCS mappings
#include <windows.h> // For Windows API functions like WideCharToMultiByte
#ifdef GetObject
#undef GetObject
#endif
#endif

// TKernel headers
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <Standard_DefineHandle.hxx>
#include <Standard_Macro.hxx>
#include <Standard_Transient.hxx>
#include <Standard_GUID.hxx>
#include <Standard_Handle.hxx>
#include <Standard_Macro.hxx>
#include <Standard_Stream.hxx>
#include <Standard_GUID.hxx>
#include <Standard_Transient.hxx>
#include <Standard_Type.hxx>

#include <Precision.hxx>

#include <Quantity_Color.hxx>
#include <Quantity_ColorRGBA.hxx>
#include <Quantity_HArray1OfColor.hxx>
#include <Quantity_TypeOfColor.hxx>

#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <TCollection_HAsciiString.hxx>
#include <TCollection_HExtendedString.hxx>

#include <NCollection_BaseAllocator.hxx>
#include <NCollection_Array1.hxx>
#include <NCollection_Array2.hxx>
#include <NCollection_Map.hxx>
#include <NCollection_BaseAllocator.hxx>
#include <NCollection_Buffer.hxx>
#include <NCollection_DataMap.hxx>
#include <NCollection_List.hxx>
#include <NCollection_Sequence.hxx>
#include <NCollection_DefineHArray1.hxx>
#include <NCollection_IndexedDataMap.hxx>
#include <NCollection_IndexedMap.hxx>
#include <NCollection_List.hxx>
#include <NCollection_Map.hxx>
#include <NCollection_Sequence.hxx>

#include <Message_ProgressIndicator.hxx>
#include <Message_ProgressRange.hxx>
#include <Message_ProgressScope.hxx>

#include <OSD_Parallel.hxx>
#include <OSD_Path.hxx>

#endif // TKERNEL_PCH_H

0 comments on commit ac5a612

Please sign in to comment.