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>
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 68d0a4f..d5c7fd1 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -113,19 +113,20 @@
# 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
##############################################################################