Vcpkg: New port (DPDK): help needed

Created on 15 Feb 2019  路  5Comments  路  Source: microsoft/vcpkg

I would like to add a port. Being relatively new to vcpkg ports and no way expert in CMake I have a couple of questions.
1) how do I prevent package to even start trying to install on unsupported platforms? I saw some ports being downloaded, configured, and failed during the build simply because the port cant build on Linux. Check current platform/architecture and issue error message before starting the download of the source package?
2) Configured, built, installed not CMake project, then what? Should I create FindMyPackage.cmake to function properly? otherwise I dont see how CMake would find my headers/libs
3) Didnt find any option to execute command (VCPKG_EXECUTE_REQUIRED_PROCESS/execute_process) which contains double quotes. Found myself writing command to a file and then executing it. Example:

FILE(WRITE tmp/build_debug.sh "make config T=x86_64-native-linuxapp-gcc\nmake -j ${PROCS} -C \"${SOURCE_PATH}\" MAKEFLAGS=\"T=x86_64-native-linuxapp-gcc -j ${PROCS}\"")
FILE(COPY tmp/build_debug.sh DESTINATION ./ FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
     )
FILE(REMOVE tmp/build_debug.sh)

4) the package (DPDK) is very rich configuration-wise, multiple modules may be built or skipped during the build, what is the best practice in vcpkg? buld minimum? all features? just the default project settings, whatever it builds? how the end user controls what and how (compiler settings) will be build during install?
5) Linux stuff, how do I check if certain package is installed on the system? like, I need nasm how do I ensure that? sure I can execute some bash command and check with package manager it it there, but is this the way in the vcpkg?

I know, lot of questions, but let me assure you, more to come :)

new-port question

Most helpful comment

Hi @kreuzerkrieg,

Thanks for the enthusiasm in adding a new port!
Porting DPDK will be a huge endeavor for sure; and DPDK would benefit in adding full CMake support upstream.

Regarding your questions:

  1. You can check the variables set in each triplet to only support specific platforms/architectures (triplets docs)

For example, here are the contents of triplets/x64-linux.cmake:

set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)

set(VCPKG_CMAKE_SYSTEM_NAME Linux)

An example of disallowing a platform can be found in ports/pthreads/portfile.cmake.
Where the following condition is added at the very beginning of the portfile.

if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
  message(FATAL_ERROR "${PORT} does not currently support UWP")
endif()
  1. Here's the documentation of how CMake finds installed packages, in short, the library needs to provide at the very least a <package_name>Config.cmake file, others file that may also be needed are: <package_name>ConfigVersion.cmake and <package_name>Targets.cmake; these are usually generated by CMake after configuring and installing from a CMakeLists.txt file.
    I don't know if you could just write a findDPDK.cmake (I'm not very experienced with CMake myself), maybe @ras0219-msft could provide some input here.

  2. Hmm, I'm not sure if it is possible... I would try to search usages of vcpkg_execute_required_process() in the whole repository to see if I can find an example or look at the source code of that function. If it is not supported then feel free to file an issue.

  3. Vcpkg follows an incremental philosophy, so adding a working port is better than not having it at all. Now, for what should be installed with the package; I would strongly recommend adding the features that would support the majority of use cases for the users of the library. I don't know the specifics of DPDK to make that judgement, but maybe the default installation is a good starting point.

Configuration can be added in following PRs, using features, similar to what has been done with boost, or other similarly feature-rich highly-customizable libraries.

  1. There's a function to find and acquire such programs conveniently called vcpkg_find_acquire_program().

Hope this helps!

All 5 comments

Hi @kreuzerkrieg,

Thanks for the enthusiasm in adding a new port!
Porting DPDK will be a huge endeavor for sure; and DPDK would benefit in adding full CMake support upstream.

Regarding your questions:

  1. You can check the variables set in each triplet to only support specific platforms/architectures (triplets docs)

For example, here are the contents of triplets/x64-linux.cmake:

set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)

set(VCPKG_CMAKE_SYSTEM_NAME Linux)

An example of disallowing a platform can be found in ports/pthreads/portfile.cmake.
Where the following condition is added at the very beginning of the portfile.

if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
  message(FATAL_ERROR "${PORT} does not currently support UWP")
endif()
  1. Here's the documentation of how CMake finds installed packages, in short, the library needs to provide at the very least a <package_name>Config.cmake file, others file that may also be needed are: <package_name>ConfigVersion.cmake and <package_name>Targets.cmake; these are usually generated by CMake after configuring and installing from a CMakeLists.txt file.
    I don't know if you could just write a findDPDK.cmake (I'm not very experienced with CMake myself), maybe @ras0219-msft could provide some input here.

  2. Hmm, I'm not sure if it is possible... I would try to search usages of vcpkg_execute_required_process() in the whole repository to see if I can find an example or look at the source code of that function. If it is not supported then feel free to file an issue.

  3. Vcpkg follows an incremental philosophy, so adding a working port is better than not having it at all. Now, for what should be installed with the package; I would strongly recommend adding the features that would support the majority of use cases for the users of the library. I don't know the specifics of DPDK to make that judgement, but maybe the default installation is a good starting point.

Configuration can be added in following PRs, using features, similar to what has been done with boost, or other similarly feature-rich highly-customizable libraries.

  1. There's a function to find and acquire such programs conveniently called vcpkg_find_acquire_program().

Hope this helps!

Hi @vicroms ,
Thanks for the input! looks like that a lot of work ahead, lets get the work done! :)

Ok, since CMake cant export imported libraries (see issue 14311) I have no idea how to export build artifacts the way it will reflect in *-config.cmake and *-target.cmake
The attempt can be seen here. Any help on how to do that will be appreciated

Ok, there is RFC PR, go ahead and check it out

resolved by #5388

Was this page helpful?
0 / 5 - 0 ratings

Related issues

husseinalihazime picture husseinalihazime  路  3Comments

cjvaijo picture cjvaijo  路  3Comments

angelmixu picture angelmixu  路  3Comments

pkeir picture pkeir  路  3Comments

tzbo picture tzbo  路  3Comments