summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/cmake/toolchains/gcc.cmake
blob: 7ea3945244078559d73caaf7b36b37bcf6805d6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
cmake_minimum_required(VERSION 3.10.0)

if(NOT "${COMPILE_DEFINITIONS}" STREQUAL "")
    ### Additional check to overcome check_[symbol|include|function]_exits using toolchain file without passing WT_ARCH and WT_OS.
    string(REGEX MATCH "-DWT_ARCH=([A-Za-z0-9]+) -DWT_OS=([A-Za-z0-9]+)" _ ${COMPILE_DEFINITIONS})
    set(wt_config_arch ${CMAKE_MATCH_1})
    set(wt_config_os ${CMAKE_MATCH_2})
else()
    set(wt_config_arch ${WT_ARCH})
    set(wt_config_os ${WT_OS})
endif()

# Include any platform specific gcc configurations and flags e.g. target-tuple, flags.
if((NOT "${wt_config_arch}" STREQUAL "") AND (NOT "${wt_config_os}" STREQUAL ""))
    if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/${wt_config_arch}/${wt_config_os}/plat_gcc.cmake")
        message(FATAL_ERROR "(${wt_config_arch}/${wt_config_os}) directory does not have a plat_gcc.cmake file")
    endif()
    include("${CMAKE_CURRENT_LIST_DIR}/${wt_config_arch}/${wt_config_os}/plat_gcc.cmake")
endif()

set(C_COMPILER_VERSION_SUFFIX)
set(CXX_COMPILER_VERSION_SUFFIX)
if(GNU_C_VERSION)
    set(C_COMPILER_VERSION_SUFFIX "-${GNU_C_VERSION}")
endif()
if(GNU_CXX_VERSION)
    set(CXX_COMPILER_VERSION_SUFFIX "-${GNU_CXX_VERSION}")
endif()

set(CMAKE_C_COMPILER "${CROSS_COMPILER_PREFIX}gcc${C_COMPILER_VERSION_SUFFIX}")
set(CMAKE_CXX_COMPILER "${CROSS_COMPILER_PREFIX}g++${CXX_COMPILER_VERSION_SUFFIX}")
set(CMAKE_ASM_COMPILER "${CROSS_COMPILER_PREFIX}gcc${C_COMPILER_VERSION_SUFFIX}")