Skip to content

cmake: bump policy_max, add FATAL_ERROR for old cmake versions - #1510

Closed
vszakats wants to merge 1 commit into
libssh2:masterfrom
vszakats:cm-bump-version
Closed

vszakats wants to merge 1 commit into
libssh2:masterfrom
vszakats:cm-bump-version

Conversation

@vszakats

@vszakats vszakats commented Jan 4, 2025

Copy link
Copy Markdown
Member

No description provided.

@vszakats vszakats added the build label Jan 4, 2025
@vszakats
vszakats force-pushed the cm-bump-version branch 2 times, most recently from 1759145 to 6cf330e Compare January 5, 2025 00:39
@vszakats
vszakats force-pushed the cm-bump-version branch 3 times, most recently from cb4fd5f to 66b3193 Compare January 29, 2025 01:51
vszakats added a commit to vszakats/libssh2 that referenced this pull request Jan 29, 2025
For no apparent reason it broke when trying to silence a CMake
deprecation warning in libssh2#1510. Then when testes locally, it did not
work either with or without the patch in libssh2#1510.

I'm not sure, but existing implementation likely worked by accident
by re-using leftovers from the preceding two integration tests.

After spending a few full days trying to fix this, I declare defeat.
If such amount of time of testing, reading documentation, blog posts,
variable traces, logs, bug reports is not enough to make this work, or
even to understand how this is supposed to work, this seems like a lost
cause.

CMake makes it impossible to cleanly query the properties of a target,
which would be essential for debugging. There are rough workarounds
with many years of iteration, and those still don't work to this day:
https://stackoverflow.com/questions/32183975/how-to-print-all-the-properties-of-a-target-in-cmake

Copy-pasting an incantation from a blog post that made this work:
https://inhzus.io/posts/2023-12-01-cmake-external-project/
almost made it work, except that it had a workaround for a 10-year old
pending bug, another workaround for Ninja which required CMake 3.29, had
many things hard-wired, and explicitly configured in weird ways. But, it
still missed to pass the libssh2 library to the test target and failed
to link.

Then tried to pass the libssh2 lib the "usual" way via:
```
target_link_libraries(test PRIVATE libssh2)
```

That also did not work because CMake decided that the external libssh2
target is of "UTILITY" type, and errored with this:
```
CMake Error at CMakeLists.txt:39 (target_link_libraries):
  Target "libssh2" of type UTILITY may not be linked into another target.
  One may link only to INTERFACE, OBJECT, STATIC or SHARED libraries, or to
  executables with the ENABLE_EXPORTS property set.
```

This type property is read-only, and documentation has no mention of it,
or how to set it whatsoever:
https://cmake.org/cmake/help/latest/module/ExternalProject.html
vszakats added a commit to vszakats/libssh2 that referenced this pull request Jan 29, 2025
For no apparent reason it broke when trying to silence a CMake
deprecation warning in libssh2#1510. Then when testes locally, it did not
work either with or without the patch in libssh2#1510.

I'm not sure, but existing implementation likely worked by accident
by re-using leftovers from the preceding two integration tests.

After spending a few full days trying to fix this, I declare defeat.
If such amount of time of testing, reading documentation, blog posts,
variable traces, logs, bug reports is not enough to make this work, or
even to understand how this is supposed to work, this seems like a lost
cause.

CMake makes it impossible to cleanly query the properties of a target,
which would be essential for debugging. There are rough workarounds
with many years of iteration, and those still don't work to this day:
https://stackoverflow.com/questions/32183975/how-to-print-all-the-properties-of-a-target-in-cmake

Copy-pasting an incantation from a blog post that made this work:
https://inhzus.io/posts/2023-12-01-cmake-external-project/
almost made it work, except that it had a workaround for a 10-year old
pending bug, another workaround for Ninja which required CMake 3.29, had
many things hard-wired, and explicitly configured in weird ways. But, it
still missed to pass the libssh2 library to the test target and failed
to link.

Then tried to pass the libssh2 lib the "usual" way via:
```
target_link_libraries(test PRIVATE libssh2)
```

That also did not work because CMake decided that the external libssh2
target is of "UTILITY" type, and errored with this:
```
CMake Error at CMakeLists.txt:39 (target_link_libraries):
  Target "libssh2" of type UTILITY may not be linked into another target.
  One may link only to INTERFACE, OBJECT, STATIC or SHARED libraries, or to
  executables with the ENABLE_EXPORTS property set.
```

This type property is read-only, and documentation has no mention of it,
or how to set it whatsoever:
https://cmake.org/cmake/help/latest/module/ExternalProject.html

