vcpkg-wip v0.1.4
MoAlyousef 4 years ago
parent df41d3eaff
commit 00121c261f

@ -1,5 +1,10 @@
# CHANGELOG # 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 ## 0.1.3 - 2020-11-27
- Support building with C++11. - Support building with C++11.
- @mrexodia implemented CMake integration and bootstrapping. - @mrexodia implemented CMake integration and bootstrapping.

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

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

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

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

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

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

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

Loading…
Cancel
Save