Skip to content

Commit 00121c2

Browse files
committed
0.1.4
1 parent df41d3e commit 00121c2

File tree

8 files changed

+39
-14
lines changed

8 files changed

+39
-14
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# CHANGELOG
22

3+
## 0.1.4 - 2021-04-11
4+
- Use `GIT_SHALLOW ON` by default when getting git dependencies.
5+
- Add cmake.description field.
6+
- Change bin.defines to bin.definitions.
7+
38
## 0.1.3 - 2020-11-27
49
- Support building with C++11.
510
- @mrexodia implemented CMake integration and bootstrapping.

CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,18 @@ cmake_minimum_required(VERSION 3.15)
1111

1212
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
1313

14-
set(cmkr_PROJECT_VERSION 0.1.3)
15-
project(cmkr VERSION ${cmkr_PROJECT_VERSION})
14+
project(cmkr
15+
VERSION 0.1.4
16+
LANGUAGES C CXX
17+
DESCRIPTION "CMakeLists generator from TOML"
18+
)
1619

1720
include(FetchContent)
1821

1922
FetchContent_Declare(
2023
filesystem
2124
GIT_REPOSITORY https://github.com/gulrak/filesystem
25+
GIT_SHALLOW ON
2226
)
2327

2428
FetchContent_MakeAvailable(filesystem)
@@ -33,6 +37,7 @@ FetchContent_MakeAvailable(mpark_variant)
3337
FetchContent_Declare(
3438
toml11
3539
GIT_REPOSITORY https://github.com/ToruNiina/toml11
40+
GIT_SHALLOW ON
3641
)
3742

3843
FetchContent_MakeAvailable(toml11)

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ minimum = "3.15"
3535

3636
[project]
3737
name = "cmkr"
38-
version = "0.1.3"
38+
version = "0.1.4"
39+
description = "CMakeLists generator from TOML"
3940

4041
[fetch-content]
4142
toml11 = { git = "https://github.com/ToruNiina/toml11" }
@@ -65,6 +66,7 @@ Currently supported fields:
6566
```toml
6667
[cmake] # required for top-level project
6768
minimum = "3.15" # required
69+
description = "" # optional
6870
subdirs = [] # optional
6971
bin-dir = "bin" # optional
7072
cpp-flags = [] # optional
@@ -102,7 +104,7 @@ sources = ["src/*.cpp"] # required, supports globbing
102104
include-dirs = ["include"] # optional
103105
alias = "" # optional
104106
features = [] # optional
105-
defines = [] # optional
107+
definitions = [] # optional
106108
link-libs = [] # optional
107109
properties = { PROPERTY1 = "property1", ... } # optional
108110

cmake.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
[cmake]
22
minimum = "3.15"
3+
description = "CMakeLists generator from TOML"
34

45
[project]
56
name = "cmkr"
6-
version = "0.1.3"
7+
version = "0.1.4"
78

89
[fetch-content]
910
toml11 = { git = "https://github.com/ToruNiina/toml11" }

include/literals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ sources = ["src/*.cpp"]
3838
include-dirs = ["include"]
3939
# alias = ""
4040
# features = []
41-
# defines = []
41+
# definitions = []
4242
# link-libs = []
4343
4444
[[install]]

src/cmake.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ CMake::CMake(const std::string &path, bool build) {
4848
const auto &cmake = toml::find(toml, "cmake");
4949
cmake_version = toml::find(cmake, "minimum").as_string();
5050

51+
if (cmake.contains("description")) {
52+
desc = toml::find(cmake, "description").as_string();
53+
}
54+
5155
if (cmake.contains("cpp-flags")) {
5256
cppflags = detail::to_string_vec(toml::find(cmake, "cpp-flags").as_array());
5357
}
@@ -182,8 +186,8 @@ CMake::CMake(const std::string &path, bool build) {
182186
b.features = detail::to_string_vec(toml::find(bin, "features").as_array());
183187
}
184188

185-
if (bin.contains("defines")) {
186-
b.defines = detail::to_string_vec(toml::find(bin, "defines").as_array());
189+
if (bin.contains("definitions")) {
190+
b.defines = detail::to_string_vec(toml::find(bin, "definitions").as_array());
187191
}
188192

189193
if (bin.contains("alias")) {

src/cmake.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ struct Install {
5858

5959
struct CMake {
6060
std::string cmake_version = "3.15";
61+
std::string desc;
6162
std::string bin_dir = "bin";
6263
std::string generator;
6364
std::string config;

src/gen.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static std::vector<std::string> expand_cmake_path(const fs::path &p) {
5151
temp.push_back(p.string());
5252
}
5353
// Normalize all paths to work with CMake (it needs a / on Windows as well)
54-
for(auto& path : temp) {
54+
for (auto &path : temp) {
5555
std::replace(path.begin(), path.end(), '\\', '/');
5656
}
5757
return temp;
@@ -159,11 +159,13 @@ int generate_cmake(const char *path) {
159159
ss << "\n\n";
160160
}
161161

162+
std::string desc = "";
163+
if (!cmake.desc.empty())
164+
desc = "\n\tLANGUAGES C CXX\n\tDESCRIPTION \"" + cmake.desc + "\"";
165+
162166
if (!cmake.proj_name.empty() && !cmake.proj_version.empty()) {
163-
ss << "set(" << cmake.proj_name << "_PROJECT_VERSION " << cmake.proj_version << ")\n"
164-
<< "project(" << cmake.proj_name << " VERSION "
165-
<< "${" << cmake.proj_name << "_PROJECT_VERSION}"
166-
<< ")\n\n";
167+
ss << "project(" << cmake.proj_name << "\n\tVERSION " << cmake.proj_version << desc
168+
<< "\n\t)\n\n";
167169
}
168170

169171
if (!cmake.packages.empty()) {
@@ -206,7 +208,12 @@ int generate_cmake(const char *path) {
206208
} else {
207209
// don't change arg
208210
}
209-
ss << "\t" << first_arg << " " << arg.second << "\n";
211+
if (first_arg != "GIT_REPOSITORY")
212+
ss << "\t" << first_arg << " " << arg.second << "\n";
213+
else
214+
ss << "\t" << first_arg << " " << arg.second << "\n\t"
215+
<< "GIT_SHALLOW "
216+
<< "ON\n";
210217
}
211218
ss << "\t)\n\n"
212219
<< "FetchContent_MakeAvailable(" << dep.first << ")\n\n";

0 commit comments

Comments
 (0)