[CMake] Using CMake with TI armcl and armar
samyuktar
sramnath at axon.com
Thu Nov 7 12:01:41 EST 2019
Hi,
I want to include some open-source stacks in my code for the CC1352P1, so
I'm trying to use cmake with armcl compiler and armar archiver.
Here is my code:
cmake_minimum_required(VERSION 3.10)
set (CMAKE_CONFIGURATION_TYPES "Debug;Release")
project(lwIP)
# Example lwIP application
set(LWIP_DIR "/Users/sramnath/lwip_blinky/lwip")
set (LWIP_DEFINITIONS LWIP_DEBUG=1)
set(CMAKE_VERBOSE_MAKEFILE ON)
#include(CMakeForceCompiler)
# this one is important
set(CMAKE_SYSTEM_NAME Generic)
set (cc1352p1_board_SRCS
${LWIP_DIR}/CC1352P1_LAUNCHXL_TIRTOS.cmd
${LWIP_DIR}/CC1352P1_LAUNCHXL_fxns.c
${LWIP_DIR}/CC1352P1_LAUNCHXL.c
${LWIP_DIR}/ccfg.c
)
set (LWIP_INCLUDE_DIRS
"${LWIP_DIR}/src/include"
"${LWIP_DIR}"
"${LWIP_DIR}/contrib/"
"${LWIP_DIR}/contrib/ports/tirtos/include"
"${LWIP_DIR}/contrib/examples/test"
# "/Users/sramnath/lwip_out/lwip/contrib/ports/tirtos"
"${LWIP_DIR}/contrib/ports/tirtos"
"${LWIP_TIRTOS_SRCS}"
)
set (LWIP_BIOS_OPTS
"--define=ti_sysbios_BIOS_swiEnabled__D=TRUE"
"--define=ti_sysbios_BIOS_taskEnabled__D=TRUE"
"--define=ti_sysbios_BIOS_clockEnabled__D=TRUE"
"--define=ti_sysbios_BIOS_runtimeCreatesEnabled__D=TRUE"
"--define=ti_sysbios_hal_Hwi_DISABLE_ALL_HOOKS"
"--define=ti_sysbios_knl_Swi_DISABLE_ALL_HOOKS"
"--define=ti_sysbios_BIOS_smpEnabled__D=FALSE"
"--define=ti_sysbios_Build_useHwiMacros"
"--define=ti_sysbios_knl_Swi_numPriorities__D=6"
"--define=ti_sysbios_knl_Task_deleteTerminatedTasks__D=FALSE"
"--define=ti_sysbios_knl_Task_numPriorities__D=16"
"--define=ti_sysbios_knl_Task_checkStackFlag__D=FALSE"
"--define=ti_sysbios_knl_Task_initStackFlag__D=TRUE"
"--define=ti_sysbios_knl_Task_DISABLE_ALL_HOOKS"
"--define=ti_sysbios_knl_Clock_TICK_SOURCE=ti_sysbios_knl_Clock_TickSource_TIMER"
"--define=ti_sysbios_knl_Clock_TICK_MODE=ti_sysbios_knl_Clock_TickMode_DYNAMIC"
"--define=ti_sysbios_hal_Core_delegate_getId=ti_sysbios_hal_CoreNull_getId__E"
"--define=ti_sysbios_hal_Core_delegate_interruptCore=ti_sysbios_hal_CoreNull_interruptCore__E"
"--define=ti_sysbios_hal_Core_delegate_lock=ti_sysbios_hal_CoreNull_lock__E"
"--define=ti_sysbios_hal_Core_delegate_unlock=ti_sysbios_hal_CoreNull_unlock__E"
"--define=ti_sysbios_hal_Core_numCores__D=1"
"--define=ti_sysbios_hal_CoreNull_numCores__D=1"
"--define=ti_sysbios_utils_Load_taskEnabled__D=TRUE"
"--define=ti_sysbios_utils_Load_swiEnabled__D=FALSE"
"--define=ti_sysbios_utils_Load_hwiEnabled__D=FALSE"
"--define=ti_sysbios_family_arm_m3_Hwi_dispatcherSwiSupport__D=TRUE"
"--define=ti_sysbios_family_arm_m3_Hwi_dispatcherTaskSupport__D=TRUE"
"--define=ti_sysbios_family_arm_m3_Hwi_dispatcherAutoNestingSupport__D=TRUE"
"--define=ti_sysbios_knl_Semaphore_supportsEvents__D=FALSE"
"--define=ti_sysbios_knl_Semaphore_supportsPriority__D=FALSE"
"--define=xdc_runtime_Assert_DISABLE_ALL"
"--define=xdc_runtime_Log_DISABLE_ALL"
)
set(CCS_PATH "/Applications/ti_ccs9/ccs9/ccs")
# set(CMAKE_MAKE_PROGRAM ${CCS_PATH}/utils/bin/gmake CACHE PATH "make
program" FORCE)
set(CG_TOOL_ROOT ${CCS_PATH}/tools/compiler/ti-cgt-arm_18.12.2.LTS)
# specify the cross compiler
SET(CMAKE_C_COMPILER_FLAGS "")
# SET(CMAKE_C_COMPILER "${CG_TOOL_ROOT}/bin/armcl ${cc1352p1_board_SRCS}"
CACHE PATH "c compiler")
SET(CMAKE_C_COMPILER
"/Applications/ti_ccs9/ccs9/ccs/tools/compiler/ti-cgt-arm_18.12.2.LTS/bin/armcl")
SET(CMAKE_CXX_COMPILER ${CMAKE_C_COMPILER} CACHE PATH "cxx compiler")
#SET(CMAKE_ASM_COMPILER ${CG_TOOL_ROOT}/bin/armasm CACHE PATH "assembler")
SET(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER} CACHE PATH "assembler")
SET(CMAKE_LINKER ${CMAKE_C_COMPILER} CACHE PATH "linker")
# Add the default include and lib directories for tool chain
include_directories(${CG_TOOL_ROOT}/include)
link_directories(${CG_TOOL_ROOT}/lib)
message("link_directories(${CG_TOOL_ROOT}/lib)")
# set target environment
set(CMAKE_FIND_ROOT_PATH ${CG_TOOL_ROOT})
# specifiy target cpu flags
set(PLATFORM_CONFIG_C_FLAGS "-mv7M4 --code_state=32
--float_support=VFPv3D16 --abi=eabi -me -g --diag_warning=225
--display_error_number --diag_wrap=off --enum_type=packed
--include_path=${CG_TOOL_ROOT}/include --define=_RM46x_
--define=_VFP_SUPPORT_=1" CACHE STRING "platform config c flags")
set(PLATFORM_CONFIG_L_FLAGS "-i ${CG_TOOL_ROOT}/lib --reread_libs
--warn_sections --rom_model")
# combine flags to C and C++ flags
SET(CMAKE_C_FLAGS "${PLATFORM_CONFIG_C_FLAGS} ${CMAKE_C_FLAGS}" CACHE STRING
"platform config c flags")
SET(CMAKE_CXX_FLAGS "${PLATFORM_CONFIG_C_FLAGS} ${CMAKE_CXX_FLAGS}" CACHE
STRING "platform config cxx flags")
SET(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS}")
SET(LIB "-l rtsv7R4_T_le_v3D16_eabi.lib")
SET(CMD_SRCS
"/Users/sramnath/lwip_blinky/lwip/CC1352P1_LAUNCHXL_TIRTOS.cmd")
set(TARGET_NAME "cc1352p1_launchxl")
# SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}
${PLATFORM_CONFIG_L_FLAGS}" CACHE STRING "platform config linker exe files")
set(LIB "liblwipboard.a")
set(CMAKE_C_OUTPUT_EXTENSION ".obj")
# cross-compiler
# CMAKE_FORCE_C_COMPILER(${CMAKE_C_COMPILER})
#executable type
set(CMAKE_EXECUTABLE_SUFFIX ".obj")
SET(CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS}
--c_file=../main.c -z --map_file=${TARGET_NAME}.map
--output_file=${TARGET_NAME} ${PLATFORM_CONFIG_L_FLAGS} ${CMD_SRCS} ${LIB}
--include_path ${LWIP_INCLUDE_DIR} --verbose <OBJECTS>" CACHE STRING
"linker executable")
MESSAGE( STATUS "Compile flags for C: " ${CMAKE_C_FLAGS} )
MESSAGE( STATUS "Compile flags for asm: " ${CMAKE_ASM_FLAGS} )
MESSAGE( STATUS "linker flags for asm: " ${CMAKE_EXE_LINKER_FLAGS} )
MESSAGE( STATUS "linker executable is " ${CMAKE_C_LINK_EXECUTABLE} )
MESSAGE( STATUS "here is the compiler you are using " ${CMAKE_C_COMPILER})
add_executable(test ${cc1352p1_board_SRCS} "../main.c" )
The trouble is, "add_executable" by default adds a -o -c <source file>
command, which is different from wha the armcl compiler is expecting (it
expects a format that is given in the CMAKE_C_LINK_EXECUTABLE variable). As
a result, it does not actually compile any of the source files to produce .o
files and I am unable to build the project.
How do I actually execute the command specified in the
CMAKE_C_LINK_EXECUTABLE variable?
When I remove the "add_executable" command, I get the following message :
/usr/local/Cellar/cmake/3.15.5/bin/cmake -S/Users/sramnath/lwip_blinky/lwip
- B/Users/sramnath/lwip_blinky/lwip/build --check-build-system
CMakeFiles/Makefile.cmake 0
/usr/local/Cellar/cmake/3.15.5/bin/cmake -E cmake_progress_start
/Users/sramnath/lwip_blinky/lwip/build/CMakeFiles
/Users/sramnath/lwip_blinky/lwip/build/CMakeFiles/progress.marks
/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/Makefile2 all
make[1]: Nothing to be done for `all'.
/usr/local/Cellar/cmake/3.15.5/bin/cmake -E cmake_progress_start
/Users/sramnath/lwip_blinky/lwip/build/CMakeFiles 0
and when I do add it, I get
/usr/local/Cellar/cmake/3.15.5/bin/cmake -S/Users/sramnath/lwip_blinky/lwip
-B/Users/sramnath/lwip_blinky/lwip/build --check-build-system
CMakeFiles/Makefile.cmake 0
/usr/local/Cellar/cmake/3.15.5/bin/cmake -E cmake_progress_start
/Users/sramnath/lwip_blinky/lwip/build/CMakeFiles
/Users/sramnath/lwip_blinky/lwip/build/CMakeFiles/progress.marks
/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/Makefile2 all
/Library/Developer/CommandLineTools/usr/bin/make -f
CMakeFiles/test.dir/build.make CMakeFiles/test.dir/depend
cd /Users/sramnath/lwip_blinky/lwip/build &&
/usr/local/Cellar/cmake/3.15.5/bin/cmake -E cmake_depends "Unix Makefiles"
/Users/sramnath/lwip_blinky/lwip /Users/sramnath/lwip_blinky/lwip
/Users/sramnath/lwip_blinky/lwip/build
/Users/sramnath/lwip_blinky/lwip/build
/Users/sramnath/lwip_blinky/lwip/build/CMakeFiles/test.dir/DependInfo.cmake
--color=
Scanning dependencies of target test
/Library/Developer/CommandLineTools/usr/bin/make -f
CMakeFiles/test.dir/build.make CMakeFiles/test.dir/build
[ 50%] Building C object CMakeFiles/test.dir/main.c.o
/Applications/ti_ccs9/ccs9/ccs/tools/compiler/ti-cgt-arm_18.12.2.LTS/bin/armcl
-I/Applications/ti_ccs9/ccs9/ccs/tools/compiler/ti-cgt-arm_18.12.2.LTS/include
-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -o
CMakeFiles/test.dir/main.c.o -c /Users/sramnath/lwip_blinky/lwip/main.c
>> WARNING: object file specified, but linking not enabled
It seems to make the .o file, but when I try to link the files, I get the
following message:
[ 60%] Linking C static library liblwipboard.a
/usr/local/Cellar/cmake/3.15.5/bin/cmake -P
CMakeFiles/lwipboard.dir/cmake_clean_target.cmake
/usr/local/Cellar/cmake/3.15.5/bin/cmake -E cmake_link_script
CMakeFiles/lwipboard.dir/link.txt --verbose=1
/Applications/ti_ccs9/ccs9/ccs/tools/compiler/ti-cgt-arm_18.12.2.LTS/bin/armar
-av liblwipboard.a CMakeFiles/lwipboard.dir/CC1352P1_LAUNCHXL_fxns.c.o
CMakeFiles/lwipboard.dir/CC1352P1_LAUNCHXL.c.o
CMakeFiles/lwipboard.dir/ccfg.c.o
==> new archive 'liblwipboard.a'
==> building archive 'liblwipboard.a'
--> error: 'CMakeFiles/lwipboard.dir/CC1352P1_LAUNCHXL_fxns.c.o' not
found
--> error: 'CMakeFiles/lwipboard.dir/CC1352P1_LAUNCHXL.c.o' not found
--> error: 'CMakeFiles/lwipboard.dir/ccfg.c.o' not found
make[2]: *** [liblwipboard.a] Error 1
make[2]: *** Deleting file `liblwipboard.a'
make[1]: *** [CMakeFiles/lwipboard.dir/all] Error 2
make: *** [all] Error 2
Please let me know how I can proceed.
--
Sent from: http://cmake.3232098.n2.nabble.com/
More information about the CMake
mailing list