Am 07.11.19 um 18:01 schrieb samyuktar:
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")

As far as I can tell, you are trying to combine the compile and link steps, but CMake expects these to be separate steps. Furthermore, cmake knows about the TI compiler (see <...>/share/cmake-3.xx/Modules/Compiler/TI-C.cmake and friends), so you shouldn't need to mess around with CMAKE_C_LINK_EXECUTABLE - let cmake handle that for you. The flags you need for linking that cmake doesn't already add for you by default should go into CMAKE_EXE_LINKER_FLAGS_<CONFIG>_INIT (see the cmake documenation for details), or be set using the add_link_options and/or target_link_options commands (again, see the cmake documentation for details).

[ 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

That compiler invocation looks wrong - I'm pretty sure the TI compiler doesn't use the MacOS10.14.sdk sysroot. I think what's happening here is that you set your toolchain settings (CMAKE_C_COMPILER and friends) after the project() command - but the project() command tells cmake to check what compiler you are using to figure out how it must be called, and it is using your host system's compiler (probably Apple's clang) to do so. You should put the toolchain definitions into a toolchain file as described in the cmake-toolchains(7) documentation and tell cmake to use it my specifying -DCMAKE_TOOLCHAIN_FILE=<path to your toolchain file> on the cmake command line.

I once played around a bit with cgtools 5.2.9 for Arm using the following toolchain file:

--- SNIP ---

# TI cgt-arm_5.2.9 cmake toolchain script
#
# This file is based on the cmake-toolchains(7) documentation.

# Set the operating system and processor architecture
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_SYSTEM_VERSION 1)

# Setup CMake's rules for using the CMAKE_FIND_ROOT_PATH for cross-compilation
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

# TI cgtools command line programs
set(SDK_PATH "/proj/he/opt/ti/ti-cgt-arm_5.2.9")
set(SDK_BIN "${SDK_PATH}/bin")

# This compiler doesn't work with CMAKE_SYSROOT, but we do need to set our
# CMAKE_FIND_ROOT_PATH. Note that setting a variable will override the value in # the cache if the CACHE option was not used, so if we want to be able to use a # CMAKE_FIND_ROOT_PATH passed to cmake via the command line, we must make sure
# not to overwrite any value that was already set.
if(NOT CMAKE_FIND_ROOT_PATH)
  set(CMAKE_FIND_ROOT_PATH ${SDK_PATH})
endif()

set(CMAKE_C_COMPILER "${SDK_BIN}/armcl")
set(CMAKE_CXX_COMPILER "${SDK_BIN}/armcl")
set(CMAKE_ASM_COMPILER "${SDK_BIN}/armasm")
set(CMAKE_AR "${SDK_BIN}/armar")
set(CMAKE_LINKER "${SDK_BIN}/armlnk")

string(CONCAT ARCH_C_FLAGS
  "-mv=7A8 --abi=eabi -me --float_support=VFPv3 --neon --printf_support=full")
set(CMAKE_C_FLAGS_INIT "${ARCH_C_FLAGS}")
set(CMAKE_CXX_FLAGS_INIT "${ARCH_C_FLAGS}")

# Normally, cmake checks if the compiler can compile and link programs. For
# TI's cgtools the link step doesn't work, and there seems to be no easy way
# to fix this. Instead, we simply disable the compiler checks for C and C++.
set(CMAKE_C_COMPILER_WORKS 1)
set(CMAKE_CXX_COMPILER_WORKS 1)

--- SNIP ---

Note that the project this was intended for thankfully never got anywhere so I didn't pursue this much further than being able to compile libz with it ("thankfully" because the TI compiler is pretty awful).

--

*Dr. Eric Dönges*
Senior Software Engineer

MVTec Software GmbH | Arnulfstr. 205 | 80634 Munich | Germany
doen...@mvtec.com <mailto:musterm...@mvtec.com> | Tel: +49 89 457 695-0 | www.mvtec.com <http://www.mvtec.com>

Find our privacy policy here <https://www.mvtec.com/imprint>.

Sign up <https://www.mvtec.com/newsletter> for our MVTec Newsletter!

Geschäftsführer: Dr. Wolfgang Eckstein, Dr. Olaf Munkelt
Amtsgericht München HRB 114695

MVTec Software GmbH Logo
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

Reply via email to