2023-11-09 07:31:26 +00:00
|
|
|
cmake_minimum_required(VERSION 3.5)
|
2021-07-08 01:45:54 +00:00
|
|
|
project(looking-glass-client C CXX)
|
2018-05-29 08:08:26 +00:00
|
|
|
|
2021-07-24 00:25:42 +00:00
|
|
|
get_filename_component(PROJECT_TOP "${PROJECT_SOURCE_DIR}/.." ABSOLUTE)
|
2021-12-14 23:56:27 +00:00
|
|
|
|
|
|
|
if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
|
2022-05-28 18:45:13 +00:00
|
|
|
message(FATAL_ERROR
|
|
|
|
"\n"
|
|
|
|
"In-source builds are not supported\n"
|
|
|
|
"See build instructions provided in: "
|
|
|
|
"${PROJECT_TOP}/doc/build.rst\n"
|
|
|
|
"Refusing to continue"
|
|
|
|
)
|
2021-12-14 23:56:27 +00:00
|
|
|
endif()
|
|
|
|
|
2021-07-24 00:25:42 +00:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${PROJECT_TOP}/cmake/" "${PROJECT_SOURCE_DIR}/cmake/")
|
2018-05-29 08:08:26 +00:00
|
|
|
|
2021-08-18 22:02:33 +00:00
|
|
|
include(CheckSubmodule)
|
2019-03-28 00:02:36 +00:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
include(CheckCCompilerFlag)
|
2019-03-28 09:27:38 +00:00
|
|
|
include(FeatureSummary)
|
2019-03-28 00:02:36 +00:00
|
|
|
|
2021-07-24 01:21:26 +00:00
|
|
|
set(OPTIMIZE_FOR_NATIVE_DEFAULT ON)
|
2021-07-24 00:25:42 +00:00
|
|
|
include(OptimizeForNative) # option(OPTIMIZE_FOR_NATIVE)
|
2021-08-16 09:43:31 +00:00
|
|
|
include(UninstallTarget)
|
2019-03-28 00:02:36 +00:00
|
|
|
|
2021-07-23 10:10:56 +00:00
|
|
|
find_package(PkgConfig)
|
2021-07-24 01:47:54 +00:00
|
|
|
pkg_check_modules(FONTCONFIG REQUIRED IMPORTED_TARGET fontconfig)
|
2021-07-23 10:10:56 +00:00
|
|
|
|
2019-03-28 09:12:18 +00:00
|
|
|
option(ENABLE_OPENGL "Enable the OpenGL renderer" ON)
|
2019-03-28 09:27:38 +00:00
|
|
|
add_feature_info(ENABLE_OPENGL ENABLE_OPENGL "Legacy OpenGL renderer.")
|
|
|
|
|
2019-03-28 09:12:18 +00:00
|
|
|
option(ENABLE_EGL "Enable the EGL renderer" ON)
|
2019-03-28 09:27:38 +00:00
|
|
|
add_feature_info(ENABLE_EGL ENABLE_EGL "EGL renderer.")
|
|
|
|
|
2019-06-18 23:13:03 +00:00
|
|
|
option(ENABLE_BACKTRACE "Enable backtrace support on crash" ON)
|
|
|
|
add_feature_info(ENABLE_BACKTRACE ENABLE_BACKTRACE "Backtrace support.")
|
|
|
|
|
2021-01-10 00:18:04 +00:00
|
|
|
option(ENABLE_ASAN "Build with AddressSanitizer" OFF)
|
|
|
|
add_feature_info(ENABLE_ASAN ENABLE_ASAN "AddressSanitizer support.")
|
|
|
|
|
2021-01-14 06:23:06 +00:00
|
|
|
option(ENABLE_UBSAN "Build with UndefinedBehaviorSanitizer" OFF)
|
|
|
|
add_feature_info(ENABLE_UBSAN ENABLE_UBSAN "UndefinedBehaviorSanitizer support.")
|
|
|
|
|
2021-12-24 07:43:20 +00:00
|
|
|
option(ENABLE_PIPEWIRE "Build with PipeWire audio output support" ON)
|
|
|
|
add_feature_info(ENABLE_PIPEWIRE ENABLE_PIPEWIRE "PipeWire audio support.")
|
|
|
|
|
2021-12-26 07:21:21 +00:00
|
|
|
option(ENABLE_PULSEAUDIO "Build with PulseAudio audio output support" ON)
|
|
|
|
add_feature_info(ENABLE_PULSEAUDIO ENABLE_PULSEAUDIO "PulseAudio audio support.")
|
|
|
|
|
2019-03-28 00:02:36 +00:00
|
|
|
add_compile_options(
|
|
|
|
"-Wall"
|
2021-01-14 08:31:12 +00:00
|
|
|
"-Wextra"
|
|
|
|
"-Wno-sign-compare"
|
|
|
|
"-Wno-unused-parameter"
|
2022-05-28 18:46:22 +00:00
|
|
|
"$<$<COMPILE_LANGUAGE:C>:-Wstrict-prototypes>"
|
2021-01-14 08:31:12 +00:00
|
|
|
"$<$<C_COMPILER_ID:GNU>:-Wimplicit-fallthrough=2>"
|
2019-03-28 00:02:36 +00:00
|
|
|
"-Werror"
|
|
|
|
"-Wfatal-errors"
|
|
|
|
"-ffast-math"
|
|
|
|
"-fdata-sections"
|
|
|
|
"-ffunction-sections"
|
|
|
|
"$<$<CONFIG:DEBUG>:-O0;-g3;-ggdb>"
|
|
|
|
)
|
2019-04-11 06:41:52 +00:00
|
|
|
|
2021-01-04 13:01:45 +00:00
|
|
|
set(EXE_FLAGS "-Wl,--gc-sections -z noexecstack")
|
2019-04-11 06:41:52 +00:00
|
|
|
set(CMAKE_C_STANDARD 11)
|
2018-05-29 08:08:26 +00:00
|
|
|
|
2021-01-27 20:13:35 +00:00
|
|
|
if (ENABLE_OPENGL)
|
|
|
|
add_definitions(-D ENABLE_OPENGL)
|
|
|
|
endif()
|
|
|
|
|
2021-01-26 10:46:30 +00:00
|
|
|
if (ENABLE_EGL)
|
|
|
|
add_definitions(-D ENABLE_EGL)
|
|
|
|
endif()
|
|
|
|
|
2021-01-10 00:18:04 +00:00
|
|
|
if(ENABLE_ASAN)
|
|
|
|
add_compile_options("-fno-omit-frame-pointer" "-fsanitize=address")
|
|
|
|
set(EXE_FLAGS "${EXE_FLAGS} -fno-omit-frame-pointer -fsanitize=address")
|
|
|
|
endif()
|
|
|
|
|
2021-01-14 06:23:06 +00:00
|
|
|
if(ENABLE_UBSAN)
|
|
|
|
add_compile_options("-fsanitize=undefined")
|
|
|
|
set(EXE_FLAGS "${EXE_FLAGS} -fsanitize=undefined")
|
|
|
|
endif()
|
|
|
|
|
2018-05-29 08:18:22 +00:00
|
|
|
add_definitions(-D ATOMIC_LOCKING)
|
2018-12-12 05:53:30 +00:00
|
|
|
add_definitions(-D GL_GLEXT_PROTOTYPES)
|
2018-05-29 08:08:26 +00:00
|
|
|
|
2020-10-08 15:17:20 +00:00
|
|
|
add_custom_command(
|
2022-05-28 18:45:13 +00:00
|
|
|
OUTPUT ${CMAKE_BINARY_DIR}/version.c
|
|
|
|
${CMAKE_BINARY_DIR}/_version.c
|
|
|
|
COMMAND ${CMAKE_COMMAND} -D PROJECT_TOP=${PROJECT_TOP} -P
|
|
|
|
${PROJECT_TOP}/version.cmake
|
2020-10-08 15:17:20 +00:00
|
|
|
)
|
|
|
|
|
2018-05-29 08:08:26 +00:00
|
|
|
include_directories(
|
2022-05-28 18:45:13 +00:00
|
|
|
${PROJECT_TOP}
|
|
|
|
${PROJECT_SOURCE_DIR}/include
|
|
|
|
${CMAKE_BINARY_DIR}
|
|
|
|
${CMAKE_BINARY_DIR}/include
|
|
|
|
${PROJECT_TOP}/repos/nanosvg/src
|
2018-05-29 08:08:26 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
link_libraries(
|
2022-05-28 18:45:13 +00:00
|
|
|
${CMAKE_DL_LIBS}
|
|
|
|
rt
|
|
|
|
m
|
2018-05-29 08:08:26 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
set(SOURCES
|
2022-05-28 18:45:13 +00:00
|
|
|
${CMAKE_BINARY_DIR}/version.c
|
|
|
|
src/main.c
|
|
|
|
src/core.c
|
|
|
|
src/app.c
|
|
|
|
src/audio.c
|
|
|
|
src/config.c
|
|
|
|
src/keybind.c
|
|
|
|
src/util.c
|
|
|
|
src/clipboard.c
|
|
|
|
src/kb.c
|
|
|
|
src/gl_dynprocs.c
|
|
|
|
src/egl_dynprocs.c
|
|
|
|
src/eglutil.c
|
|
|
|
src/overlay_utils.c
|
|
|
|
src/render_queue.c
|
|
|
|
|
|
|
|
src/overlay/splash.c
|
|
|
|
src/overlay/alert.c
|
|
|
|
src/overlay/fps.c
|
|
|
|
src/overlay/graphs.c
|
|
|
|
src/overlay/help.c
|
|
|
|
src/overlay/config.c
|
|
|
|
src/overlay/msg.c
|
|
|
|
src/overlay/status.c
|
2018-05-29 08:08:26 +00:00
|
|
|
)
|
|
|
|
|
2021-07-18 00:17:20 +00:00
|
|
|
# Force cimgui to build as a static library.
|
|
|
|
set(IMGUI_STATIC "yes" CACHE STRING "Build as a static library")
|
|
|
|
|
2022-05-25 18:08:22 +00:00
|
|
|
add_subdirectory("${PROJECT_TOP}/resources" "${CMAKE_BINARY_DIR}/resources")
|
2020-01-31 10:39:57 +00:00
|
|
|
add_subdirectory("${PROJECT_TOP}/common" "${CMAKE_BINARY_DIR}/common" )
|
|
|
|
add_subdirectory("${PROJECT_TOP}/repos/LGMP/lgmp" "${CMAKE_BINARY_DIR}/LGMP" )
|
|
|
|
add_subdirectory("${PROJECT_TOP}/repos/PureSpice" "${CMAKE_BINARY_DIR}/PureSpice")
|
2021-08-16 10:00:37 +00:00
|
|
|
add_subdirectory("${PROJECT_TOP}/repos/cimgui" "${CMAKE_BINARY_DIR}/cimgui" EXCLUDE_FROM_ALL)
|
2020-01-09 09:32:42 +00:00
|
|
|
|
2021-01-15 09:30:03 +00:00
|
|
|
add_subdirectory(displayservers)
|
2019-03-28 00:02:36 +00:00
|
|
|
add_subdirectory(renderers)
|
|
|
|
|
2018-05-29 08:08:26 +00:00
|
|
|
add_executable(looking-glass-client ${SOURCES})
|
2021-07-08 01:45:54 +00:00
|
|
|
|
|
|
|
target_compile_definitions(looking-glass-client PRIVATE CIMGUI_DEFINE_ENUMS_AND_STRUCTS=1)
|
|
|
|
|
2019-03-28 00:02:36 +00:00
|
|
|
target_link_libraries(looking-glass-client
|
2022-05-28 18:45:13 +00:00
|
|
|
${EXE_FLAGS}
|
|
|
|
PkgConfig::FONTCONFIG
|
|
|
|
lg_resources
|
|
|
|
lg_common
|
|
|
|
displayservers
|
|
|
|
lgmp
|
|
|
|
purespice
|
|
|
|
renderers
|
|
|
|
cimgui
|
2019-03-28 00:02:36 +00:00
|
|
|
)
|
2019-03-28 09:27:38 +00:00
|
|
|
|
2022-01-27 06:57:30 +00:00
|
|
|
if (ENABLE_PIPEWIRE OR ENABLE_PULSEAUDIO)
|
2022-05-28 18:45:13 +00:00
|
|
|
add_definitions(-D ENABLE_AUDIO)
|
|
|
|
add_subdirectory(audiodevs)
|
|
|
|
pkg_check_modules(SAMPLERATE REQUIRED IMPORTED_TARGET samplerate)
|
|
|
|
target_link_libraries(looking-glass-client
|
|
|
|
PkgConfig::SAMPLERATE
|
|
|
|
audiodevs
|
|
|
|
)
|
2022-01-27 06:57:30 +00:00
|
|
|
endif()
|
|
|
|
|
2021-07-01 23:47:57 +00:00
|
|
|
install(TARGETS looking-glass-client
|
2022-05-28 18:45:13 +00:00
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
|
|
COMPONENT binary)
|
2019-03-31 18:26:37 +00:00
|
|
|
|
2019-03-28 09:27:38 +00:00
|
|
|
feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES)
|