cmake icon indicating copy to clipboard operation
cmake copied to clipboard

drop REQUIRED from all find_package

Open marakew opened this issue 2 years ago • 8 comments

can you please drop it let rewrite it by CMAKE_DISABLE_FIND_PACKAGE_<NAME> thanks

marakew avatar Jan 08 '23 00:01 marakew

What specific problem are you having?

pdimov avatar Jan 08 '23 01:01 pdimov

i want set manual external library instead use find_package

as example set(CMAKE_DISABLE_FIND_PACKAGE_ZLIB 1) set(ZLIB_FOUND 1) add_library(ZLIB::ZLIB UNKNOWN IMPORTED) ...etc

but with REQUIRED keyword i got always fail to processing cmake

marakew avatar Jan 08 '23 17:01 marakew

Does this refer to a Boost built with b2 or to one built with CMake?

pdimov avatar Jan 08 '23 17:01 pdimov

If with CMake, the config files don't use find_package or REQUIRED; they use find_dependency (e.g. find_dependency(ZLIB). This macro automatically sets QUIET or REQUIRED to match the parent find_package call. So if you call find_package(boost_iostreams REQUIRED), it will invoke find_package(ZLIB REQUIRED), but if you call find_package(boost_iostreams), it will invoke find_package(ZLIB). This is standard CMake behavior.

pdimov avatar Jan 08 '23 17:01 pdimov

Opened a CMake issue about this at https://gitlab.kitware.com/cmake/cmake/-/issues/24293.

pdimov avatar Jan 08 '23 18:01 pdimov

you seems dont understand me i don't want use find_package at all i want rewrite it by my own infrastructure with REQUIRED in boost it will impossible

my above example will work it REQUIRED will drop from find_package and users will able to rewrite by own env settings without using find_package for searching

2023-01-08 19:57 GMT+02:00, Peter Dimov @.***>:

If with CMake, the config files don't use find_package or REQUIRED; they use find_dependency (e.g. find_dependency(ZLIB). This macro automatically sets QUIET or REQUIRED to match the parent find_package call. So if you call find_package(boost_iostreams REQUIRED), it will invoke find_package(ZLIB REQUIRED), but if you call find_package(boost_iostreams), it will invoke find_package(ZLIB). This is standard CMake behavior.

-- Reply to this email directly or view it on GitHub: https://github.com/boostorg/cmake/issues/34#issuecomment-1374891778 You are receiving this because you authored the thread.

Message ID: @.***>

marakew avatar Jan 08 '23 18:01 marakew

So, your complaint is not about find_dependency(ZLIB) in the installed CMake config files, but (for example) about this use of find_package:

https://github.com/boostorg/iostreams/blob/d1c1114a611afb090a007c9ff3e94efbcb914ef3/CMakeLists.txt#L30

pdimov avatar Jan 08 '23 23:01 pdimov

yes and all another "required" with may present or will present in boost/cmake infrastructure just remove it to allow users ovewrite by own libs settings

2023-01-09 1:25 GMT+02:00, Peter Dimov @.***>:

So, your complaint is not above find_dependency(ZLIB) in the installed CMake config files, but (for example) about this use of find_package:

https://github.com/boostorg/iostreams/blob/d1c1114a611afb090a007c9ff3e94efbcb914ef3/CMakeLists.txt#L30

-- Reply to this email directly or view it on GitHub: https://github.com/boostorg/cmake/issues/34#issuecomment-1374958322 You are receiving this because you authored the thread.

Message ID: @.***>

marakew avatar Jan 09 '23 21:01 marakew