Merge pull request #213 from janisozaur/headers-check
Check that headers include all other necessary header files to compile as a stand alone unit.
This commit is contained in:
commit
3844a52347
5 changed files with 26 additions and 5 deletions
|
@ -148,7 +148,8 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG=${DEBUG_LEVEL}")
|
|||
# include lib
|
||||
include_directories("lib/")
|
||||
# add source files
|
||||
file(GLOB_RECURSE OLOCO_SOURCES "src/*.cpp" "src/*.h" "src/*.hpp")
|
||||
file(GLOB_RECURSE OLOCO_SOURCES "src/*.cpp")
|
||||
file(GLOB_RECURSE OLOCO_HEADERS "src/*.h" "src/*.hpp")
|
||||
|
||||
|
||||
if (APPLE)
|
||||
|
@ -224,3 +225,19 @@ if (APPLE)
|
|||
target_compile_definitions(${PROJECT} PRIVATE COMPAT_STD_BYTE=1)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# Add headers check to verify all headers carry their dependencies.
|
||||
# Only valid for Clang for now:
|
||||
# - GCC 8 does not support -Wno-pragma-once-outside-header
|
||||
# - Other compilers status unknown
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
add_library(${PROJECT}-headers-check OBJECT ${OLOCO_HEADERS})
|
||||
set_target_properties(${PROJECT}-headers-check PROPERTIES LINKER_LANGUAGE CXX)
|
||||
set_source_files_properties(${OLOCO_HEADERS} PROPERTIES LANGUAGE CXX)
|
||||
add_definitions("-x c++ -Wno-pragma-once-outside-header -Wno-unused-const-variable")
|
||||
get_target_property(OPENLOCO_INCLUDE_DIRS ${PROJECT} INCLUDE_DIRECTORIES)
|
||||
set_target_properties(${PROJECT}-headers-check PROPERTIES INCLUDE_DIRECTORIES "${OPENLOCO_INCLUDE_DIRS}")
|
||||
else ()
|
||||
# Dummy target to ease invocation
|
||||
add_custom_target(${PROJECT}-headers-check)
|
||||
endif ()
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#define UNUSED_IMG(x) (x)
|
||||
|
||||
namespace openloco::image_ids
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
namespace openloco::utility
|
||||
{
|
||||
template<typename T, size_t N>
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace openloco::utility
|
|||
std::string to_utf8(const std::wstring_view& src);
|
||||
std::wstring to_utf16(const std::string_view& src);
|
||||
|
||||
static inline bool iequals(const std::string_view& a, const std::string_view& b)
|
||||
inline bool iequals(const std::string_view& a, const std::string_view& b)
|
||||
{
|
||||
if (a.size() != b.size())
|
||||
{
|
||||
|
|
|
@ -95,7 +95,7 @@ namespace openloco::ui
|
|||
return out;
|
||||
}
|
||||
|
||||
static constexpr widget_t make_remap_widget(gfx::point_t origin, gfx::ui_size_t size, widget_type type, uint8_t colour, uint32_t content = 0xFFFFFFFF, string_id tooltip = string_ids::null)
|
||||
constexpr widget_t make_remap_widget(gfx::point_t origin, gfx::ui_size_t size, widget_type type, uint8_t colour, uint32_t content = 0xFFFFFFFF, string_id tooltip = string_ids::null)
|
||||
{
|
||||
widget_t out = make_widget(origin, size, type, colour, content, tooltip);
|
||||
|
||||
|
@ -105,7 +105,7 @@ namespace openloco::ui
|
|||
return out;
|
||||
}
|
||||
|
||||
static constexpr widget_t make_text_widget(gfx::point_t origin, gfx::ui_size_t size, widget_type type, uint8_t colour, string_id content, string_id tooltip = string_ids::null)
|
||||
constexpr widget_t make_text_widget(gfx::point_t origin, gfx::ui_size_t size, widget_type type, uint8_t colour, string_id content, string_id tooltip = string_ids::null)
|
||||
{
|
||||
widget_t out = {};
|
||||
out.left = origin.x;
|
||||
|
@ -120,7 +120,7 @@ namespace openloco::ui
|
|||
return out;
|
||||
}
|
||||
|
||||
static constexpr widget_t widget_end()
|
||||
constexpr widget_t widget_end()
|
||||
{
|
||||
widget_t out = {};
|
||||
out.type = widget_type::end;
|
||||
|
|
Loading…
Reference in a new issue