Fixing CMake 3.6 deprecation message
- CMake 3.6 finally adds proper cross-compiler detection - When detected, use full compiler detection infrastructure - Still maintains compatibility back to CMake 2.8 (at least for now) - With new detection, selecting only the C compiler as it speeds up the CMake generaion process - Added a GCC 4.9 minimum version requirement for Bootloader
This commit is contained in:
parent
253d96af8c
commit
9cc29cbffc
@ -103,7 +103,7 @@ include_directories (
|
|||||||
#
|
#
|
||||||
|
|
||||||
#| Project
|
#| Project
|
||||||
project ( kiibohd_bootloader )
|
project ( kiibohd_bootloader C )
|
||||||
|
|
||||||
#| Target Name (output name)
|
#| Target Name (output name)
|
||||||
set ( TARGET kiibohd_bootloader )
|
set ( TARGET kiibohd_bootloader )
|
||||||
@ -113,6 +113,20 @@ cmake_minimum_required ( VERSION 2.8 )
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
# Minimum Compiler Version Checks
|
||||||
|
#
|
||||||
|
|
||||||
|
# Due to optimization requirements, we have to impose a minimum GCC version on the bootloader
|
||||||
|
set ( BOOTLOADER_MIN_GCC_VERSION "4.9" )
|
||||||
|
if ( "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" )
|
||||||
|
if ( CMAKE_C_COMPILER_VERSION VERSION_LESS "${BOOTLOADER_MIN_GCC_VERSION}" )
|
||||||
|
message( FATAL_ERROR "arm-none-eabi-gcc ${BOOTLOADER_MIN_GCC_VERSION} or higher is required for bootloader" )
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
###
|
###
|
||||||
# CMake Build Env
|
# CMake Build Env
|
||||||
#
|
#
|
||||||
|
@ -38,8 +38,8 @@ set( CHIP
|
|||||||
#| clang does work though
|
#| clang does work though
|
||||||
#| Currently only arm is supported with clang
|
#| Currently only arm is supported with clang
|
||||||
set( COMPILER
|
set( COMPILER
|
||||||
"gcc" # arm-none-eabi-gcc / avr-gcc - Default
|
"gcc" # arm-none-eabi-gcc / avr-gcc / host-gcc - Default
|
||||||
# "clang" # arm-none-eabi
|
# "clang" # arm-none-eabi / host
|
||||||
CACHE STRING "Compiler Type"
|
CACHE STRING "Compiler Type"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ set( COMPILER
|
|||||||
###
|
###
|
||||||
# Compiler Intialization
|
# Compiler Intialization
|
||||||
#
|
#
|
||||||
set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/Lib/CMake )
|
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/Lib/CMake )
|
||||||
include( initialize )
|
include( initialize )
|
||||||
|
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ set( MAIN_SRCS
|
|||||||
#
|
#
|
||||||
|
|
||||||
#| Project
|
#| Project
|
||||||
project( kiibohd_controller )
|
project( kiibohd_controller C )
|
||||||
|
|
||||||
#| Target Name (output name)
|
#| Target Name (output name)
|
||||||
set( TARGET kiibohd )
|
set( TARGET kiibohd )
|
||||||
|
@ -10,22 +10,53 @@
|
|||||||
###
|
###
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
# Compiler Check
|
||||||
|
#
|
||||||
|
|
||||||
#| Set the Compilers (must be set first)
|
#|
|
||||||
include( CMakeForceCompiler )
|
#| In CMake 3.6 a new feature to configure try_compile to work with cross-compilers
|
||||||
message( STATUS "Compiler Selected:" )
|
#| https://cmake.org/cmake/help/v3.6/variable/CMAKE_TRY_COMPILE_TARGET_TYPE.html#variable:CMAKE_TRY_COMPILE_TARGET_TYPE
|
||||||
if ( "${COMPILER}" MATCHES "gcc" )
|
#| If we detect CMake 3.6 or higher, use the new method
|
||||||
cmake_force_c_compiler ( arm-none-eabi-gcc ARMCCompiler )
|
#|
|
||||||
cmake_force_cxx_compiler( arm-none-eabi-g++ ARMCxxCompiler )
|
if ( NOT CMAKE_VERSION VERSION_LESS "3.6" )
|
||||||
set( _CMAKE_TOOLCHAIN_PREFIX arm-none-eabi- )
|
# Prepare for cross-compilation
|
||||||
message( "gcc" )
|
set( CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY" )
|
||||||
elseif ( "${COMPILER}" MATCHES "clang" )
|
set( CMAKE_SYSTEM_NAME "Generic" )
|
||||||
cmake_force_c_compiler ( clang ARMCCompiler )
|
|
||||||
cmake_force_cxx_compiler( clang++ ARMCxxCompiler )
|
message( STATUS "Compiler Selected:" )
|
||||||
set( _CMAKE_TOOLCHAIN_PREFIX llvm- )
|
if ( "${COMPILER}" MATCHES "gcc" )
|
||||||
message( "clang" )
|
set( CMAKE_C_COMPILER arm-none-eabi-gcc )
|
||||||
|
set( _CMAKE_TOOLCHAIN_PREFIX arm-none-eabi- )
|
||||||
|
message( "gcc" )
|
||||||
|
elseif ( "${COMPILER}" MATCHES "clang" )
|
||||||
|
set( CMAKE_C_COMPILER clang )
|
||||||
|
set( CMAKE_C_COMPILER_ID ARMCCompiler )
|
||||||
|
set( _CMAKE_TOOLCHAIN_PREFIX llvm- )
|
||||||
|
message( "clang" )
|
||||||
|
else ()
|
||||||
|
message( AUTHOR_WARNING "COMPILER: ${COMPILER} - Unknown compiler selection" )
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
#|
|
||||||
|
#| Before CMake 3.6 the cmake_force_c_compiler command was necessary to select cross-compilers
|
||||||
|
#| and other problemmatic compilers.
|
||||||
|
#|
|
||||||
else ()
|
else ()
|
||||||
message( AUTHOR_WARNING "COMPILER: ${COMPILER} - Unknown compiler selection" )
|
# Set the Compilers (must be set first)
|
||||||
|
include( CMakeForceCompiler )
|
||||||
|
message( STATUS "Compiler Selected:" )
|
||||||
|
if ( "${COMPILER}" MATCHES "gcc" )
|
||||||
|
cmake_force_c_compiler( arm-none-eabi-gcc ARMCCompiler )
|
||||||
|
set( _CMAKE_TOOLCHAIN_PREFIX arm-none-eabi- )
|
||||||
|
message( "gcc" )
|
||||||
|
elseif ( "${COMPILER}" MATCHES "clang" )
|
||||||
|
cmake_force_c_compiler( clang ARMCCompiler )
|
||||||
|
set( _CMAKE_TOOLCHAIN_PREFIX llvm- )
|
||||||
|
message( "clang" )
|
||||||
|
else ()
|
||||||
|
message( AUTHOR_WARNING "COMPILER: ${COMPILER} - Unknown compiler selection" )
|
||||||
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user