|
| 1 | +# Copyright (C) 2024-2026 Intel Corporation |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | + |
| 4 | +cmake_minimum_required(VERSION 3.15) |
| 5 | + |
| 6 | +project(vsyncalter |
| 7 | + VERSION 4.0.0 |
| 8 | + DESCRIPTION "VSync Alteration Library and Tools" |
| 9 | + LANGUAGES CXX |
| 10 | +) |
| 11 | + |
| 12 | +# Set C++ standard |
| 13 | +set(CMAKE_CXX_STANDARD 11) |
| 14 | +set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 15 | +set(CMAKE_CXX_EXTENSIONS OFF) |
| 16 | + |
| 17 | +# Build type |
| 18 | +if(NOT CMAKE_BUILD_TYPE) |
| 19 | + set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE) |
| 20 | +endif() |
| 21 | + |
| 22 | +message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") |
| 23 | +message(STATUS "System: ${CMAKE_SYSTEM_NAME}") |
| 24 | + |
| 25 | +# Platform detection |
| 26 | +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") |
| 27 | + set(PLATFORM "linux") |
| 28 | + message(STATUS "Detected platform: Linux") |
| 29 | +else() |
| 30 | + message(FATAL_ERROR "Unsupported platform: ${CMAKE_SYSTEM_NAME}") |
| 31 | +endif() |
| 32 | + |
| 33 | +# Options |
| 34 | +option(BUILD_SHARED_LIBS "Build shared libraries" ON) |
| 35 | +option(BUILD_SWGENLOCK "Build swgenlock application" ON) |
| 36 | +option(BUILD_PLLCTL "Build pllctl application" ON) |
| 37 | +option(BUILD_VBLMON "Build vblmon application" ON) |
| 38 | +option(BUILD_FRAMESYNC "Build framesync application" ON) |
| 39 | +option(UNITTEST_ENABLE_COVERAGE "Enable code coverage instrumentation for unit tests" OFF) |
| 40 | + |
| 41 | +# Global include directories |
| 42 | +include_directories( |
| 43 | + ${CMAKE_SOURCE_DIR}/cmn |
| 44 | + ${CMAKE_SOURCE_DIR}/os |
| 45 | + ${CMAKE_SOURCE_DIR}/lib |
| 46 | +) |
| 47 | + |
| 48 | +# Include directories for applications (without lib) |
| 49 | +set(APP_INCLUDE_DIRS |
| 50 | + ${CMAKE_SOURCE_DIR}/cmn |
| 51 | + ${CMAKE_SOURCE_DIR}/os |
| 52 | +) |
| 53 | + |
| 54 | +# Platform-specific settings |
| 55 | +if(PLATFORM STREQUAL "linux") |
| 56 | + # Linux-specific includes and libraries |
| 57 | + include_directories(/usr/include/drm) |
| 58 | + |
| 59 | + # Find required libraries |
| 60 | + find_library(RT_LIBRARY rt REQUIRED) |
| 61 | + find_library(DRM_LIBRARY drm REQUIRED) |
| 62 | + find_library(PCIACCESS_LIBRARY pciaccess REQUIRED) |
| 63 | + |
| 64 | + set(PLATFORM_LIBS ${RT_LIBRARY} ${DRM_LIBRARY} ${PCIACCESS_LIBRARY}) |
| 65 | + |
| 66 | + message(STATUS "Linux libraries found:") |
| 67 | + message(STATUS " - rt: ${RT_LIBRARY}") |
| 68 | + message(STATUS " - drm: ${DRM_LIBRARY}") |
| 69 | + message(STATUS " - pciaccess: ${PCIACCESS_LIBRARY}") |
| 70 | + |
| 71 | +endif() |
| 72 | + |
| 73 | +# Add subdirectories |
| 74 | +add_subdirectory(lib) |
| 75 | + |
| 76 | +if(BUILD_PLLCTL) |
| 77 | + add_subdirectory(pllctl) |
| 78 | +endif() |
| 79 | + |
| 80 | +if(BUILD_VBLMON) |
| 81 | + add_subdirectory(vblmon) |
| 82 | +endif() |
| 83 | + |
| 84 | +if(BUILD_SWGENLOCK) |
| 85 | + add_subdirectory(swgenlock) |
| 86 | +endif() |
| 87 | + |
| 88 | +if(BUILD_FRAMESYNC) |
| 89 | + add_subdirectory(framesync) |
| 90 | +endif() |
| 91 | + |
| 92 | +# Installation |
| 93 | +install(DIRECTORY cmn/ DESTINATION include/vsyncalter |
| 94 | + FILES_MATCHING PATTERN "*.h") |
| 95 | + |
| 96 | +install(DIRECTORY os/ DESTINATION include/vsyncalter/os |
| 97 | + FILES_MATCHING PATTERN "*.h") |
| 98 | + |
| 99 | +# Print summary |
| 100 | +message(STATUS "") |
| 101 | +message(STATUS "==================================================") |
| 102 | +message(STATUS "VSync Alteration Build Configuration Summary") |
| 103 | +message(STATUS "==================================================") |
| 104 | +message(STATUS " Version: ${PROJECT_VERSION}") |
| 105 | +message(STATUS " Platform: ${PLATFORM}") |
| 106 | +message(STATUS " Build type: ${CMAKE_BUILD_TYPE}") |
| 107 | +message(STATUS " Build framesync: ${BUILD_FRAMESYNC}") |
| 108 | +message(STATUS " Shared libraries: ${BUILD_SHARED_LIBS}") |
| 109 | +message(STATUS " Build pllctl: ${BUILD_PLLCTL}") |
| 110 | +message(STATUS " Build vblmon: ${BUILD_VBLMON}") |
| 111 | +message(STATUS " Build swgenlock: ${BUILD_SWGENLOCK}") |
| 112 | +message(STATUS " Coverage enabled: ${UNITTEST_ENABLE_COVERAGE}") |
| 113 | +message(STATUS " Install prefix: ${CMAKE_INSTALL_PREFIX}") |
| 114 | +message(STATUS "==================================================") |
| 115 | +message(STATUS "") |
0 commit comments