![]() If I then use that 3rd-party CMake module in my CMake code and there I just do a simple install( TARGETS my_target. Because it prevents the following use-case (I was trying to explain above):Īssume that from some 3rd-party CMake module you get some functionality which conditionally uses a newer CMake feature if the used cmake version is new enough, e.g. So, for cmake_minumum_required( VERSION min.max ) there is no way to determine max (especially if CMAKE_VERSION is newer than max)!? Instead, they use the new features (and set the policies to NEW where needed for such things for itself). Think of it this way: if CMake locked its features behind minimum CMake declarations, then CMake’s own modules would “never” be able to use new features. Conditionals to do other things if better replacements are available are still possible. It more says that “this project requires 3.20 to work at all, but it knows about 3.22 and is OK with policies added to that point”. Which pretty much says that my code is not supposed to know and therefore not use the FILE_SET featureĮh. (Maybe I am just blind and overlooked the correct CMake variable but I was unable to find it.) So, is it somehow possibly to honor the chosen CMake (compatibility) version and not use a feature that comes from a later CMake version (even if using an up-to-date cmake executable)? However, it obviously does not work this way and CMake gives me an error “ install TARGETS target my_target is exported but not all of its file sets are installed”. ) without installing the FILE_SET - I thought I could prevent choosing this half-implemented execution path by using the above if. (Assume above code snippet comes from some 3rd-party CMake module into my CMake code.)Īs my implementation was not entirely done - I was still using install( TARGETS. However, I noticed even if I am using cmake_minimum_required( VERSION 3.20.3.22 ), which pretty much says that my code is not supposed to know and therefore not use the FILE_SET feature, the value of CMAKE_VERSION still shows the real version of the cmake executable and therefore the first branch from the above if would be chosen. ![]() Target_sources( my_target PUBLIC FILE_SET. And in general it works, as CMAKE_VERSION gives me back the version of the cmake executable: if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.23") I thought I could just check for CMAKE_VERSION to determine if the FILE_SET feature is available and then use it. I am trying to extend my CMake project with (optional) support for the new FILE_SET feature introduced with CMake 3.23. ![]() Tl dr Is there any way to determine the existence of a CMake feature if it does not have a policy?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |