Skip to content

Commit

Permalink
Sort out versioning
Browse files Browse the repository at this point in the history
I should've done this ages ago
  • Loading branch information
LunarWatcher committed Dec 22, 2024
1 parent 3db0097 commit 3cda748
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
31 changes: 25 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,31 @@ set(CURL_INSTALL OFF CACHE STRING "" FORCE)


include(FetchContent)
FetchContent_Declare(stc GIT_REPOSITORY https://github.com/LunarWatcher/stc)
FetchContent_Declare(stc
GIT_REPOSITORY https://github.com/LunarWatcher/stc
)
FetchContent_Declare(cpr
GIT_REPOSITORY https://github.com/libcpr/cpr.git
GIT_TAG 1.10.0)
GIT_TAG 1.11.1
)
FetchContent_Declare(nlohmann
GIT_REPOSITORY https://github.com/nlohmann/json
GIT_TAG v3.11.2)
GIT_TAG v3.11.3
)
FetchContent_Declare(spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog
GIT_TAG v1.11.0)
GIT_TAG v1.15.0
)
FetchContent_Declare(lua-cmake
GIT_REPOSITORY https://github.com/LunarWatcher/lua-cmake/
)
FetchContent_Declare(fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG 9.1.0)
GIT_TAG 11.0.2
)

FetchContent_MakeAvailable(stc)
FetchContent_MakeAvailable(fmt)
#FetchContent_MakeAvailable(cpr)
FetchContent_MakeAvailable(nlohmann)
FetchContent_MakeAvailable(spdlog)
FetchContent_MakeAvailable(lua-cmake)
Expand All @@ -62,6 +67,20 @@ if (NOT cpr_POPULATED)
FetchContent_Populate(cpr)
add_subdirectory(${cpr_SOURCE_DIR} ${cpr_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()

# Versioning {{{
find_program(GIT git)
if (GIT)
execute_process(COMMAND ${GIT} describe --tags --always
OUTPUT_VARIABLE UPM_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS "Detected version: ${UPM_VERSION}")
else()
message(WARNING "Git not found. Defaulting to unknown version. This will not have an effect on the program beyond a missing version")
set(UPM_VERSION "VERSION UNKNOWN. Who doesn't have Git? It's the 2020s. Install it already")
endif()
# }}}

add_subdirectory(src)
add_subdirectory(tests EXCLUDE_FROM_ALL)
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ set (SOURCE_FILES

add_library(upm_sources STATIC ${SOURCE_FILES})

target_compile_options(upm_sources PUBLIC -DUPM_VERSION="${UPM_VERSION}")

target_link_libraries(upm_sources PUBLIC stc cpr::cpr fmt::fmt nlohmann_json::nlohmann_json spdlog::spdlog lua::lib)
target_include_directories(upm_sources PUBLIC .)

Expand Down

0 comments on commit 3cda748

Please sign in to comment.