Skip to content

Commit

Permalink
Add precompiled header
Browse files Browse the repository at this point in the history
All modern C++ compiler support precompiled headers, add one to increase build performance.
  • Loading branch information
vbaderks committed Jan 18, 2025
1 parent e88e420 commit 84c8bbd
Show file tree
Hide file tree
Showing 17 changed files with 81 additions and 25 deletions.
7 changes: 5 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) Team CharLS.
# SPDX-FileCopyrightText: © 2016 Team CharLS
# SPDX-License-Identifier: BSD-3-Clause

root = true
Expand All @@ -22,4 +22,7 @@ insert_final_newline = true
indent_size = 2

[*.manifest]
indent_size = 2
indent_size = 2

[*.props, .runsettings]
indent_size = 2
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ if(NOT BUILD_SHARED_LIBS)
target_compile_definitions(charls PUBLIC CHARLS_STATIC)
endif()

target_precompile_headers(charls PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pch.hpp)

# Use different DLL filenames on Windows. It allows platform neutral adapters to load dynamically the correct version.
if(WIN32 AND BUILD_SHARED_LIBS)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
Expand Down Expand Up @@ -128,6 +130,7 @@ target_sources(charls
"${CMAKE_CURRENT_LIST_DIR}/lossless_traits.hpp"
"${CMAKE_CURRENT_LIST_DIR}/make_scan_codec.hpp"
"${CMAKE_CURRENT_LIST_DIR}/make_scan_codec.cpp"
"${CMAKE_CURRENT_LIST_DIR}/pch.hpp"
"${CMAKE_CURRENT_LIST_DIR}/quantization_lut.hpp"
"${CMAKE_CURRENT_LIST_DIR}/quantization_lut.cpp"
"${CMAKE_CURRENT_LIST_DIR}/regular_mode_context.hpp"
Expand Down
7 changes: 5 additions & 2 deletions src/CharLS.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@
<ClCompile>
<PreprocessorDefinitions>CHARLS_LIBRARY_BUILD;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<PrecompiledHeader>
</PrecompiledHeader>
<PrecompiledHeader>Use</PrecompiledHeader>
</ClCompile>
<Link>
</Link>
Expand Down Expand Up @@ -213,6 +212,9 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="golomb_lut.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="quantization_lut.cpp" />
<ClCompile Include="validate_spiff_header.cpp" />
<ClCompile Include="version.cpp" />
Expand Down Expand Up @@ -242,6 +244,7 @@
<ClInclude Include="color_transform.hpp" />
<ClInclude Include="conditional_static_cast.hpp" />
<ClInclude Include="constants.hpp" />
<ClInclude Include="pch.hpp" />
<ClInclude Include="regular_mode_context.hpp" />
<ClInclude Include="run_mode_context.hpp" />
<ClInclude Include="copy_to_line_buffer.hpp" />
Expand Down
10 changes: 8 additions & 2 deletions src/CharLS.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
<ClCompile Include="quantization_lut.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\include\charls\charls.ixx">
<Filter>Header Files</Filter>
<ClCompile Include="pch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -156,6 +156,9 @@
<ClInclude Include="..\include\charls\undef_macros.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="pch.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="charls.rc" />
Expand All @@ -171,6 +174,9 @@
<Filter>Design</Filter>
</None>
<None Include="packages.config" />
<None Include="..\include\charls\charls.ixx">
<Filter>Header Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Filter Include="Header Files">
Expand Down
6 changes: 4 additions & 2 deletions src/charls_jpegls_decoder.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Copyright (c) Team CharLS.
// SPDX-FileCopyrightText: © 2019 Team CharLS
// SPDX-License-Identifier: BSD-3-Clause

#include "charls/charls_jpegls_decoder.h"
#include "pch.hpp"

#include <charls/charls_jpegls_decoder.h>

#include "constants.hpp"
#include "jpeg_stream_reader.hpp"
Expand Down
4 changes: 3 additions & 1 deletion src/charls_jpegls_encoder.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Team CharLS.
// SPDX-FileCopyrightText: © 2019 Team CharLS
// SPDX-License-Identifier: BSD-3-Clause

#include "pch.hpp"

#include "charls/charls_jpegls_encoder.h"

#include "charls/version.h"
Expand Down
4 changes: 3 additions & 1 deletion src/golomb_lut.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Team CharLS.
// SPDX-FileCopyrightText: © 2023 Team CharLS
// SPDX-License-Identifier: BSD-3-Clause

#include "pch.hpp"

#include "golomb_lut.hpp"

#include "conditional_static_cast.hpp"
Expand Down
4 changes: 3 additions & 1 deletion src/jpeg_stream_reader.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Team CharLS.
// SPDX-FileCopyrightText: © 2009 Team CharLS
// SPDX-License-Identifier: BSD-3-Clause

#include "pch.hpp"

#include "jpeg_stream_reader.hpp"

#include "color_transform.hpp"
Expand Down
4 changes: 3 additions & 1 deletion src/jpeg_stream_writer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Team CharLS.
// SPDX-FileCopyrightText: © 2009 Team CharLS
// SPDX-License-Identifier: BSD-3-Clause

#include "pch.hpp"

#include "jpeg_stream_writer.hpp"

#include "constants.hpp"
Expand Down
6 changes: 3 additions & 3 deletions src/jpegls_error.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Team CharLS.
// SPDX-FileCopyrightText: © 2018 Team CharLS
// SPDX-License-Identifier: BSD-3-Clause

#include "charls/jpegls_error.hpp"
#include "pch.hpp"

#include <string>
#include "charls/jpegls_error.hpp"

namespace charls {

Expand Down
4 changes: 3 additions & 1 deletion src/make_scan_codec.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Team CharLS.
// SPDX-FileCopyrightText: © 2009 Team CharLS
// SPDX-License-Identifier: BSD-3-Clause

#include "pch.hpp"

#include "make_scan_codec.hpp"

#include "default_traits.hpp"
Expand Down
4 changes: 4 additions & 0 deletions src/pch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// SPDX-FileCopyrightText: © 2025 Team CharLS
// SPDX-License-Identifier: BSD-3-Clause

#include "pch.hpp"
21 changes: 21 additions & 0 deletions src/pch.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-FileCopyrightText: © 2025 Team CharLS
// SPDX-License-Identifier: BSD-3-Clause

#pragma once

#include <algorithm>
#include <array>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <limits>
#include <memory>
#include <new>
#include <numeric>
#include <system_error>
#include <type_traits>
#include <utility>
#include <vector>
7 changes: 4 additions & 3 deletions src/quantization_lut.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// Copyright (c) Team CharLS.
// SPDX-FileCopyrightText: © 2023 Team CharLS
// SPDX-License-Identifier: BSD-3-Clause

#include "pch.hpp"

#include "quantization_lut.hpp"

#include "charls/public_types.h"
#include <charls/public_types.h>
#include "jpegls_algorithm.hpp"

#include "jpegls_preset_coding_parameters.hpp"

namespace charls {
Expand Down
6 changes: 4 additions & 2 deletions src/validate_spiff_header.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// Copyright (c) Team CharLS.
// SPDX-FileCopyrightText: © 2022 Team CharLS
// SPDX-License-Identifier: BSD-3-Clause

#include "pch.hpp"

#include <charls/validate_spiff_header.h>

#include "charls/validate_spiff_header.h"
#include "util.hpp"

using namespace charls;
Expand Down
7 changes: 4 additions & 3 deletions src/version.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// Copyright (c) Team CharLS.
// SPDX-FileCopyrightText: © 2019 Team CharLS
// SPDX-License-Identifier: BSD-3-Clause

#include "charls/version.h"
#include "pch.hpp"

#include "util.hpp"
#include <charls/version.h>

#include "util.hpp"

using namespace charls;

Expand Down
2 changes: 1 addition & 1 deletion unittest/CharLSUnitTest.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<SubSystem>Windows</SubSystem>
<AdditionalLibraryDirectories>$(SolutionDir)build\intermediate\CharLS\$(Platform)\$(Configuration)\</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories Condition="'$(Platform)'=='Win32'">$(SolutionDir)build\intermediate\CharLS\x86\$(Configuration)\</AdditionalLibraryDirectories>
<AdditionalDependencies>make_scan_codec.obj;jpegls_error.obj;jpeg_stream_writer.obj;jpeg_stream_reader.obj;charls_jpegls_decoder.obj;charls_jpegls_encoder.obj;version.obj;validate_spiff_header.obj;golomb_lut.obj;quantization_lut.obj;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>pch.obj;make_scan_codec.obj;jpegls_error.obj;jpeg_stream_writer.obj;jpeg_stream_reader.obj;charls_jpegls_decoder.obj;charls_jpegls_encoder.obj;version.obj;validate_spiff_header.obj;golomb_lut.obj;quantization_lut.obj;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down

0 comments on commit 84c8bbd

Please sign in to comment.