sony / nmos-cpp

An NMOS (Networked Media Open Specifications) Registry and Node in C++ (IS-04, IS-05)
Apache License 2.0
136 stars 80 forks source link

Conan 2 #373

Closed garethsb closed 4 months ago

garethsb commented 4 months ago
garethsb commented 4 months ago

Noticed while I was updating CI and documentation that at the moment, the Dependencies doc says:

Install a DNS Service Discovery implementation, since this isn't currently handled by Conan

That isn't true - hasn't been true for a long time now. However, we haven't changed this because the required library is different on Windows (mDNSResponder) than on Linux (Avahi or mDNSResponder), and that can't be expressed in a simple conanfile.txt. It would be good to improve this, as it would simplify the build even further. We could adopt the CCI conanfile.py which expresses the necessary logic.

garethsb commented 4 months ago

Not sure whether we want to note anywhere what a user will experience if they are not ready for the migration, which requires:

If they try to use previous cmake command without -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES, or if they do not have CMake 3.24 or higher (e.g. CMake 3.20 supplied with Visual Studio 2019) so the CMAKE_PROJECT_TOP_LEVEL_INCLUDES will just be ignored, they'll get this error from find_package(Boost).

cmake .. -DCMAKE_CONFIGURATION_TYPES="Debug;Release"
-- Building for: Visual Studio 16 2019
...
CMake Error at C:/Program Files/CMake/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find Boost (missing: Boost_INCLUDE_DIR system date_time regex
  thread) (Required is at least version "1.54.0")
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files/CMake/share/cmake-3.28/Modules/FindBoost.cmake:2393 (find_package_handle_standard_args)
  cmake/NmosCppDependencies.cmake:19 (find_package)
  CMakeLists.txt:21 (include)

-- Configuring incomplete, errors occurred!

If they have conan 1.X but do use the new cmake command, they'll get an error message telling them they need Conan 2.0.5 or higher.

cmake .. -DCMAKE_CONFIGURATION_TYPES="Debug;Release" -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES="third_party/cmake/conan_provider.cmake"
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19045.
WARN: Migration: Updating settings.yml
CMake Error at third_party/cmake/conan_provider.cmake:487 (message):
  CMake-Conan: Conan version must be 2.0.5 or later
Call Stack (most recent call first):
  third_party/cmake/conan_provider.cmake:516 (conan_version_check)
  cmake/NmosCppDependencies.cmake:19 (find_package)
  CMakeLists.txt:21 (include)

-- Configuring incomplete, errors occurred!
lo-simon commented 4 months ago

How about under the Recent Activity, we extend and bold the wording Update to Conan 2; Conan 1.X is no longer supported with a MUST and otherwise you will get error.

garethsb commented 4 months ago

I've started investigating how to use Conan 2 with earlier versions of CMake, by manually running conan install and passing a generated preset/toolchain to CMake.

Approximately...

mkdir build
cd build
conan install .. -g CMakeToolchain --settings:all build_type=Release --build=missing --output-folder=conan
conan install .. -g CMakeToolchain --settings:all build_type=Debug --build=missing --output-folder=conan

then either... (hmm, this doesn't work because the generated CMakePresets.json is in the build/conan directory not the source directory)

cmake .. --preset conan-default -DCMAKE_CONFIGURATION_TYPES="Debug;Release"

or... (this does seem to work...)

cmake .. -G "Visual Studio 16 2019" -DCMAKE_TOOLCHAIN_FILE=conan/conan_toolchain.cmake -DCMAKE_CONFIGURATION_TYPES="Debug;Release"