Re: [CMake] Automatically add a revision number to the CPack installer name

2012-03-09 Thread Eric Noulard
2012/3/9 Glenn Ramsey g...@componic.co.nz:

 Thanks Eric, this lead me to a solution that works for me, where the
 revision number is updated at build time. For future reference here is what
 I did:

[...]

This is a nice and relatively easy solution.
Thank you for sharing the final solution.


-- 
Erk
Le gouvernement représentatif n'est pas la démocratie --
http://www.le-message.org
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


[CMake] Automatically add a revision number to the CPack installer name

2012-03-08 Thread Glenn Ramsey
Is it possible to add, at build time, a revision number to the installer file 
name produced by CPack? I understand that to get the revision number at build 
time one must run a command and I have used that technique to generate a source 
code header, but I cannot figure out how to apply it to the package file name. 
The simplest method would appear to be to add a post-build command that renames 
the file to the package target, but it appears that this cannot be currently 
done [1].


A previous list message [1] suggests the following:


If you want to hook it up automatically, you could write your own
version of the package target that just calls cpack itself in
${CMAKE_BINARY_DIR}. That target could have a post-build rule that
does the rename.


When I tried that. It created an infinite loop with cpack calling make and make 
calling cpack.


What would I need to do to correctly implement this solution? Is there another 
way to do it?


Glenn

[1] http://www.cmake.org/pipermail/cmake/2011-May/00.html
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Automatically add a revision number to the CPack installer name

2012-03-08 Thread David Cole
On Thu, Mar 8, 2012 at 3:57 PM, Glenn Ramsey g...@componic.co.nz wrote:
 Is it possible to add, at build time, a revision number to the installer
 file name produced by CPack? I understand that to get the revision number at
 build time one must run a command and I have used that technique to generate
 a source code header, but I cannot figure out how to apply it to the package
 file name. The simplest method would appear to be to add a post-build
 command that renames the file to the package target, but it appears that
 this cannot be currently done [1].

 A previous list message [1] suggests the following:

 If you want to hook it up automatically, you could write your own
 version of the package target that just calls cpack itself in
 ${CMAKE_BINARY_DIR}. That target could have a post-build rule that
 does the rename.


 When I tried that. It created an infinite loop with cpack calling make and
 make calling cpack.

 What would I need to do to correctly implement this solution? Is there
 another way to do it?

 Glenn

 [1] http://www.cmake.org/pipermail/cmake/2011-May/00.html
 --

 Powered by www.kitware.com

 Visit other Kitware open-source projects at
 http://www.kitware.com/opensource/opensource.html

 Please keep messages on-topic and check the CMake FAQ at:
 http://www.cmake.org/Wiki/CMake_FAQ

 Follow this link to subscribe/unsubscribe:
 http://www.cmake.org/mailman/listinfo/cmake

Set CPACK_PACKAGE_FILE_NAME before including CPack.

From Modules/CPack.cmake:

#  CPACK_PACKAGE_FILE_NAME - The name of the package file to generate,
#  not including the extension. For example, cmake-2.6.1-Linux-i686.
#  The default value is
#  ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}.

The default should already include the version number. Perhaps you
could simply encode your build number into your CPACK_PACKAGE_VERSION
value, and it then the rest would be automatic.


HTH,
David
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Automatically add a revision number to the CPack installer name

2012-03-08 Thread Michael Jackson
I do something like this in my CPack file:

set(DREAM3D_VERSION_SHORT ${DREAM3DLib_VER_MAJOR}.${DREAM3DLib_VER_MINOR})

set(CPACK_PACKAGE_FILE_NAME 
DREAM3D-${DREAM3D_VERSION_SHORT}-${CMAKE_SYSTEM_NAME})


Where the DREAM3D_Lib_VER_* variables are generated with a call to my SCM (git 
in my case)
--
Mike Jackson www.bluequartz.net

On Mar 8, 2012, at 3:57 PM, Glenn Ramsey wrote:

 Is it possible to add, at build time, a revision number to the installer file 
 name produced by CPack? I understand that to get the revision number at build 
 time one must run a command and I have used that technique to generate a 
 source code header, but I cannot figure out how to apply it to the package 
 file name. The simplest method would appear to be to add a post-build command 
 that renames the file to the package target, but it appears that this cannot 
 be currently done [1].
 
 A previous list message [1] suggests the following:
 
 If you want to hook it up automatically, you could write your own
 version of the package target that just calls cpack itself in
 ${CMAKE_BINARY_DIR}. That target could have a post-build rule that
 does the rename.
 
 When I tried that. It created an infinite loop with cpack calling make and 
 make calling cpack.
 
 What would I need to do to correctly implement this solution? Is there 
 another way to do it?
 
 Glenn
 
 [1] http://www.cmake.org/pipermail/cmake/2011-May/00.html
 --
 
 Powered by www.kitware.com
 
 Visit other Kitware open-source projects at 
 http://www.kitware.com/opensource/opensource.html
 
 Please keep messages on-topic and check the CMake FAQ at: 
 http://www.cmake.org/Wiki/CMake_FAQ
 
 Follow this link to subscribe/unsubscribe:
 http://www.cmake.org/mailman/listinfo/cmake

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Automatically add a revision number to the CPack installer name

2012-03-08 Thread Glenn Ramsey

Hi Mike,

When, during the build process is the call to the SCM made? If it is at build 
time, rather than cmake time, then how do you do it?


Glenn

On 09/03/12 10:15, Michael Jackson wrote:

I do something like this in my CPack file:

set(DREAM3D_VERSION_SHORT ${DREAM3DLib_VER_MAJOR}.${DREAM3DLib_VER_MINOR})

set(CPACK_PACKAGE_FILE_NAME 
DREAM3D-${DREAM3D_VERSION_SHORT}-${CMAKE_SYSTEM_NAME})


Where the DREAM3D_Lib_VER_* variables are generated with a call to my SCM (git 
in my case)
--
Mike Jacksonwww.bluequartz.net

On Mar 8, 2012, at 3:57 PM, Glenn Ramsey wrote:


Is it possible to add, at build time, a revision number to the installer file 
name produced by CPack? I understand that to get the revision number at build 
time one must run a command and I have used that technique to generate a source 
code header, but I cannot figure out how to apply it to the package file name. 
The simplest method would appear to be to add a post-build command that renames 
the file to the package target, but it appears that this cannot be currently 
done [1].

A previous list message [1] suggests the following:


If you want to hook it up automatically, you could write your own
version of the package target that just calls cpack itself in
${CMAKE_BINARY_DIR}. That target could have a post-build rule that
does the rename.


When I tried that. It created an infinite loop with cpack calling make and make 
calling cpack.

What would I need to do to correctly implement this solution? Is there another 
way to do it?

Glenn

[1]http://www.cmake.org/pipermail/cmake/2011-May/00.html
--



--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Automatically add a revision number to the CPack installer name

2012-03-08 Thread Michael Jackson
The call is during CMake time. Which means you need to rerun cmake if your 
repository version runs. I guess you could try an add_custom_command(...) and 
run the SVN command to get the revision number and make it a prebuild step for 
one of your targets. Then it should get run at every build. 
--
Mike Jackson www.bluequartz.net

On Mar 8, 2012, at 4:44 PM, Glenn Ramsey wrote:

 Hi Mike,
 
 When, during the build process is the call to the SCM made? If it is at build 
 time, rather than cmake time, then how do you do it?
 
 Glenn
 
 On 09/03/12 10:15, Michael Jackson wrote:
 I do something like this in my CPack file:
 
 set(DREAM3D_VERSION_SHORT ${DREAM3DLib_VER_MAJOR}.${DREAM3DLib_VER_MINOR})
 
 set(CPACK_PACKAGE_FILE_NAME 
 DREAM3D-${DREAM3D_VERSION_SHORT}-${CMAKE_SYSTEM_NAME})
 
 
 Where the DREAM3D_Lib_VER_* variables are generated with a call to my SCM 
 (git in my case)
 --
 Mike Jacksonwww.bluequartz.net
 
 On Mar 8, 2012, at 3:57 PM, Glenn Ramsey wrote:
 
 Is it possible to add, at build time, a revision number to the installer 
 file name produced by CPack? I understand that to get the revision number 
 at build time one must run a command and I have used that technique to 
 generate a source code header, but I cannot figure out how to apply it to 
 the package file name. The simplest method would appear to be to add a 
 post-build command that renames the file to the package target, but it 
 appears that this cannot be currently done [1].
 
 A previous list message [1] suggests the following:
 
 If you want to hook it up automatically, you could write your own
 version of the package target that just calls cpack itself in
 ${CMAKE_BINARY_DIR}. That target could have a post-build rule that
 does the rename.
 
 When I tried that. It created an infinite loop with cpack calling make and 
 make calling cpack.
 
 What would I need to do to correctly implement this solution? Is there 
 another way to do it?
 
 Glenn
 
 [1]http://www.cmake.org/pipermail/cmake/2011-May/00.html
 --
 
 
 --
 
 Powered by www.kitware.com
 
 Visit other Kitware open-source projects at 
 http://www.kitware.com/opensource/opensource.html
 
 Please keep messages on-topic and check the CMake FAQ at: 
 http://www.cmake.org/Wiki/CMake_FAQ
 
 Follow this link to subscribe/unsubscribe:
 http://www.cmake.org/mailman/listinfo/cmake

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Automatically add a revision number to the CPack installer name

2012-03-08 Thread Glenn Ramsey
Yes, you can use add_custom_command(...) to run a script to get the revision 
number, but I don't think you can use that to alter CPACK_PACKAGE_FILE_NAME, 
which has been set at cmake time.


Glenn

On 09/03/12 10:52, Michael Jackson wrote:

The call is during CMake time. Which means you need to rerun cmake if your
repository version runs. I guess you could try an add_custom_command(...) and
run the SVN command to get the revision number and make it a prebuild step
for one of your targets. Then it should get run at every build. -- Mike
Jacksonwww.bluequartz.net

On Mar 8, 2012, at 4:44 PM, Glenn Ramsey wrote:


Hi Mike,

When, during the build process is the call to the SCM made? If it is at
build time, rather than cmake time, then how do you do it?

Glenn

On 09/03/12 10:15, Michael Jackson wrote:

I do something like this in my CPack file:

set(DREAM3D_VERSION_SHORT
${DREAM3DLib_VER_MAJOR}.${DREAM3DLib_VER_MINOR})

set(CPACK_PACKAGE_FILE_NAME
DREAM3D-${DREAM3D_VERSION_SHORT}-${CMAKE_SYSTEM_NAME})


Where the DREAM3D_Lib_VER_* variables are generated with a call to my SCM
(git in my case) -- Mike Jacksonwww.bluequartz.net

On Mar 8, 2012, at 3:57 PM, Glenn Ramsey wrote:


Is it possible to add, at build time, a revision number to the
installer file name produced by CPack? I understand that to get the
revision number at build time one must run a command and I have used
that technique to generate a source code header, but I cannot figure
out how to apply it to the package file name. The simplest method would
appear to be to add a post-build command that renames the file to the
package target, but it appears that this cannot be currently done [1].

A previous list message [1] suggests the following:


If you want to hook it up automatically, you could write your own
version of the package target that just calls cpack itself in
${CMAKE_BINARY_DIR}. That target could have a post-build rule that
does the rename.


When I tried that. It created an infinite loop with cpack calling make
and make calling cpack.

What would I need to do to correctly implement this solution? Is there
another way to do it?

Glenn

[1]http://www.cmake.org/pipermail/cmake/2011-May/00.html




--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Automatically add a revision number to the CPack installer name

2012-03-08 Thread Eric Noulard
2012/3/8 Glenn Ramsey g...@componic.co.nz:
 Yes, you can use add_custom_command(...) to run a script to get the revision
 number, but I don't think you can use that to alter CPACK_PACKAGE_FILE_NAME,
 which has been set at cmake time.

This true but how wouldn't a revision update trigger a CMake re-run?

Whatever the reason if you want to change/alter/set a CPACK_xxx value
at CPack time ,
independently of CMakre re-run, you can use  a CPACK_PROJECT_CONFIG_FILE:

CPACK_PROJECT_CONFIG_FILE
   CPack-time project CPack configuration file.

   This file included at cpack time, once per generator after CPack has
   set CPACK_GENERATOR to the actual generator being used.  It allows
   per-generator setting of CPACK_* variables at cpack time.

In your CMakeLists.txt you have to:

set(CPACK_PROJECT_CONFIG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/MyCPackConf.cmake)

then write the logic you want in MyCPackConf.cmake.

see:
http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#Overall_usage_.28common_to_all_generators.29

This CPACK_PROJECT_CONFIG_FILE is a CMake script file loaded by CPack
(which includes
a CMake script interpreter) you cannot use non scriptable CMake command in there
(and no add_xxx to make it simple) but you can perfectly use
execute_process in order to run
some SCM commands.

