This repository has been archived on 2024-06-12. You can view files and clone it, but cannot push or open issues or pull requests.
MPortLink/CMakeLists.txt

43 lines
1.1 KiB
CMake
Raw Permalink Normal View History

2023-12-20 21:18:00 +00:00
cmake_minimum_required(VERSION 3.18.4)
project(mportlink)
2023-12-25 14:06:59 +00:00
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -Os")
2023-12-24 21:06:56 +00:00
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}")
2023-12-20 21:18:00 +00:00
file(GLOB_RECURSE SRC_FILES_LIST src/*.c)
find_package(PkgConfig REQUIRED)
2023-12-23 23:33:54 +00:00
pkg_search_module(UDEV REQUIRED libudev)
2023-12-20 21:18:00 +00:00
include_directories(${UDEV_INCLUDE_DIRS})
link_directories(${UDEV_LIBRARY_DIRS})
add_definitions(${UDEV_CFLAGS_OTHER})
2023-12-20 21:18:00 +00:00
add_executable(${PROJECT_NAME} ${SRC_FILES_LIST})
target_link_libraries(${PROJECT_NAME} ${UDEV_LIBRARIES})