myx-cmake/MyxCMake/modules/MyxCMakeCompiler.cmake

59 lines
2.2 KiB
CMake
Raw Normal View History

2022-05-06 09:49:46 +00:00
include_guard(GLOBAL)
2021-12-08 11:32:04 +00:00
# C compiler name
if(CMAKE_C_COMPILER_ID STREQUAL "Intel")
set(CMAKE_C_COMPILER_IS_INTEL ON)
2022-01-25 10:21:05 +00:00
elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang" OR
CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
2021-12-08 11:32:04 +00:00
set(CMAKE_C_COMPILER_IS_CLANG ON)
elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU")
set(CMAKE_C_COMPILER_IS_GCC ON)
elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
set(CMAKE_C_COMPILER_IS_MSVC ON)
endif()
# C++ compiler name
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
set(CMAKE_CXX_COMPILER_IS_INTEL ON)
2022-01-25 10:21:05 +00:00
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
2021-12-08 11:32:04 +00:00
set(CMAKE_CXX_COMPILER_IS_CLANG ON)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_COMPILER_IS_GCC ON)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(CMAKE_CXX_COMPILER_IS_MSVC ON)
endif()
# Предпочтительные пути к утилитам для компоновки
if(CMAKE_CXX_COMPILER_IS_GCC)
2022-05-06 09:49:46 +00:00
# cmake-format: off
2021-12-08 11:32:04 +00:00
# Astra Linux Smolensk 1.5
2022-05-06 09:49:46 +00:00
if(MYX_CMAKE_LSB_DISTRIBUTOR_ID STREQUAL "AstraLinuxSE" AND
MYX_CMAKE_LSB_CODENAME STREQUAL "smolensk" AND
MYX_CMAKE_LSB_RELEASE_VERSION STREQUAL "1.5")
2021-12-08 11:32:04 +00:00
find_program(CMAKE_GCC_AR NAMES "/usr/bin/x86_64-linux-gnu-gcc-ar-4.7")
find_program(CMAKE_GCC_NM NAMES "/usr/bin/x86_64-linux-gnu-gcc-nm-4.7")
2022-01-25 10:21:05 +00:00
find_program(CMAKE_GCC_RANLIB NAMES "/usr/bin/x86_64-linux-gnu-gcc-ranlib-4.7")
2021-12-08 11:32:04 +00:00
# Elbrus E2K
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "e2k")
2022-05-06 09:49:46 +00:00
find_program(CMAKE_GCC_AR NAMES "/usr/${CMAKE_SYSTEM_PROCESSOR}-linux/bin/ar")
find_program(CMAKE_GCC_NM NAMES "/usr/${CMAKE_SYSTEM_PROCESSOR}-linux/bin/nm")
find_program(CMAKE_GCC_RANLIB NAMES "/usr/${CMAKE_SYSTEM_PROCESSOR}-linux/bin/ranlib")
2021-12-08 11:32:04 +00:00
else()
find_program(CMAKE_GCC_AR NAMES "gcc-ar" "ar")
find_program(CMAKE_GCC_NM NAMES "gcc-nm" "nm")
find_program(CMAKE_GCC_RANLIB NAMES "gcc-ranlib" "ranlib")
endif()
2022-05-06 09:49:46 +00:00
# cmake-format: on
2021-12-08 11:32:04 +00:00
if(CMAKE_GCC_AR)
2022-01-25 10:21:05 +00:00
set(CMAKE_AR ${CMAKE_GCC_AR} CACHE STRING "" FORCE)
2021-12-08 11:32:04 +00:00
endif()
if(CMAKE_GCC_NM)
2022-01-25 10:21:05 +00:00
set(CMAKE_NM ${CMAKE_GCC_NM} CACHE STRING "" FORCE)
2021-12-08 11:32:04 +00:00
endif()
if(CMAKE_GCC_RANLIB)
2022-01-25 10:21:05 +00:00
set(CMAKE_RANLIB ${CMAKE_GCC_RANLIB} CACHE STRING "" FORCE)
2021-12-08 11:32:04 +00:00
endif()
endif()