conan icon indicating copy to clipboard operation
conan copied to clipboard

feat: Add CONAN_RUNTIME_LIB_DIRS to the conan_toolchain.cmake

Open ErniGH opened this issue 11 months ago • 2 comments

Changelog: Feature: Add CONAN_RUNTIME_LIB_DIRS variable to the conan_toolchain.cmake Docs: https://github.com/conan-io/docs/pull/3698

Close: #15810

ErniGH avatar Mar 21 '24 17:03 ErniGH

I still think that it would be important to make CONAN_RUNTIME_LIB_DIRS a generator expression for multi-config systems, or at least a _RELEASE, _DEBUG one. There is risk of bringing the wrong runtime just because -s build_type=Debug was executed last.

indeed! This was a further step - we first need to check whether the file(GET_RUNTIME_DEPENDENCIES ...) functionality accepts a generator expression - probably works during install, but unsure about configure time

jcar87 avatar Apr 09 '24 09:04 jcar87

The changes in this PR cause a warning to be issued:

CMake Warning (dev) at build/generators/conan_toolchain.cmake:106:
  Syntax Warning in cmake code at column 213

  Argument not separated from preceding token by whitespace.
Call Stack (most recent call first):
  build/CMakeFiles/3.27.4/CMakeSystem.cmake:6 (include)
  CMakeLists.txt:3 (project)

I can get it to not show that warning by doing semi-colon ; separated lists inside the generator expression, rather than space separated. However, then it doesn't work

The cmake_install.cmake file then generates something like this:

  elseif(CMAKE_INSTALL_CONFIG_NAME MATCHES "^([Rr][Ee][Ll][Ee][Aa][Ss][Ee])$")
    file(GET_RUNTIME_DEPENDENCIES
      RESOLVED_DEPENDENCIES_VAR _CMAKE_DEPS
      EXECUTABLES
        "C:/Users/xxx/conan-cmake-install-runtime-dependencies/build/Release/my_app.exe"
      DIRECTORIES
        "\$<1:\"C:/Users/xxx/.conan2/p/b/libpn0bfb1d18b1c7b/p/bin"
        "C:/Users/xxx/.conan2/p/zlib47a1fa7d4bdbe/p/bin"
        "C:/Users/xxx/.conan2/p/gtestd45050d57d0d9/p/bin\">\$<0:\"C:/Users/xxx/.conan2/p/b/libpn185873a63e4d5/p/bin"
        "C:/Users/xxx/.conan2/p/b/zlib00e783ae4582e/p/bin"
        "C:/Users/xxx/.conan2/p/b/gtest2d6a2ca931073/p/bin\">"

the 0 and the 1 in the generator expression here seems correct in the sense that it matches the configuration in the generated file - but something is off and it doesn't seem that cmake is picking up the correct directories because the install command then fails. Using this https://github.com/jcar87/conan-cmake-install-runtime-dependencies as a test project on windows

jcar87 avatar Apr 29 '24 10:04 jcar87