Merge pull request #143 from build-cpp/project-improvements

Project improvements
main
Duncan Ogilvie 6 months ago committed by GitHub
commit 714a666e88
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -4,6 +4,8 @@ on: [push, pull_request]
jobs: jobs:
clang-format: clang-format:
# Skip building pull requests from the same repository
if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@ -27,6 +29,8 @@ jobs:
exit 1 exit 1
editorconfig: editorconfig:
# Skip building pull requests from the same repository
if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:

3
CMakeLists.txt generated

@ -94,7 +94,6 @@ target_link_libraries(cmkr PRIVATE
ghc_filesystem ghc_filesystem
mpark_variant mpark_variant
ordered_map ordered_map
nlohmann_json
) )
get_directory_property(CMKR_VS_STARTUP_PROJECT DIRECTORY ${PROJECT_SOURCE_DIR} DEFINITION VS_STARTUP_PROJECT) get_directory_property(CMKR_VS_STARTUP_PROJECT DIRECTORY ${PROJECT_SOURCE_DIR} DEFINITION VS_STARTUP_PROJECT)
@ -103,7 +102,7 @@ if(NOT CMKR_VS_STARTUP_PROJECT)
endif() endif()
set(CMKR_TARGET cmkr) set(CMKR_TARGET cmkr)
generate_resources(${CMKR_TARGET}) include("cmake/custom_targets.cmake")
install( install(
TARGETS TARGETS

@ -36,11 +36,8 @@ link-libraries = [
"ghc_filesystem", "ghc_filesystem",
"mpark_variant", "mpark_variant",
"ordered_map", "ordered_map",
"nlohmann_json",
] ]
cmake-after = """ include-after = ["cmake/custom_targets.cmake"]
generate_resources(${CMKR_TARGET})
"""
[[install]] [[install]]
targets = ["cmkr"] targets = ["cmkr"]

@ -0,0 +1,18 @@
generate_resources(cmkr)
add_custom_target(regenerate-cmake
COMMAND "$<TARGET_FILE:cmkr>" gen
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
)
if(CMAKE_CONFIGURATION_TYPES)
add_custom_target(run-tests
COMMAND "${CMAKE_CTEST_COMMAND}" -C $<CONFIG>
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/tests"
)
else()
add_custom_target(run-tests
COMMAND "${CMAKE_CTEST_COMMAND}"
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/tests"
)
endif()

@ -681,7 +681,10 @@ static std::string vcpkg_escape_identifier(const std::string &name) {
ch = '-'; ch = '-';
} }
escaped += std::tolower(ch); if (ch >= 'A' && ch <= 'Z') {
ch += ('a' - 'A');
}
escaped += ch;
} }
if (!vcpkg_valid_identifier(escaped)) { if (!vcpkg_valid_identifier(escaped)) {
throw std::runtime_error("The escaped project name '" + escaped + "' is not usable with [vcpkg]"); throw std::runtime_error("The escaped project name '" + escaped + "' is not usable with [vcpkg]");

@ -381,7 +381,8 @@ Project::Project(const Project *parent, const std::string &path, bool build) : p
if (ch == '_') { if (ch == '_') {
normalized += '-'; normalized += '-';
} else if (ch >= 'A' && ch <= 'Z') { } else if (ch >= 'A' && ch <= 'Z') {
normalized += std::tolower(ch); ch += ('a' - 'A');
normalized += ch;
} else if (ch == '-' || (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'z')) { } else if (ch == '-' || (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'z')) {
normalized += ch; normalized += ch;
} else { } else {
@ -532,8 +533,11 @@ Project::Project(const Project *parent, const std::string &path, bool build) : p
key = "URL"; key = "URL";
} else if (hash_algorithms.contains(key)) { } else if (hash_algorithms.contains(key)) {
std::string algo; std::string algo;
for (auto c : key) { for (auto ch : key) {
algo.push_back(std::toupper(c)); if (ch >= 'a' && ch <= 'z') {
ch -= ('a' - 'A');
}
algo.push_back(ch);
} }
key = "URL_HASH"; key = "URL_HASH";
value = algo + "=" + value; value = algo + "=" + value;

4
third_party/CMakeLists.txt generated vendored

@ -16,7 +16,3 @@ target_include_directories(toml11 INTERFACE toml11-3.6.0)
# https://github.com/mpark/variant (BSL-1.0) # https://github.com/mpark/variant (BSL-1.0)
add_library(mpark_variant INTERFACE) add_library(mpark_variant INTERFACE)
target_include_directories(mpark_variant INTERFACE variant-1.4.0/include) target_include_directories(mpark_variant INTERFACE variant-1.4.0/include)
# https://github.com/nlohmann/json (MIT)
add_library(nlohmann_json INTERFACE)
target_include_directories(nlohmann_json INTERFACE nlohmann-3.9.1/include)

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2013-2021 Niels Lohmann
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save