You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The generated files related to workspaces for CMake are not using the actual targets that CMake creates but the imported ones from the editable packages (that points to the files that the actual target is generating). This creates a kind of frankenstein-project that works, but it would fail if the dependencies are in the wrong order, and it cannot take the advantages of having the full project modeled by CMake.
Proposal: workspace command can generate all the files needed for the workspace:
root CMakeLists.txt:
cmake_minimum_required(VERSION 3.10)
project(workspace LANGUAGES CXX)
include("${CMAKE_CURRENT_SOURCE_DIR}/conanbuildinfo.cmake")
conan_basic_setup(TARGETS)
include("${CMAKE_CURRENT_SOURCE_DIR}/conanworkspace.cmake")
conanbuildinfo.cmake: this file is generated on the fly using the provided settings/configuration, but without dependencies (from an empty conanfile.txt). We want this file to keep executing the Conan magic invoked in conan_basic_setup.
conanworkspace.cmake: this file orchestrate everything related to the workspace:
cmake_minimum_required(VERSION 3.10)
# List of targets involved in the workspaceset(ws_targets "pkgA""pkgB""pkgC")
# Override functions to avoid importing existing TARGETs (or calling again Conan Magic)function(conan_basic_setup)
message("Ignored call to 'conan_basic_setup'")
endfunction()
# Do not use find_package for those packages handled within the workspacefunction(find_package)
if(NOT"${ARG0}"IN_LIST ws_targets)
# Note.- If it's been already overridden, it will recurse forever message("find_package(${ARG0})")
_find_package(${ARGV})
else()
message("find_package(${ARG0}) ignored, it is a target handled by Conan workspace")
endif()
endfunction()
# Add subdirectories for packages (like it is now) and create aliasesadd_subdirectory("sources/pkgA""build/pkgA")
add_library(pkgA::pkgA ALIAS pkgA)
add_library(CONAN_PKG::pkgA ALIAS pkgA)
Given these files, we would be creating the CMake project and all the packages included in the workspace would be actual CMake targets. Adding those aliases we guaranteed that we are able to link with the actual targets pkgA and also with CONAN_PKG::pkgA (generator cmake) and pkgA::pkgA (generator cmake_find_package)... for other genrators or packages linking with requirements using the ${CONAN_LIBS} this approach is not going to work out of the box.
Additionally, we should warn the user about packages that are in the graph but not included in the workspace because those packages are not built again and won't take into account changes of sources or libraries (but this is a different issue to be solved)
The text was updated successfully, but these errors were encountered:
The generated files related to workspaces for
CMake
are not using the actual targets that CMake creates but the imported ones from the editable packages (that points to the files that the actual target is generating). This creates a kind of frankenstein-project that works, but it would fail if the dependencies are in the wrong order, and it cannot take the advantages of having the full project modeled by CMake.Proposal:
workspace
command can generate all the files needed for the workspace:root
CMakeLists.txt
:conanbuildinfo.cmake
: this file is generated on the fly using the provided settings/configuration, but without dependencies (from an empty conanfile.txt). We want this file to keep executing the Conan magic invoked inconan_basic_setup
.conanworkspace.cmake
: this file orchestrate everything related to the workspace:Given these files, we would be creating the CMake project and all the packages included in the workspace would be actual CMake targets. Adding those aliases we guaranteed that we are able to link with the actual targets
pkgA
and also withCONAN_PKG::pkgA
(generatorcmake
) andpkgA::pkgA
(generatorcmake_find_package
)... for other genrators or packages linking with requirements using the${CONAN_LIBS}
this approach is not going to work out of the box.Additionally, we should warn the user about packages that are in the graph but not included in the workspace because those packages are not built again and won't take into account changes of sources or libraries (but this is a different issue to be solved)
The text was updated successfully, but these errors were encountered: