Add LTO/IPO support in CMake

This commit is contained in:
Alik Aslanyan 2021-04-01 09:09:49 +04:00
parent 69590f9777
commit 5cd3bc72d7
No known key found for this signature in database
GPG key ID: 7FE6FD5D5BC4CCF6
4 changed files with 26 additions and 5 deletions

View file

@ -1,4 +1,6 @@
cmake_minimum_required(VERSION 2.8.12)
cmake_minimum_required(VERSION 3.9)
cmake_policy(SET CMP0069 NEW)
project(xmrig)
option(WITH_HWLOC "Enable hwloc support" ON)
@ -31,6 +33,7 @@ option(WITH_DMI "Enable DMI/SMBIOS reader" ON)
option(BUILD_STATIC "Build static binary" OFF)
option(ARM_TARGET "Force use specific ARM target 8 or 7" 0)
option(HWLOC_DEBUG "Enable hwloc debug helpers and log" OFF)
option(WITH_IPO "Enable IPO / LTO optimizations" OFF)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
@ -82,7 +85,7 @@ set(HEADERS_CRYPTO
src/crypto/cn/skein_port.h
src/crypto/cn/soft_aes.h
src/crypto/common/HugePagesInfo.h
src/crypto/common/MemoryPool.h
src/crypto/common/MemoryPool.hhttps://gcc.gnu.org/onlinedocs/gccint/LTO-Overview.html
src/crypto/common/Nonce.h
src/crypto/common/portable/mm_malloc.h
src/crypto/common/VirtualMemory.h
@ -171,6 +174,19 @@ else()
endif()
endif()
if(WITH_IPO)
include(CheckIPOSupported)
check_ipo_supported(RESULT IPO_SUPPORTED OUTPUT IPO_ERROR)
if( IPO_SUPPORTED )
message(STATUS "IPO / LTO enabled")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
message(STATUS "IPO / LTO not supported: <${IPO_ERROR}>")
endif()
endif()
add_definitions(-DXMRIG_MINER_PROJECT -DXMRIG_JSON_SINGLE_LINE_ARRAY)
add_definitions(-D__STDC_FORMAT_MACROS -DUNICODE -D_FILE_OFFSET_BITS=64)

View file

@ -1,4 +1,5 @@
cmake_minimum_required(VERSION 2.8.12)
cmake_minimum_required(VERSION 3.9)
cmake_policy(SET CMP0069 NEW)
project(argon2 C)
set(CMAKE_C_STANDARD 99)

View file

@ -1,4 +1,6 @@
cmake_minimum_required (VERSION 2.8.12)
cmake_minimum_required(VERSION 3.9)
cmake_policy(SET CMP0069 NEW)
project (hwloc C)
include_directories(include)

View file

@ -1,4 +1,6 @@
cmake_minimum_required (VERSION 2.8.12)
cmake_minimum_required(VERSION 3.9)
cmake_policy(SET CMP0069 NEW)
project (ethash C)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Os")