toml-checker v0.1.4
MoAlyousef 4 years ago
parent df41d3eaff
commit 00121c261f

@ -1,5 +1,10 @@
# CHANGELOG
## 0.1.4 - 2021-04-11
- Use `GIT_SHALLOW ON` by default when getting git dependencies.
- Add cmake.description field.
- Change bin.defines to bin.definitions.
## 0.1.3 - 2020-11-27
- Support building with C++11.
- @mrexodia implemented CMake integration and bootstrapping.

@ -11,14 +11,18 @@ cmake_minimum_required(VERSION 3.15)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(cmkr_PROJECT_VERSION 0.1.3)
project(cmkr VERSION ${cmkr_PROJECT_VERSION})
project(cmkr
VERSION 0.1.4
LANGUAGES C CXX
DESCRIPTION "CMakeLists generator from TOML"
)
include(FetchContent)
FetchContent_Declare(
filesystem
GIT_REPOSITORY https://github.com/gulrak/filesystem
GIT_SHALLOW ON
)
FetchContent_MakeAvailable(filesystem)
@ -33,6 +37,7 @@ FetchContent_MakeAvailable(mpark_variant)
FetchContent_Declare(
toml11
GIT_REPOSITORY https://github.com/ToruNiina/toml11
GIT_SHALLOW ON
)
FetchContent_MakeAvailable(toml11)

@ -35,7 +35,8 @@ minimum = "3.15"
[project]
name = "cmkr"
version = "0.1.3"
version = "0.1.4"
description = "CMakeLists generator from TOML"
[fetch-content]
toml11 = { git = "https://github.com/ToruNiina/toml11" }
@ -65,6 +66,7 @@ Currently supported fields:
```toml
[cmake] # required for top-level project
minimum = "3.15" # required
description = "" # optional
subdirs = [] # optional
bin-dir = "bin" # optional
cpp-flags = [] # optional
@ -102,7 +104,7 @@ sources = ["src/*.cpp"] # required, supports globbing
include-dirs = ["include"] # optional
alias = "" # optional
features = [] # optional
defines = [] # optional
definitions = [] # optional
link-libs = [] # optional
properties = { PROPERTY1 = "property1", ... } # optional

@ -1,9 +1,10 @@
[cmake]
minimum = "3.15"
description = "CMakeLists generator from TOML"
[project]
name = "cmkr"
version = "0.1.3"
version = "0.1.4"
[fetch-content]
toml11 = { git = "https://github.com/ToruNiina/toml11" }

@ -38,7 +38,7 @@ sources = ["src/*.cpp"]
include-dirs = ["include"]
# alias = ""
# features = []
# defines = []
# definitions = []
# link-libs = []
[[install]]

@ -48,6 +48,10 @@ CMake::CMake(const std::string &path, bool build) {
const auto &cmake = toml::find(toml, "cmake");
cmake_version = toml::find(cmake, "minimum").as_string();
if (cmake.contains("description")) {
desc = toml::find(cmake, "description").as_string();
}
if (cmake.contains("cpp-flags")) {
cppflags = detail::to_string_vec(toml::find(cmake, "cpp-flags").as_array());
}
@ -182,8 +186,8 @@ CMake::CMake(const std::string &path, bool build) {
b.features = detail::to_string_vec(toml::find(bin, "features").as_array());
}
if (bin.contains("defines")) {
b.defines = detail::to_string_vec(toml::find(bin, "defines").as_array());
if (bin.contains("definitions")) {
b.defines = detail::to_string_vec(toml::find(bin, "definitions").as_array());
}
if (bin.contains("alias")) {

@ -58,6 +58,7 @@ struct Install {
struct CMake {
std::string cmake_version = "3.15";
std::string desc;
std::string bin_dir = "bin";
std::string generator;
std::string config;

@ -51,7 +51,7 @@ static std::vector<std::string> expand_cmake_path(const fs::path &p) {
temp.push_back(p.string());
}
// Normalize all paths to work with CMake (it needs a / on Windows as well)
for(auto& path : temp) {
for (auto &path : temp) {
std::replace(path.begin(), path.end(), '\\', '/');
}
return temp;
@ -159,11 +159,13 @@ int generate_cmake(const char *path) {
ss << "\n\n";
}
std::string desc = "";
if (!cmake.desc.empty())
desc = "\n\tLANGUAGES C CXX\n\tDESCRIPTION \"" + cmake.desc + "\"";
if (!cmake.proj_name.empty() && !cmake.proj_version.empty()) {
ss << "set(" << cmake.proj_name << "_PROJECT_VERSION " << cmake.proj_version << ")\n"
<< "project(" << cmake.proj_name << " VERSION "
<< "${" << cmake.proj_name << "_PROJECT_VERSION}"
<< ")\n\n";
ss << "project(" << cmake.proj_name << "\n\tVERSION " << cmake.proj_version << desc
<< "\n\t)\n\n";
}
if (!cmake.packages.empty()) {
@ -206,7 +208,12 @@ int generate_cmake(const char *path) {
} else {
// don't change arg
}
ss << "\t" << first_arg << " " << arg.second << "\n";
if (first_arg != "GIT_REPOSITORY")
ss << "\t" << first_arg << " " << arg.second << "\n";
else
ss << "\t" << first_arg << " " << arg.second << "\n\t"
<< "GIT_SHALLOW "
<< "ON\n";
}
ss << "\t)\n\n"
<< "FetchContent_MakeAvailable(" << dep.first << ")\n\n";

Loading…
Cancel
Save