CMakeLists.txt : Link options not working properly

Hello,

I am using the TI-CGT compiler and have been successful in getting all my
source files to compile. However, I am unable to get the link command to
successfully link, and I have crafted a manual link command which I have to
then manually enter into the terminal once the build compiles all the files
and fails at the link stage.
I derived the link command from Code Composer Studio and took guidance for
what libraries are missing. However when I tried to add this to the
target_link_libraries in CMake, that didn’t work.

Here is my manual link command:

“/Applications/ti_ccs9/ccs9/ccs/tools/compiler/ti-cgt-arm_18.12.2.LTS/bin/armcl”
-mv7M4 --code_state=16 --float_support=FPv4SPD16 -me
–define=DeviceFamily_CC13X2 -g --diag_warning=225 --diag_warning=255
–diag_wrap=off --display_error_number --gen_func_subsections=on -z
-m"lwipthreads_CC1352P1_LAUNCHXL_tirtos_ccs.map"
-i"/Applications/ti_ccs9/simplelink_cc13x2_26x2_sdk_3_20_00_68/source"
-i"/Applications/ti_ccs9/simplelink_cc13x2_26x2_sdk_3_20_00_68/kernel/tirtos/packages"
-i"/Applications/ti_ccs9/ccs9/ccs/tools/compiler/ti-cgt-arm_18.12.2.LTS/lib"
–diag_wrap=off --display_error_number --warn_sections
–xml_link_info=“lwipthreads_CC1352P1_LAUNCHXL_tirtos_ccs_linkInfo.xml”
–rom_model --output_file=“lwipthreads_CC1352P1_LAUNCHXL_tirtos_ccs.out”
“CMakeFiles/test.out.dir/main_tirtos.c.obj”
“…/CC1352P1_LAUNCHXL_TIRTOS.cmd”
-l"/Applications/ti_ccs9/simplelink_cc13x2_26x2_sdk_3_20_00_68/source/ti/grlib/lib/ccs/m4f/grlib.a"
-lliblwipcontribapps.a -lliblwipboard.a -lliblwipcore.a
-lliblwipcontribporttirtos.a -l"ti/display/lib/display.aem4f"
-l"/Applications/ti_ccs9/simplelink_cc13x2_26x2_sdk_3_20_00_68/source/third_party/spiffs/lib/ccs/m4f/spiffs_cc26xx.a"
-l"/Applications/ti_ccs9/simplelink_cc13x2_26x2_sdk_3_20_00_68/source/ti/drivers/rf/lib/rf_multiMode_cc13x2.aem4f"
-l"/Applications/ti_ccs9/simplelink_cc13x2_26x2_sdk_3_20_00_68/source/ti/drivers/lib/drivers_cc13x2.aem4f"
-l"/Applications/ti_ccs9/simplelink_cc13x2_26x2_sdk_3_20_00_68/kernel/tirtos/packages/ti/dpl/lib/dpl_cc13x2.aem4f"
-l"…/linker.cmd"
-l"/Applications/ti_ccs9/simplelink_cc13x2_26x2_sdk_3_20_00_68/source/ti/devices/cc13x2_cc26x2/driverlib/bin/ccs/driverlib.lib"
-llibc.a

Here, liblwipcore.a, liblwipcontribporttirtos.a, liblwipboard.a,
liblwipcontribapps.a, are libraries that I have made using my
CMakeLists.txt. The rest are standard libraries coming from TI’s SDK.

The other thing is that I am unable to add the
…/CC1352P1_LAUNCHXL_TIRTOS.cmd in the CMakeLists.txt the way that I need it
in the linker command that I added above. This file has some information
about sections for .data, .code, .bss, flash memory partitions and the
system memory map etc. so it is definitely required by the CC1352P1 board to
be able to run this on the board.

Here is what I have in CMakeLists.txt for the link step :

