Files
libucore/CMakeLists.txt
2026-04-06 23:40:21 +02:00

47 lines
1.9 KiB
CMake

cmake_minimum_required(VERSION 3.12)
project(libucore C)
execute_process(COMMAND git -C ${CMAKE_SOURCE_DIR} describe --abbrev=5 --dirty --always OUTPUT_VARIABLE version_revision WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_STRIP_TRAILING_WHITESPACE)
cmake_host_system_information(RESULT build_host QUERY HOSTNAME)
set(libucore_VERSION_MAJOR 1)
set(libucore_VERSION_MINOR 0)
set(libucore_VERSION_PATCH 0)
set(libucore_VERSION ${libucore_VERSION_MAJOR}.${libucore_VERSION_MINOR}.${libucore_VERSION_PATCH}.${version_revision})
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_C_STANDARD 17)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wundef -Wcast-qual -Wshadow -Wcast-align -pipe -Wno-unused-parameter -Werror=implicit-function-declaration -Winit-self")
add_definitions(-D_FILE_OFFSET_BITS=64)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -O2")
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
option(CODE_COVERAGE "build with code coverage intrumentation" OFF)
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
# Set the property for multi-config generators as well, if applicable
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release RelWithDebInfo MinSizeRel)
endif()
set(build_type ${CMAKE_BUILD_TYPE})
if (CODE_COVERAGE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
add_definitions(-DCOVERAGE)
set(build_type "${build_type}-coverage")
endif()
add_compile_definitions($<$<CONFIG:Debug>:DEBUG>)
option(BUILD_SANITIZE "build with address sanitizer" OFF)
if (BUILD_SANITIZE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
set(build_type "${build_type}-sanitize")
endif()
find_package(PkgConfig REQUIRED)
pkg_check_modules(CHECK REQUIRED IMPORTED_TARGET check)
include_directories(include)
add_subdirectory(src)
add_subdirectory(test)
add_subdirectory(include)