logiops/CMakeLists.txt

42 lines
1.2 KiB
CMake
Raw Normal View History

cmake_minimum_required(VERSION 3.10)
set(CMAKE_INSTALL_PREFIX /usr)
project(logiops)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -Wall -Wextra")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2020-04-11 00:53:13 +00:00
find_package(Git)
# Set version number
if(GIT_FOUND AND EXISTS ${CMAKE_SOURCE_DIR}/.git)
2020-07-15 17:16:43 +00:00
execute_process(COMMAND ${GIT_EXECUTABLE} describe
OUTPUT_VARIABLE LOGIOPS_VERSION
RESULT_VARIABLE LOGIOPS_VERSION_RET
ERROR_QUIET)
if(NOT LOGIOPS_VERSION_RET EQUAL "0")
2020-04-11 00:53:13 +00:00
execute_process(COMMAND ${GIT_EXECUTABLE}
2020-07-15 17:16:43 +00:00
rev-parse --short HEAD
OUTPUT_VARIABLE LOGIOPS_COMMIT_HASH)
set(LOGIOPS_VERSION git-${LOGIOPS_COMMIT_HASH})
2020-04-11 00:53:13 +00:00
endif()
2020-07-15 17:16:43 +00:00
string(REGEX REPLACE "\n$" "" LOGIOPS_VERSION ${LOGIOPS_VERSION})
elseif(EXISTS ${CMAKE_SOURCE_DIR}/version.txt)
file(READ version.txt LOGIOPS_VERSION)
string(REGEX REPLACE "\n$" "" LOGIOPS_VERSION ${LOGIOPS_VERSION})
2020-04-11 00:53:13 +00:00
endif()
2020-07-15 17:16:43 +00:00
if(NOT LOGIOPS_VERSION)
2020-04-11 00:53:13 +00:00
set(LOGIOPS_VERSION "null")
endif()
2020-07-15 17:16:43 +00:00
message("LogiOps Version Number: ${LOGIOPS_VERSION}")
2020-04-11 00:53:13 +00:00
add_definitions( -DLOGIOPS_VERSION="${LOGIOPS_VERSION}")
add_subdirectory(src/logid)