set( cc1352p1_libs
${TIRTOS_SDK}/source/ti/display/lib/display.aem4f
${TIRTOS_SDK}/source/ti/grlib/lib/ccs/m4f/grlib.a
${TIRTOS_SDK}/source/third_party/spiffs/lib/ccs/m4f/spiffs_cc26xx.a
${TIRTOS_SDK}/source/ti/drivers/rf/lib/rf_multiMode_cc13x2.aem4f
${TIRTOS_SDK}/source/ti/drivers/lib/drivers_cc13x2.aem4f
${TIRTOS_SDK}/kernel/tirtos/packages/ti/dpl/lib/dpl_cc13x2.aem4f
${TIRTOS_SDK}/source/ti/devices/cc13x2_cc26x2/driverlib/bin/ccs/driverlib.lib
/Applications/ti_ccs9/ccs9/ccs/tools/compiler/ti-cgt-arm_18.12.2.LTS/lib/rtsv7M4_T_le_v4SPD16_eabi.lib
${LWIP_DIR}/linker.cmd
)
set( cc1352p1_lib_dirs
${TIRTOS_SDK}/source/ti/display/lib
${TIRTOS_SDK}/source/ti/grlib/lib/ccs/m4f
${TIRTOS_SDK}/source/third_party/spiffs/lib/ccs/m4f
${TIRTOS_SDK}/source/ti/drivers/rf/lib
${TIRTOS_SDK}/source/ti/drivers/lib
${TIRTOS_SDK}/kernel/tirtos/packages/ti/dpl/lib
${TIRTOS_SDK}/source/ti/devices/cc13x2_cc26x2/driverlib/bin/ccs
${TIRTOS_SDK}/source/third_party/fatfs/lib/ccs/m4
/Applications/ti_ccs9/ccs9/ccs/tools/compiler/ti-cgt-arm_18.12.2.LTS/lib
)
add_link_options(test.out …/CC1352P1_LAUNCHXL_TIRTOS.cmd)
target_link_libraries(test.out lwipcontribapps lwipboard
lwipcontribporttirtos lwipcontribexamples lwipcore
${CMAKE_COMPILER_PATH}/lib/libc.a ${cc1352p1_libs})
add_definitions( ${LWIP_COMPILE_OPTIONS}) # ${LWIP_BIOS_OPTS} )

Here’s the error that I get when I say make:

WARNING: invalid linker option
–warn_sections–xml_link_info=gpiointerrupt_CC1352P1_LAUNCHXL_tirtos_ccs_linkInfo.xml
(ignored)

