2019-03-28 00:02:36 +00:00
|
|
|
cmake_minimum_required(VERSION 3.0)
|
2018-05-29 08:08:26 +00:00
|
|
|
project(looking-glass-client C)
|
|
|
|
|
|
|
|
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")
|
|
|
|
|
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
|
|
|
|
|
|
|
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()
|
|
|
|
endif()
|
|
|
|
|
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-01-15 09:30:03 +00:00
|
|
|
option(ENABLE_X11 "Build with X11 support" ON)
|
2021-01-20 04:32:05 +00:00
|
|
|
add_feature_info(ENABLE_X11 ENABLE_X11 "X11 support.")
|
2021-01-15 09:30:03 +00:00
|
|
|
|
2021-01-11 23:47:17 +00:00
|
|
|
option(ENABLE_WAYLAND "Build with Wayland support" ON)
|
|
|
|
add_feature_info(ENABLE_WAYLAND ENABLE_WAYLAND "Wayland 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"
|
|
|
|
"$<$<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-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:08:26 +00:00
|
|
|
find_package(PkgConfig)
|
|
|
|
pkg_check_modules(PKGCONFIG REQUIRED
|
|
|
|
sdl2
|
2020-01-13 11:21:12 +00:00
|
|
|
)
|
|
|
|
|
2018-05-29 08:08:26 +00:00
|
|
|
find_package(GMP)
|
|
|
|
|
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)
|
2019-04-11 01:12:59 +00:00
|
|
|
get_filename_component(PROJECT_TOP "${PROJECT_SOURCE_DIR}/.." ABSOLUTE)
|
2018-05-29 08:08:26 +00:00
|
|
|
|
2020-10-08 15:17:20 +00:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${CMAKE_BINARY_DIR}/version.c
|
|
|
|
${CMAKE_BINARY_DIR}/_version.c
|
2020-10-08 15:51:28 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -D PROJECT_TOP=${PROJECT_TOP} -P
|
2020-10-08 15:17:20 +00:00
|
|
|
${PROJECT_TOP}/version.cmake
|
|
|
|
)
|
|
|
|
|
2018-05-29 08:08:26 +00:00
|
|
|
include_directories(
|
2019-03-28 00:02:36 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/include
|
2019-03-28 08:56:14 +00:00
|
|
|
${CMAKE_BINARY_DIR}/include
|
2020-01-13 11:21:12 +00:00
|
|
|
${PKGCONFIG_INCLUDE_DIRS} ${PKGCONFIG_OPT_INCLUDE_DIRS}
|
2018-05-29 08:08:26 +00:00
|
|
|
${GMP_INCLUDE_DIR}
|
|
|
|
)
|
|
|
|
|
|
|
|
link_libraries(
|
2020-01-13 11:21:12 +00:00
|
|
|
${PKGCONFIG_LIBRARIES} ${PKGCONFIG_OPT_LIBRARIES}
|
2018-05-29 08:08:26 +00:00
|
|
|
${GMP_LIBRARIES}
|
2019-12-27 10:48:03 +00:00
|
|
|
${CMAKE_DL_LIBS}
|
2019-04-11 06:41:52 +00:00
|
|
|
rt
|
|
|
|
m
|
2018-05-29 08:08:26 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
set(SOURCES
|
2020-10-08 15:17:20 +00:00
|
|
|
${CMAKE_BINARY_DIR}/version.c
|
2019-03-28 00:02:36 +00:00
|
|
|
src/main.c
|
2021-01-25 08:58:36 +00:00
|
|
|
src/core.c
|
2019-03-30 01:26:06 +00:00
|
|
|
src/app.c
|
2019-03-30 04:52:00 +00:00
|
|
|
src/config.c
|
2021-01-25 16:34:22 +00:00
|
|
|
src/keybind.c
|
2019-03-28 00:02:36 +00:00
|
|
|
src/lg-renderer.c
|
|
|
|
src/ll.c
|
2021-01-25 08:58:36 +00:00
|
|
|
src/util.c
|
|
|
|
src/clipboard.c
|
|
|
|
src/kb.c
|
2021-01-26 10:46:30 +00:00
|
|
|
src/egl_dynprocs.c
|
2018-05-29 08:08:26 +00:00
|
|
|
)
|
|
|
|
|
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")
|
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)
|
2019-03-28 01:42:41 +00:00
|
|
|
add_subdirectory(fonts)
|
2019-03-28 00:02:36 +00:00
|
|
|
|
2018-05-29 08:08:26 +00:00
|
|
|
add_executable(looking-glass-client ${SOURCES})
|
2020-01-13 11:21:12 +00:00
|
|
|
target_compile_options(looking-glass-client PUBLIC ${PKGCONFIG_CFLAGS_OTHER} ${PKGCONFIG_OPT_CFLAGS_OTHER})
|
2019-03-28 00:02:36 +00:00
|
|
|
target_link_libraries(looking-glass-client
|
2019-04-11 06:41:52 +00:00
|
|
|
${EXE_FLAGS}
|
2019-04-11 01:12:59 +00:00
|
|
|
lg_common
|
2021-01-15 09:30:03 +00:00
|
|
|
displayservers
|
2020-01-09 09:32:42 +00:00
|
|
|
lgmp
|
2020-01-31 10:39:57 +00:00
|
|
|
purespice
|
2019-03-28 00:02:36 +00:00
|
|
|
renderers
|
2019-03-28 01:42:41 +00:00
|
|
|
fonts
|
2019-03-28 00:02:36 +00:00
|
|
|
)
|
2019-03-28 09:27:38 +00:00
|
|
|
|
2019-03-31 18:26:37 +00:00
|
|
|
install(PROGRAMS ${CMAKE_BINARY_DIR}/looking-glass-client DESTINATION bin/ COMPONENT binary)
|
|
|
|
|
2019-03-28 09:27:38 +00:00
|
|
|
feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES)
|