Add support for private- target options

toml-checker archive_af3807ca
Duncan Ogilvie 4 years ago
parent 17f085c66d
commit af3807ca2b

@ -2,7 +2,7 @@ include_guard()
# 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_TAG "archive_64b58425" CACHE STRING "cmkr git tag (this needs to be available forever)" FORCE)
set(CMKR_TAG "archive_5ad6134e" CACHE STRING "cmkr git tag (this needs to be available forever)" FORCE)
# Set these from the command line to customize for development/debugging purposes
set(CMKR_EXECUTABLE "" CACHE FILEPATH "cmkr executable")

@ -56,17 +56,33 @@ struct Target {
std::string name;
TargetType type = {};
ConditionVector headers;
ConditionVector sources;
// https://cmake.org/cmake/help/latest/manual/cmake-commands.7.html#project-commands
ConditionVector compile_definitions;
ConditionVector private_compile_definitions;
ConditionVector compile_features;
ConditionVector private_compile_features;
ConditionVector compile_options;
ConditionVector private_compile_options;
ConditionVector include_directories;
ConditionVector private_include_directories;
ConditionVector link_directories;
ConditionVector private_link_directories;
ConditionVector link_libraries;
ConditionVector private_link_libraries;
ConditionVector link_options;
ConditionVector private_link_options;
ConditionVector precompile_headers;
ConditionVector headers;
ConditionVector sources;
ConditionVector private_precompile_headers;
std::string alias;
tsl::ordered_map<std::string, std::string> properties;

@ -183,14 +183,30 @@ CMake::CMake(const std::string &path, bool build) {
get_optional(t, "headers", target.headers);
get_optional(t, "sources", target.sources);
get_optional(t, "compile-definitions", target.compile_definitions);
get_optional(t, "private-compile-definitions", target.private_compile_definitions);
get_optional(t, "compile-features", target.compile_features);
get_optional(t, "private-compile-features", target.private_compile_features);
get_optional(t, "compile-options", target.compile_options);
get_optional(t, "private-compile-options", target.private_compile_options);
get_optional(t, "include-directories", target.include_directories);
get_optional(t, "private-include-directories", target.private_include_directories);
get_optional(t, "link-directories", target.link_directories);
get_optional(t, "private-link-directories", target.private_link_directories);
get_optional(t, "link-libraries", target.link_libraries);
get_optional(t, "private-link-libraries", target.private_link_libraries);
get_optional(t, "link-options", target.link_options);
get_optional(t, "private-link-options", target.private_link_options);
get_optional(t, "precompile-headers", target.precompile_headers);
get_optional(t, "private-precompile-headers", target.private_precompile_headers);
if (!target.headers.empty()) {
auto &sources = target.sources.nth(0).value();

@ -568,6 +568,7 @@ int generate_cmake(const char *path, bool root) {
cmd("FetchContent_MakeAvailable")("vcpkg");
cmd("include")("${vcpkg_SOURCE_DIR}/scripts/buildsystems/vcpkg.cmake");
cmd("endif")();
endl();
// clang-format on
// Generate vcpkg.json
@ -749,19 +750,34 @@ int generate_cmake(const char *path, bool root) {
cmd("add_library")(target.alias, "ALIAS", target.name);
}
auto target_cmd = [&](const char *command, const cmake::ConditionVector &cargs) {
gen.handle_condition(
cargs, [&](const std::string &, const std::vector<std::string> &args) { cmd(command)(target.name, target_scope, args); });
auto target_cmd = [&](const char *command, const cmake::ConditionVector &cargs, const std::string &scope) {
gen.handle_condition(cargs,
[&](const std::string &, const std::vector<std::string> &args) { cmd(command)(target.name, scope, args); });
};
target_cmd("target_compile_definitions", target.compile_definitions);
target_cmd("target_compile_features", target.compile_features);
target_cmd("target_compile_options", target.compile_options);
target_cmd("target_include_directories", target.include_directories);
target_cmd("target_link_directories", target.link_directories);
target_cmd("target_link_libraries", target.link_libraries);
target_cmd("target_link_options", target.link_options);
target_cmd("target_precompile_headers", target.precompile_headers);
target_cmd("target_compile_definitions", target.compile_definitions, target_scope);
target_cmd("target_compile_definitions", target.private_compile_definitions, "PRIVATE");
target_cmd("target_compile_features", target.compile_features, target_scope);
target_cmd("target_compile_features", target.private_compile_features, "PRIVATE");
target_cmd("target_compile_options", target.compile_options, target_scope);
target_cmd("target_compile_options", target.private_compile_options, "PRIVATE");
target_cmd("target_include_directories", target.include_directories, target_scope);
target_cmd("target_include_directories", target.private_include_directories, "PRIVATE");
target_cmd("target_link_directories", target.link_directories, target_scope);
target_cmd("target_link_directories", target.private_link_directories, "PRIVATE");
target_cmd("target_link_libraries", target.link_libraries, target_scope);
target_cmd("target_link_libraries", target.private_link_libraries, "PRIVATE");
target_cmd("target_link_options", target.link_options, target_scope);
target_cmd("target_link_options", target.private_link_options, "PRIVATE");
target_cmd("target_precompile_headers", target.precompile_headers, target_scope);
target_cmd("target_precompile_headers", target.private_precompile_headers, "PRIVATE");
if (!target.properties.empty()) {
cmd("set_target_properties")(target.name, "PROPERTIES", target.properties).endl();
@ -773,6 +789,7 @@ int generate_cmake(const char *path, bool root) {
cmd("unset")("CMKR_TARGET");
cmd("unset")("CMKR_SOURCES");
endl();
}
}

Loading…
Cancel
Save