From: Guillaume Solignac Date: Thu, 9 Jan 2025 11:19:31 +0000 (-0800) Subject: build: expose VPP_PLATFORM to out-of-tree plugins X-Git-Tag: v25.06-rc0~43 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=ec68cec6c84e5dc9acaf7828c0118bb71fffc561;p=vpp.git build: expose VPP_PLATFORM to out-of-tree plugins We move the VPP_PLATFORM logic from src/CMakeLists.txt to cmake/cpu.cmake so that out-of-tree plugins can leverage it as well. Type: improvement Signed-off-by: Guillaume Solignac Change-Id: I767a75f45c07aed7db4034b18ab4b5c67fda06ee --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f6d07be0b79..967c7772ff3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,27 +13,6 @@ cmake_minimum_required(VERSION 3.13) -if(DEFINED VPP_PLATFORM AND VPP_PLATFORM STREQUAL "default") - unset(VPP_PLATFORM) - unset(VPP_PLATFORM CACHE) - set(VPP_PLATFORM_NAME "default") -elseif(DEFINED VPP_PLATFORM) - set(platform_file ${CMAKE_SOURCE_DIR}/cmake/platform/${VPP_PLATFORM}.cmake) - if(NOT EXISTS ${platform_file}) - message(FATAL_ERROR "unknown platform ${VPP_PLATFORM}") - endif() - include(${platform_file}) - set(VPP_PLATFORM_NAME ${VPP_PLATFORM}) -else() - set(VPP_PLATFORM_NAME "default") -endif() - -if (DEFINED VPP_PLATFORM_C_COMPILER_NAMES) - set(CMAKE_C_COMPILER_NAMES ${VPP_PLATFORM_C_COMPILER_NAME}) -else() - set(CMAKE_C_COMPILER_NAMES clang gcc cc) -endif() - project(vpp C) if(NOT DEFINED CMAKE_INSTALL_LIBDIR AND EXISTS "/etc/debian_version") diff --git a/src/cmake/CMakeLists.txt b/src/cmake/CMakeLists.txt index 74cd385a1ce..8f7ad0e8513 100644 --- a/src/cmake/CMakeLists.txt +++ b/src/cmake/CMakeLists.txt @@ -25,3 +25,13 @@ install( COMPONENT vpp-dev ) + +install( + DIRECTORY + platform/ + + DESTINATION + ${VPP_LIBRARY_DIR}/cmake/vpp/platform + + COMPONENT vpp-dev +) diff --git a/src/cmake/cpu.cmake b/src/cmake/cpu.cmake index 25e966dcf7a..b1b802a5506 100644 --- a/src/cmake/cpu.cmake +++ b/src/cmake/cpu.cmake @@ -21,6 +21,31 @@ macro(set_log2_cacheline_size var n) endif() endmacro() +############################################################################## +# Platform selection +############################################################################## + +if(DEFINED VPP_PLATFORM AND VPP_PLATFORM STREQUAL "default") + unset(VPP_PLATFORM) + unset(VPP_PLATFORM CACHE) + set(VPP_PLATFORM_NAME "default") +elseif(DEFINED VPP_PLATFORM) + set(platform_file ${CMAKE_CURRENT_LIST_DIR}/platform/${VPP_PLATFORM}.cmake) + if(NOT EXISTS ${platform_file}) + message(FATAL_ERROR "unknown platform ${VPP_PLATFORM}") + endif() + include(${platform_file}) + set(VPP_PLATFORM_NAME ${VPP_PLATFORM}) +else() + set(VPP_PLATFORM_NAME "default") +endif() + +if (DEFINED VPP_PLATFORM_C_COMPILER_NAMES) + set(CMAKE_C_COMPILER_NAMES ${VPP_PLATFORM_C_COMPILER_NAME}) +else() + set(CMAKE_C_COMPILER_NAMES clang gcc cc) +endif() + ############################################################################## # Cache line size ##############################################################################