build: Fix crossbuilding definitions 66/41166/5
authorRenato Botelho do Couto <[email protected]>
Thu, 20 Jun 2024 16:01:40 +0000 (11:01 -0500)
committerMatthew Smith <[email protected]>
Fri, 12 Jul 2024 12:40:15 +0000 (12:40 +0000)
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 <[email protected]>
src/CMakeLists.txt

index 68d0a4f..d5c7fd1 100644 (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
 ##############################################################################