2020-11-11 01:42:54 +01:00
cmake_minimum_required ( VERSION 3.12 )
2018-05-09 02:01:27 +02:00
project ( monero-gui )
2019-09-29 17:29:22 +02:00
message ( STATUS "Initiating compile using CMake ${CMAKE_VERSION}" )
2022-07-15 22:21:47 +02:00
set ( VERSION_MAJOR "18" )
2023-02-18 21:49:51 +01:00
set ( VERSION_MINOR "2" )
2023-03-27 15:53:17 +02:00
set ( VERSION_REVISION "2" )
2020-07-09 08:13:08 +02:00
set ( VERSION "0.${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION}" )
2019-09-29 17:29:22 +02:00
2020-05-15 04:24:14 +02:00
option ( STATIC "Link libraries statically, requires static Qt" )
2018-05-09 02:01:27 +02:00
2020-06-17 13:37:36 +02:00
option ( USE_DEVICE_TREZOR "Trezor support compilation" ON )
2018-05-09 02:01:27 +02:00
option ( WITH_SCANNER "Enable webcam QR scanner" OFF )
2021-12-17 16:43:00 +01:00
option ( WITH_DESKTOP_ENTRY "Ask to install desktop entry on first startup" ON )
2022-05-01 06:09:29 +02:00
option ( WITH_UPDATER "Regularly check for new updates" ON )
2018-05-09 02:01:27 +02:00
option ( DEV_MODE "Checkout latest monero master on build" OFF )
2019-09-29 17:29:22 +02:00
list ( INSERT CMAKE_MODULE_PATH 0 "${CMAKE_SOURCE_DIR}/cmake" )
2020-05-27 02:12:40 +02:00
include ( CheckCCompilerFlag )
include ( CheckCXXCompilerFlag )
include ( CheckLinkerFlag )
2018-05-09 02:01:27 +02:00
set ( BUILD_GUI_DEPS ON )
2020-09-22 16:36:12 +02:00
set ( BUILD_64 ON CACHE BOOL "Build 64-bit binaries" )
2018-05-09 02:01:27 +02:00
2020-09-20 03:51:40 +02:00
if ( NOT MANUAL_SUBMODULES )
find_package ( Git )
if ( GIT_FOUND )
if ( NOT DEV_MODE )
function ( check_submodule relative_path )
execute_process ( COMMAND git rev-parse "HEAD" WORKING_DIRECTORY ${ CMAKE_CURRENT_SOURCE_DIR } / ${ relative_path } OUTPUT_VARIABLE localHead )
execute_process ( COMMAND git rev-parse "HEAD:${relative_path}" WORKING_DIRECTORY ${ CMAKE_CURRENT_SOURCE_DIR } OUTPUT_VARIABLE checkedHead )
string ( COMPARE EQUAL "${localHead}" "${checkedHead}" upToDate )
if ( upToDate )
message ( STATUS "Submodule '${relative_path}' is up-to-date" )
else ( )
message ( FATAL_ERROR "Submodule '${relative_path}' is not using the checked head. Please update all submodules with\ngit submodule update --init --force --recursive\nor run cmake with -DMANUAL_SUBMODULES=1,\n or if you want to build from latest master run cmake with -DDEV_MODE=ON,\n or run make devmode" )
endif ( )
endfunction ( )
message ( STATUS "Checking submodules" )
check_submodule ( monero )
else ( )
execute_process ( COMMAND ${ GIT_EXECUTABLE } fetch WORKING_DIRECTORY ${ CMAKE_CURRENT_SOURCE_DIR } /monero RESULT_VARIABLE GIT_FETCH_RESULT )
execute_process ( COMMAND ${ GIT_EXECUTABLE } checkout -f origin/master WORKING_DIRECTORY ${ CMAKE_CURRENT_SOURCE_DIR } /monero RESULT_VARIABLE GIT_CHECKOUT_MASTER_RESULT )
2021-03-12 01:19:59 +01:00
execute_process ( COMMAND ${ GIT_EXECUTABLE } submodule sync --recursive WORKING_DIRECTORY ${ CMAKE_CURRENT_SOURCE_DIR } /monero RESULT_VARIABLE GIT_SUBMODULE_SYNC_RESULT )
2020-09-20 03:51:40 +02:00
execute_process ( COMMAND ${ GIT_EXECUTABLE } submodule update --init --force --recursive WORKING_DIRECTORY ${ CMAKE_CURRENT_SOURCE_DIR } /monero RESULT_VARIABLE GIT_SUBMODULE_UPDATE_RESULT )
2021-03-12 01:19:59 +01:00
if ( NOT GIT_FETCH_RESULT EQUAL "0" OR NOT GIT_CHECKOUT_MASTER_RESULT EQUAL "0" OR NOT GIT_SUBMODULE_SYNC_RESULT EQUAL "0" OR NOT GIT_SUBMODULE_UPDATE_RESULT EQUAL "0" )
2020-09-20 03:51:40 +02:00
message ( FATAL_ERROR "Updating git submodule to master (-DDEV_MODE=ON) failed" )
2018-05-09 02:01:27 +02:00
endif ( )
2020-08-26 02:52:36 +02:00
endif ( )
2018-05-09 02:01:27 +02:00
endif ( )
endif ( )
add_subdirectory ( monero )
2021-05-08 23:29:57 +02:00
add_subdirectory ( external )
2020-08-29 04:27:31 +02:00
set ( CMAKE_AUTOMOC ON )
set ( CMAKE_AUTORCC ON )
set ( CMAKE_AUTOUIC ON )
2019-10-05 15:11:18 +02:00
get_directory_property ( ARCH_WIDTH DIRECTORY "monero" DEFINITION ARCH_WIDTH )
2019-09-29 17:29:22 +02:00
2019-12-19 15:43:31 +01:00
if ( NOT CMAKE_BUILD_TYPE STREQUAL "Debug" )
add_definitions ( -DQT_NO_DEBUG )
endif ( )
2019-09-29 17:29:22 +02:00
if ( STATIC )
2019-12-24 12:19:00 +01:00
message ( STATUS "Initiating static build" )
2020-11-11 01:42:54 +01:00
set ( CMAKE_FIND_LIBRARY_SUFFIXES ".a" ${ CMAKE_FIND_LIBRARY_SUFFIXES } )
2019-11-28 13:05:07 +01:00
add_definitions ( -DMONERO_GUI_STATIC )
2019-09-29 17:29:22 +02:00
endif ( )
include ( CMakePackageConfigHelpers )
2018-05-09 02:01:27 +02:00
include_directories ( ${ EASYLOGGING_INCLUDE } )
link_directories ( ${ EASYLOGGING_LIBRARY_DIRS } )
include ( VersionGui )
2019-09-29 17:29:22 +02:00
2018-05-09 02:01:27 +02:00
message ( STATUS "${CMAKE_MODULE_PATH}" )
2019-09-29 17:29:22 +02:00
2018-05-09 02:01:27 +02:00
if ( WITH_SCANNER )
add_definitions ( -DWITH_SCANNER )
endif ( )
2019-09-29 17:29:22 +02:00
2021-12-17 16:43:00 +01:00
if ( WITH_DESKTOP_ENTRY )
add_definitions ( -DWITH_DESKTOP_ENTRY )
endif ( )
2022-05-01 06:09:29 +02:00
if ( WITH_UPDATER )
add_definitions ( -DWITH_UPDATER )
endif ( )
2019-09-29 17:29:22 +02:00
# Sodium
2018-05-09 02:01:27 +02:00
find_library ( SODIUM_LIBRARY sodium )
message ( STATUS "libsodium: libraries at ${SODIUM_LIBRARY}" )
2019-09-29 17:29:22 +02:00
2020-10-21 18:19:26 +02:00
if ( UNIX AND NOT APPLE AND NOT ANDROID )
2020-10-11 21:51:05 +02:00
set ( CMAKE_SKIP_RPATH ON )
2020-11-11 01:42:54 +01:00
set ( CMAKE_FIND_LIBRARY_SUFFIXES_PREV ${ CMAKE_FIND_LIBRARY_SUFFIXES } )
set ( CMAKE_FIND_LIBRARY_SUFFIXES ".so" )
2018-05-09 02:01:27 +02:00
find_package ( X11 REQUIRED )
2020-11-11 01:42:54 +01:00
set ( CMAKE_FIND_LIBRARY_SUFFIXES ${ CMAKE_FIND_LIBRARY_SUFFIXES_PREV } )
2018-05-09 02:01:27 +02:00
message ( STATUS "X11_FOUND = ${X11_FOUND}" )
message ( STATUS "X11_INCLUDE_DIR = ${X11_INCLUDE_DIR}" )
message ( STATUS "X11_LIBRARIES = ${X11_LIBRARIES}" )
include_directories ( ${ X11_INCLUDE_DIR } )
link_directories ( ${ X11_LIBRARIES } )
if ( STATIC )
find_library ( XCB_LIBRARY xcb )
message ( STATUS "Found xcb library: ${XCB_LIBRARY}" )
endif ( )
endif ( )
2019-10-07 14:07:09 +02:00
set ( QT5_LIBRARIES
Q t 5 C o r e
Q t 5 Q u i c k
Q t 5 G u i
Q t 5 Q m l
Q t 5 S v g
2020-06-21 02:08:37 +02:00
Q t 5 X m l
2019-10-07 14:07:09 +02:00
)
2020-05-27 02:12:40 +02:00
if ( WITH_SCANNER )
list ( APPEND QT5_LIBRARIES Qt5Multimedia )
endif ( )
2020-07-08 01:04:47 +02:00
if ( APPLE )
list ( APPEND QT5_LIBRARIES Qt5MacExtras )
2020-10-28 01:54:32 +01:00
endif ( )
2020-07-08 01:04:47 +02:00
2020-10-28 01:54:32 +01:00
if ( UNIX )
2020-08-28 13:33:34 +02:00
if ( NOT CMAKE_PREFIX_PATH AND DEFINED ENV{CMAKE_PREFIX_PATH} )
message ( STATUS "Using CMAKE_PREFIX_PATH environment variable: '$ENV{CMAKE_PREFIX_PATH}'" )
set ( CMAKE_PREFIX_PATH $ENV{ CMAKE_PREFIX_PATH } )
endif ( )
2020-10-28 01:54:32 +01:00
if ( APPLE AND NOT CMAKE_PREFIX_PATH )
2020-07-08 01:04:47 +02:00
execute_process ( COMMAND brew --prefix qt5 OUTPUT_VARIABLE QT5_DIR OUTPUT_STRIP_TRAILING_WHITESPACE )
list ( APPEND CMAKE_PREFIX_PATH ${ QT5_DIR } )
endif ( )
endif ( )
2020-07-15 01:36:30 +02:00
find_package ( PkgConfig REQUIRED )
2020-05-15 04:25:51 +02:00
# TODO: drop this once we switch to Qt 5.14+
2020-07-15 01:36:30 +02:00
pkg_check_modules ( Qt5QmlModels_PKG_CONFIG QUIET Qt5QmlModels )
if ( Qt5QmlModels_PKG_CONFIG_FOUND )
2020-05-15 04:25:51 +02:00
list ( APPEND QT5_LIBRARIES Qt5QmlModels )
endif ( )
2020-06-21 02:08:37 +02:00
# TODO: drop this once we switch to Qt 5.12+
find_package ( Qt5XmlPatterns QUIET )
if ( Qt5XmlPatterns_FOUND )
list ( APPEND QT5_LIBRARIES Qt5XmlPatterns )
endif ( )
2019-10-07 14:07:09 +02:00
foreach ( QT5_MODULE ${ QT5_LIBRARIES } )
find_package ( ${ QT5_MODULE } REQUIRED )
2020-07-15 01:36:30 +02:00
include_directories ( ${ ${QT5_MODULE } _INCLUDE_DIRS} )
2019-10-07 14:07:09 +02:00
endforeach ( )
2020-10-21 18:19:26 +02:00
if ( NOT ( CMAKE_CROSSCOMPILING AND ANDROID ) )
pkg_check_modules ( QT5_PKG_CONFIG REQUIRED ${ QT5_LIBRARIES } )
else ( )
set ( QT5_LIBRARIES_ABI )
foreach ( QT5_MODULE ${ QT5_LIBRARIES } )
list ( APPEND QT5_LIBRARIES_ABI "${QT5_MODULE}_${CMAKE_ANDROID_ARCH_ABI}" )
endforeach ( )
pkg_check_modules ( QT5_PKG_CONFIG REQUIRED ${ QT5_LIBRARIES_ABI } )
endif ( )
2019-10-07 14:07:09 +02:00
2020-11-10 01:05:15 +01:00
get_target_property ( QMAKE_IMPORTED_LOCATION Qt5::qmake IMPORTED_LOCATION )
get_filename_component ( QT_INSTALL_PREFIX "${QMAKE_IMPORTED_LOCATION}/../.." ABSOLUTE )
if ( APPLE AND NOT STATIC )
set ( CMAKE_BUILD_RPATH "${QT_INSTALL_PREFIX}/lib" )
endif ( )
2020-06-21 02:08:37 +02:00
if ( QT5_PKG_CONFIG_FOUND )
set ( QT5_PKG_CONFIG "QT5_PKG_CONFIG" )
if ( STATIC )
set ( QT5_PKG_CONFIG "${QT5_PKG_CONFIG}_STATIC" )
2019-10-07 14:07:09 +02:00
endif ( )
2020-06-21 02:08:37 +02:00
2020-10-27 12:49:38 +01:00
if ( UNIX AND CMAKE_PREFIX_PATH )
2020-11-01 23:26:41 +01:00
if ( APPLE )
list ( JOIN ${ QT5_PKG_CONFIG } _LDFLAGS_OTHER " " ${ QT5_PKG_CONFIG } _LDFLAGS_OTHER )
endif ( )
2020-08-28 13:33:34 +02:00
# temporal workaround for https://bugreports.qt.io/browse/QTBUG-80922
2020-11-10 01:05:15 +01:00
STRING ( REPLACE "${QT5_PKG_CONFIG_Qt5Core_PREFIX}" "${QT_INSTALL_PREFIX}" ${ QT5_PKG_CONFIG } _LDFLAGS_OTHER "${${QT5_PKG_CONFIG}_LDFLAGS_OTHER}" )
STRING ( REPLACE "${QT5_PKG_CONFIG_Qt5Core_PREFIX}" "${QT_INSTALL_PREFIX}" ${ QT5_PKG_CONFIG } _LIBRARIES "${${QT5_PKG_CONFIG}_LIBRARIES}" )
STRING ( REPLACE "${QT5_PKG_CONFIG_Qt5Core_PREFIX}" "${QT_INSTALL_PREFIX}" ${ QT5_PKG_CONFIG } _INCLUDE_DIRS "${${QT5_PKG_CONFIG}_INCLUDE_DIRS}" )
STRING ( REPLACE "${QT5_PKG_CONFIG_Qt5Core_PREFIX}" "${QT_INSTALL_PREFIX}" ${ QT5_PKG_CONFIG } _LIBRARY_DIRS "${${QT5_PKG_CONFIG}_LIBRARY_DIRS}" )
2020-07-08 01:04:47 +02:00
endif ( )
2020-06-21 02:08:37 +02:00
set ( QT5_LIBRARIES ${ ${QT5_PKG_CONFIG } _LIBRARIES} ${ ${QT5_PKG_CONFIG } _LDFLAGS_OTHER} )
include_directories ( ${ ${QT5_PKG_CONFIG } _INCLUDE_DIRS} )
link_directories ( ${ ${QT5_PKG_CONFIG } _LIBRARY_DIRS} )
2019-10-07 14:07:09 +02:00
endif ( )
list ( APPEND QT5_LIBRARIES
$ { Q t 5 G u i _ P L U G I N S }
$ { Q t 5 S v g _ P L U G I N S }
$ { Q t 5 Q m l _ P L U G I N S }
$ { Q t 5 N e t w o r k _ P L U G I N S }
)
if ( STATIC )
2020-06-21 02:08:37 +02:00
set ( QT5_EXTRA_PATHS ${ QT5_PKG_CONFIG_Qt5Qml_PREFIX } /qml/Qt/labs/folderlistmodel )
list ( APPEND QT5_EXTRA_PATHS ${ QT5_PKG_CONFIG_Qt5Qml_PREFIX } /qml/Qt/labs/settings )
2019-07-01 10:42:23 +02:00
list ( APPEND QT5_EXTRA_PATHS ${ QT5_PKG_CONFIG_Qt5Qml_PREFIX } /qml/Qt/labs/platform )
2020-06-21 02:08:37 +02:00
list ( APPEND QT5_EXTRA_PATHS ${ QT5_PKG_CONFIG_Qt5Qml_PREFIX } /qml/QtGraphicalEffects )
list ( APPEND QT5_EXTRA_PATHS ${ QT5_PKG_CONFIG_Qt5Qml_PREFIX } /qml/QtGraphicalEffects/private )
list ( APPEND QT5_EXTRA_PATHS ${ QT5_PKG_CONFIG_Qt5Qml_PREFIX } /qml/QtMultimedia )
2020-11-11 01:42:54 +01:00
list ( APPEND QT5_EXTRA_PATHS ${ QT5_PKG_CONFIG_Qt5Qml_PREFIX } /qml/QtQml )
2021-04-06 20:03:05 +02:00
list ( APPEND QT5_EXTRA_PATHS ${ QT5_PKG_CONFIG_Qt5Qml_PREFIX } /qml/QtQml/Models.2 )
2020-06-21 02:08:37 +02:00
list ( APPEND QT5_EXTRA_PATHS ${ QT5_PKG_CONFIG_Qt5Qml_PREFIX } /qml/QtQuick.2 )
list ( APPEND QT5_EXTRA_PATHS ${ QT5_PKG_CONFIG_Qt5Qml_PREFIX } /qml/QtQuick/Controls )
list ( APPEND QT5_EXTRA_PATHS ${ QT5_PKG_CONFIG_Qt5Qml_PREFIX } /qml/QtQuick/Controls.2 )
list ( APPEND QT5_EXTRA_PATHS ${ QT5_PKG_CONFIG_Qt5Qml_PREFIX } /qml/QtQuick/Dialogs )
list ( APPEND QT5_EXTRA_PATHS ${ QT5_PKG_CONFIG_Qt5Qml_PREFIX } /qml/QtQuick/Dialogs/Private )
list ( APPEND QT5_EXTRA_PATHS ${ QT5_PKG_CONFIG_Qt5Qml_PREFIX } /qml/QtQuick/Layouts )
list ( APPEND QT5_EXTRA_PATHS ${ QT5_PKG_CONFIG_Qt5Qml_PREFIX } /qml/QtQuick/PrivateWidgets )
list ( APPEND QT5_EXTRA_PATHS ${ QT5_PKG_CONFIG_Qt5Qml_PREFIX } /qml/QtQuick/Templates.2 )
list ( APPEND QT5_EXTRA_PATHS ${ QT5_PKG_CONFIG_Qt5Qml_PREFIX } /qml/QtQuick/Window.2 )
list ( APPEND QT5_EXTRA_PATHS ${ QT5_PKG_CONFIG_Qt5Qml_PREFIX } /qml/QtQuick/XmlListModel )
set ( QT5_EXTRA_LIBRARIES_LIST
q t q u i c k t e m p l a t e s 2 p l u g i n
Q t 5 Q u i c k T e m p l a t e s 2
q t q u i c k c o n t r o l s 2 p l u g i n
Q t 5 Q u i c k C o n t r o l s 2
2019-10-07 14:07:09 +02:00
d i a l o g p l u g i n
d i a l o g s p r i v a t e p l u g i n
q m l f o l d e r l i s t m o d e l p l u g i n
q m l s e t t i n g s p l u g i n
2019-07-01 10:42:23 +02:00
q t l a b s p l a t f o r m p l u g i n
2019-10-07 14:07:09 +02:00
q m l x m l l i s t m o d e l p l u g i n
q q u i c k l a y o u t s p l u g i n
2021-04-06 20:03:05 +02:00
m o d e l s p l u g i n
2020-06-21 02:08:37 +02:00
)
if ( WITH_SCANNER )
list ( APPEND QT5_EXTRA_LIBRARIES_LIST
d e c l a r a t i v e _ m u l t i m e d i a
2021-05-08 13:00:45 +02:00
Q t 5 M u l t i m e d i a Q u i c k
2020-06-21 02:08:37 +02:00
)
endif ( )
list ( APPEND QT5_EXTRA_LIBRARIES_LIST
2019-10-07 14:07:09 +02:00
q t g r a p h i c a l e f f e c t s p l u g i n
q t g r a p h i c a l e f f e c t s p r i v a t e
q t q u i c k 2 p l u g i n
q t q u i c k c o n t r o l s p l u g i n
w i d g e t s p l u g i n
w i n d o w p l u g i n
)
2020-11-11 01:42:54 +01:00
if ( NOT ${ Qt5Core_VERSION } VERSION_LESS 5.14 )
list ( APPEND QT5_EXTRA_LIBRARIES_LIST qmlplugin )
endif ( )
2020-06-21 02:08:37 +02:00
set ( QT5_EXTRA_LIBRARIES )
foreach ( LIBRARY ${ QT5_EXTRA_LIBRARIES_LIST } )
2020-07-16 01:26:14 +02:00
find_library ( ${ LIBRARY } _LIBRARY ${ LIBRARY } PATHS ${ QT5_EXTRA_PATHS } REQUIRED )
2020-06-21 02:08:37 +02:00
list ( APPEND QT5_EXTRA_LIBRARIES ${ ${LIBRARY } _LIBRARY} )
endforeach ( )
2019-10-07 14:07:09 +02:00
if ( MINGW )
if ( CMAKE_BUILD_TYPE STREQUAL "Debug" )
2020-06-21 02:08:37 +02:00
list ( APPEND QT5_EXTRA_LIBRARIES D3D11 Dwrite D2d1 )
2019-10-07 14:07:09 +02:00
endif ( )
endif ( )
2020-06-21 02:08:37 +02:00
set ( QT5_LIBRARIES
$ { Q T 5 _ E X T R A _ L I B R A R I E S }
$ { Q T 5 _ L I B R A R I E S }
)
2020-07-16 01:26:14 +02:00
set ( QT5_INTEGRATION_LIBRARIES_LIST
Q t 5 E v e n t D i s p a t c h e r S u p p o r t
Q t 5 P a c k e t P r o t o c o l
Q t 5 T h e m e S u p p o r t
Q t 5 F o n t D a t a b a s e S u p p o r t
)
2020-06-21 02:08:37 +02:00
2020-07-16 01:26:14 +02:00
if ( UNIX AND NOT APPLE )
list ( APPEND QT5_INTEGRATION_LIBRARIES_LIST
Q t 5 X c b Q p a
Q t 5 S e r v i c e S u p p o r t
Q t 5 G l x S u p p o r t
2020-06-21 02:08:37 +02:00
)
2020-09-13 00:06:45 +02:00
elseif ( MINGW )
list ( APPEND QT5_INTEGRATION_LIBRARIES_LIST qtfreetype )
2020-06-21 02:08:37 +02:00
endif ( )
2020-07-16 01:26:14 +02:00
foreach ( LIBRARY ${ QT5_INTEGRATION_LIBRARIES_LIST } )
find_library ( ${ LIBRARY } _LIBRARY ${ LIBRARY } PATHS ${ QT5_EXTRA_PATHS } REQUIRED )
list ( APPEND QT5_LIBRARIES ${ ${LIBRARY } _LIBRARY} )
endforeach ( )
if ( UNIX AND NOT APPLE )
2020-11-11 01:42:54 +01:00
pkg_check_modules ( X11XCB_XCBGLX REQUIRED x11-xcb xcb-glx )
list ( APPEND QT5_LIBRARIES ${ X11XCB_XCBGLX_LIBRARIES } )
pkg_check_modules ( FONTCONFIG REQUIRED fontconfig )
list ( APPEND QT5_LIBRARIES ${ FONTCONFIG_STATIC_LIBRARIES } )
2020-07-16 01:26:14 +02:00
endif ( )
2019-10-07 14:07:09 +02:00
endif ( )
2020-10-21 18:19:26 +02:00
if ( ANDROID )
set ( QT5_EXTRA_LIBRARIES_LIST
G L E S v 2
l o g
z
j n i g r a p h i c s
a n d r o i d
E G L
Q t 5 V i r t u a l K e y b o a r d _ $ { C M A K E _ A N D R O I D _ A R C H _ A B I }
c + + _ s h a r e d
)
foreach ( LIBRARY ${ QT5_EXTRA_LIBRARIES_LIST } )
find_library ( ${ LIBRARY } _LIBRARY ${ LIBRARY } PATHS "${ANDROID_TOOLCHAIN_ROOT}/sysroot/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/${ANDROID_PLATFORM_LEVEL}" REQUIRED )
list ( APPEND QT5_LIBRARIES ${ ${LIBRARY } _LIBRARY} )
endforeach ( )
endif ( )
2019-10-02 17:11:59 +02:00
if ( MINGW )
set ( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wa,-mbig-obj" )
2020-11-09 09:34:41 +01:00
set ( EXTRA_LIBRARIES mswsock;ws2_32;iphlpapi;crypt32;bcrypt )
2019-10-02 17:11:59 +02:00
if ( DEPENDS )
set ( ICU_LIBRARIES icuio icui18n icuuc icudata icutu iconv )
else ( )
set ( ICU_LIBRARIES icuio icuin icuuc icudt icutu iconv )
endif ( )
2020-07-08 01:04:47 +02:00
elseif ( APPLE )
set ( EXTRA_LIBRARIES "-framework AppKit" )
elseif ( OPENBSD OR ANDROID )
2019-10-02 17:11:59 +02:00
set ( EXTRA_LIBRARIES "" )
elseif ( FREEBSD )
set ( EXTRA_LIBRARIES execinfo )
elseif ( DRAGONFLY )
find_library ( COMPAT compat )
set ( EXTRA_LIBRARIES execinfo ${ COMPAT } )
elseif ( CMAKE_SYSTEM_NAME MATCHES "(SunOS|Solaris)" )
set ( EXTRA_LIBRARIES socket nsl resolv )
elseif ( NOT MSVC AND NOT DEPENDS )
find_library ( RT rt )
set ( EXTRA_LIBRARIES ${ RT } )
endif ( )
list ( APPEND EXTRA_LIBRARIES ${ CMAKE_DL_LIBS } )
2019-10-02 22:33:48 +02:00
if ( APPLE )
2021-10-28 14:25:17 +02:00
cmake_policy ( SET CMP0042 NEW )
2019-10-02 22:33:48 +02:00
endif ( )
if ( APPLE AND NOT IOS )
2021-09-13 02:33:34 +02:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=default -std=c++11" )
2019-10-02 22:33:48 +02:00
endif ( )
if ( APPLE )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=default -DGTEST_HAS_TR1_TUPLE=0" )
endif ( )
2019-11-29 11:09:00 +01:00
# warnings
add_c_flag_if_supported ( -Wformat C_SECURITY_FLAGS )
add_cxx_flag_if_supported ( -Wformat CXX_SECURITY_FLAGS )
add_c_flag_if_supported ( -Wformat-security C_SECURITY_FLAGS )
add_cxx_flag_if_supported ( -Wformat-security CXX_SECURITY_FLAGS )
# -fstack-protector
if ( NOT OPENBSD AND NOT ( WIN32 AND ( CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 9.1 ) ) )
add_c_flag_if_supported ( -fstack-protector C_SECURITY_FLAGS )
add_cxx_flag_if_supported ( -fstack-protector CXX_SECURITY_FLAGS )
add_c_flag_if_supported ( -fstack-protector-strong C_SECURITY_FLAGS )
add_cxx_flag_if_supported ( -fstack-protector-strong CXX_SECURITY_FLAGS )
endif ( )
# New in GCC 8.2
if ( NOT OPENBSD AND NOT ( WIN32 AND ( CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 9.1 ) ) )
add_c_flag_if_supported ( -fcf-protection=full C_SECURITY_FLAGS )
add_cxx_flag_if_supported ( -fcf-protection=full CXX_SECURITY_FLAGS )
endif ( )
2021-05-05 21:39:15 +02:00
if ( NOT WIN32 AND NOT OPENBSD AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
2019-11-29 11:09:00 +01:00
add_c_flag_if_supported ( -fstack-clash-protection C_SECURITY_FLAGS )
add_cxx_flag_if_supported ( -fstack-clash-protection CXX_SECURITY_FLAGS )
endif ( )
# Removed in GCC 9.1 (or before ?), but still accepted, so spams the output
if ( NOT ( CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 9.1 ) )
add_c_flag_if_supported ( -mmitigate-rop C_SECURITY_FLAGS )
add_cxx_flag_if_supported ( -mmitigate-rop CXX_SECURITY_FLAGS )
endif ( )
# linker
2020-08-28 19:54:17 +02:00
if ( APPLE )
add_linker_flag_if_supported ( -Wl,-bind_at_load LD_SECURITY_FLAGS )
add_linker_flag_if_supported ( -Wl,-dead_strip LD_SECURITY_FLAGS )
add_linker_flag_if_supported ( -Wl,-dead_strip_dylibs LD_SECURITY_FLAGS )
endif ( )
2020-07-08 01:04:47 +02:00
if ( NOT APPLE AND NOT ( WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "GNU" ) )
2020-05-14 20:48:08 +02:00
# Windows binaries die on startup with PIE when compiled with GCC
2019-11-29 11:09:00 +01:00
add_linker_flag_if_supported ( -pie LD_SECURITY_FLAGS )
endif ( )
add_linker_flag_if_supported ( -Wl,-z,relro LD_SECURITY_FLAGS )
add_linker_flag_if_supported ( -Wl,-z,now LD_SECURITY_FLAGS )
add_linker_flag_if_supported ( -Wl,-z,noexecstack noexecstack_SUPPORTED )
if ( noexecstack_SUPPORTED )
set ( LD_SECURITY_FLAGS "${LD_SECURITY_FLAGS} -Wl,-z,noexecstack" )
endif ( )
add_linker_flag_if_supported ( -Wl,-z,noexecheap noexecheap_SUPPORTED )
if ( noexecheap_SUPPORTED )
set ( LD_SECURITY_FLAGS "${LD_SECURITY_FLAGS} -Wl,-z,noexecheap" )
endif ( )
2020-04-08 04:31:16 +02:00
# some windows linker bits
if ( WIN32 )
add_linker_flag_if_supported ( -Wl,--dynamicbase LD_SECURITY_FLAGS )
add_linker_flag_if_supported ( -Wl,--nxcompat LD_SECURITY_FLAGS )
add_linker_flag_if_supported ( -Wl,--high-entropy-va LD_SECURITY_FLAGS )
endif ( )
2020-03-06 12:54:16 +01:00
if ( STATIC )
2020-05-27 02:12:40 +02:00
add_linker_flag_if_supported ( -static-libgcc STATIC_FLAGS )
add_linker_flag_if_supported ( -static-libstdc++ STATIC_FLAGS )
2020-03-06 12:54:16 +01:00
if ( MINGW )
add_linker_flag_if_supported ( -static STATIC_FLAGS )
endif ( )
endif ( )
2020-04-08 04:31:16 +02:00
# With GCC 6.1.1 the compiled binary malfunctions due to aliasing. Until that
# is fixed in the code (Issue #847), force compiler to be conservative.
add_c_flag_if_supported ( -fno-strict-aliasing C_SECURITY_FLAGS )
add_cxx_flag_if_supported ( -fno-strict-aliasing CXX_SECURITY_FLAGS )
2020-05-27 02:12:40 +02:00
add_c_flag_if_supported ( -fPIC C_SECURITY_FLAGS )
add_cxx_flag_if_supported ( -fPIC CXX_SECURITY_FLAGS )
2019-11-29 11:09:00 +01:00
message ( STATUS "Using C security hardening flags: ${C_SECURITY_FLAGS}" )
message ( STATUS "Using C++ security hardening flags: ${CXX_SECURITY_FLAGS}" )
message ( STATUS "Using linker security hardening flags: ${LD_SECURITY_FLAGS}" )
2020-04-08 04:31:16 +02:00
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 ${C_SECURITY_FLAGS}" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ${CXX_SECURITY_FLAGS}" )
2020-03-06 12:54:16 +01:00
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LD_SECURITY_FLAGS} ${STATIC_FLAGS}" )
2019-10-02 22:33:48 +02:00
2020-06-30 19:07:35 +02:00
add_subdirectory ( translations )
2018-05-09 02:01:27 +02:00
add_subdirectory ( src )