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

Project refactor
vcpkg-wip
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:
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,18 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build
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 --install build --config ${{ env.BUILD_TYPE }}
- name: Check if cmkr was run
run: |
./install/bin/cmkr gen
git diff --exit-code
- name: Test
run: |
cd build/tests

76
CMakeLists.txt generated

@ -23,10 +23,6 @@ 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)
endif()
project(cmkr
LANGUAGES
CXX
@ -57,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
@ -121,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(

@ -2,29 +2,19 @@
version = "2.8...3.8"
[project]
cmake-before = """
# Hack to hide a warning during cmkr bootstrapping on Windows
if(CMAKE_BUILD_TYPE)
endif()
"""
name = "cmkr"
version = "0.1.4"
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"

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

@ -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

@ -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();

@ -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

@ -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

@ -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

@ -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 <exception>

@ -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 <sstream>
@ -16,7 +16,7 @@ namespace build {
int run(int argc, char **argv) {
cmake::CMake cmake(".", true);
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]);
}
}

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

@ -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 <cassert>

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

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

Loading…
Cancel
Save