You should be able to override CPACK_PACKAGE_FILE_NAME dynamically in there.
You have access to all CPACK_xxx variable value.

However, in this script file you do not have access to CMAKE_xxx
variables you can usually access in CMakeLists.txt
(no CMAKE_PROJECT_NAME, nor orther variables YOU defined in the CMakeLists.txt
 besides CPACK_xxx ones)
If you need some of these values you'll have to create a
MyCPackConf.cmake.in
which will be configured **at CMake-time**
into
MyCPackConf.cmake

CMake itself is using this with the CMakeCPackOptions.cmake.in file
at the root of CMake
sources.
-- 
Erk
Le gouvernement représentatif n'est pas la démocratie --
http://www.le-message.org
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Automatically add a revision number to the CPack installer name

2012-03-08 Thread Glenn Ramsey

On 09/03/12 12:00, Eric Noulard wrote:

2012/3/8 Glenn Ramseyg...@componic.co.nz:

Yes, you can use add_custom_command(...) to run a script to get the revision
number, but I don't think you can use that to alter CPACK_PACKAGE_FILE_NAME,
which has been set at cmake time.


This true but how wouldn't a revision update trigger a CMake re-run?

Whatever the reason if you want to change/alter/set a CPACK_xxx value
at CPack time ,
independently of CMakre re-run, you can use  a CPACK_PROJECT_CONFIG_FILE:

CPACK_PROJECT_CONFIG_FILE
CPack-time project CPack configuration file.

This file included at cpack time, once per generator after CPack has
set CPACK_GENERATOR to the actual generator being used.  It allows
per-generator setting of CPACK_* variables at cpack time.

In your CMakeLists.txt you have to:

set(CPACK_PROJECT_CONFIG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/MyCPackConf.cmake)

then write the logic you want in MyCPackConf.cmake.

see:
http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#Overall_usage_.28common_to_all_generators.29

This CPACK_PROJECT_CONFIG_FILE is a CMake script file loaded by CPack
(which includes
a CMake script interpreter) you cannot use non scriptable CMake command in there
(and no add_xxx to make it simple) but you can perfectly use
execute_process in order to run
some SCM commands.

You should be able to override CPACK_PACKAGE_FILE_NAME dynamically in there.
You have access to all CPACK_xxx variable value.

However, in this script file you do not have access to CMAKE_xxx
variables you can usually access in CMakeLists.txt
(no CMAKE_PROJECT_NAME, nor orther variables YOU defined in the CMakeLists.txt
  besides CPACK_xxx ones)
If you need some of these values you'll have to create a
MyCPackConf.cmake.in
which will be configured **at CMake-time**
into
MyCPackConf.cmake

CMake itself is using this with the CMakeCPackOptions.cmake.in file
at the root of CMake
sources.


Thanks Eric, this lead me to a solution that works for me, where the revision 
number is updated at build time. For future reference here is what I did:


-- CMakeLists.txt --

cmake_minimum_required(VERSION 2.8)
project(myapp)

add_executable(main main.cpp)
install(TARGETS main DESTINATION .)

add_custom_target(first ALL
# update the working copy
COMMAND ${Subversion_SVN_EXECUTABLE} update ${CMAKE_SOURCE_DIR}

# generate cpackoptions.cmake at build time so we get the
# most recent revision number
COMMAND ${CMAKE_COMMAND}
-DSOURCE_DIR=${CMAKE_SOURCE_DIR}
-DBINARY_DIR=${CMAKE_BINARY_DIR}
-Dproj_name=${CMAKE_PROJECT_NAME}
-P ${CMAKE_SOURCE_DIR}/create-cpackoptions.cmake
)

add_dependencies(main first)

set(CPACK_PROJECT_CONFIG_FILE ${CMAKE_BINARY_DIR}/CPackOptions.cmake)

include(CPack)


-- create-cpackoptions.cmake --

include(FindSubversion)
Subversion_WC_INFO(${SOURCE_DIR} ${proj_name})

set(revision ${${proj_name}_WC_REVISION})

configure_file(${SOURCE_DIR}/CPackOptions.cmake.in
${BINARY_DIR}/CPackOptions.cmake
@ONLY)

-- cpackOptions.cmake.in --

set(CPACK_PACKAGE_FILE_NAME 
@proj_name@-${CPACK_PACKAGE_VERSION}r@revision@-${CPACK_SYSTEM_NAME})





--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake