diff --git a/CMakeLists.txt b/CMakeLists.txt index 04cbec4..3c2aff5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,61 +16,75 @@ project(cmkr VERSION ${cmkr_PROJECT_VERSION}) include(FetchContent) +message(STATUS "Fetching filesystem...") FetchContent_Declare( filesystem GIT_REPOSITORY https://github.com/gulrak/filesystem ) - FetchContent_MakeAvailable(filesystem) +message(STATUS "Fetching mpark_variant...") FetchContent_Declare( mpark_variant URL https://github.com/mpark/variant/archive/v1.4.0.tar.gz ) - FetchContent_MakeAvailable(mpark_variant) +message(STATUS "Fetching toml11...") FetchContent_Declare( toml11 GIT_REPOSITORY https://github.com/ToruNiina/toml11 ) - FetchContent_MakeAvailable(toml11) set(CMKRLIB_SOURCES - src/cmake.cpp - src/gen.cpp - src/help.cpp - src/build.cpp - src/error.cpp + 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/fs.hpp + include/args.h + include/build.h + include/error.h + include/gen.h + include/help.h + include/literals.h + cmake.toml ) add_library(cmkrlib STATIC ${CMKRLIB_SOURCES}) +source_group(TREE ${PROJECT_SOURCE_DIR} FILES ${CMKRLIB_SOURCES}) + target_include_directories(cmkrlib PUBLIC include - ) +) target_link_libraries(cmkrlib PUBLIC toml11::toml11 ghc_filesystem mpark_variant - ) +) target_compile_features(cmkrlib PUBLIC cxx_std_11 - ) +) set(CMKR_SOURCES src/main.cpp - src/args.cpp + cmake.toml ) add_executable(cmkr ${CMKR_SOURCES}) +source_group(TREE ${PROJECT_SOURCE_DIR} FILES ${CMKR_SOURCES}) + target_link_libraries(cmkr PUBLIC cmkrlib - ) +) install( TARGETS cmkr diff --git a/cmake.toml b/cmake.toml index be05a27..65556fa 100644 --- a/cmake.toml +++ b/cmake.toml @@ -13,7 +13,7 @@ mpark_variant = { url = "https://github.com/mpark/variant/archive/v1.4.0.tar.gz" [[target]] name = "cmkrlib" type = "static" -sources = ["src/cmake.cpp", "src/gen.cpp", "src/help.cpp", "src/build.cpp", "src/error.cpp"] +sources = ["src/cmkrlib/*.cpp", "src/cmkrlib/*.hpp", "include/*.h"] include-directories = ["include"] compile-features = ["cxx_std_11"] link-libraries = ["toml11::toml11", "ghc_filesystem", "mpark_variant"] @@ -21,7 +21,7 @@ link-libraries = ["toml11::toml11", "ghc_filesystem", "mpark_variant"] [[target]] name = "cmkr" type = "executable" -sources = ["src/main.cpp", "src/args.cpp"] +sources = ["src/main.cpp"] link-libraries = ["cmkrlib"] [[install]] diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index b460abd..c35b2dd 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -9,7 +9,6 @@ endif() cmake_minimum_required(VERSION 3.15) -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set_property(GLOBAL PROPERTY USE_FOLDERS ON) set(example_PROJECT_VERSION 0.1.0) @@ -17,9 +16,12 @@ project(example VERSION ${example_PROJECT_VERSION}) set(EXAMPLE_SOURCES src/example.cpp + cmake.toml ) add_executable(example ${EXAMPLE_SOURCES}) +source_group(TREE ${PROJECT_SOURCE_DIR} FILES ${EXAMPLE_SOURCES}) + diff --git a/include/literals.h b/include/literals.h index 8e63c4b..3859dfb 100644 --- a/include/literals.h +++ b/include/literals.h @@ -1,16 +1,15 @@ #pragma once -const char *hello_world = R"lit( +static const char *hello_world = R"lit( #include int %s() { std::cout << "Hello World!\n"; return 0; } +)lit" + 1; // skip initial newline -)lit"; - -const char *cmake_toml = R"lit( +static const char *cmake_toml = R"lit( [cmake] minimum = "3.15" # subdirs = [] @@ -44,5 +43,4 @@ include-directories = ["include"] [[install]] %s = ["%s"] destination = "${CMAKE_INSTALL_PREFIX}/%s" - -)lit"; +)lit" + 1; // skip initial newline diff --git a/src/args.cpp b/src/cmkrlib/args.cpp similarity index 100% rename from src/args.cpp rename to src/cmkrlib/args.cpp diff --git a/src/build.cpp b/src/cmkrlib/build.cpp similarity index 100% rename from src/build.cpp rename to src/cmkrlib/build.cpp diff --git a/src/cmake.cpp b/src/cmkrlib/cmake.cpp similarity index 99% rename from src/cmake.cpp rename to src/cmkrlib/cmake.cpp index ea3b80e..033f738 100644 --- a/src/cmake.cpp +++ b/src/cmkrlib/cmake.cpp @@ -218,7 +218,7 @@ CMake::CMake(const std::string &path, bool build) { target.properties = toml::find(t, "properties"); } - binaries.push_back(target); + targets.push_back(target); } } diff --git a/src/cmake.hpp b/src/cmkrlib/cmake.hpp similarity index 97% rename from src/cmake.hpp rename to src/cmkrlib/cmake.hpp index 22932be..f510eb8 100644 --- a/src/cmake.hpp +++ b/src/cmkrlib/cmake.hpp @@ -73,7 +73,7 @@ struct CMake { std::vector