2019-04-09 06:28:11 +00:00
|
|
|
cmake_minimum_required(VERSION 3.0)
|
|
|
|
project(looking-glass-host C)
|
|
|
|
|
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)
|
|
|
|
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"
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2021-07-24 00:25:42 +00:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${PROJECT_TOP}/cmake/" "${PROJECT_SOURCE_DIR}/cmake/")
|
2019-04-09 06:28:11 +00:00
|
|
|
|
2021-12-14 23:56:27 +00:00
|
|
|
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG" CACHE STRING "compiler flags" FORCE)
|
|
|
|
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG" CACHE STRING "compiler flags" FORCE)
|
|
|
|
|
2021-08-18 22:02:33 +00:00
|
|
|
include(CheckSubmodule)
|
2021-07-01 23:48:45 +00:00
|
|
|
include(GNUInstallDirs)
|
2019-04-09 06:28:11 +00:00
|
|
|
include(CheckCCompilerFlag)
|
|
|
|
include(FeatureSummary)
|
|
|
|
|
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-04-09 06:28:11 +00:00
|
|
|
|
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.")
|
|
|
|
|
2019-04-09 06:28:11 +00:00
|
|
|
add_compile_options(
|
|
|
|
"-Wall"
|
|
|
|
"-Werror"
|
|
|
|
"-Wfatal-errors"
|
|
|
|
"-ffast-math"
|
|
|
|
"-fdata-sections"
|
|
|
|
"-ffunction-sections"
|
|
|
|
"$<$<CONFIG:DEBUG>:-O0;-g3;-ggdb>"
|
|
|
|
)
|
2019-04-10 12:04:36 +00:00
|
|
|
set(CMAKE_C_STANDARD 11)
|
2019-04-09 06:28:11 +00:00
|
|
|
|
2021-08-13 06:09:54 +00:00
|
|
|
if(WIN32)
|
|
|
|
add_compile_options("-fdebug-prefix-map=${PROJECT_TOP}/=")
|
|
|
|
endif()
|
|
|
|
|
2020-10-08 15:17:20 +00:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${CMAKE_BINARY_DIR}/version.c
|
2021-07-21 01:00:29 +00:00
|
|
|
${CMAKE_BINARY_DIR}/include/version.h
|
2020-10-08 15:17:20 +00:00
|
|
|
${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
|
|
|
|
)
|
|
|
|
|
2019-04-09 06:28:11 +00:00
|
|
|
include_directories(
|
|
|
|
${PROJECT_SOURCE_DIR}/include
|
|
|
|
${CMAKE_BINARY_DIR}/include
|
|
|
|
)
|
|
|
|
|
|
|
|
#link_libraries(
|
|
|
|
#)
|
|
|
|
|
|
|
|
set(SOURCES
|
2020-10-08 15:17:20 +00:00
|
|
|
${CMAKE_BINARY_DIR}/version.c
|
2019-04-09 06:28:11 +00:00
|
|
|
src/app.c
|
|
|
|
)
|
|
|
|
|
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" )
|
2019-04-09 06:28:11 +00:00
|
|
|
add_subdirectory(platform)
|
|
|
|
|
2019-04-10 12:04:36 +00:00
|
|
|
if(WIN32)
|
2021-07-20 00:41:17 +00:00
|
|
|
set_source_files_properties(platform/Windows/resource.rc PROPERTIES
|
2021-07-21 01:00:29 +00:00
|
|
|
OBJECT_DEPENDS "${PROJECT_SOURCE_DIR}/platform/Windows/app.manifest;${PROJECT_TOP}/resources/icon.ico;${CMAKE_BINARY_DIR}/include/version.h"
|
2021-07-20 00:41:17 +00:00
|
|
|
)
|
2021-07-05 04:46:11 +00:00
|
|
|
add_executable(looking-glass-host WIN32
|
|
|
|
platform/Windows/resource.rc
|
|
|
|
${SOURCES}
|
|
|
|
)
|
2019-04-10 12:04:36 +00:00
|
|
|
else()
|
|
|
|
add_executable(looking-glass-host ${SOURCES})
|
|
|
|
endif()
|
2019-04-09 06:28:11 +00:00
|
|
|
target_link_libraries(looking-glass-host
|
2019-04-11 01:03:30 +00:00
|
|
|
lg_common
|
2019-04-09 06:28:11 +00:00
|
|
|
platform
|
2020-01-09 04:42:32 +00:00
|
|
|
lgmp
|
2019-04-09 06:28:11 +00:00
|
|
|
)
|
2021-01-04 13:01:45 +00:00
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
set_target_properties(looking-glass-host PROPERTIES LINK_FLAGS "-Wl,--gc-sections -Wl,--nxcompat")
|
|
|
|
else()
|
|
|
|
set_target_properties(looking-glass-host PROPERTIES LINK_FLAGS "-Wl,--gc-sections -z noexecstack")
|
|
|
|
endif()
|
|
|
|
|
2021-07-01 23:48:45 +00:00
|
|
|
install(TARGETS looking-glass-host
|
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
|
|
COMPONENT binary)
|
2019-04-09 06:28:11 +00:00
|
|
|
|
|
|
|
feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES)
|