mirror of
https://github.com/build-cpp/cmkr
synced 2026-06-08 13:22:55 +00:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ef537ce084 | |||
| 9cdd0f7344 | |||
| e69cf4d2b9 | |||
| e98a906231 | |||
| 9a82f8c796 | |||
| 13255c68cf | |||
| 5768460827 | |||
| 50d4a905b6 | |||
| f957cec2dc | |||
| 232e49e087 | |||
| 7408d42160 |
Generated
+1
-1
@@ -25,7 +25,7 @@ project(cmkr
|
|||||||
LANGUAGES
|
LANGUAGES
|
||||||
CXX
|
CXX
|
||||||
VERSION
|
VERSION
|
||||||
0.2.12
|
0.2.13
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
"CMakeLists generator from TOML"
|
"CMakeLists generator from TOML"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -70,3 +70,4 @@ arguments:
|
|||||||
- https://github.com/mpark/variant
|
- https://github.com/mpark/variant
|
||||||
- https://www.svgrepo.com/svg/192268/hammer
|
- https://www.svgrepo.com/svg/192268/hammer
|
||||||
- https://github.com/can1357 for buying `cmkr.build` ❤️
|
- https://github.com/can1357 for buying `cmkr.build` ❤️
|
||||||
|
- https://github.com/JustasMasiulis for fixing the dark theme ❤️
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ cmkr-include = false
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "cmkr"
|
name = "cmkr"
|
||||||
version = "0.2.12"
|
version = "0.2.13"
|
||||||
description = "CMakeLists generator from TOML"
|
description = "CMakeLists generator from TOML"
|
||||||
languages = ["CXX"]
|
languages = ["CXX"]
|
||||||
subdirs = ["third_party", "tests"]
|
subdirs = ["third_party", "tests"]
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@ include_guard()
|
|||||||
|
|
||||||
# Change these defaults to point to your infrastructure if desired
|
# Change these defaults to point to your infrastructure if desired
|
||||||
set(CMKR_REPO "https://github.com/build-cpp/cmkr" CACHE STRING "cmkr git repository" FORCE)
|
set(CMKR_REPO "https://github.com/build-cpp/cmkr" CACHE STRING "cmkr git repository" FORCE)
|
||||||
set(CMKR_TAG "v0.2.12" CACHE STRING "cmkr git tag (this needs to be available forever)" FORCE)
|
set(CMKR_TAG "v0.2.13" CACHE STRING "cmkr git tag (this needs to be available forever)" FORCE)
|
||||||
set(CMKR_COMMIT_HASH "" CACHE STRING "cmkr git commit hash (optional)" FORCE)
|
set(CMKR_COMMIT_HASH "" CACHE STRING "cmkr git commit hash (optional)" FORCE)
|
||||||
|
|
||||||
# To bootstrap/generate a cmkr project: cmake -P cmkr.cmake
|
# To bootstrap/generate a cmkr project: cmake -P cmkr.cmake
|
||||||
|
|||||||
+4
-2
@@ -200,7 +200,9 @@ working-directory = "mytest-dir"
|
|||||||
condition = "mycondition"
|
condition = "mycondition"
|
||||||
targets = ["mytarget", "mytest"]
|
targets = ["mytarget", "mytest"]
|
||||||
destination = ["bin"]
|
destination = ["bin"]
|
||||||
|
component = "mycomponent"
|
||||||
files = ["content/my.png"]
|
files = ["content/my.png"]
|
||||||
dirs = [""]
|
dirs = ["include"]
|
||||||
configs = [""]
|
configs = ["Release", "Debug"]
|
||||||
|
optional = false
|
||||||
```
|
```
|
||||||
@@ -128,6 +128,7 @@ struct Install {
|
|||||||
std::vector<std::string> configs;
|
std::vector<std::string> configs;
|
||||||
std::string destination;
|
std::string destination;
|
||||||
std::string component;
|
std::string component;
|
||||||
|
bool optional = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Subdir {
|
struct Subdir {
|
||||||
|
|||||||
+12
-6
@@ -162,10 +162,11 @@ struct Command {
|
|||||||
return "\"\"";
|
return "\"\"";
|
||||||
}
|
}
|
||||||
// Don't quote arguments that don't need quoting
|
// Don't quote arguments that don't need quoting
|
||||||
if (str.find(' ') == std::string::npos && str.find('\"') == std::string::npos && str.find('/') == std::string::npos &&
|
// https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#unquoted-argument
|
||||||
str.find(';') == std::string::npos) {
|
// NOTE: Normally '/' does not require quoting according to the documentation but this has been the case here
|
||||||
|
// previously, so for backwards compatibility its still here.
|
||||||
|
if (str.find_first_of("()#\"\\'> |/;") == str.npos)
|
||||||
return str;
|
return str;
|
||||||
}
|
|
||||||
std::string result;
|
std::string result;
|
||||||
result += "\"";
|
result += "\"";
|
||||||
for (char ch : str) {
|
for (char ch : str) {
|
||||||
@@ -633,8 +634,12 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
|
|||||||
cmd("include")("FetchContent");
|
cmd("include")("FetchContent");
|
||||||
cmd("message")("STATUS", "Fetching vcpkg (" + version_name + ")...");
|
cmd("message")("STATUS", "Fetching vcpkg (" + version_name + ")...");
|
||||||
cmd("FetchContent_Declare")("vcpkg", "URL", url);
|
cmd("FetchContent_Declare")("vcpkg", "URL", url);
|
||||||
cmd("FetchContent_MakeAvailable")("vcpkg");
|
// Not using FetchContent_MakeAvailable here in case vcpkg adds CMakeLists.txt
|
||||||
cmd("include")("${vcpkg_SOURCE_DIR}/scripts/buildsystems/vcpkg.cmake");
|
cmd("FetchContent_GetProperties")("vcpkg");
|
||||||
|
cmd("if")("NOT", "vcpkg_POPULATED");
|
||||||
|
cmd("FetchContent_Populate")("vcpkg");
|
||||||
|
cmd("include")("${vcpkg_SOURCE_DIR}/scripts/buildsystems/vcpkg.cmake");
|
||||||
|
cmd("endif")();
|
||||||
cmd("endif")();
|
cmd("endif")();
|
||||||
endl();
|
endl();
|
||||||
// clang-format on
|
// clang-format on
|
||||||
@@ -1040,8 +1045,9 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
|
|||||||
component_name = inst.targets.front();
|
component_name = inst.targets.front();
|
||||||
}
|
}
|
||||||
auto component = std::make_pair("COMPONENT", component_name);
|
auto component = std::make_pair("COMPONENT", component_name);
|
||||||
|
auto optional = inst.optional ? "OPTIONAL" : "";
|
||||||
ConditionScope cs(gen, inst.condition);
|
ConditionScope cs(gen, inst.condition);
|
||||||
cmd("install")(targets, dirs, files, configs, destination, component);
|
cmd("install")(targets, dirs, files, configs, destination, component, optional);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -619,6 +619,7 @@ Project::Project(const Project *parent, const std::string &path, bool build) {
|
|||||||
i.optional("configs", inst.configs);
|
i.optional("configs", inst.configs);
|
||||||
i.required("destination", inst.destination);
|
i.required("destination", inst.destination);
|
||||||
i.optional("component", inst.component);
|
i.optional("component", inst.component);
|
||||||
|
i.optional("optional", inst.optional);
|
||||||
installs.push_back(inst);
|
installs.push_back(inst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -627,6 +628,7 @@ Project::Project(const Project *parent, const std::string &path, bool build) {
|
|||||||
auto &v = checker.create(toml, "vcpkg");
|
auto &v = checker.create(toml, "vcpkg");
|
||||||
v.optional("url", vcpkg.url);
|
v.optional("url", vcpkg.url);
|
||||||
v.optional("version", vcpkg.version);
|
v.optional("version", vcpkg.version);
|
||||||
|
|
||||||
for (const auto &p : v.find("packages").as_array()) {
|
for (const auto &p : v.find("packages").as_array()) {
|
||||||
Vcpkg::Package package;
|
Vcpkg::Package package;
|
||||||
const auto &package_str = p.as_string().str;
|
const auto &package_str = p.as_string().str;
|
||||||
|
|||||||
Generated
+8
-8
@@ -14,7 +14,7 @@ add_test(
|
|||||||
WORKING_DIRECTORY
|
WORKING_DIRECTORY
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/basic"
|
"${CMAKE_CURRENT_LIST_DIR}/basic"
|
||||||
COMMAND
|
COMMAND
|
||||||
$<TARGET_FILE:cmkr>
|
"$<TARGET_FILE:cmkr>"
|
||||||
build
|
build
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ add_test(
|
|||||||
WORKING_DIRECTORY
|
WORKING_DIRECTORY
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/interface"
|
"${CMAKE_CURRENT_LIST_DIR}/interface"
|
||||||
COMMAND
|
COMMAND
|
||||||
$<TARGET_FILE:cmkr>
|
"$<TARGET_FILE:cmkr>"
|
||||||
build
|
build
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ add_test(
|
|||||||
WORKING_DIRECTORY
|
WORKING_DIRECTORY
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/fetch-content"
|
"${CMAKE_CURRENT_LIST_DIR}/fetch-content"
|
||||||
COMMAND
|
COMMAND
|
||||||
$<TARGET_FILE:cmkr>
|
"$<TARGET_FILE:cmkr>"
|
||||||
build
|
build
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ add_test(
|
|||||||
WORKING_DIRECTORY
|
WORKING_DIRECTORY
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/conditions"
|
"${CMAKE_CURRENT_LIST_DIR}/conditions"
|
||||||
COMMAND
|
COMMAND
|
||||||
$<TARGET_FILE:cmkr>
|
"$<TARGET_FILE:cmkr>"
|
||||||
build
|
build
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ add_test(
|
|||||||
WORKING_DIRECTORY
|
WORKING_DIRECTORY
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/vcpkg"
|
"${CMAKE_CURRENT_LIST_DIR}/vcpkg"
|
||||||
COMMAND
|
COMMAND
|
||||||
$<TARGET_FILE:cmkr>
|
"$<TARGET_FILE:cmkr>"
|
||||||
build
|
build
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ add_test(
|
|||||||
WORKING_DIRECTORY
|
WORKING_DIRECTORY
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/cxx-standard"
|
"${CMAKE_CURRENT_LIST_DIR}/cxx-standard"
|
||||||
COMMAND
|
COMMAND
|
||||||
$<TARGET_FILE:cmkr>
|
"$<TARGET_FILE:cmkr>"
|
||||||
build
|
build
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ add_test(
|
|||||||
WORKING_DIRECTORY
|
WORKING_DIRECTORY
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/globbing"
|
"${CMAKE_CURRENT_LIST_DIR}/globbing"
|
||||||
COMMAND
|
COMMAND
|
||||||
$<TARGET_FILE:cmkr>
|
"$<TARGET_FILE:cmkr>"
|
||||||
build
|
build
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ add_test(
|
|||||||
WORKING_DIRECTORY
|
WORKING_DIRECTORY
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/templates"
|
"${CMAKE_CURRENT_LIST_DIR}/templates"
|
||||||
COMMAND
|
COMMAND
|
||||||
$<TARGET_FILE:cmkr>
|
"$<TARGET_FILE:cmkr>"
|
||||||
build
|
build
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user