error #10056: symbol “free” redefined: first defined in
“/Users/sramnath/ccs_workspaces/sdk_3_2/spiEthernet/tirtos_builds_CC1352P1_L
AUNCHXL_release_ccs/Debug/configPkg/package/cfg/release_pem4f.oem4f”;
redefined in
“/Applications/ti_ccs9/ccs9/ccs/tools/compiler/ti-cgt-arm_18.12.2.LTS/lib/rt
sv7M4_T_le_v4SPD16_eabi.lib<memory.c.obj>”
error #10056: symbol “realloc” redefined: first defined in
“/Users/sramnath/ccs_workspaces/sdk_3_2/spiEthernet/tirtos_builds_CC1352P1_L
AUNCHXL_release_ccs/Debug/configPkg/package/cfg/release_pem4f.oem4f”;
redefined in
“/Applications/ti_ccs9/ccs9/ccs/tools/compiler/ti-cgt-arm_18.12.2.LTS/lib/rt
sv7M4_T_le_v4SPD16_eabi.lib<memory.c.obj>”
error #10056: symbol “memalign” redefined: first defined in
“/Users/sramnath/ccs_workspaces/sdk_3_2/spiEthernet/tirtos_builds_CC1352P1_L
AUNCHXL_release_ccs/Debug/configPkg/package/cfg/release_pem4f.oem4f”;
redefined in
“/Applications/ti_ccs9/ccs9/ccs/tools/compiler/ti-cgt-arm_18.12.2.LTS/lib/rt
sv7M4_T_le_v4SPD16_eabi.lib<memory.c.obj>”
error #10056: symbol “calloc” redefined: first defined in
“/Users/sramnath/ccs_workspaces/sdk_3_2/spiEthernet/tirtos_builds_CC1352P1_L
AUNCHXL_release_ccs/Debug/configPkg/package/cfg/release_pem4f.oem4f”;
redefined in
“/Applications/ti_ccs9/ccs9/ccs/tools/compiler/ti-cgt-arm_18.12.2.LTS/lib/rt
sv7M4_T_le_v4SPD16_eabi.lib<memory.c.obj>”
error #10056: symbol “malloc” redefined: first defined in
“/Users/sramnath/ccs_workspaces/sdk_3_2/spiEthernet/tirtos_builds_CC1352P1_L
AUNCHXL_release_ccs/Debug/configPkg/package/cfg/release_pem4f.oem4f”;
redefined in
“/Applications/ti_ccs9/ccs9/ccs/tools/compiler/ti-cgt-arm_18.12.2.LTS/lib/rt
sv7M4_T_le_v4SPD16_eabi.lib<memory.c.obj>”
“…/linker.cmd”, line 646: warning #10096-D: specified address lies outside
memory map
error #10264: DEFAULT memory range overlaps existing memory range RAM
undefined first referenced
symbol in file --------- ----------------
__aeabi_cdcmple
/Users/sramnath/ccs_workspaces/sdk_3_2/spiEthernet/tirtos_builds_CC1352P1_LAUNCHXL_release_ccs/Debug/configPkg/package/cfg/release_pem4f.oem4f
__aeabi_cdrcmple
/Users/sramnath/ccs_workspaces/sdk_3_2/spiEthernet/tirtos_builds_CC1352P1_LAUNCHXL_release_ccs/Debug/configPkg/package/cfg/release_pem4f.oem4f
__aeabi_d2iz
/Users/sramnath/ccs_workspaces/sdk_3_2/spiEthernet/tirtos_builds_CC1352P1_LAUNCHXL_release_ccs/Debug/configPkg/package/cfg/release_pem4f.oem4f
__aeabi_d2uiz
/Users/sramnath/ccs_workspaces/sdk_3_2/spiEthernet/tirtos_builds_CC1352P1_LAUNCHXL_release_ccs/Debug/configPkg/package/cfg/release_pem4f.oem4f
__aeabi_dmul
/Users/sramnath/ccs_workspaces/sdk_3_2/spiEthernet/tirtos_builds_CC1352P1_LAUNCHXL_release_ccs/Debug/configPkg/package/cfg/release_pem4f.oem4f
__aeabi_dsub
/Users/sramnath/ccs_workspaces/sdk_3_2/spiEthernet/tirtos_builds_CC1352P1_LAUNCHXL_release_ccs/Debug/configPkg/package/cfg/release_pem4f.oem4f
__aeabi_f2d
/Users/sramnath/ccs_workspaces/sdk_3_2/spiEthernet/tirtos_builds_CC1352P1_LAUNCHXL_release_ccs/Debug/configPkg/package/cfg/release_pem4f.oem4f
__aeabi_i2d
/Users/sramnath/ccs_workspaces/sdk_3_2/spiEthernet/tirtos_builds_CC1352P1_LAUNCHXL_release_ccs/Debug/configPkg/package/cfg/release_pem4f.oem4f
__aeabi_uidivmod
/Users/sramnath/ccs_workspaces/sdk_3_2/spiEthernet/tirtos_builds_CC1352P1_LAUNCHXL_release_ccs/src/sysbios/rom_sysbios.aem4f<rom_sysbios.obj>
primary_heap_end
/Users/sramnath/ccs_workspaces/sdk_3_2/spiEthernet/tirtos_builds_CC1352P1_LAUNCHXL_release_ccs/Debug/configPkg/package/cfg/release_pem4f.oem4f
primary_heap_start
/Users/sramnath/ccs_workspaces/sdk_3_2/spiEthernet/tirtos_builds_CC1352P1_LAUNCHXL_release_ccs/Debug/configPkg/package/cfg/release_pem4f.oem4f
sys_init liblwipcore.a<init.c.obj>
sys_mbox_trypost liblwipcore.a<tcpip.c.obj>
sys_mbox_valid liblwipcore.a<tcpip.c.obj>
sys_now liblwipcore.a<netif.c.obj>
error #10234-D: unresolved symbols remain
error #10010: errors encountered during linking; “test.out” not built

These errors are all resolved when I manually enter the above linker
command.

Please help me out with the link step of the CMake command.