|
| 1 | +cmake_minimum_required(VERSION 3.28) |
| 2 | +set(CMAKE_CXX_EXTENSIONS OFF) |
| 3 | + |
| 4 | + |
| 5 | +project(git2cpp CXX) |
| 6 | + |
| 7 | +if(NOT CMAKE_CXX_STANDARD) |
| 8 | + set(CMAKE_CXX_STANDARD 20) |
| 9 | +endif() |
| 10 | +message(STATUS "🔧 C++ standard: ${CMAKE_CXX_STANDARD}") |
| 11 | +set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 12 | + |
| 13 | + |
| 14 | +set(GIT2CPP_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src) |
| 15 | + |
| 16 | +# Versionning |
| 17 | +# =========== |
| 18 | +file(STRINGS "${GIT2CPP_SOURCE_DIR}/version.hpp" git2cpp_version_defines |
| 19 | + REGEX "#define GIT2CPP_VERSION_(MAJOR|MINOR|PATCH)") |
| 20 | + |
| 21 | +foreach(ver ${git2cpp_version_defines}) |
| 22 | + if(ver MATCHES "#define GIT2CPP_VERSION_(MAJOR|MINOR|PATCH) ([0-9]+);$") |
| 23 | + set(PROJECT_VERSION_${CMAKE_MATCH_1} "${CMAKE_MATCH_2}" CACHE INTERNAL "") |
| 24 | + endif() |
| 25 | +endforeach() |
| 26 | + |
| 27 | +set(CMAKE_PROJECT_VERSION |
| 28 | + ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) |
| 29 | + |
| 30 | +message(STATUS "Building git2cpp v${CMAKE_PROJECT_VERSION}") |
| 31 | + |
| 32 | +# Dependencies |
| 33 | +# ============ |
| 34 | + |
| 35 | +find_package(libgit2) |
| 36 | +# CLI11 is a single header, not packaged for cmake |
| 37 | + |
| 38 | +# Build |
| 39 | +# ===== |
| 40 | + |
| 41 | +set(GIT2CPP_SRC |
| 42 | + ${GIT2CPP_SOURCE_DIR}/subcommand/init_subcommand.cpp |
| 43 | + ${GIT2CPP_SOURCE_DIR}/subcommand/init_subcommand.hpp |
| 44 | + ${GIT2CPP_SOURCE_DIR}/subcommand/status_subcommand.cpp |
| 45 | + ${GIT2CPP_SOURCE_DIR}/subcommand/status_subcommand.hpp |
| 46 | + ${GIT2CPP_SOURCE_DIR}/utils/common.cpp |
| 47 | + ${GIT2CPP_SOURCE_DIR}/utils/common.hpp |
| 48 | + ${GIT2CPP_SOURCE_DIR}/utils/git_exception.cpp |
| 49 | + ${GIT2CPP_SOURCE_DIR}/utils/git_exception.hpp |
| 50 | + ${GIT2CPP_SOURCE_DIR}/wrapper/refs_wrapper.cpp |
| 51 | + ${GIT2CPP_SOURCE_DIR}/wrapper/refs_wrapper.hpp |
| 52 | + ${GIT2CPP_SOURCE_DIR}/wrapper/repository_wrapper.cpp |
| 53 | + ${GIT2CPP_SOURCE_DIR}/wrapper/repository_wrapper.hpp |
| 54 | + ${GIT2CPP_SOURCE_DIR}/wrapper/status_wrapper.cpp |
| 55 | + ${GIT2CPP_SOURCE_DIR}/wrapper/status_wrapper.hpp |
| 56 | + ${GIT2CPP_SOURCE_DIR}/main.cpp |
| 57 | + ${GIT2CPP_SOURCE_DIR}/version.hpp |
| 58 | +) |
| 59 | + |
| 60 | +add_executable(git2cpp ${GIT2CPP_SRC}) |
| 61 | +target_link_libraries(git2cpp PRIVATE libgit2::libgit2package) |
| 62 | + |
0 commit comments