RecipeAppendVersionNumberToInstallpath: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
(New page: In some situations, it's necessary to keep older versions of a program along with the newer. Here is a recipe for appending the version number to your install path: <pre>PROJECT(MyProg C...)
 
(Replace content with link to new CMake community wiki)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
In some situations, it's necessary to keep older versions of a program along with the newer.  Here is a recipe for appending the version number to your install path:
{{CMake/Template/Moved}}


<pre>PROJECT(MyProg C)
This page has moved [https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/recipe/AppendVersionNumberToInstallpath here].
SET (VERSION "0.1.4")
...
IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
SET(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}-${VERSION}"
CACHE STRING "Install path" FORCE)
ENDIF()
...
 
# and if you use CPack, just default the installer to the right path using:
set(CPACK_PACKAGE_INSTALL_DIRECTORY "SIS-${VERSION}")</pre>
The CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT is necessary here because if it's missing, the path becomes recursive and will continue to append ${PROJECT_NAME}-${VERSION} to the path infinitely.  The conditional ensures that it only does this once.

Latest revision as of 15:41, 30 April 2018


The CMake community Wiki has moved to the Kitware GitLab Instance.

This page has moved here.