LookingGlass/client/CMakeLists.txt

159 lines
4.1 KiB
CMake
Raw Normal View History

2019-03-28 00:02:36 +00:00
cmake_minimum_required(VERSION 3.0)
project(looking-glass-client C CXX)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")
2019-03-28 00:02:36 +00:00
include(GNUInstallDirs)
include(CheckCCompilerFlag)
include(FeatureSummary)
2019-03-28 00:02:36 +00:00
option(OPTIMIZE_FOR_NATIVE "Build with -march=native" ON)
if(OPTIMIZE_FOR_NATIVE)
CHECK_C_COMPILER_FLAG("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
if(COMPILER_SUPPORTS_MARCH_NATIVE)
add_compile_options("-march=native")
endif()
else()
add_compile_options("-march=nehalem" "-mtune=generic")
2019-03-28 00:02:36 +00:00
endif()
option(ENABLE_OPENGL "Enable the OpenGL renderer" ON)
add_feature_info(ENABLE_OPENGL ENABLE_OPENGL "Legacy OpenGL renderer.")
option(ENABLE_EGL "Enable the EGL renderer" ON)
add_feature_info(ENABLE_EGL ENABLE_EGL "EGL renderer.")
option(ENABLE_BACKTRACE "Enable backtrace support on crash" ON)
add_feature_info(ENABLE_BACKTRACE ENABLE_BACKTRACE "Backtrace support.")
option(ENABLE_ASAN "Build with AddressSanitizer" OFF)
add_feature_info(ENABLE_ASAN ENABLE_ASAN "AddressSanitizer support.")
option(ENABLE_UBSAN "Build with UndefinedBehaviorSanitizer" OFF)
add_feature_info(ENABLE_UBSAN ENABLE_UBSAN "UndefinedBehaviorSanitizer support.")
option(ENABLE_SDL "Build with SDL support" OFF)
add_feature_info(ENABLE_SDL ENABLE_SDL "SDL support.")
option(ENABLE_X11 "Build with X11 support" ON)
add_feature_info(ENABLE_X11 ENABLE_X11 "X11 support.")
option(ENABLE_WAYLAND "Build with Wayland support" ON)
add_feature_info(ENABLE_WAYLAND ENABLE_WAYLAND "Wayland support.")
option(ENABLE_LIBDECOR "Build with libdecor support" OFF)
add_feature_info(ENABLE_LIBDECOR ENABLE_LIBDECOR "libdecor support.")
if (NOT ENABLE_SDL AND NOT ENABLE_X11 AND NOT ENABLE_WAYLAND)
message(FATAL_ERROR "One of ENABLE_SDL, ENABLE_X11, or ENABLE_WAYLAND must be on")
endif()
2019-03-28 00:02:36 +00:00
add_compile_options(
"-Wall"
"-Wextra"
"-Wno-sign-compare"
"-Wno-unused-parameter"
"$<$<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>"
)
2021-01-04 13:01:45 +00:00
set(EXE_FLAGS "-Wl,--gc-sections -z noexecstack")
set(CMAKE_C_STANDARD 11)
if (ENABLE_OPENGL)
add_definitions(-D ENABLE_OPENGL)
endif()
if (ENABLE_EGL)
add_definitions(-D ENABLE_EGL)
endif()
if(ENABLE_ASAN)
add_compile_options("-fno-omit-frame-pointer" "-fsanitize=address")
set(EXE_FLAGS "${EXE_FLAGS} -fno-omit-frame-pointer -fsanitize=address")
endif()
if(ENABLE_UBSAN)
add_compile_options("-fsanitize=undefined")
set(EXE_FLAGS "${EXE_FLAGS} -fsanitize=undefined")
endif()
find_package(GMP)
2018-05-29 08:18:22 +00:00
add_definitions(-D ATOMIC_LOCKING)
add_definitions(-D GL_GLEXT_PROTOTYPES)
get_filename_component(PROJECT_TOP "${PROJECT_SOURCE_DIR}/.." ABSOLUTE)
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/version.c
${CMAKE_BINARY_DIR}/_version.c
COMMAND ${CMAKE_COMMAND} -D PROJECT_TOP=${PROJECT_TOP} -P
${PROJECT_TOP}/version.cmake
)
include_directories(
2019-03-28 00:02:36 +00:00
${PROJECT_SOURCE_DIR}/include
${CMAKE_BINARY_DIR}/include
${GMP_INCLUDE_DIR}
)
link_libraries(
${GMP_LIBRARIES}
${CMAKE_DL_LIBS}
rt
m
)
set(SOURCES
${CMAKE_BINARY_DIR}/version.c
2019-03-28 00:02:36 +00:00
src/main.c
src/core.c
src/app.c
src/config.c
src/keybind.c
2019-03-28 00:02:36 +00:00
src/lg-renderer.c
src/ll.c
src/util.c
src/clipboard.c
src/kb.c
src/egl_dynprocs.c
)
# Force cimgui to build as a static library.
set(IMGUI_STATIC "yes" CACHE STRING "Build as a static library")
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")
add_subdirectory("${PROJECT_TOP}/repos/cimgui" "${CMAKE_BINARY_DIR}/cimgui" )
2020-01-09 09:32:42 +00:00
add_subdirectory(displayservers)
2019-03-28 00:02:36 +00:00
add_subdirectory(renderers)
2019-03-28 01:42:41 +00:00
add_subdirectory(fonts)
2019-03-28 00:02:36 +00:00
add_executable(looking-glass-client ${SOURCES})
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
${EXE_FLAGS}
lg_common
displayservers
2020-01-09 09:32:42 +00:00
lgmp
purespice
2019-03-28 00:02:36 +00:00
renderers
2019-03-28 01:42:41 +00:00
fonts
cimgui
2019-03-28 00:02:36 +00:00
)
2021-07-01 23:47:57 +00:00
install(TARGETS looking-glass-client
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT binary)
2019-03-31 18:26:37 +00:00
feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES)