Skip to content

Commit 4e55489

Browse files
committed
update 0.1.1
1 parent 18034af commit 4e55489

File tree

14 files changed

+197
-36
lines changed

14 files changed

+197
-36
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ bin2
33
compile_commands.json
44
.clangd
55
temp.*
6-
.vs
6+
.vs
7+
.cache

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# CHANGELOG
22

3-
## 0.1.0 - Unreleased
3+
## 0.1.1 - 2020-11-19
44
- Add support for globbing.
55
- Add support for find_package components.
66
- Add options.
7+
- Add installs.
78
- Support aliases.
89
- Support interface libs (header-only libs).
9-
- Support testing.
10+
- Support testing.
11+
- Require cmake >= 3.15.

CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# This file was generated automatically by cmkr.
22

3-
cmake_minimum_required(VERSION 3.14)
3+
cmake_minimum_required(VERSION 3.15)
44

55
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
66

7-
project(cmkr VERSION 0.1.0)
7+
project(cmkr VERSION 0.1.1)
88

99
include(FetchContent)
1010

@@ -49,5 +49,10 @@ target_link_libraries(cmkr PUBLIC
4949
cmkrlib
5050
)
5151

52+
install(
53+
TARGETS cmkr
54+
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
55+
)
56+
5257

5358

README.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ cmkr, pronounced "cmaker", is A CMakeLists.txt generator from TOML.
44

55

66
## Building
7-
cmkr requires a C++17 compiler, cmake >= 3.14.
7+
cmkr requires a C++17 compiler, cmake >= 3.15.
88
```
99
git clone https://github.com/moalyousef/cmkr
1010
cd cmkr
@@ -16,7 +16,7 @@ cmake --build bin
1616
cmkr parses cmake.toml files (using toml11 by Toru Niina) at the project directory. A basic hello world format with the minimum required fields:
1717
```toml
1818
[cmake]
19-
minimum = "3.14"
19+
minimum = "3.15"
2020

2121
[project]
2222
name = "app"
@@ -31,14 +31,14 @@ sources = ["src/main.cpp"]
3131
This project's cmake.toml:
3232
```toml
3333
[cmake]
34-
minimum = "3.14"
34+
minimum = "3.15"
3535

3636
[project]
3737
name = "cmkr"
3838
version = "0.1.0"
3939

4040
[fetch-content]
41-
toml11 = { GIT_REPOSITORY = "https://github.com/ToruNiina/toml11" }
41+
toml11 = { git = "https://github.com/ToruNiina/toml11" }
4242

4343
[[bin]]
4444
name = "cmkrlib"
@@ -53,12 +53,16 @@ name = "cmkr"
5353
type = "exe"
5454
sources = ["src/main.cpp", "src/args.cpp"]
5555
link-libs = ["cmkrlib"]
56+
57+
[[install]]
58+
targets = ["cmkr"]
59+
destination = "${CMAKE_INSTALL_PREFIX}/bin"
5660
```
5761

5862
Currently supported fields:
5963
```toml
6064
[cmake] # required for top-level project
61-
minimum = "3.14" # required
65+
minimum = "3.15" # required
6266
subdirs = [] # optional
6367
bin-dir = "bin" # optional
6468
cpp-flags = [] # optional
@@ -76,7 +80,7 @@ Boost = { version = "1.74.0", required = false, components = ["system"] } # opti
7680
spdlog = "*"
7781

7882
[fetch-content] # optional, runs fetchContent
79-
toml11 = { GIT_REPOSITORY = "https://github.com/ToruNiina/toml11", GIT_TAG = "v3.5.0" } # optional
83+
toml11 = { git = "https://github.com/ToruNiina/toml11", tag = "v3.5.0" } # optional
8084

8185
[options] # optional
8286
APP_BUILD_STUFF = false # optional
@@ -92,10 +96,17 @@ features = [] # optional
9296
defines = [] # optional
9397
link-libs = [] # optional
9498

95-
[[test]] # optional
99+
[[test]] # optional, can define several
96100
name = "test1" # required
97101
command = "app" # required
98102
arguments = ["arg1", "arg2"] # optional
103+
104+
[[install]] # optional, can define several
105+
targets = ["app"] # optional
106+
files = ["include/*.h"] # optional
107+
dirs = [] # optional
108+
configs = [] # optional (Release|Debug...etc)
109+
destination = "${CMAKE_INSTALL_PREFIX}/bin" # required
99110
```
100111

