build: Fix crossbuilding definitions

CMAKE_C_COMPILER_TARGET doesn't need to be set when it's not cross
compiling, and based on wrong identation of that line I suspect it was
intended to be inside CMAKE_CROSSCOMPILING conditional.

With this line moved inside, it ends up being the only place where
COMPILER_SUFFIX is used, so, move its declaration there as well.

It will not bring any change to currently supported systems but will
make it easier to build VPP on systems running musl libc.

Type: fix

Change-Id: Ia8e16d9e8ad9c987ddf246dd0e3f8636ccad1362
Signed-off-by: Renato Botelho do Couto <renato@netgate.com>
This commit is contained in:
Renato Botelho do Couto
2024-06-20 11:01:40 -05:00
committed by Matthew Smith
parent d18726eaac
commit e69ec9c101

View File

@ -113,19 +113,20 @@ endif()
# cross compiling
##############################################################################
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(COMPILER_SUFFIX "linux-gnu")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
set(COMPILER_SUFFIX "freebsd")
endif()
if(CMAKE_CROSSCOMPILING)
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(COMPILER_SUFFIX "linux-gnu")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
set(COMPILER_SUFFIX "freebsd")
endif()
set(CMAKE_IGNORE_PATH
/usr/lib/${CMAKE_HOST_SYSTEM_PROCESSOR}-${COMPILER_SUFFIX}/
/usr/lib/${CMAKE_HOST_SYSTEM_PROCESSOR}-${COMPILER_SUFFIX}/lib/
)
endif()
set(CMAKE_C_COMPILER_TARGET ${CMAKE_SYSTEM_PROCESSOR}-${COMPILER_SUFFIX})
endif()
##############################################################################
# build config
##############################################################################