From 6395267e4b2da61700dcd32f8a5690fcdecd1f3e Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Mon, 3 May 2021 17:10:06 +0200 Subject: [PATCH] Merge cmkrlib into the cmkr target --- .gitattributes | 1 + .github/workflows/build.yml | 4 ++ CMakeLists.txt | 72 +++++++++--------------- cmake.toml | 11 +--- include/{args.h => args.hpp} | 8 --- include/{build.h => build.hpp} | 12 +--- {src/cmkrlib => include}/cmake.hpp | 0 {src/cmkrlib => include}/enum_helper.hpp | 0 include/{error.h => error.hpp} | 8 --- {src/cmkrlib => include}/fs.hpp | 0 include/{gen.h => gen.hpp} | 8 --- include/{help.h => help.hpp} | 8 --- include/{literals.h => literals.hpp} | 0 src/{cmkrlib => }/args.cpp | 8 +-- src/{cmkrlib => }/build.cpp | 6 +- src/{cmkrlib => }/cmake.cpp | 0 src/{cmkrlib => }/error.cpp | 2 +- src/{cmkrlib => }/gen.cpp | 6 +- src/{cmkrlib => }/help.cpp | 2 +- src/main.cpp | 2 +- 20 files changed, 50 insertions(+), 108 deletions(-) create mode 100644 .gitattributes rename include/{args.h => args.hpp} (73%) rename include/{build.h => build.hpp} (61%) rename {src/cmkrlib => include}/cmake.hpp (100%) rename {src/cmkrlib => include}/enum_helper.hpp (100%) rename include/{error.h => error.hpp} (87%) rename {src/cmkrlib => include}/fs.hpp (100%) rename include/{gen.h => gen.hpp} (80%) rename include/{help.h => help.hpp} (77%) rename include/{literals.h => literals.hpp} (100%) rename src/{cmkrlib => }/args.cpp (96%) rename src/{cmkrlib => }/build.cpp (97%) rename src/{cmkrlib => }/cmake.cpp (100%) rename src/{cmkrlib => }/error.cpp (95%) rename src/{cmkrlib => }/gen.cpp (99%) rename src/{cmkrlib => }/help.cpp (97%) diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..167f1bd --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +CMakeLists.txt linguist-generated \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 13a9079..7dca60f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,6 +4,8 @@ on: [push, pull_request] jobs: build: + # Skip building pull requests from the same repository + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != '${{ github.repository }}' runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -14,10 +16,12 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + - name: Build run: | cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} cmake --build build --config ${{ env.BUILD_TYPE }} --parallel + - name: Test run: | cd build/tests diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a2012a..11f29fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,55 +53,26 @@ add_subdirectory(tests) set(CMAKE_FOLDER ${CMKR_CMAKE_FOLDER}) -# Target cmkrlib -unset(cmkrlib_SOURCES) - -list(APPEND cmkrlib_SOURCES - "src/cmkrlib/args.cpp" - "src/cmkrlib/build.cpp" - "src/cmkrlib/cmake.cpp" - "src/cmkrlib/error.cpp" - "src/cmkrlib/gen.cpp" - "src/cmkrlib/help.cpp" - "src/cmkrlib/cmake.hpp" - "src/cmkrlib/enum_helper.hpp" - "src/cmkrlib/fs.hpp" - "include/args.h" - "include/build.h" - "include/error.h" - "include/gen.h" - "include/help.h" - "include/literals.h" -) - -list(APPEND cmkrlib_SOURCES - cmake.toml -) - -add_library(cmkrlib STATIC ${cmkrlib_SOURCES}) - -source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${cmkrlib_SOURCES}) - -target_compile_features(cmkrlib PUBLIC - cxx_std_11 -) - -target_include_directories(cmkrlib PUBLIC - include -) - -target_link_libraries(cmkrlib PUBLIC - toml11 - ghc_filesystem - mpark_variant - ordered_map -) - # Target cmkr unset(cmkr_SOURCES) list(APPEND cmkr_SOURCES + "src/args.cpp" + "src/build.cpp" + "src/cmake.cpp" + "src/error.cpp" + "src/gen.cpp" + "src/help.cpp" "src/main.cpp" + "include/args.hpp" + "include/build.hpp" + "include/cmake.hpp" + "include/enum_helper.hpp" + "include/error.hpp" + "include/fs.hpp" + "include/gen.hpp" + "include/help.hpp" + "include/literals.hpp" ) list(APPEND cmkr_SOURCES @@ -117,8 +88,19 @@ endif() source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${cmkr_SOURCES}) +target_compile_features(cmkr PRIVATE + cxx_std_11 +) + +target_include_directories(cmkr PRIVATE + include +) + target_link_libraries(cmkr PRIVATE - cmkrlib + toml11 + ghc_filesystem + mpark_variant + ordered_map ) install( diff --git a/cmake.toml b/cmake.toml index b1a9fd9..bd8e0e8 100644 --- a/cmake.toml +++ b/cmake.toml @@ -8,18 +8,13 @@ description = "CMakeLists generator from TOML" languages = ["CXX"] subdirs = ["third_party", "tests"] -[target.cmkrlib] -type = "static" -sources = ["src/cmkrlib/*.cpp", "src/cmkrlib/*.hpp", "include/*.h"] +[target.cmkr] +type = "executable" +sources = ["src/*.cpp", "include/*.hpp"] include-directories = ["include"] compile-features = ["cxx_std_11"] link-libraries = ["toml11", "ghc_filesystem", "mpark_variant", "ordered_map"] -[target.cmkr] -type = "executable" -sources = ["src/main.cpp"] -link-libraries = ["cmkrlib"] - [[install]] targets = ["cmkr"] destination = "${CMAKE_INSTALL_PREFIX}/bin" diff --git a/include/args.h b/include/args.hpp similarity index 73% rename from include/args.h rename to include/args.hpp index 6cb9d3c..6662261 100644 --- a/include/args.h +++ b/include/args.hpp @@ -1,6 +1,5 @@ #pragma once -#ifdef __cplusplus namespace cmkr { namespace args { @@ -9,11 +8,4 @@ const char *handle_args(int argc, char **argv); } // namespace args } // namespace cmkr -extern "C" { -#endif - const char *cmkr_args_handle_args(int, char **); - -#ifdef __cplusplus -} -#endif diff --git a/include/build.h b/include/build.hpp similarity index 61% rename from include/build.h rename to include/build.hpp index 58663d1..068d2b0 100644 --- a/include/build.h +++ b/include/build.hpp @@ -1,7 +1,5 @@ #pragma once -#ifdef __cplusplus - namespace cmkr { namespace build { @@ -13,15 +11,9 @@ int install(); } // namespace build } // namespace cmkr -extern "C" { -#endif int cmkr_build_run(int argc, char **argv); -int cmkr_build_clean(void); - -int cmkr_build_install(void); +int cmkr_build_clean(); -#ifdef __cplusplus -} -#endif +int cmkr_build_install(); diff --git a/src/cmkrlib/cmake.hpp b/include/cmake.hpp similarity index 100% rename from src/cmkrlib/cmake.hpp rename to include/cmake.hpp diff --git a/src/cmkrlib/enum_helper.hpp b/include/enum_helper.hpp similarity index 100% rename from src/cmkrlib/enum_helper.hpp rename to include/enum_helper.hpp diff --git a/include/error.h b/include/error.hpp similarity index 87% rename from include/error.h rename to include/error.hpp index ca795c1..a7b3e3d 100644 --- a/include/error.h +++ b/include/error.hpp @@ -1,6 +1,5 @@ #pragma once -#ifdef __cplusplus namespace cmkr { namespace error { @@ -25,11 +24,4 @@ struct Status { } // namespace error } // namespace cmkr -extern "C" { -#endif - const char *cmkr_error_status_string(int); - -#ifdef __cplusplus -} -#endif diff --git a/src/cmkrlib/fs.hpp b/include/fs.hpp similarity index 100% rename from src/cmkrlib/fs.hpp rename to include/fs.hpp diff --git a/include/gen.h b/include/gen.hpp similarity index 80% rename from include/gen.h rename to include/gen.hpp index a2c99c0..13f1e15 100644 --- a/include/gen.h +++ b/include/gen.hpp @@ -1,6 +1,5 @@ #pragma once -#ifdef __cplusplus namespace cmkr { namespace gen { @@ -11,13 +10,6 @@ int generate_cmake(const char *path, bool root = true); } // namespace gen } // namespace cmkr -extern "C" { -#endif - int cmkr_gen_generate_project(const char *typ); int cmkr_gen_generate_cmake(const char *path); - -#ifdef __cplusplus -} -#endif diff --git a/include/help.h b/include/help.hpp similarity index 77% rename from include/help.h rename to include/help.hpp index 6c4f2e6..a2da1b4 100644 --- a/include/help.h +++ b/include/help.hpp @@ -1,6 +1,5 @@ #pragma once -#ifdef __cplusplus namespace cmkr { namespace help { @@ -11,13 +10,6 @@ const char *message() noexcept; } // namespace help } // namespace cmkr -extern "C" { -#endif - const char *cmkr_help_version(void); const char *cmkr_help_message(void); - -#ifdef __cplusplus -} -#endif diff --git a/include/literals.h b/include/literals.hpp similarity index 100% rename from include/literals.h rename to include/literals.hpp diff --git a/src/cmkrlib/args.cpp b/src/args.cpp similarity index 96% rename from src/cmkrlib/args.cpp rename to src/args.cpp index 05cf3db..311ff13 100644 --- a/src/cmkrlib/args.cpp +++ b/src/args.cpp @@ -1,7 +1,7 @@ -#include "args.h" -#include "build.h" -#include "gen.h" -#include "help.h" +#include "args.hpp" +#include "build.hpp" +#include "gen.hpp" +#include "help.hpp" #include "fs.hpp" #include diff --git a/src/cmkrlib/build.cpp b/src/build.cpp similarity index 97% rename from src/cmkrlib/build.cpp rename to src/build.cpp index 2c4f0e6..06a24c8 100644 --- a/src/cmkrlib/build.cpp +++ b/src/build.cpp @@ -1,7 +1,7 @@ -#include "build.h" +#include "build.hpp" #include "cmake.hpp" -#include "error.h" -#include "gen.h" +#include "error.hpp" +#include "gen.hpp" #include "fs.hpp" #include diff --git a/src/cmkrlib/cmake.cpp b/src/cmake.cpp similarity index 100% rename from src/cmkrlib/cmake.cpp rename to src/cmake.cpp diff --git a/src/cmkrlib/error.cpp b/src/error.cpp similarity index 95% rename from src/cmkrlib/error.cpp rename to src/error.cpp index d5245c6..a8d2552 100644 --- a/src/cmkrlib/error.cpp +++ b/src/error.cpp @@ -1,4 +1,4 @@ -#include "error.h" +#include "error.hpp" #include diff --git a/src/cmkrlib/gen.cpp b/src/gen.cpp similarity index 99% rename from src/cmkrlib/gen.cpp rename to src/gen.cpp index 11df317..5633bf8 100644 --- a/src/cmkrlib/gen.cpp +++ b/src/gen.cpp @@ -1,7 +1,7 @@ -#include "gen.h" +#include "gen.hpp" #include "cmake.hpp" -#include "error.h" -#include "literals.h" +#include "error.hpp" +#include "literals.hpp" #include "fs.hpp" #include diff --git a/src/cmkrlib/help.cpp b/src/help.cpp similarity index 97% rename from src/cmkrlib/help.cpp rename to src/help.cpp index 04c3eb4..5d93f57 100644 --- a/src/cmkrlib/help.cpp +++ b/src/help.cpp @@ -1,4 +1,4 @@ -#include "help.h" +#include "help.hpp" namespace cmkr { namespace help { diff --git a/src/main.cpp b/src/main.cpp index fc8d75f..748bd0e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,4 @@ -#include "args.h" +#include "args.hpp" #include #include