101112
The cmkr executable can be run from the command-line:
@@ -105,6 +116,7 @@ arguments:
105116
init [exe|lib|shared|static|interface] Starts a new project in the same directory.
106117
gen Generates CMakeLists.txt file.
107118
build <extra cmake args> Run cmake and build.
119+
install Run cmake --install. Needs admin privileges.
108120
clean Clean the build directory.
109121
help Show help.
110122
version Current cmkr version.

cmake.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[cmake]
2-
minimum = "3.14"
2+
minimum = "3.15"
33

44
[project]
55
name = "cmkr"
6-
version = "0.1.0"
6+
version = "0.1.1"
77

88
[fetch-content]
9-
toml11 = { GIT_REPOSITORY = "https://github.com/ToruNiina/toml11" }
9+
toml11 = { git = "https://github.com/ToruNiina/toml11" }
1010

1111
[[bin]]
1212
name = "cmkrlib"
@@ -22,3 +22,6 @@ type = "exe"
2222
sources = ["src/main.cpp", "src/args.cpp"]
2323
link-libs = ["cmkrlib"]
2424

25+
[[install]]
26+
targets = ["cmkr"]
27+
destination = "${CMAKE_INSTALL_PREFIX}/bin"

include/build.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ int run(int argc, char **argv);
88

99
int clean();
1010

11+
int install();
12+
1113
} // namespace cmkr::build
1214
extern "C" {
1315
#endif
@@ -16,6 +18,8 @@ int cmkr_build_run(int argc, char **argv);
1618

1719
int cmkr_build_clean(void);
1820

21+
int cmkr_build_install(void);
22+
1923
#ifdef __cplusplus
2024
}
2125
#endif

include/error.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ struct Status {
1010
InitError,
1111
GenerationError,
1212
BuildError,
13+
CleanError,
14+
InstallError,
1315
};
1416
Status(Code ec) noexcept;
1517
operator int() const noexcept;

include/literals.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ int %s() {
77
std::cout << "Hello World!\n";
88
return 0;
99
}
10+
1011
)lit";
1112

1213
const char *cmake_toml = R"lit(
1314
[cmake]
14-
minimum = "3.14"
15+
minimum = "3.15"
1516
# subdirs = []
1617
# bin-dir = ""
1718
# cpp-flags = []
@@ -39,4 +40,9 @@ include-dirs = ["include"]
3940
# features = []
4041
# defines = []
4142
# link-libs = []
43+
44+
[[install]]
45+
%s = ["%s"]
46+
destination = "${CMAKE_INSTALL_PREFIX}/%s"
47+
4248
)lit";

src/args.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ const char *handle_args(int argc, char **argv) {
2828
} else if (main_arg == "version") {
2929
return cmkr::help::version();
3030
} else if (main_arg == "init") {
31-
if (args.size() < 3)
32-
return "Please provide a project type!";
33-
auto ret = cmkr::gen::generate_project(args[2].c_str());
31+
std::string typ = "exe";
32+
if (args.size() > 2)
33+
typ = args[2];
34+
auto ret = cmkr::gen::generate_project(typ.c_str());
3435
if (ret)
3536
return "Initialization failure!";
3637
return "Directory initialized!";
@@ -39,6 +40,11 @@ const char *handle_args(int argc, char **argv) {
3940
if (ret)
4041
return "CMake build error!";
4142
return "CMake run completed!";
43+
} else if (main_arg == "install") {
44+
auto ret = build::install();
45+
if (ret)
46+
return "CMake install error!";
47+
return "CMake install completed!";
4248
} else if (main_arg == "clean") {
4349
auto ret = build::clean();
4450
if (ret)

src/build.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ int clean() {
5757
return !ret;
5858
}
5959

60+
int install() {
61+
cmake::CMake cmake(".", false);
62+
auto cmd = "cmake --install " + cmake.bin_dir;
63+
return ::system(cmd.c_str());
64+
}
65+
6066
} // namespace cmkr::build
6167

6268
int cmkr_build_run(int argc, char **argv) {
@@ -75,6 +81,16 @@ int cmkr_build_clean(void) {
7581
} catch (const std::system_error &e) {
7682
return e.code().value();
7783
} catch (...) {
78-
return cmkr::error::Status(cmkr::error::Status::Code::BuildError);
84+
return cmkr::error::Status(cmkr::error::Status::Code::CleanError);
85+
}
86+
}
87+
88+
int cmkr_build_install(void) {
89+
try {
90+
return cmkr::build::install();
91+
} catch (const std::system_error &e) {
92+
return e.code().value();
93+
} catch (...) {
94+
return cmkr::error::Status(cmkr::error::Status::Code::InstallError);
7995
}
8096
}

0 commit comments

Comments
 (0)