2019-04-09 06:28:11 +00:00
|
|
|
cmake_minimum_required(VERSION 3.0)
|
|
|
|
project(looking-glass-host C)
|
|
|
|
|
2021-06-05 16:25:48 +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)
|
|
|
|
|
2019-04-09 06:28:11 +00:00
|
|
|
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")
|
|
|
|
|
2021-07-01 23:48:45 +00:00
|
|
|
include(GNUInstallDirs)
|
2019-04-09 06:28:11 +00:00
|
|
|
include(CheckCCompilerFlag)
|
|
|
|
include(FeatureSummary)
|
|
|
|
|
2021-01-27 21:07:42 +00:00
|
|
|
option(OPTIMIZE_FOR_NATIVE "Build with -march=native" OFF)
|
2019-04-09 06:28:11 +00:00
|
|
|
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()
|
2021-01-27 21:07:42 +00:00
|
|
|
else()
|
2021-07-20 00:55:20 +00:00
|
|
|
CHECK_C_COMPILER_FLAG("-march=x86-64-v2" COMPILER_SUPPORTS_MARCH_X86_64_V2)
|
|
|
|
if(COMPILER_SUPPORTS_MARCH_X86_64_V2)
|
|
|
|
add_compile_options("-march=x86-64-v2")
|
|
|
|
else()
|
|
|
|
CHECK_C_COMPILER_FLAG("-march=nehalem" COMPILER_SUPPORTS_MARCH_NEHALEM)
|
|
|
|
if(COMPILER_SUPPORTS_MARCH_NEHALEM)
|
|
|
|
add_compile_options("-march=nehalem")
|
|
|
|
endif()
|
2021-01-27 21:07:42 +00:00
|
|
|
endif()
|
2019-04-09 06:28:11 +00:00
|
|
|
endif()
|
|
|
|
|
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
|
|
|
|
2019-04-11 01:03:30 +00:00
|
|
|
get_filename_component(PROJECT_TOP "${PROJECT_SOURCE_DIR}/.." ABSOLUTE)
|
2019-04-09 06:28:11 +00:00
|
|
|
|
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
|
|
|
|
${PKGCONFIG_INCLUDE_DIRS}
|
|
|
|
${GMP_INCLUDE_DIR}
|
|
|
|
)
|
|
|
|
|
|
|
|
#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)
|