1
0
mirror of https://github.com/CPunch/Laika.git synced 2026-02-10 01:40:05 +00:00

Refactored how CMake passes version & settings info

- keys can now be passed per-build passing -DLAIKA_PUBKEY=[pubkey] & -LAIKA_PRIVKEY=[pubkey] to `cmake -B`
- if those definitions aren't passed, the default public & private key will be used (for quick testing)
This commit is contained in:
2022-01-30 01:15:51 -06:00
parent 7481431551
commit 6fb8aa9b8a
8 changed files with 72 additions and 23 deletions

View File

@@ -5,12 +5,24 @@ set(CMAKE_C_STANDARD_REQUIRED ON)
set(LIB_INCLUDEDIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
# DO NOT USE THESE KEYS, TESTING ONLY
if(NOT LAIKA_PUBKEY)
set(LAIKA_PUBKEY "997d026d1c65deb6c30468525132be4ea44116d6f194c142347b67ee73d18814")
endif ()
if(NOT LAIKA_PRIVKEY)
set(LAIKA_PRIVKEY "1dbd33962f1e170d1e745c6d3e19175049b5616822fac2fa3535d7477957a841")
endif ()
# version details
set(LAIKA_VERSION_MAJOR 0)
set(LAIKA_VERSION_MINOR 0)
project(LaikaLib VERSION ${LAIKA_VERSION_MAJOR}.${LAIKA_VERSION_MINOR})
message(STATUS "Building config file")
configure_file(${LIB_INCLUDEDIR}/lconfig.h.in ${LIB_INCLUDEDIR}/lconfig.h)
# Put CMake targets (ALL_BUILD/ZERO_CHECK) into a folder
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
@@ -23,7 +35,7 @@ add_library(LaikaLib STATIC ${LIBSOURCE})
target_link_libraries(LaikaLib PRIVATE ${sodium_LIBRARY_RELEASE})
# add the version definitions and the 'DEBUG' preprocessor definition if we're compiling as Debug
target_compile_definitions(LaikaLib PUBLIC LAIKA_VERSION_MAJOR=${LAIKA_VERSION_MAJOR} LAIKA_VERSION_MINOR=${LAIKA_VERSION_MINOR} "$<$<CONFIG:Debug>:DEBUG>")
target_compile_definitions(LaikaLib PUBLIC "$<$<CONFIG:Debug>:DEBUG>")
# add include directory
target_include_directories(LaikaLib PUBLIC ${LIB_INCLUDEDIR} ${sodium_INCLUDE_DIR})