mirror of
https://github.com/google/sentencepiece.git
synced 2024-10-26 11:38:45 +03:00
Fixed the issue of concatinating paths for pkg-config
This commit is contained in:
parent
de150504f8
commit
460d15b31d
@ -94,6 +94,30 @@ if (NOT DEFINED CMAKE_INSTALL_INCDIR)
|
|||||||
set(CMAKE_INSTALL_INCDIR include)
|
set(CMAKE_INSTALL_INCDIR include)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# SPDX-License-Identifier: (MIT OR CC0-1.0)
|
||||||
|
# Copyright 2020 Jan Tojnar
|
||||||
|
# https://github.com/jtojnar/cmake-snips
|
||||||
|
#
|
||||||
|
# Modelled after Python’s os.path.join
|
||||||
|
# https://docs.python.org/3.7/library/os.path.html#os.path.join
|
||||||
|
# Windows not supported
|
||||||
|
function(join_paths joined_path first_path_segment)
|
||||||
|
set(temp_path "${first_path_segment}")
|
||||||
|
foreach(current_segment IN LISTS ARGN)
|
||||||
|
if(NOT ("${current_segment}" STREQUAL ""))
|
||||||
|
if(IS_ABSOLUTE "${current_segment}")
|
||||||
|
set(temp_path "${current_segment}")
|
||||||
|
else()
|
||||||
|
set(temp_path "${temp_path}/${current_segment}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
set(${joined_path} "${temp_path}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
join_paths(libdir_for_pc_file "\${exec_prefix}" "${CMAKE_INSTALL_LIBDIR}")
|
||||||
|
join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||||
|
|
||||||
configure_file("${PROJECT_SOURCE_DIR}/config.h.in" "config.h")
|
configure_file("${PROJECT_SOURCE_DIR}/config.h.in" "config.h")
|
||||||
configure_file("${PROJECT_SOURCE_DIR}/sentencepiece.pc.in" "sentencepiece.pc" @ONLY)
|
configure_file("${PROJECT_SOURCE_DIR}/sentencepiece.pc.in" "sentencepiece.pc" @ONLY)
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
prefix=@prefix@
|
prefix=@prefix@
|
||||||
exec_prefix=@exec_prefix@
|
exec_prefix=@exec_prefix@
|
||||||
libdir=@libdir@
|
libdir=@libdir_for_pc_file@
|
||||||
includedir=@includedir@
|
includedir=@includedir_for_pc_file@
|
||||||
|
|
||||||
Name: @PROJECT_NAME@
|
Name: @PROJECT_NAME@
|
||||||
Description: Unsupervised text tokenizer and detokenizer for Neural Network-based text generation.
|
Description: Unsupervised text tokenizer and detokenizer for Neural Network-based text generation.
|
||||||
|
20
third_party/absl/flags/flag.cc
vendored
20
third_party/absl/flags/flag.cc
vendored
@ -61,8 +61,8 @@ struct FlagFunc {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using FlagMap = std::map<std::string, FlagFunc *>;
|
using FlagMap = std::map<std::string, std::shared_ptr<FlagFunc>>;
|
||||||
using FlagList = std::vector<FlagFunc *>;
|
using FlagList = std::vector<std::shared_ptr<FlagFunc>>;
|
||||||
|
|
||||||
FlagMap *GetFlagMap() {
|
FlagMap *GetFlagMap() {
|
||||||
static auto *flag_map = new FlagMap;
|
static auto *flag_map = new FlagMap;
|
||||||
@ -111,7 +111,7 @@ std::string PrintHelp(const char *programname) {
|
|||||||
os << PACKAGE_STRING << "\n\n";
|
os << PACKAGE_STRING << "\n\n";
|
||||||
os << "Usage: " << programname << " [options] files\n\n";
|
os << "Usage: " << programname << " [options] files\n\n";
|
||||||
|
|
||||||
for (const auto *func : *GetFlagList()) {
|
for (auto func : *GetFlagList()) {
|
||||||
os << " --" << func->name << " (" << func->help << ")";
|
os << " --" << func->name << " (" << func->help << ")";
|
||||||
os << " type: " << func->type << " default: " << func->default_value
|
os << " type: " << func->type << " default: " << func->default_value
|
||||||
<< '\n';
|
<< '\n';
|
||||||
@ -123,7 +123,7 @@ std::string PrintHelp(const char *programname) {
|
|||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void RegisterFlag(const std::string &name, FlagFunc *func) {
|
void RegisterFlag(const std::string &name, std::shared_ptr<FlagFunc> func) {
|
||||||
GetFlagList()->emplace_back(func);
|
GetFlagList()->emplace_back(func);
|
||||||
GetFlagMap()->emplace(name, func);
|
GetFlagMap()->emplace(name, func);
|
||||||
}
|
}
|
||||||
@ -140,7 +140,7 @@ Flag<T>::Flag(const char *name, const char *type, const char *help,
|
|||||||
func_->set_value = [this](const std::string &value) {
|
func_->set_value = [this](const std::string &value) {
|
||||||
this->set_value_as_str(value);
|
this->set_value_as_str(value);
|
||||||
};
|
};
|
||||||
RegisterFlag(name, func_.get());
|
RegisterFlag(name, func_);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -219,4 +219,14 @@ std::vector<char *> ParseCommandLine(int argc, char *argv[]) {
|
|||||||
|
|
||||||
return output_args;
|
return output_args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CleanupFlags() {
|
||||||
|
static bool is_shutdown = false;
|
||||||
|
if (!is_shutdown) {
|
||||||
|
delete internal::GetFlagList();
|
||||||
|
delete internal::GetFlagMap();
|
||||||
|
is_shutdown = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace absl
|
} // namespace absl
|
||||||
|
10
third_party/absl/flags/flag.h
vendored
10
third_party/absl/flags/flag.h
vendored
@ -24,7 +24,8 @@ namespace absl {
|
|||||||
namespace internal {
|
namespace internal {
|
||||||
struct FlagFunc;
|
struct FlagFunc;
|
||||||
|
|
||||||
void RegisterFlag(const std::string &name, FlagFunc *func);
|
void RegisterFlag(const std::string &name, std::shared_ptr<FlagFunc> func);
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -39,7 +40,7 @@ class Flag {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
T value_;
|
T value_;
|
||||||
std::unique_ptr<internal::FlagFunc> func_;
|
std::shared_ptr<internal::FlagFunc> func_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -52,6 +53,11 @@ void SetFlag(Flag<T> *flag, const V &v) {
|
|||||||
const T value(v);
|
const T value(v);
|
||||||
flag->set_value(value);
|
flag->set_value(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define HAS_ABSL_CLEANUP_FLAGS
|
||||||
|
|
||||||
|
void CleanupFlags();
|
||||||
|
|
||||||
} // namespace absl
|
} // namespace absl
|
||||||
|
|
||||||
#define ABSL_FLAG(Type, name, defautl_value, help) \
|
#define ABSL_FLAG(Type, name, defautl_value, help) \
|
||||||
|
Loading…
Reference in New Issue
Block a user