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 ( kiibohd_bootloader )
|
||||
project ( kiibohd_bootloader C )
|
||||
|
||||
#| Target Name (output name)
|
||||
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
|
||||
#
|
||||
|
@ -38,8 +38,8 @@ set( CHIP
|
||||
#| clang does work though
|
||||
#| Currently only arm is supported with clang
|
||||
set( COMPILER
|
||||
"gcc" # arm-none-eabi-gcc / avr-gcc - Default
|
||||
# "clang" # arm-none-eabi
|
||||
"gcc" # arm-none-eabi-gcc / avr-gcc / host-gcc - Default
|
||||
# "clang" # arm-none-eabi / host
|
||||
CACHE STRING "Compiler Type"
|
||||
)
|
||||
|
||||
@ -48,7 +48,7 @@ set( COMPILER
|
||||
###
|
||||
# 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 )
|
||||
|
||||
|
||||
@ -139,7 +139,7 @@ set( MAIN_SRCS
|
||||
#
|
||||
|
||||
#| Project
|
||||
project( kiibohd_controller )
|
||||
project( kiibohd_controller C )
|
||||
|
||||
#| Target Name (output name)
|
||||
set( TARGET kiibohd )
|
||||
|
@ -10,22 +10,53 @@
|
||||
###
|
||||
|
||||
|
||||
###
|
||||
# Compiler Check
|
||||
#
|
||||
|
||||
#| 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 )
|
||||
cmake_force_cxx_compiler( arm-none-eabi-g++ ARMCxxCompiler )
|
||||
set( _CMAKE_TOOLCHAIN_PREFIX arm-none-eabi- )
|
||||
message( "gcc" )
|
||||
elseif ( "${COMPILER}" MATCHES "clang" )
|
||||
cmake_force_c_compiler ( clang ARMCCompiler )
|
||||
cmake_force_cxx_compiler( clang++ ARMCxxCompiler )
|
||||
set( _CMAKE_TOOLCHAIN_PREFIX llvm- )
|
||||
message( "clang" )
|
||||
#|
|
||||
#| In CMake 3.6 a new feature to configure try_compile to work with cross-compilers
|
||||
#| https://cmake.org/cmake/help/v3.6/variable/CMAKE_TRY_COMPILE_TARGET_TYPE.html#variable:CMAKE_TRY_COMPILE_TARGET_TYPE
|
||||
#| If we detect CMake 3.6 or higher, use the new method
|
||||
#|
|
||||
if ( NOT CMAKE_VERSION VERSION_LESS "3.6" )
|
||||
# Prepare for cross-compilation
|
||||
set( CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY" )
|
||||
set( CMAKE_SYSTEM_NAME "Generic" )
|
||||
|
||||
message( STATUS "Compiler Selected:" )
|
||||
if ( "${COMPILER}" MATCHES "gcc" )
|
||||
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 ()
|
||||
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 ()
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user