diff --git a/Help/variable/CMAKE_LANG_COMPILER_ID.rst b/Help/variable/CMAKE_LANG_COMPILER_ID.rst index 1c3b134d0..81976a918 100644 --- a/Help/variable/CMAKE_LANG_COMPILER_ID.rst +++ b/Help/variable/CMAKE_LANG_COMPILER_ID.rst @@ -11,6 +11,7 @@ include: Absoft = Absoft Fortran (absoft.com) ADSP = Analog VisualDSP++ (analog.com) AppleClang = Apple Clang (apple.com) + ARMCC = ARM Compiler (arm.com) CCur = Concurrent Fortran (ccur.com) Clang = LLVM Clang (clang.llvm.org) Cray = Cray Compiler (cray.com) diff --git a/Modules/CMakeCompilerIdDetection.cmake b/Modules/CMakeCompilerIdDetection.cmake index 19bcbcc28..cbc005570 100644 --- a/Modules/CMakeCompilerIdDetection.cmake +++ b/Modules/CMakeCompilerIdDetection.cmake @@ -89,6 +89,7 @@ function(compiler_id_detection outvar lang) MSVC ADSP IAR + ARMCC ) if (lang STREQUAL C) list(APPEND ordered_compilers diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake index 25af3e39e..91111d299 100644 --- a/Modules/CMakeDetermineASMCompiler.cmake +++ b/Modules/CMakeDetermineASMCompiler.cmake @@ -92,6 +92,10 @@ if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_IAR ) set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_IAR "IAR Assembler") + list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS ARMCC) + set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_ARMCC ) + set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_ARMCC "(ARM Compiler)|(ARM Assembler)") + include(CMakeDetermineCompilerId) CMAKE_DETERMINE_COMPILER_ID_VENDOR(ASM${ASM_DIALECT}) diff --git a/Modules/Compiler/ARMCC-ASM.cmake b/Modules/Compiler/ARMCC-ASM.cmake new file mode 100644 index 000000000..8e3cfc5c8 --- /dev/null +++ b/Modules/Compiler/ARMCC-ASM.cmake @@ -0,0 +1,7 @@ +include(Compiler/ARMCC) + +set(CMAKE_ASM_OUTPUT_EXTENSION ".o") +set(CMAKE_ASM_OUTPUT_EXTENSION_REPLACE 1) + +set(CMAKE_ASM_COMPILE_OBJECT " -o ") +set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;asm;msa) diff --git a/Modules/Compiler/ARMCC-C.cmake b/Modules/Compiler/ARMCC-C.cmake new file mode 100644 index 000000000..dcdcaab4a --- /dev/null +++ b/Modules/Compiler/ARMCC-C.cmake @@ -0,0 +1,2 @@ +include(Compiler/ARMCC) +__compiler_armcc(C) diff --git a/Modules/Compiler/ARMCC-CXX.cmake b/Modules/Compiler/ARMCC-CXX.cmake new file mode 100644 index 000000000..811fc93bd --- /dev/null +++ b/Modules/Compiler/ARMCC-CXX.cmake @@ -0,0 +1,2 @@ +include(Compiler/ARMCC) +__compiler_armcc(CXX) diff --git a/Modules/Compiler/ARMCC-DetermineCompiler.cmake b/Modules/Compiler/ARMCC-DetermineCompiler.cmake new file mode 100644 index 000000000..a3667d7c2 --- /dev/null +++ b/Modules/Compiler/ARMCC-DetermineCompiler.cmake @@ -0,0 +1,16 @@ +# ARMCC Toolchain +set(_compiler_id_pp_test "defined(__ARMCC_VERSION)") + +set(_compiler_id_version_compute " +#if __ARMCC_VERSION >= 1000000 + /* __ARMCC_VERSION = VRRPPPP */ + # define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__ARMCC_VERSION/1000000) + # define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__ARMCC_VERSION/10000 % 100) + # define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__ARMCC_VERSION % 10000) +#else + /* __ARMCC_VERSION = VRPPPP */ + # define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__ARMCC_VERSION/100000) + # define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__ARMCC_VERSION/10000 % 10) + # define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__ARMCC_VERSION % 10000) +#endif +") diff --git a/Modules/Compiler/ARMCC.cmake b/Modules/Compiler/ARMCC.cmake new file mode 100644 index 000000000..3cf628c0d --- /dev/null +++ b/Modules/Compiler/ARMCC.cmake @@ -0,0 +1,36 @@ +if(_ARMCC_CMAKE_LOADED) + return() +endif() +set(_ARMCC_CMAKE_LOADED TRUE) + +# See ARM Compiler documentation at: +# http://infocenter.arm.com/help/topic/com.arm.doc.set.swdev/index.html + +get_filename_component(_CMAKE_C_TOOLCHAIN_LOCATION "${CMAKE_C_COMPILER}" PATH) +get_filename_component(_CMAKE_CXX_TOOLCHAIN_LOCATION "${CMAKE_CXX_COMPILER}" PATH) + +set(CMAKE_EXECUTABLE_SUFFIX ".elf") + +find_program(CMAKE_ARMCC_LINKER armlink HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" ) +find_program(CMAKE_ARMCC_AR armar HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" ) + +set(CMAKE_LINKER "${CMAKE_ARMCC_LINKER}" CACHE FILEPATH "The ARMCC linker" FORCE) +mark_as_advanced(CMAKE_ARMCC_LINKER) +set(CMAKE_AR "${CMAKE_ARMCC_AR}" CACHE FILEPATH "The ARMCC archiver" FORCE) +mark_as_advanced(CMAKE_ARMCC_AR) + +macro(__compiler_armcc lang) + set(CMAKE_${lang}_FLAGS_INIT "") + set(CMAKE_${lang}_FLAGS_DEBUG_INIT "-g") + set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "-Ospace -DNDEBUG") + set(CMAKE_${lang}_FLAGS_RELEASE_INIT "-Otime -DNDEBUG") + set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "-O2 -g") + + set(CMAKE_${lang}_OUTPUT_EXTENSION ".o") + set(CMAKE_${lang}_OUTPUT_EXTENSION_REPLACE 1) + + set(CMAKE_${lang}_LINK_EXECUTABLE " -o --list .map") + set(CMAKE_${lang}_CREATE_STATIC_LIBRARY " --create -cr ") + + set(CMAKE_DEPFILE_FLAGS_${lang} "--depend= --depend_single_line --no_depend_system_headers") +endmacro()