libssh2's `docs/INSTALL_CMAKE.md` mentions ExternalProject as a way to
use libssh2. Added there with the initial CMake commit. It probably
should be deleted from there.
vszakats added a commit to vszakats/libssh2 that referenced this pull request Jan 29, 2025
For no apparent reason it broke when trying to silence a CMake
deprecation warning in libssh2#1510. Then when testes locally, it did not
work either with or without the patch in libssh2#1510.

I'm not sure, but existing implementation likely worked by accident
by re-using leftovers from the preceding two integration tests.

After spending a few full days trying to fix this, I declare defeat.
If such amount of time of testing, reading documentation, blog posts,
variable traces, logs, bug reports is not enough to make this work, or
even to understand how this is supposed to work, this seems like a lost
cause.

CMake makes it impossible to cleanly query the properties of a target,
which would be essential for debugging. There are rough workarounds
with many years of iteration, and those still don't work to this day:
https://stackoverflow.com/questions/32183975/how-to-print-all-the-properties-of-a-target-in-cmake

Copy-pasting an incantation from a blog post that made this work:
https://inhzus.io/posts/2023-12-01-cmake-external-project/
almost made it work, except that it had a workaround for a 10-year old
pending bug, another workaround for Ninja which required CMake 3.29, had
many things hard-wired, and explicitly configured in weird ways. But, it
still missed to pass the libssh2 library to the test target and failed
to link.

Then tried to pass the libssh2 lib the "usual" way via:
```
target_link_libraries(test PRIVATE libssh2)
```

That also did not work because CMake decided that the external libssh2
target is of "UTILITY" type, and errored with this:
```
CMake Error at CMakeLists.txt:39 (target_link_libraries):
  Target "libssh2" of type UTILITY may not be linked into another target.
  One may link only to INTERFACE, OBJECT, STATIC or SHARED libraries, or to
  executables with the ENABLE_EXPORTS property set.
```

This type property is read-only, and documentation has no mention of it,
or how to set it whatsoever:
https://cmake.org/cmake/help/latest/module/ExternalProject.html

libssh2's `docs/INSTALL_CMAKE.md` mentions ExternalProject as a way to
use libssh2. Added there with the initial CMake commit. It probably
should be deleted from there.

This consumption method has a single mention in public issues:
libssh2#1116
vszakats added a commit to vszakats/libssh2 that referenced this pull request Jan 29, 2025
For no reason it broke when trying to silence a CMake deprecation
warning in libssh2#1510. Then when tested locally, it did not work either with
or without the patch in libssh2#1510.

I'm not sure, but existing implementation may have worked by accident
by re-using leftovers from the preceding two integration tests.

After spending a days trying to fix this, I declare defeat. If such
amount of time of testing, reading documentation, blog posts, variable
traces, logs, bug reports is not enough to make this work, or even
to understand how this should work, this seems like a lost cause.

CMake makes it impossible to cleanly query the properties of a target,
which would be essential for debugging. There are rough workarounds
with years of iteration, and those still don't work to this day:
https://stackoverflow.com/questions/32183975/how-to-print-all-the-properties-of-a-target-in-cmake

Copy-pasting an incantation from a blog post that made this work:
https://inhzus.io/posts/2023-12-01-cmake-external-project/
almost made it work, except that it had a workaround for a 10-year old
pending bug, another workaround for Ninja which required CMake 3.29,
with settings hard-wired, and explicitly configured in weird ways. But,
it still missed to pass the libssh2 library to the test target and
failed to link.

Then tried to pass the libssh2 lib the "usual" way via:
```
target_link_libraries(test PRIVATE libssh2)
```

That also did not work because CMake decided that the external libssh2
target is of "UTILITY" type, and errored with:
```
CMake Error at CMakeLists.txt:39 (target_link_libraries):
  Target "libssh2" of type UTILITY may not be linked into another target.
  One may link only to INTERFACE, OBJECT, STATIC or SHARED libraries, or to
  executables with the ENABLE_EXPORTS property set.
```

This type property is read-only, and documentation has no mention of it,
or how to set it whatsoever:
https://cmake.org/cmake/help/latest/module/ExternalProject.html

libssh2's `docs/INSTALL_CMAKE.md` mentions ExternalProject as a way to
use libssh2. Added there with the initial CMake commit. We should
probably delete it from there.

This consumption method has a single mention in public issues:
libssh2#1116

Closes libssh2#1522
```
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.
Call Stack (most recent call first):
  /Users/runner/work/apothecary/apothecary/apothecary/build/curl/build_osx_MAC/CMakeFiles/3.31.0/CMakeSystem.cmake:6 (include)
  /Users/runner/work/apothecary/apothecary/apothecary/build/curl/build_osx_MAC/CMakeFiles/CMakeScratch/TryCompile-tyvpOc/CMakeLists.txt:5 (project)
```
@vszakats vszakats closed this in 717c083 Jan 29, 2025
@vszakats
vszakats deleted the cm-bump-version branch January 29, 2025 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant