From b5752b7c2be1a94f0c57b5a6ef3428ff638cab1e Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Mon, 5 Apr 2021 14:49:32 +0200 Subject: [PATCH] Breaking change, rename 'cmake.minimum' to 'cmake.version' and make it optional --- CMakeLists.txt | 15 +++++++++------ cmake.toml | 2 +- include/literals.h | 2 +- src/cmkrlib/cmake.cpp | 4 ++-- src/cmkrlib/cmake.hpp | 5 +++-- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 82eeb81..9073fab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,24 +1,26 @@ # This file was generated automatically by cmkr. -# Create a configure-time dependency on cmake.toml to improve IDE support -configure_file(cmake.toml cmake.toml COPYONLY) - cmake_minimum_required(VERSION 2.8...3.8) -# Regenerate CMakeLists.txt file when necessary +# Regenerate CMakeLists.txt automatically in the root project set(CMKR_ROOT_PROJECT OFF) if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) set(CMKR_ROOT_PROJECT ON) + # Bootstrap cmkr include(cmkr.cmake OPTIONAL RESULT_VARIABLE CMKR_INCLUDE_RESULT) if(CMKR_INCLUDE_RESULT) cmkr() endif() + # Enable folder support + set_property(GLOBAL PROPERTY USE_FOLDERS ON) endif() -# Enable folder support -set_property(GLOBAL PROPERTY USE_FOLDERS ON) +# Create a configure-time dependency on cmake.toml to improve IDE support +if(CMKR_ROOT_PROJECT) + configure_file(cmake.toml cmake.toml COPYONLY) +endif() # Hack to hide a warning during cmkr bootstrapping on Windows if(CMAKE_BUILD_TYPE) @@ -34,6 +36,7 @@ project(cmkr "CMakeLists generator from TOML" ) +# third_party set(CMKR_CMAKE_FOLDER ${CMAKE_FOLDER}) if(CMAKE_FOLDER) set(CMAKE_FOLDER "${CMAKE_FOLDER}/third_party") diff --git a/cmake.toml b/cmake.toml index c7bbbe8..56b4cac 100644 --- a/cmake.toml +++ b/cmake.toml @@ -1,5 +1,5 @@ [cmake] -minimum = "2.8...3.8" +version = "2.8...3.8" [project] cmake-before = """ diff --git a/include/literals.h b/include/literals.h index 3859dfb..e4f0185 100644 --- a/include/literals.h +++ b/include/literals.h @@ -11,7 +11,7 @@ int %s() { static const char *cmake_toml = R"lit( [cmake] -minimum = "3.15" +version = "3.15" # subdirs = [] # build-dir = "" # cpp-flags = [] diff --git a/src/cmkrlib/cmake.cpp b/src/cmkrlib/cmake.cpp index 80a500d..c8de88a 100644 --- a/src/cmkrlib/cmake.cpp +++ b/src/cmkrlib/cmake.cpp @@ -58,8 +58,8 @@ CMake::CMake(const std::string &path, bool build) { } else { if (toml.contains("cmake")) { const auto &cmake = toml::find(toml, "cmake"); - cmake_version = toml::find(cmake, "minimum").as_string(); - cmkr_include = toml::find_or(cmake, "cmkr-include", "cmkr.cmake"); + cmake_version = toml::find(cmake, "version").as_string(); + cmkr_include = toml::find_or(cmake, "cmkr-include", cmkr_include); cppflags = optional_array(cmake, "cpp-flags"); cflags = optional_array(cmake, "c-flags"); linkflags = optional_array(cmake, "link-flags"); diff --git a/src/cmkrlib/cmake.hpp b/src/cmkrlib/cmake.hpp index 5d7d967..cfce1c5 100644 --- a/src/cmkrlib/cmake.hpp +++ b/src/cmkrlib/cmake.hpp @@ -79,8 +79,9 @@ struct Install { }; struct CMake { - std::string cmake_version; - std::string cmkr_include; + // This is the CMake version required to use all cmkr versions. + std::string cmake_version = "3.15"; + std::string cmkr_include = "cmkr.cmake"; std::string build_dir = "build"; std::string generator; std::string config;