Adding a pre-compiled header for MSVC

release/4.3a0
Frank Dellaert 2018-11-04 12:37:43 -05:00
parent 1427977230
commit e38a3156c3
4 changed files with 119 additions and 14 deletions

27
cmake/GtsamAddPch.cmake Normal file
View File

@ -0,0 +1,27 @@
###############################################################################
# Macro:
#
# gtsamAddPch(precompiledHeader precompiledSource sources)
#
# Adds a precompiled header to compile all sources with. Currently only on MSVC.
# Inspired by https://stackoverflow.com/questions/148570/
#
# Arguments:
# precompiledHeader: the header file that includes headers to be precompiled.
# precompiledSource: the source file that simply includes that header above.
# sources: the list of source files to apply this to.
#
macro(gtsamAddPch precompiledHeader precompiledSource sources)
get_filename_component(pchBasename ${precompiledHeader} NAME_WE)
SET(precompiledBinary "${CMAKE_CURRENT_BINARY_DIR}/${pchBasename}.pch")
IF(MSVC)
message(STATUS "Adding precompiled header for MSVC")
set_source_files_properties(${precompiledSource}
PROPERTIES COMPILE_FLAGS "/Yc\"${precompiledHeader}\" /Fp\"${precompiledBinary}\""
OBJECT_OUTPUTS "${precompiledBinary}")
set_source_files_properties(${sources}
PROPERTIES COMPILE_FLAGS "/Yu\"${precompiledHeader}\" /FI\"${precompiledHeader}\" /Fp\"${precompiledBinary}\""
OBJECT_DEPENDS "${precompiledBinary}")
ENDIF(MSVC)
endmacro(gtsamAddPch)

View File

@ -65,20 +65,19 @@ foreach(subdir ${gtsam_subdirs})
endforeach(subdir)
# To add additional sources to gtsam when building the full library (static or shared)
# Add the subfolder with _srcs appended to the end to this list
set(gtsam_srcs
${3rdparty_srcs}
${base_srcs}
${geometry_srcs}
${inference_srcs}
${symbolic_srcs}
${discrete_srcs}
${linear_srcs}
${nonlinear_srcs}
${slam_srcs}
${navigation_srcs}
${gtsam_core_headers}
)
# append the subfolder with _srcs appended to the end to this list
set(gtsam_srcs ${3rdparty_srcs})
foreach(subdir ${gtsam_subdirs})
list(APPEND gtsam_srcs ${${subdir}_srcs})
endforeach(subdir)
list(APPEND gtsam_srcs ${gtsam_core_headers})
IF(MSVC)
# Add precompiled header to sources
include(gtsamAddPch)
gtsamAddPch("precompiled_header.h" "precompiled_header.cpp" ${gtsam_srcs})
list(INSERT gtsam_srcs 0 "precompiled_header.cpp")
ENDIF(MSVC)
# Generate and install config and dllexport files
configure_file(config.h.in config.h)
@ -155,6 +154,7 @@ if(MSVC)
APPEND PROPERTY COMPILE_FLAGS "/bigobj")
endif()
# Create the matlab toolbox for the gtsam library
if (GTSAM_INSTALL_MATLAB_TOOLBOX)
# Set up codegen

View File

@ -0,0 +1,19 @@
/* ----------------------------------------------------------------------------
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
* Atlanta, Georgia 30332-0415
* All Rights Reserved
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
* See LICENSE for the license information
* -------------------------------------------------------------------------- */
/**
* @file precompiled_header.cpp
* @brief We need exactly one compilation unit that includes the precompiled headers
* @author Frank Dellaert
* @date November 2018
*/
#include "precompiled_header.h"

View File

@ -0,0 +1,59 @@
/* ----------------------------------------------------------------------------
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
* Atlanta, Georgia 30332-0415
* All Rights Reserved
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
* See LICENSE for the license information
* -------------------------------------------------------------------------- */
/**
* @file precompiled_header.h>
* @brief Include headers that will be included nearly everywhere
* @author Frank Dellaert
* @date November 2018
*/
#pragma once
// All headers in base:
#include <gtsam/base/Lie.h>
#include <gtsam/base/chartTesting.h>
#include <gtsam/base/cholesky.h>
#include <gtsam/base/concepts.h>
#include <gtsam/base/ConcurrentMap.h>
#include <gtsam/base/debug.h>
#include <gtsam/base/DerivedValue.h>
#include <gtsam/base/DSFVector.h>
#include <gtsam/base/FastDefaultAllocator.h>
#include <gtsam/base/FastList.h>
#include <gtsam/base/FastMap.h>
#include <gtsam/base/FastSet.h>
#include <gtsam/base/FastVector.h>
#include <gtsam/base/GenericValue.h>
#include <gtsam/base/Group.h>
#include <gtsam/base/Lie.h>
#include <gtsam/base/lieProxies.h>
#include <gtsam/base/Manifold.h>
#include <gtsam/base/Matrix.h>
#include <gtsam/base/numericalDerivative.h>
#include <gtsam/base/OptionalJacobian.h>
#include <gtsam/base/ProductLieGroup.h>
#include <gtsam/base/serialization.h>
#include <gtsam/base/serializationTestHelpers.h>
#include <gtsam/base/SymmetricBlockMatrix.h>
#include <gtsam/base/Testable.h>
#include <gtsam/base/TestableAssertions.h>
#include <gtsam/base/testLie.h>
#include <gtsam/base/ThreadsafeException.h>
#include <gtsam/base/timing.h>
#include <gtsam/base/treeTraversal-inst.h>
#include <gtsam/base/types.h>
#include <gtsam/base/Value.h>
#include <gtsam/base/Vector.h>
#include <gtsam/base/VectorSpace.h>
#include <gtsam/base/VerticalBlockMatrix.h>