I’d be curious if there are edge cases that challenge that advice. As an aside, pretty much every time CMakeLists.txt or reusable CMake modules start manipulating these variables, they lose portability, gain complexity, or both.Īnyway, CMAKE_INSTALL_PREFIX seems to mostly work a lot of the time, but I’m currently convinced that it has been sufficiently surpassed by other mechanisms at this point to just stop using it full-stop. Ideally in a mechanism like a CMake toolchain file of maybe a CMake preset to keep your logic consistent, reusable, and tidy. Usually you (or at least consumers of your project!) really want to directly manipulate CMAKE_PREFIX_PATH or CMAKE_SYSTEM_PREFIX_PATH to alter configure-time logic. Now, invoke CMake to configuration its build, passing CMAKEINSTALLPREFIX to instruct CMake to use the passed directory as its installation location instead of the current directory. Import your targets inside your Config. By using the NAMESPACE argument, we tell CMake to prepend the prefix JSONUtils:: to all targets imported. I think the fact that CMAKE_INSTALL_PREFIX affects configure-time logic just reinforces that position. This will install the import script JSONUtilsTargets.cmake that, when included in other scripts, will load the targets defined in the export jsonutils-export. The -prefix argument to cmake -install is generally the best way to set an installation prefix because it lets you decouple install-time requirements from your configuration logic.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |