WIP: Trying to fix linkage issues with multi configuration generators and others#7524
WIP: Trying to fix linkage issues with multi configuration generators and others#7524Neumann-A wants to merge 72 commits intomicrosoft:masterfrom
Conversation
…d cmake style work)
Lists in generator expressions are never a good idea....
…gex to remove debug suffixes?
CMake generator expressions and lists do not play nicely and require a lot of attention to handle correctly.
For some reason cmake generates an invalid ninja build script -> made a bug report to cmake
|
TODO:
|
# Conflicts: # ports/cpprestsdk/CONTROL # ports/pybind11/CONTROL # scripts/buildsystems/vcpkg.cmake
# Conflicts: # ports/duktape/CONTROL
|
Remaining regressions:
OSX extras (no clue since/build logs are gone currently and I don't have direct acces to an osx machine):
|
|
I have added tensorflow to the CI skip list on linux because it is flaky. @dan-shaw is working independently on it to address the issues. In the future it should not show up on your failed list (after the change propagates). |
# Conflicts: # ports/duktape/CONTROL # ports/glew/vcpkg-cmake-wrapper.cmake # ports/liblas/CONTROL # ports/pcl/CONTROL # ports/qt5-base/CONTROL # ports/wavpack/CONTROL # ports/xalan-c/CONTROL # scripts/buildsystems/vcpkg.cmake
# Conflicts: # ports/arrow/CONTROL # ports/curl/CONTROL
I always mix up ARGN/ARGV
|
@Neumann-A Is this PR being worked on or changes you want to see merged? If so, it might make sense to open a new PR, otherwise we might lose track of the changes. |
|
This is still necessary for multi configuration generators like VS project files. You can live without it if you use the single configuration VS CMake integration which I personally don't like since it reruns cmake configure every time you switch configurations. |
|
Closing this PR since it seems that no progress is being made. Please reopen if work is still being done. |
Long story short see #5543
Trying to find the problems with the changes here ;) (code still requires a lot of cleanup)
The Problem
Multi configuration generators are not able to setup CMAKE_PREFIX_PATH in a way that allows proper finding of release/debug libraries if the library is not named differently in the debug build (limitations of cmakes find_library call) or vcpkg does not "correctly" name the debug library as cmake users would expect them to be. As such multi configuration generators are currently broken with vcpkg if the consumed library is not found by a <package>config.cmake or have the cmake expected naming.
Alternative solution
Provide vcpkg_cmake_wrapper.cmake for every affect library (however many that might be)
What did not work (e.g. #5543)
Lets start with what does not work: (either after find_package or after find_library)
Main failure reason: code expects a single filepath in the variable. Generator expressions work roughly 95% of the time but there are limitations like IF(EXISTS), setting the IMPORT_LOCATION or CMAKE_REQUIRED_LIBRARIES for function signature checks.
How does this solution work
Since fixing variables cannot be done in the search/find stage we have to fix the paths in the link stage/setup stage.
Explained in steps:
a) Use the search names to search explicitly in the release and debug folder (also includes a search with and without common debug suffixes)
b) setup cache variables
VCPKG_LIBTRACK_<libname_rel>_RELEASE,VCPKG_LIBTRACK_<libname_dbg>_RELEASE,VCPKG_LIBTRACK_<libname_dbg>_DEBUG,VCPKG_LIBTRACK_<libname_rel>_DEBUGto point to the expected pathsc) return the appropriate filepath depending on the given variable name
_RELEASE/_DEBUGorCMAKE_BUILD_TYPEd) if c) is inconclusive return whatever the initial find_library call found (current behavior)
a) check
(IMPORTED|IMPLIB)_LOCATION_(RELEASE|DEBUG)for correctnessb) if only
(IMPORTED|IMPLIB)_LOCATIONis set. Setup(IMPORTED|IMPLIB)_LOCATION_(RELEASE|DEBUG)usingVCPKG_LIBTRACK_<libname>_(RELEASE|DEBUG)c) if any required
VCPKG_LIBTRACK_variable cannot be found -> ERRORa) scan list for paths prefixed in the vcpkg directory -> if not prefixed do nothing else go to b)
b) check if the element before the prefixed path is a keyword (debug|optimized|general) -> check path (should be correct; error otherwise)
c) if no keyword replace the path with one including keywords and paths to the debug and release version of the library using
VCPKG_LIBTRACK_<libname>_(RELEASE|DEBUG)Possible problems
In 3a) 3b): If the library names in debug/release are not following common conventions there might be problems in setting up
VCPKG_LIBTRACK_<libname>_(RELEASE|DEBUG).Other Benefits
Since 3a) searches with and without common debug suffixes the library naming is not that important and common debug suffixes might be dropped or added to libraries as VCPKG likes to do it (no cmake "blessed" lib names).
How to merge this PR in the future
Split it up in three different PRs: