Merge pull request #19 from build-cpp/project-refactor

Project refactor
toml-checker
Duncan Ogilvie 4 years ago committed by GitHub
commit 8ea0c7396c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

1
.gitattributes vendored

@ -0,0 +1 @@
CMakeLists.txt linguist-generated

@ -4,6 +4,8 @@ on: [push, pull_request]
jobs: jobs:
build: 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 }} runs-on: ${{ matrix.os }}
strategy: strategy:
fail-fast: false fail-fast: false
@ -14,10 +16,18 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Build - name: Build
run: | run: |
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} "-DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/install"
cmake --build build --config ${{ env.BUILD_TYPE }} --parallel cmake --build build --config ${{ env.BUILD_TYPE }} --parallel
cmake --install build --config ${{ env.BUILD_TYPE }}
- name: Check if cmkr was run
run: |
./install/bin/cmkr gen
git diff --exit-code
- name: Test - name: Test
run: | run: |
cd build/tests cd build/tests

76
CMakeLists.txt generated

@ -23,10 +23,6 @@ if(CMKR_ROOT_PROJECT)
configure_file(cmake.toml cmake.toml COPYONLY) configure_file(cmake.toml cmake.toml COPYONLY)
endif() endif()
# Hack to hide a warning during cmkr bootstrapping on Windows
if(CMAKE_BUILD_TYPE)
endif()
project(cmkr project(cmkr
LANGUAGES LANGUAGES
CXX CXX
@ -57,55 +53,26 @@ add_subdirectory(tests)
set(CMAKE_FOLDER ${CMKR_CMAKE_FOLDER}) 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 # Target cmkr
unset(cmkr_SOURCES) unset(cmkr_SOURCES)
list(APPEND 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" "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 list(APPEND cmkr_SOURCES
@ -121,8 +88,19 @@ endif()
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${cmkr_SOURCES}) 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 target_link_libraries(cmkr PRIVATE
cmkrlib toml11
ghc_filesystem
mpark_variant
ordered_map
) )
install( install(

@ -2,29 +2,19 @@
version = "2.8...3.8" version = "2.8...3.8"
[project] [project]
cmake-before = """
# Hack to hide a warning during cmkr bootstrapping on Windows
if(CMAKE_BUILD_TYPE)
endif()
"""
name = "cmkr" name = "cmkr"
version = "0.1.4" version = "0.1.4"
description = "CMakeLists generator from TOML" description = "CMakeLists generator from TOML"
languages = ["CXX"] languages = ["CXX"]
subdirs = ["third_party", "tests"] subdirs = ["third_party", "tests"]
[target.cmkrlib] [target.cmkr]
type = "static" type = "executable"
sources = ["src/cmkrlib/*.cpp", "src/cmkrlib/*.hpp", "include/*.h"] sources = ["src/*.cpp", "include/*.hpp"]
include-directories = ["include"] include-directories = ["include"]
compile-features = ["cxx_std_11"] compile-features = ["cxx_std_11"]
link-libraries = ["toml11", "ghc_filesystem", "mpark_variant", "ordered_map"] link-libraries = ["toml11", "ghc_filesystem", "mpark_variant", "ordered_map"]
[target.cmkr]
type = "executable"
sources = ["src/main.cpp"]
link-libraries = ["cmkrlib"]
[[install]] [[install]]
targets = ["cmkr"] targets = ["cmkr"]
destination = "${CMAKE_INSTALL_PREFIX}/bin" destination = "${CMAKE_INSTALL_PREFIX}/bin"

@ -78,6 +78,7 @@ else()
) )
message(STATUS "[cmkr] Building cmkr...") message(STATUS "[cmkr] Building cmkr...")
cmkr_exec("${CMAKE_COMMAND}" cmkr_exec("${CMAKE_COMMAND}"
--no-warn-unused-cli
"${CMKR_DIRECTORY}" "${CMKR_DIRECTORY}"
"-B${CMKR_DIRECTORY}/build" "-B${CMKR_DIRECTORY}/build"
"-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_BUILD_TYPE=Release"

@ -1,6 +1,5 @@
#pragma once #pragma once
#ifdef __cplusplus
namespace cmkr { namespace cmkr {
namespace args { namespace args {
@ -9,11 +8,4 @@ const char *handle_args(int argc, char **argv);
} // namespace args } // namespace args
} // namespace cmkr } // namespace cmkr
extern "C" {
#endif
const char *cmkr_args_handle_args(int, char **); const char *cmkr_args_handle_args(int, char **);
#ifdef __cplusplus
}
#endif

@ -1,7 +1,5 @@
#pragma once #pragma once
#ifdef __cplusplus
namespace cmkr { namespace cmkr {
namespace build { namespace build {
@ -13,15 +11,9 @@ int install();
} // namespace build } // namespace build
} // namespace cmkr } // namespace cmkr
extern "C" {
#endif
int cmkr_build_run(int argc, char **argv); int cmkr_build_run(int argc, char **argv);
int cmkr_build_clean(void); int cmkr_build_clean();
int cmkr_build_install(void);
#ifdef __cplusplus int cmkr_build_install();
}
#endif

@ -1,6 +1,5 @@
#pragma once #pragma once
#ifdef __cplusplus
namespace cmkr { namespace cmkr {
namespace error { namespace error {
@ -25,11 +24,4 @@ struct Status {
} // namespace error } // namespace error
} // namespace cmkr } // namespace cmkr
extern "C" {
#endif
const char *cmkr_error_status_string(int); const char *cmkr_error_status_string(int);
#ifdef __cplusplus
}
#endif

@ -1,6 +1,5 @@
#pragma once #pragma once
#ifdef __cplusplus
namespace cmkr { namespace cmkr {
namespace gen { namespace gen {
@ -11,13 +10,6 @@ int generate_cmake(const char *path, bool root = true);
} // namespace gen } // namespace gen
} // namespace cmkr } // namespace cmkr
extern "C" {
#endif
int cmkr_gen_generate_project(const char *typ); int cmkr_gen_generate_project(const char *typ);
int cmkr_gen_generate_cmake(const char *path); int cmkr_gen_generate_cmake(const char *path);
#ifdef __cplusplus
}
#endif

@ -1,6 +1,5 @@
#pragma once #pragma once
#ifdef __cplusplus
namespace cmkr { namespace cmkr {
namespace help { namespace help {
@ -11,13 +10,6 @@ const char *message() noexcept;
} // namespace help } // namespace help
} // namespace cmkr } // namespace cmkr
extern "C" {
#endif
const char *cmkr_help_version(void); const char *cmkr_help_version(void);
const char *cmkr_help_message(void); const char *cmkr_help_message(void);
#ifdef __cplusplus
}
#endif

@ -1,7 +1,7 @@
#include "args.h" #include "args.hpp"
#include "build.h" #include "build.hpp"
#include "gen.h" #include "gen.hpp"
#include "help.h" #include "help.hpp"
#include "fs.hpp" #include "fs.hpp"
#include <exception> #include <exception>

@ -1,7 +1,7 @@
#include "build.h" #include "build.hpp"
#include "cmake.hpp" #include "cmake.hpp"
#include "error.h" #include "error.hpp"
#include "gen.h" #include "gen.hpp"
#include "fs.hpp" #include "fs.hpp"
#include <sstream> #include <sstream>
@ -16,7 +16,7 @@ namespace build {
int run(int argc, char **argv) { int run(int argc, char **argv) {
cmake::CMake cmake(".", true); cmake::CMake cmake(".", true);
if (argc > 2) { if (argc > 2) {
for (size_t i = 2; i < argc; ++i) { for (int i = 2; i < argc; ++i) {
cmake.build_args.push_back(argv[i]); cmake.build_args.push_back(argv[i]);
} }
} }

@ -1,4 +1,4 @@
#include "error.h" #include "error.hpp"
#include <assert.h> #include <assert.h>

@ -1,7 +1,7 @@
#include "gen.h" #include "gen.hpp"
#include "cmake.hpp" #include "cmake.hpp"
#include "error.h" #include "error.hpp"
#include "literals.h" #include "literals.hpp"
#include "fs.hpp" #include "fs.hpp"
#include <cassert> #include <cassert>

@ -1,4 +1,4 @@
#include "help.h" #include "help.hpp"
namespace cmkr { namespace cmkr {
namespace help { namespace help {

@ -1,4 +1,4 @@
#include "args.h" #include "args.hpp"
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>

Loading…
Cancel
Save