h2o / picotls

TLS 1.3 implementation in C (master supports RFC8446 as well as draft-26, -27, -28)
540 stars 143 forks source link

Loading picotls using FetchContent_MakeAvailable() fails because of fusion #392

Closed huitema closed 2 years ago

huitema commented 2 years ago

I am trying to integrate the build of picotls in the build of picoquic. The first attempt was to add lines in the CMakeFile.txt of Picoquic, such as:

  include(FetchContent)
  FetchContent_Declare(   picotls
      GIT_REPOSITORY      https://github.com/h2o/picotls.git)
  FetchContent_MakeAvailable(picotls)
  set(PTLS_INCLUDE_DIRS ${picotls_SOURCE_DIR}/include)
  set(PTLS_LIBRARIES picotls-core picotls-openssl picotls-fusion)

This works on some platforms, as long as picotls-fusion is supported, but it fails on others, such as MacOS M1, that have no support for fusion. In that case, the build will later fail.

In the current state of picoquic, without using "FetchContent", things work because picotls is entirely build, before calling cmake for picoquic. The cmake script of Picoquic will test whether the fusion library was built, and set compile flags accordingly. But I cannot use that trick here -- there is a single call for cmake of picoquic and picotls, before make itself is run. I only have a bad solution: never use "fusion" in picoquic, remove all dependencies. Works, but then, fusion is never used. Any idea on how to do that better?

kazuho commented 2 years ago

Can you access the variables being used in picotls/CMakeFiles.txt? If so, checking the value of WITH_FUSION would be the thing to do.

Otherwise, we should probably discuss building fusion on platforms other than x86-64. This can be a no-op (i.e., all callbacks of ptls_aead_algorithm_t set to NULL). I think it's bizarre to build an AEAD backend specific to x86-64 on platforms other than x86-64 (do we want to build ptls-openssl when openssl is missing?), but having an option to detect availability at runtime does provide flexibility.

huitema commented 2 years ago

Fixed by simply disabling fusion support for Windows.