build: Add FreeBSD as a supported platform for cmake
Allow FreeBSD as a platform in the main CMakeLists file. This requires a
correct target for the compiler and an explicit name in the system
check.
The included subdirs require further changes to build, but the compiler
needs to find them before it can complain.
Type: improvement
Change-Id: Ic56fe68290519ef5d3ed61082e7fb0ba0528a3fc
Signed-off-by: Tom Jones <thj@freebsd.org>
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 7c4f8db..9415c4d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -112,14 +112,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)
set(CMAKE_IGNORE_PATH
- /usr/lib/${CMAKE_HOST_SYSTEM_PROCESSOR}-linux-gnu/
- /usr/lib/${CMAKE_HOST_SYSTEM_PROCESSOR}-linux-gnu/lib/
+ /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}-linux-gnu)
-
+ set(CMAKE_C_COMPILER_TARGET ${CMAKE_SYSTEM_PROCESSOR}-${COMPILER_SUFFIX})
##############################################################################
# build config
##############################################################################
@@ -252,7 +258,7 @@
DESTINATION ${VPP_RUNTIME_DIR}
COMPONENT vpp-dev
)
-elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
+elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux|FreeBSD")
find_package(OpenSSL)
set(SUBDIRS
vppinfra svm vlib vlibmemory vlibapi vnet vpp vat vat2 vcl vpp-api