-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
szip: conan v2 support #13551
szip: conan v2 support #13551
Conversation
This comment has been minimized.
This comment has been minimized.
Hooks produced the following warnings for commit 49a83d9szip/2.1.1
|
This comment has been minimized.
This comment has been minimized.
Hooks produced the following warnings for commit a11570cszip/2.1.1
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same feedback as the question on Slack and the issue you created :)
e6dceb8
to
0c395e5
Compare
I've fixed things up and squashed the commits so the diff is more straight forward. |
This comment has been minimized.
This comment has been minimized.
I have no idea why the static build works fine, but the shared build fails -- the test can't find the header file... |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
installing this from scratch... I noticed the shared export is missing a public definition
set_target_properties(szip-shared PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "SZ_BUILT_AS_DYNAMIC_LIB=1"
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
INTERFACE_LINK_LIBRARIES "m"
)
full cmake for reference
cat /home/cmcarthur/szip-2.1.1/./share/cmake/szip-targets.cmake
# Generated by CMake
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.6)
message(FATAL_ERROR "CMake >= 2.6.0 required")
endif()
cmake_policy(PUSH)
cmake_policy(VERSION 2.6...3.20)
#----------------------------------------------------------------
# Generated CMake target import file.
#----------------------------------------------------------------
# Commands may need to know the format version.
set(CMAKE_IMPORT_FILE_VERSION 1)
# Protect against multiple inclusion, which would fail when already imported targets are added once more.
set(_targetsDefined)
set(_targetsNotDefined)
set(_expectedTargets)
foreach(_expectedTarget szip-static szip-shared)
list(APPEND _expectedTargets ${_expectedTarget})
if(NOT TARGET ${_expectedTarget})
list(APPEND _targetsNotDefined ${_expectedTarget})
endif()
if(TARGET ${_expectedTarget})
list(APPEND _targetsDefined ${_expectedTarget})
endif()
endforeach()
if("${_targetsDefined}" STREQUAL "${_expectedTargets}")
unset(_targetsDefined)
unset(_targetsNotDefined)
unset(_expectedTargets)
set(CMAKE_IMPORT_FILE_VERSION)
cmake_policy(POP)
return()
endif()
if(NOT "${_targetsDefined}" STREQUAL "")
message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n")
endif()
unset(_targetsDefined)
unset(_targetsNotDefined)
unset(_expectedTargets)
# Compute the installation prefix relative to this file.
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
if(_IMPORT_PREFIX STREQUAL "/")
set(_IMPORT_PREFIX "")
endif()
# Create imported target szip-static
add_library(szip-static STATIC IMPORTED)
set_target_properties(szip-static PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
INTERFACE_LINK_LIBRARIES "m"
)
# Create imported target szip-shared
add_library(szip-shared SHARED IMPORTED)
set_target_properties(szip-shared PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "SZ_BUILT_AS_DYNAMIC_LIB=1"
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
INTERFACE_LINK_LIBRARIES "m"
)
if(CMAKE_VERSION VERSION_LESS 2.8.12)
message(FATAL_ERROR "This file relies on consumers using CMake 2.8.12 or greater.")
endif()
# Load information for each installed configuration.
get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
file(GLOB CONFIG_FILES "${_DIR}/szip-targets-*.cmake")
foreach(f ${CONFIG_FILES})
include(${f})
endforeach()
# Cleanup temporary variables.
set(_IMPORT_PREFIX)
# Loop over all imported files and verify that they actually exist
foreach(target ${_IMPORT_CHECK_TARGETS} )
foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )
if(NOT EXISTS "${file}" )
message(FATAL_ERROR "The imported target \"${target}\" references the file
\"${file}\"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
\"${CMAKE_CURRENT_LIST_FILE}\"
but not all the files it references.
")
endif()
endforeach()
unset(_IMPORT_CHECK_FILES_FOR_${target})
endforeach()
unset(_IMPORT_CHECK_TARGETS)
# This file does not depend on other imported targets which have
# been exported from the same project but in a separate export set.
# Commands beyond this point should not need to know the version.
set(CMAKE_IMPORT_FILE_VERSION)
cmake_policy(POP)
Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
This comment has been minimized.
This comment has been minimized.
Great eyes, thanks, I've added it |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Some kind of cross-compile problem?
And then the error is:
The recipe used |
… like cross-building mac -> mac arm
@paulharris if downstream projects are not using the correct CMake targets we should open PRs to help them improve their CMake as for the variables being the wrong casing there are cases thats also true the openssl recipes has some examples for adding it for the new generators as well (sorry for the spam) |
This comment has been minimized.
This comment has been minimized.
This is what drives me to the edge, I just want to get it working and move back to my own work! |
Including legacy finders. See new target_legacy_package and target_v1_legacy_package
I've done that in the past. HDF5 in particular is active, and there are some recent github issues related to their cmake. and, if we aim to support the older versions of HDF5, etc, we still need this recipe to work with the older versions of that library.
More spam = more I can get some understanding. I still feel like I'm in the dark most of the time. So, how do I write package_info() if I would like to support for both Conan v2 and v1:
The first one is the only new item in the list. I'm pushing a commit that does all of these, AND adds some extra tests - I wonder if we can ask the CI to run them?
Where "legacy" refers to find_package(SZIP) and SZIP_FOUND and SZIP_LIBRARIES etc ... so that we have find_package(szip) as the primary, as per @prince-chrismc suggestion above. What needs to change? |
I can't figure it how to support ${SZIP_LIBRARIES} in test_legacy_package (ie conan v2 mode). If not, then that means the HDF5 (and other) packages will stop working during the conan v1->v2 switch. |
This comment has been minimized.
This comment has been minimized.
recipes/szip/all/conanfile.py
Outdated
tools.save(module_file, content) | ||
content += """\ | ||
set (SZIP_FOUND TRUE) | ||
set (SZIP_LIBRARIES szip::szip) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this does not exist 😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is my attempt to tackle this problem: #13551 (comment)
would appreciate some guidance ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, how do I write package_info() if I would like to support for both Conan v2 and v1:
find_package(szip CONFIG)
andtarget_link_libraries(thingy szip::szip)
(because it seems right)find_package(szip CONFIG)
andtarget_link_libraries(thingy szip-shared)
(or szip-static, depending on what was built)find_package(SZIP)
andtarget_link_libraries(thingy ${SZIP_LIBRARIES})
(support legacy)find_package(SZIP)
andtarget_link_libraries(thingy szip-shared)
(or szip-static, depending on what was built)
Out of all of these only the second one is "official"
As you've pointed out, we do not want to set the direction, szip is unmainteed AFAIK so there's no way to add to it at this point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so just patch HDF5 (and others) to link to whichever target is available with the if (TARGET szip-shared)
trick in the test_package
This is exactly why we need to match szip targets (and not HDF5's custom variables) lol -- I couldn't agree more 🤣 It's a matter of perspective, since you require HDF5 your concern is around that library, making sure it works. And that's totally okay (most likely a good thing). I don't use either of these so I have a very broad CCI contributor view -- so there's a very good middle ground to make both of us happy. I know those are bad because Conan does expose imaginary variables, there's a bunch of small issues with the old generators, relying on those is bad too. That's why we've landed on focusing on exposing the official targets. And this we agree on
We already have to patch out everything you are trying to get to work
for the oldest of the generators, so it never really worked from the Conan side.
this line needs to be fixes with the same code that's in the test packages if target ... else static stuff. (so it works in both v1 and v2).
We can not afford to add extras to szip solely for HDF5, its a dangerous slippery slope because then we'd need to add tons of wrong targets to every recipe for all the other downstream projects. It would get out of hand quickly. Take a look at the folly patches, those are horrible - we can not patch all those deps for that one project.
That's exactly why we have a What will need to happen is this needs to be updated to match szip's build script and installation. Then in the HDF5 recipe we will need the toolchain to set the values in their custom find szip module https://github.com/HDFGroup/hdf5/blob/c8fdd92cd4d53e5343b475b85c013de60ba13555/config/cmake/FindSZIP.cmake quickly searching github https://github.com/search?l=CMake&q=FindSZIP&type=Code, it's only the HDF5 project that's using this (or projects using it) so it does not make sense to expose this to everything that does not need it |
TL;DR Dont waste time in this recipe trying to fix HDF5 - there no way to "not invent/start things here first" and make HDF5 work Let's work on fixing the HDF5 recipe, with toolchains we have a lot more options about passing in values which should be more then enough to get (at least) less patches in HDF5 (and hopefully none) |
Thanks @prince-chrismc I appreciate all your work and text here. |
Thats my job to write those! This has been something on my mind for a while, but I've struggled with a title. Maybe along side #13673 I will try to bring this in 💟 |
Ok I simplified the recipe a bunch, please review. |
This comment has been minimized.
This comment has been minimized.
cmake.install() | ||
# TODO: to remove in conan v2 once cmake_find_package* generators removed | ||
self._create_cmake_module_alias_targets( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quickly this should be required for the test_v1_package
🤔
You should check the https://github.com/conan-io/conan-center-index/tree/master/docs/package_templates/cmake_package for a reference about the 2.0 migration
Theres extras in here I am not sure about
If you'd like we can do a zoom to finish this up and it will be easier to work instead of the horrible time zone gap
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chris was awesome in the zoom, and so now I'm a little bit wiser than before :)
This comment has been minimized.
This comment has been minimized.
All green in build 22 (
|
Please check the patch - there are a few questions around the targets.
The old recipe generated targets for
szip-static
andszip-shared
.It also generated an alias target for szip::szip but only for the older finders.
I want to generate the szip::szip target, and am wondering if we should continue to generate the other plain ones (and how would it be done).
Also, I get a weird error message when trying to build locally from test_package:
What does it mean and how do I fix it?