Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added missing include guards. Fixes a lot of compile issues. #39

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 23 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.8)
project(hpp_skel LANGUAGES CXX)
project(gzip-hpp LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED on)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
Expand Down Expand Up @@ -28,26 +28,31 @@ if (WERROR)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
endif()

# mason_use is a mason function within the mason.cmake file and provides ready-to-go vars, like "STATIC_LIBS" and "INCLUDE_DIRS"
mason_use(catch VERSION 1.9.6 HEADER_ONLY)
include_directories(SYSTEM ${MASON_PACKAGE_catch_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)

mason_use(benchmark VERSION 1.3.0)
include_directories(SYSTEM ${MASON_PACKAGE_benchmark_INCLUDE_DIRS})
add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)

mason_use(zlib VERSION 1.2.8)
include_directories(SYSTEM ${MASON_PACKAGE_zlib_INCLUDE_DIRS})
if (gzip_BUILD_TESTS)
# mason_use is a mason function within the mason.cmake file and provides ready-to-go vars, like "STATIC_LIBS" and "INCLUDE_DIRS"
mason_use(catch VERSION 1.9.6 HEADER_ONLY)
include_directories(SYSTEM ${MASON_PACKAGE_catch_INCLUDE_DIRS})

include_directories("${PROJECT_SOURCE_DIR}/include")
mason_use(benchmark VERSION 1.3.0)
include_directories(SYSTEM ${MASON_PACKAGE_benchmark_INCLUDE_DIRS})

file(GLOB TEST_SOURCES test/*.cpp)
add_executable(unit-tests ${TEST_SOURCES})
mason_use(zlib VERSION 1.2.8)
include_directories(SYSTEM ${MASON_PACKAGE_zlib_INCLUDE_DIRS})

# libbenchmark.a supports threads and therefore needs pthread support
find_package(Threads REQUIRED)
file(GLOB BENCH_SOURCES bench/*.cpp)
add_executable(bench-tests ${BENCH_SOURCES})
file(GLOB TEST_SOURCES test/*.cpp)
add_executable(unit-tests ${TEST_SOURCES})

# link zlib static library to the unit-tests binary so the tests know where to find the zlib impl code
target_link_libraries(unit-tests ${MASON_PACKAGE_zlib_STATIC_LIBS})
target_link_libraries(bench-tests ${MASON_PACKAGE_benchmark_STATIC_LIBS} ${CMAKE_THREAD_LIBS_INIT} ${MASON_PACKAGE_zlib_STATIC_LIBS})
# libbenchmark.a supports threads and therefore needs pthread support
find_package(Threads REQUIRED)
file(GLOB BENCH_SOURCES bench/*.cpp)
add_executable(bench-tests ${BENCH_SOURCES})

# link zlib static library to the unit-tests binary so the tests know where to find the zlib impl code
target_link_libraries(unit-tests ${MASON_PACKAGE_zlib_STATIC_LIBS})
target_link_libraries(bench-tests ${MASON_PACKAGE_benchmark_STATIC_LIBS} ${CMAKE_THREAD_LIBS_INIT} ${MASON_PACKAGE_zlib_STATIC_LIBS})
endif()
6 changes: 6 additions & 0 deletions include/gzip/compress.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#ifndef GZIP_HPP_INCLUDE_GZIP_COMPRESS_HPP
#define GZIP_HPP_INCLUDE_GZIP_COMPRESS_HPP


#include <gzip/config.hpp>

// zlib
Expand Down Expand Up @@ -111,3 +115,5 @@ inline std::string compress(const char* data,
}

} // namespace gzip

#endif // GZIP_HPP_INCLUDE_GZIP_COMPRESS_HPP
5 changes: 5 additions & 0 deletions include/gzip/decompress.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef GZIP_HPP_INCLUDE_GZIP_DECOMPRESS_HPP
#define GZIP_HPP_INCLUDE_GZIP_DECOMPRESS_HPP

#include <gzip/config.hpp>

// zlib
Expand Down Expand Up @@ -103,3 +106,5 @@ inline std::string decompress(const char* data, std::size_t size)
}

} // namespace gzip

#endif // GZIP_HPP_INCLUDE_GZIP_DECOMPRESS_HPP
5 changes: 5 additions & 0 deletions include/gzip/utils.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef GZIP_HPP_INCLUDE_GZIP_UTILS_HPP
#define GZIP_HPP_INCLUDE_GZIP_UTILS_HPP

#include <cstdlib>

namespace gzip {
Expand All @@ -20,3 +23,5 @@ inline bool is_compressed(const char* data, std::size_t size)
(static_cast<uint8_t>(data[0]) == 0x1F && static_cast<uint8_t>(data[1]) == 0x8B));
}
} // namespace gzip

#endif // GZIP_HPP_INCLUDE_GZIP_UTILS_HPP