mirror of
https://github.com/build-cpp/cmkr
synced 2026-06-08 13:22:55 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3caf593438 | |||
| c94dbd6416 | |||
| a1eaf601c6 | |||
| 10320c8e55 | |||
| 45e12c8d98 | |||
| e12ebc060d | |||
| c6e3fc159f | |||
| dc6f306d9c | |||
| e08bd5a311 | |||
| 068977e2f5 |
Generated
+2
-2
@@ -1,7 +1,7 @@
|
||||
# This file is automatically generated from cmake.toml - DO NOT EDIT
|
||||
# See https://github.com/build-cpp/cmkr for more information
|
||||
|
||||
cmake_minimum_required(VERSION 2.8...3.8)
|
||||
cmake_minimum_required(VERSION 2.8...3.31)
|
||||
|
||||
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
|
||||
message(FATAL_ERROR "In-tree builds are not supported. Run CMake from a separate directory: cmake -B build")
|
||||
@@ -22,7 +22,7 @@ project(cmkr
|
||||
LANGUAGES
|
||||
CXX
|
||||
VERSION
|
||||
0.2.39
|
||||
0.2.42
|
||||
DESCRIPTION
|
||||
"CMakeLists generator from TOML"
|
||||
)
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
[cmake]
|
||||
version = "2.8...3.8"
|
||||
version = "2.8...3.31"
|
||||
cmkr-include = false
|
||||
|
||||
[project]
|
||||
name = "cmkr"
|
||||
version = "0.2.39"
|
||||
version = "0.2.42"
|
||||
description = "CMakeLists generator from TOML"
|
||||
languages = ["CXX"]
|
||||
include-after = [
|
||||
|
||||
+1
-1
@@ -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 "v0.2.39" CACHE STRING "cmkr git tag (this needs to be available forever)" FORCE)
|
||||
set(CMKR_TAG "v0.2.42" CACHE STRING "cmkr git tag (this needs to be available forever)" FORCE)
|
||||
set(CMKR_COMMIT_HASH "" CACHE STRING "cmkr git commit hash (optional)" FORCE)
|
||||
|
||||
# To bootstrap/generate a cmkr project: cmake -P cmkr.cmake
|
||||
|
||||
+10
-9
@@ -865,12 +865,17 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
|
||||
comment("vcpkg settings");
|
||||
auto emit_overlay = [&cmd](const std::string &name, const std::vector<std::string> &overlay) {
|
||||
if (!overlay.empty()) {
|
||||
std::vector<std::string> set_args;
|
||||
for (const auto &directory : overlay) {
|
||||
if (!fs::path(directory).is_relative()) {
|
||||
throw std::runtime_error("[vcpkg] overlay is not a relative path: " + directory);
|
||||
}
|
||||
if (!fs::is_directory(directory)) {
|
||||
throw std::runtime_error("[vcpkg] overlay is not a directory: " + directory);
|
||||
}
|
||||
set_args.emplace_back("${CMAKE_CURRENT_SOURCE_DIR}/" + directory);
|
||||
}
|
||||
cmd("set")(name, overlay);
|
||||
cmd("set")(name, set_args);
|
||||
}
|
||||
};
|
||||
emit_overlay("VCPKG_OVERLAY_PORTS", project.vcpkg.overlay_ports);
|
||||
@@ -938,15 +943,11 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
|
||||
cmd("endif")();
|
||||
cmd("message")("STATUS", "Fetching vcpkg (" + version_name + ")...");
|
||||
cmd("FetchContent_Declare")("vcpkg", vcpkg_args);
|
||||
// Not using FetchContent_MakeAvailable here in case vcpkg adds CMakeLists.txt
|
||||
cmd("FetchContent_GetProperties")("vcpkg");
|
||||
cmd("if")("NOT", "vcpkg_POPULATED");
|
||||
cmd("FetchContent_Populate")("vcpkg");
|
||||
cmd("if")("CMAKE_HOST_SYSTEM_NAME", "STREQUAL", "Darwin", "AND", "CMAKE_OSX_ARCHITECTURES", "STREQUAL", RawArg("\"\""));
|
||||
cmd("set")("CMAKE_OSX_ARCHITECTURES", "${CMAKE_HOST_SYSTEM_PROCESSOR}", "CACHE", "STRING", RawArg("\"\""), "FORCE");
|
||||
cmd("endif")();
|
||||
cmd("include")("${vcpkg_SOURCE_DIR}/scripts/buildsystems/vcpkg.cmake");
|
||||
cmd("FetchContent_MakeAvailable")("vcpkg").endl();
|
||||
cmd("if")("CMAKE_HOST_SYSTEM_NAME", "STREQUAL", "Darwin", "AND", "CMAKE_OSX_ARCHITECTURES", "STREQUAL", RawArg("\"\""));
|
||||
cmd("set")("CMAKE_OSX_ARCHITECTURES", "${CMAKE_HOST_SYSTEM_PROCESSOR}", "CACHE", "STRING", RawArg("\"\""), "FORCE");
|
||||
cmd("endif")();
|
||||
cmd("include")("${vcpkg_SOURCE_DIR}/scripts/buildsystems/vcpkg.cmake");
|
||||
cmd("endif")();
|
||||
endl();
|
||||
// clang-format on
|
||||
|
||||
+12
-9
@@ -656,22 +656,25 @@ Project::Project(const Project *parent, const std::string &path, bool build) : p
|
||||
// Add support for relative paths for (private-)link-libraries
|
||||
const auto fix_relative_paths = [&name, &path](ConditionVector &libraries, const char *key) {
|
||||
for (const auto &library_entries : libraries) {
|
||||
for (auto &library_path : libraries[library_entries.first]) {
|
||||
for (auto &library : libraries[library_entries.first]) {
|
||||
// Skip processing paths with potential CMake macros in them (this check isn't perfect)
|
||||
// https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#variable-references
|
||||
if ((library_path.find("${") != std::string::npos || library_path.find("$ENV{") != std::string::npos ||
|
||||
library_path.find("$CACHE{") != std::string::npos) &&
|
||||
library_path.find('}') != std::string::npos) {
|
||||
if ((library.find("${") != std::string::npos || library.find("$ENV{") != std::string::npos ||
|
||||
library.find("$CACHE{") != std::string::npos) &&
|
||||
library.find('}') != std::string::npos) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (fs::exists(fs::path(path) / library_path)) {
|
||||
// If the file path is relative, prepend ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
library_path.insert(0, "${CMAKE_CURRENT_SOURCE_DIR}/");
|
||||
} else if (library_path.find_first_of(R"(\/)") != std::string::npos) {
|
||||
auto library_path = fs::path(path) / library;
|
||||
if (fs::exists(library_path)) {
|
||||
if (!fs::is_directory(library_path)) {
|
||||
// If the file path is relative (and not a directory), prepend ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
library.insert(0, "${CMAKE_CURRENT_SOURCE_DIR}/");
|
||||
}
|
||||
} else if (library.find_first_of(R"(\/)") != std::string::npos) {
|
||||
// Error if the path contains a directory separator and the file doesn't exist
|
||||
throw std::runtime_error("Attempted to link against a library file that doesn't exist for target \"" + name + "\" in \"" +
|
||||
key + "\": " + library_path);
|
||||
key + "\": " + library);
|
||||
} else {
|
||||
// NOTE: We cannot check if system libraries exist, so we leave them as-is
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user