Fixed compilation on macos

This commit is contained in:
Bartek Kryza
2022-08-08 18:21:08 +02:00
parent e3434bfc59
commit b066348429
9 changed files with 37 additions and 27 deletions

View File

@@ -11,6 +11,7 @@ project(clang-uml)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_VERBOSE_MAKEFILE OFF) set(CMAKE_VERBOSE_MAKEFILE OFF)
set(CMAKE_FIND_DEBUG_MODE OFF)
# #
# clang-uml custom defines # clang-uml custom defines
@@ -44,7 +45,6 @@ include(AddLLVM)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
message(STATUS "LLVM library dir: ${LLVM_LIBRARY_DIR}") message(STATUS "LLVM library dir: ${LLVM_LIBRARY_DIR}")
link_directories(${LLVM_LIBRARY_DIR})
if(LINK_LLVM_SHARED) if(LINK_LLVM_SHARED)
set(LIBTOOLING_LIBS clang-cpp LLVM) set(LIBTOOLING_LIBS clang-cpp LLVM)
@@ -86,18 +86,25 @@ find_package(Threads REQUIRED)
# Setup yaml-cpp # Setup yaml-cpp
# #
message(STATUS "Checking for yaml-cpp...") message(STATUS "Checking for yaml-cpp...")
find_package(yaml-cpp REQUIRED) if(APPLE)
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules(YAML_CPP yaml-cpp)
find_path(YAML_CPP_INCLUDE_DIR
NAMES yaml.h
PATHS ${YAML_CPP_INCLUDE_DIR} /usr/local/include/yaml-cpp)
find_library(YAML_CPP_LIBRARY
NAMES yaml-cpp
PATHS ${YAML_CPP_LIBRARIES} /usr/local/lib)
set(YAML_CPP_LIBRARY_DIR /usr/local/lib)
endif()
else(APPLE)
find_package(yaml-cpp REQUIRED)
endif(APPLE)
#message(STATUS "Checking for libclang...") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -std=c++17 -Wno-unused-parameter -Wno-unused-private-field")
#set(LLVM_PREFERRED_VERSION 14.0.0)
# Add
# -DLLVM_CONFIG_PATH=/path/to/llvm-config
# to use custom LLVM version
#find_package(LibClang REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -std=c++17") link_directories(${LLVM_LIBRARY_DIR} ${YAML_CPP_LIBRARY_DIR})
message(STATUS "Using CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
# #
# Setup thirdparty sources # Setup thirdparty sources
@@ -119,16 +126,17 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
OUTPUT_VARIABLE GCC_STDDEF_INCLUDE) OUTPUT_VARIABLE GCC_STDDEF_INCLUDE)
message(STATUS "FOUND GCC STDDEF INCLUDE ${GCC_STDDEF_INCLUDE}") message(STATUS "FOUND GCC STDDEF INCLUDE ${GCC_STDDEF_INCLUDE}")
include_directories(${GCC_STDDEF_INCLUDE}) include_directories(${GCC_STDDEF_INCLUDE})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${GCC_STDDEF_INCLUDE} -Wno-unused-parameter") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${GCC_STDDEF_INCLUDE}")
endif() endif()
message(STATUS "Using CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
# #
# Setup include directories # Setup include directories
# #
include_directories(${LLVM_INCLUDE_DIRS}) include_directories(${LLVM_INCLUDE_DIRS})
include_directories(${CLANG_UML_INSTALL_INCLUDE_DIR}) include_directories(${CLANG_UML_INSTALL_INCLUDE_DIR})
include_directories(${YAML_CPP_INCLUDE_DIR}) include_directories(${YAML_CPP_INCLUDE_DIRS})
include_directories(${UML_HEADERS_DIR}) include_directories(${UML_HEADERS_DIR})
include_directories(${THIRDPARTY_HEADERS_DIR}) include_directories(${THIRDPARTY_HEADERS_DIR})
include_directories(${PROJECT_SOURCE_DIR}/src/) include_directories(${PROJECT_SOURCE_DIR}/src/)

View File

@@ -108,9 +108,9 @@ private:
namespace std { namespace std {
template <> template <>
struct hash< struct hash<
std::reference_wrapper<const clanguml::class_diagram::model::class_>> { std::reference_wrapper<clanguml::class_diagram::model::class_>> {
std::size_t operator()(const std::reference_wrapper< std::size_t operator()(const std::reference_wrapper<
const clanguml::class_diagram::model::class_> &key) const clanguml::class_diagram::model::class_> &key) const
{ {
using clanguml::common::id_t; using clanguml::common::id_t;

View File

@@ -213,9 +213,9 @@ void diagram::get_parents(
bool found_new{false}; bool found_new{false};
for (const auto &parent : parents) { for (const auto &parent : parents) {
for (const auto &pp : parent.get().parents()) { for (const auto &pp : parent.get().parents()) {
const auto p = get_class(pp.id()); auto p = get_class(pp.id());
if (p.has_value()) { if (p.has_value()) {
auto [it, found] = parents.emplace(p.value()); auto [it, found] = parents.emplace(std::ref(p.value()));
if (found) if (found)
found_new = true; found_new = true;
} }

View File

@@ -219,7 +219,7 @@ private:
cd, element.get().path().to_string()); cd, element.get().path().to_string());
while (parent.has_value()) { while (parent.has_value()) {
parents.emplace(std::ref(parent.value())); parents.emplace(parent.value());
parent = detail::get<ElementT, DiagramT>( parent = detail::get<ElementT, DiagramT>(
cd, parent.value().path().to_string()); cd, parent.value().path().to_string());
} }

View File

@@ -57,9 +57,9 @@ private:
namespace std { namespace std {
template <> template <>
struct hash<std::reference_wrapper<const clanguml::common::model::package>> { struct hash<std::reference_wrapper<clanguml::common::model::package>> {
std::size_t operator()( std::size_t operator()(
const std::reference_wrapper<const clanguml::common::model::package> const std::reference_wrapper<clanguml::common::model::package>
&key) const &key) const
{ {
using clanguml::common::id_t; using clanguml::common::id_t;

View File

@@ -144,9 +144,9 @@ template <> struct hash<clanguml::common::model::filesystem_path> {
namespace std { namespace std {
template <> template <>
struct hash< struct hash<
std::reference_wrapper<const clanguml::common::model::source_file>> { std::reference_wrapper<clanguml::common::model::source_file>> {
std::size_t operator()( std::size_t operator()(
const std::reference_wrapper<const clanguml::common::model::source_file> const std::reference_wrapper<clanguml::common::model::source_file>
&key) const &key) const
{ {
using clanguml::common::id_t; using clanguml::common::id_t;

View File

@@ -115,6 +115,6 @@ template <typename T>
using reference_vector = std::vector<std::reference_wrapper<T>>; using reference_vector = std::vector<std::reference_wrapper<T>>;
template <typename T> template <typename T>
using reference_set = std::unordered_set<std::reference_wrapper<const T>>; using reference_set = std::unordered_set<std::reference_wrapper<T>>;
} // namespace clang::common } // namespace clang::common

View File

@@ -103,7 +103,7 @@ void generator::generate(std::ostream &ostr) const
// Generate files and folders // Generate files and folders
util::for_each_if( util::for_each_if(
m_model, [this](const auto &f) { return true; }, m_model, [](const auto &f) { return true; },
[this, &ostr](const auto &f) { [this, &ostr](const auto &f) {
generate(dynamic_cast<source_file &>(*f), ostr); generate(dynamic_cast<source_file &>(*f), ostr);
}); });

View File

@@ -253,9 +253,11 @@ bool starts_with(
normal_prefix /= element; normal_prefix /= element;
} }
return std::search(normal_path.begin(), normal_path.end(), auto normal_path_str = normal_path.string();
normal_prefix.begin(), auto normal_prefix_str = normal_prefix.string();
normal_prefix.end()) == normal_path.begin(); return std::search(normal_path_str.begin(), normal_path_str.end(),
normal_prefix_str.begin(),
normal_prefix_str.end()) == normal_path_str.begin();
} }
template <> bool starts_with(const std::string &s, const std::string &prefix) template <> bool starts_with(const std::string &s, const std::string &prefix)