43 lines
1.1 KiB
CMake
43 lines
1.1 KiB
CMake
cmake_minimum_required(VERSION 3.18.4)
|
|
project(mportlink)
|
|
|
|
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -Os")
|
|
|
|
set(VERSION_MAJOR 0)
|
|
set(VERSION_MINOR 1)
|
|
set(VERSION_PATCH 0)
|
|
string(TIMESTAMP CURRENT_YEAR "%y" UTC)
|
|
string(TIMESTAMP DAY_OF_YEAR "%j" UTC)
|
|
|
|
string(CONCAT BASEVERSION "${VERSION_MAJOR}" "." "${VERSION_MINOR}" "." "${VERSION_PATCH}")
|
|
string(CONCAT BUILDVERSION "${BASEVERSION}" "." "${CURRENT_YEAR}" "${DAY_OF_YEAR}")
|
|
|
|
execute_process(
|
|
COMMAND git describe HEAD
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
OUTPUT_VARIABLE GIT_VERSION
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
ERROR_QUIET
|
|
)
|
|
|
|
if(GIT_SHORT_HASH STREQUAL "")
|
|
set(VERSION "${BUILDVERSION}")
|
|
else()
|
|
set(VERSION "${GIT_VERSION}")
|
|
endif()
|
|
|
|
add_definitions(-DVERSION="${VERSION}")
|
|
|
|
file(GLOB_RECURSE SRC_FILES_LIST src/*.c)
|
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
pkg_search_module(UDEV REQUIRED libudev)
|
|
|
|
include_directories(${UDEV_INCLUDE_DIRS})
|
|
link_directories(${UDEV_LIBRARY_DIRS})
|
|
add_definitions(${UDEV_CFLAGS_OTHER})
|
|
|
|
add_executable(${PROJECT_NAME} ${SRC_FILES_LIST})
|
|
target_link_libraries(${PROJECT_NAME} ${UDEV_LIBRARIES})
|