[feature] msvc-static

main
gmh5225 2 years ago
parent 153bdbe591
commit 981c48dbc5
No known key found for this signature in database
GPG Key ID: 3BBC731F40B2CEC1

@ -0,0 +1,27 @@
---
# Automatically generated from tests/msvc-static/cmake.toml - DO NOT EDIT
layout: default
title: msvc static
permalink: /examples/msvc-static
parent: Examples
nav_order: 8
---
# msvc static
A msvc-static `cmake.toml` project:
```toml
[project]
name = "msvc-static"
description = "msvc static"
[target.basic]
type = "executable"
sources = ["src/msvc-static.cpp"]
msvc-static = true
```
<sup><sub>This page was automatically generated from [tests/msvc-static/cmake.toml](https://github.com/build-cpp/cmkr/tree/main/tests/msvc-static/cmake.toml).</sub></sup>

@ -103,6 +103,8 @@ struct Target {
Condition<std::string> cmake_after;
ConditionVector include_before;
ConditionVector include_after;
bool allow_msvc_static = false;
};
struct Template {

@ -1026,6 +1026,10 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
gen.conditional_cmake(tmplate->outline.cmake_after);
}
if (target.allow_msvc_static && !target.name.empty()) {
cmd("set_property")("TARGET", target.name, "PROPERTY", "MSVC_RUNTIME_LIBRARY", "MultiThreaded$<$<CONFIG:Debug>:Debug>");
}
cmd("unset")("CMKR_TARGET");
cmd("unset")("CMKR_SOURCES");
}

@ -514,6 +514,8 @@ Project::Project(const Project *parent, const std::string &path, bool build) {
t.optional("precompile-headers", target.precompile_headers);
t.optional("private-precompile-headers", target.private_precompile_headers);
t.optional("msvc-static", target.allow_msvc_static);
if (!target.headers.empty()) {
auto &sources = target.sources.nth(0).value();
const auto &headers = target.headers.nth(0)->second;

10
tests/CMakeLists.txt generated

@ -88,3 +88,13 @@ add_test(
build
)
add_test(
NAME
msvc-static
WORKING_DIRECTORY
"${CMAKE_CURRENT_LIST_DIR}/msvc-static"
COMMAND
"$<TARGET_FILE:cmkr>"
build
)

@ -0,0 +1,11 @@
# A msvc-static `cmake.toml` project:
[project]
name = "msvc-static"
description = "msvc static"
[target.basic]
type = "executable"
sources = ["src/msvc-static.cpp"]
msvc-static = true

@ -0,0 +1,5 @@
#include <cstdio>
int main() {
puts("Hello from cmkr(msvc-static)!");
}
Loading…
Cancel
Save