Reputation: 707
Ouch! I inadvertently updated CMake to 3.9.1 (long story, and I don't know the old version), which is not terribly new, but is what Ubuntu/PopOS! 17.10 seem to support, and now my project failed to find my tools. Okay, I said, my original toolchain file used the obsolete/deprecated "force toolchain" thing, which was given to me several years ago. Having recently learned the correct way, I updated my toolchain file, and all works fine - until it is time to link. Now, the link fails with no input files; in other words, the command looks like this:
ld
There were no changes to my CMakeLists.txt file, and I am stumped! What could cause the link command to change so drastically?
Here is the new toolchain file:
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
set(XILINX_ROOT /home/bgrimes/osu/tools/opt/pkg/petalinux)
set(XILINX_TOOLS ${XILINX_ROOT}/tools/linux-i386/gcc-arm-linux-gnueabi)
set(CMAKE_C_COMPILER "${XILINX_TOOLS}/bin/arm-linux-gnueabihf-gcc")
set(CMAKE_CXX_COMPILER "${XILINX_TOOLS}/bin/arm-linux-gnueabihf-g++")
set(CMAKE_CXX_LINK_EXECUTABLE "${XILINX_TOOLS}/bin/arm-linux-gnueabihf-ld")
#set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=cortex-a9" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv7-a" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mthumb" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=hard" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=vfpv3" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXILINX" )
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -fno-exceptions")
Here is the old toolchain file:
INCLUDE(CMakeForceCompiler)
SET(CMAKE_SYSTEM_NAME "Linux")
CMAKE_FORCE_C_COMPILER(arm-linux-gnueabihf-gcc GNU)
CMAKE_FORCE_CXX_COMPILER(arm-linux-gnueabihf-g++ GNU)
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=cortex-a9" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv7-a" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mthumb" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=hard" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=vfpv3" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXILINX" )
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -fno-exceptions" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "" FORCE )
set( CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "" FORCE )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "" FORCE )
Upvotes: 0
Views: 978
Reputation: 65928
Variable CMAKE_CXX_LINK_EXECUTABLE denotes the rule for link, not just a linker.
So setting it with
set(CMAKE_CXX_LINK_EXECUTABLE "${XILINX_TOOLS}/bin/arm-linux-gnueabihf-ld")
effectively makes the linker to be called without any arguments.
Common way to set this variable is:
set(CMAKE_LINKER "${XILINX_TOOLS}/bin/arm-linux-gnueabihf-ld")
set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_LINKER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
See also that answer: CMake: use a custom linker.
Note, that CMAKE_LINKER
variable is not a special variable by itself: CMake knows nothing about it. In the example above this variable is referred via <CMAKE_LINKER>
construction in the rule.
Upvotes: 1