CMake:Multiple versions: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
(New page: Multiple versions)
 
m (Fix minor but fatal spelling)
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
When multiple ABI-incompatible versions of libraries are installed, it is likely that existing FindXXX modules will not be able to find a version in a nonstandard location, or will find a combination of libraries that produces a broken executable.  Some will work correctly if XXX_DIR is set the first time CMake is run, but if the wrong version is found on the first pass (perhaps because the user didn't know they had to set this variable in advanced), the only way (short of manually editing a possibly huge number of advanced cache entries) to switch versions is to delete the cache and try again.
When multiple ABI-incompatible versions of libraries are installed, it is likely that existing FindXXX modules will not be able to find a version in a nonstandard location, or will find a combination of libraries that produces a broken executable.  Some will work correctly if XXX_DIR is set the first time CMake is run, but if the wrong version is found on the first pass (perhaps because the user didn't know they had to set this variable in advance), the only way (short of manually editing a possibly huge number of advanced cache entries) to switch versions is to delete the cache and try again.


A suggestion is for all packages to make all the advanced XXX_INCLUDES, XXX_LIBRARIES, ... cache entries subordinate to an XXX_DIR cache entry (which takes precedence over an XXX_DIR environment variable.  When XXX_DIR is set, it should take precedence over system search paths (i.e. must use HINTS because PATHS is searched [http://public.kitware.com/Bug/view.php?id=8035 too late]).  If XXX_DIR is changed, the advanced entries should be recomputed.  CMake currently makes this awkward, but the [http://github.com/jedbrown/cmake-modules/tree/master/FindPackageMultipass.cmake FindPackageMultipass] module provides some help.  For example usage, see [http://github.com/jedbrown/cmake-modules/tree/master/FindPETSc.cmake FindPETSc.cmake] or [http://github.com/jedbrown/cmake-modules/tree/master/FindiMesh.cmake FindiMesh.cmake].  Since almost every package would be better with this behavior, maybe something similar could be incorporated in CMake or at least a nicer interface could be designed.
A suggestion is for all packages to make all the advanced XXX_INCLUDES, XXX_LIBRARIES, ... cache entries subordinate to an XXX_DIR cache entry (which takes precedence over an XXX_DIR environment variable.  When XXX_DIR is set, it should take precedence over system search paths (i.e. must use HINTS because PATHS is searched [http://public.kitware.com/Bug/view.php?id=8035 too late]).  If XXX_DIR is changed, the advanced entries should be recomputed.  CMake currently makes this awkward, but the [http://github.com/jedbrown/cmake-modules/tree/master/FindPackageMultipass.cmake FindPackageMultipass] module provides some help.  For example usage, see [http://github.com/jedbrown/cmake-modules/tree/master/FindPETSc.cmake FindPETSc.cmake] or [http://github.com/jedbrown/cmake-modules/tree/master/FindiMesh.cmake FindiMesh.cmake].  Since almost every package would be better with this behavior, maybe something similar could be incorporated in CMake or at least a nicer interface could be designed.


Handling multiple versions correctly with wrapper compilers, Makefile includes, and pkg-config requires preserving the semantics of the linker.  See [http://github.com/jedbrown/cmake-modules/tree/master/ResolveCompilerPaths.cmake ResolveCompilerPaths] and the discussion at [[Static libraries]].
Handling multiple versions correctly with wrapper compilers, Makefile includes, and pkg-config requires preserving the semantics of the linker.  See [http://github.com/jedbrown/cmake-modules/tree/master/ResolveCompilerPaths.cmake ResolveCompilerPaths] and the discussion of [[CMake:Static libraries| static libraries]].

Revision as of 08:31, 15 November 2011

When multiple ABI-incompatible versions of libraries are installed, it is likely that existing FindXXX modules will not be able to find a version in a nonstandard location, or will find a combination of libraries that produces a broken executable. Some will work correctly if XXX_DIR is set the first time CMake is run, but if the wrong version is found on the first pass (perhaps because the user didn't know they had to set this variable in advance), the only way (short of manually editing a possibly huge number of advanced cache entries) to switch versions is to delete the cache and try again.

A suggestion is for all packages to make all the advanced XXX_INCLUDES, XXX_LIBRARIES, ... cache entries subordinate to an XXX_DIR cache entry (which takes precedence over an XXX_DIR environment variable. When XXX_DIR is set, it should take precedence over system search paths (i.e. must use HINTS because PATHS is searched too late). If XXX_DIR is changed, the advanced entries should be recomputed. CMake currently makes this awkward, but the FindPackageMultipass module provides some help. For example usage, see FindPETSc.cmake or FindiMesh.cmake. Since almost every package would be better with this behavior, maybe something similar could be incorporated in CMake or at least a nicer interface could be designed.

Handling multiple versions correctly with wrapper compilers, Makefile includes, and pkg-config requires preserving the semantics of the linker. See ResolveCompilerPaths and the discussion of static libraries.