[CMake] Building a Version Header

2010-07-07 Thread Clark Gaebel
I would like to generate file that looks something like this:

// version.h
#define VERSION v0.1-345-ga77ede8

where the version string is the result of running git describe --tags
--dirty. How can I auto-generate this file, include it in my project,
and have it regenerate as a pre-build event?

-- 
Regards,
-Clark

___
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] Building a Version Header

2010-07-07 Thread Clark Gaebel
Couple things wrong with this:

1) I'm using git
2) If it outputs to the build directory, how do I refer to it?

On 07/07/10 22:43, John Drescher wrote:
 On Wed, Jul 7, 2010 at 9:44 PM, Clark Gaebel cg.wowus...@gmail.com wrote:
   
 I would like to generate file that looks something like this:

// version.h
#define VERSION v0.1-345-ga77ede8

 where the version string is the result of running git describe --tags
 --dirty. How can I auto-generate this file, include it in my project,
 and have it regenerate as a pre-build event?

 
 You want to do that with configure_file

 The following is an example that grabs the subversion rev and puts
 that into a version header file.

 In CMakeLists.txt for the LungAnalysis project

 set (${PROJECT_NAME}_VERSION_MAJOR 0)
 set (${PROJECT_NAME}_VERSION_MINOR 25)
 set (${PROJECT_NAME}_VERSION_PATCH 3)

 FIND_PACKAGE(Subversion)
 IF(Subversion_FOUND)
 #Use the FindSubversion.cmake module to get the svn rev and append
 that to the patch version.
   Subversion_WC_INFO(${PROJECT_SOURCE_DIR} Project)
   MESSAGE(Current revision is ${Project_WC_REVISION})
   Subversion_WC_LOG(${PROJECT_SOURCE_DIR} Project)
   MESSAGE(Last changed log is ${Project_LAST_CHANGED_LOG})
   
   set (${PROJECT_NAME}_VERSION_PATCH
 ${${PROJECT_NAME}_VERSION_PATCH}.${Project_WC_REVISION})
   
 ENDIF(Subversion_FOUND)

 configure_file (
   ${PROJECT_SOURCE_DIR}/${PROJECT_NAME}Config.h.in
   ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.h
 )

 LungAnalysisConfig.h.in:
 //The configured settings for the project
 #define LungAnalysis_VERSION_MAJOR @LungAnalysis_VERSION_MAJOR@
 #define LungAnalysis_VERSION_MINOR @LungAnalysis_VERSION_MINOR@
 #define LungAnalysis_VERSION_PATCH @LungAnalysis_VERSION_PATCH@


 So then in the binary folder the LungAnalysisConfig.h will look like

 #define LungAnalysis_VERSION_MAJOR 0
 #define LungAnalysis_VERSION_MINOR 25
 #define LungAnalysis_VERSION_PATCH 3.903

 for svn revision 903

 John
   

-- 
Regards,
-Clark

___
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] Building a Version Header

2010-07-07 Thread Clark Gaebel
Is there any way I can use the output from a command-line program (in
this case, git describe --dirty) instead of using FindGit?

On 07/07/10 22:58, John Drescher wrote:
 1) I'm using git
 
 I know. You have some work to do..
 On top of the minor differences in what you want the FindGIt.cmake
 does not have that option to return the version so you need to adapt
 it to get the git version similar to the way the FindSubversion.cmake
 module does for subversion repositories.

   
 2) If it outputs to the build directory, how do I refer to it?
 
 You can include files from your build folder in your project.

 Just add
 include_directories(${PROJECT_BINARY_DIR})

 in your CMakeLists.txt

 then use the header as you would any other header in your project.
 John
   

-- 
Regards,
-Clark

___
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] Building a Version Header

2010-07-07 Thread Clark Gaebel
Thank you! That's perfect. I just KNEW there would be a command to do that!

On 07/07/10 23:10, John Drescher wrote:
 On Wed, Jul 7, 2010 at 11:04 PM, John Drescher dresche...@gmail.com wrote:
   
 On Wed, Jul 7, 2010 at 10:59 PM, Clark Gaebel cg.wowus...@gmail.com wrote:
 
 Is there any way I can use the output from a command-line program (in
 this case, git describe --dirty) instead of using FindGit?

   
 I believe
 add_custom_command

 but I can not help with an example of that.

 
 When looking at the source for FindSubversion.cmake this looks pretty
 easy to modify. I guess you can put the Macro code inside your
 CMakeLists.txt if you do not want to mess with Findgit.cmake.

 MACRO(Subversion_WC_INFO dir prefix)
 # the subversion commands should be executed with the C locale, otherwise
 # the message (which are parsed) may be translated, Alex
 SET(_Subversion_SAVED_LC_ALL $ENV{LC_ALL})
 SET(ENV{LC_ALL} C)

 EXECUTE_PROCESS(COMMAND ${Subversion_SVN_EXECUTABLE} --version
   WORKING_DIRECTORY ${dir}
   OUTPUT_VARIABLE Subversion_VERSION_SVN
   OUTPUT_STRIP_TRAILING_WHITESPACE)

 EXECUTE_PROCESS(COMMAND ${Subversion_SVN_EXECUTABLE} info ${dir}
   OUTPUT_VARIABLE ${prefix}_WC_INFO
   ERROR_VARIABLE Subversion_svn_info_error
   RESULT_VARIABLE Subversion_svn_info_result
   OUTPUT_STRIP_TRAILING_WHITESPACE)

 IF(NOT ${Subversion_svn_info_result} EQUAL 0)
   MESSAGE(SEND_ERROR Command \${Subversion_SVN_EXECUTABLE} info
 ${dir}\ failed with output:\n${Subversion_svn_info_error})
 ELSE(NOT ${Subversion_svn_info_result} EQUAL 0)

   STRING(REGEX REPLACE ^(.*\n)?svn, version ([.0-9]+).*
 \\2 Subversion_VERSION_SVN ${Subversion_VERSION_SVN})
   STRING(REGEX REPLACE ^(.*\n)?URL: ([^\n]+).*
 \\2 ${prefix}_WC_URL ${${prefix}_WC_INFO})
   STRING(REGEX REPLACE ^(.*\n)?Revision: ([^\n]+).*
 \\2 ${prefix}_WC_REVISION ${${prefix}_WC_INFO})
   STRING(REGEX REPLACE ^(.*\n)?Last Changed Author: ([^\n]+).*
 \\2 ${prefix}_WC_LAST_CHANGED_AUTHOR ${${prefix}_WC_INFO})
   STRING(REGEX REPLACE ^(.*\n)?Last Changed Rev: ([^\n]+).*
 \\2 ${prefix}_WC_LAST_CHANGED_REV ${${prefix}_WC_INFO})
   STRING(REGEX REPLACE ^(.*\n)?Last Changed Date: ([^\n]+).*
 \\2 ${prefix}_WC_LAST_CHANGED_DATE ${${prefix}_WC_INFO})

 ENDIF(NOT ${Subversion_svn_info_result} EQUAL 0)

 # restore the previous LC_ALL
 SET(ENV{LC_ALL} ${_Subversion_SAVED_LC_ALL})

   ENDMACRO(Subversion_WC_INFO)


 All the work you need is in the EXECUTE_PROCESS. Replace the
 subversion commands with git commands and fixup the output.

 John
   

-- 
Regards,
-Clark

___
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] Building a Version Header

2010-07-07 Thread Clark Gaebel
Okay, I've almost got it. How do I make configure_file generate
something like...

source:
#cmakedefine VERSION

result:
#define VERSION v0.1-abcdef

where v0.1-abcdef is the contents of the variable PROJECT_VERSION in
my CMakeLists.txt

On 07/07/10 23:10, John Drescher wrote:
 On Wed, Jul 7, 2010 at 11:04 PM, John Drescher dresche...@gmail.com wrote:
   
 On Wed, Jul 7, 2010 at 10:59 PM, Clark Gaebel cg.wowus...@gmail.com wrote:
 
 Is there any way I can use the output from a command-line program (in
 this case, git describe --dirty) instead of using FindGit?

   
 I believe
 add_custom_command

 but I can not help with an example of that.

 
 When looking at the source for FindSubversion.cmake this looks pretty
 easy to modify. I guess you can put the Macro code inside your
 CMakeLists.txt if you do not want to mess with Findgit.cmake.

 MACRO(Subversion_WC_INFO dir prefix)
 # the subversion commands should be executed with the C locale, otherwise
 # the message (which are parsed) may be translated, Alex
 SET(_Subversion_SAVED_LC_ALL $ENV{LC_ALL})
 SET(ENV{LC_ALL} C)

 EXECUTE_PROCESS(COMMAND ${Subversion_SVN_EXECUTABLE} --version
   WORKING_DIRECTORY ${dir}
   OUTPUT_VARIABLE Subversion_VERSION_SVN
   OUTPUT_STRIP_TRAILING_WHITESPACE)

 EXECUTE_PROCESS(COMMAND ${Subversion_SVN_EXECUTABLE} info ${dir}
   OUTPUT_VARIABLE ${prefix}_WC_INFO
   ERROR_VARIABLE Subversion_svn_info_error
   RESULT_VARIABLE Subversion_svn_info_result
   OUTPUT_STRIP_TRAILING_WHITESPACE)

 IF(NOT ${Subversion_svn_info_result} EQUAL 0)
   MESSAGE(SEND_ERROR Command \${Subversion_SVN_EXECUTABLE} info
 ${dir}\ failed with output:\n${Subversion_svn_info_error})
 ELSE(NOT ${Subversion_svn_info_result} EQUAL 0)

   STRING(REGEX REPLACE ^(.*\n)?svn, version ([.0-9]+).*
 \\2 Subversion_VERSION_SVN ${Subversion_VERSION_SVN})
   STRING(REGEX REPLACE ^(.*\n)?URL: ([^\n]+).*
 \\2 ${prefix}_WC_URL ${${prefix}_WC_INFO})
   STRING(REGEX REPLACE ^(.*\n)?Revision: ([^\n]+).*
 \\2 ${prefix}_WC_REVISION ${${prefix}_WC_INFO})
   STRING(REGEX REPLACE ^(.*\n)?Last Changed Author: ([^\n]+).*
 \\2 ${prefix}_WC_LAST_CHANGED_AUTHOR ${${prefix}_WC_INFO})
   STRING(REGEX REPLACE ^(.*\n)?Last Changed Rev: ([^\n]+).*
 \\2 ${prefix}_WC_LAST_CHANGED_REV ${${prefix}_WC_INFO})
   STRING(REGEX REPLACE ^(.*\n)?Last Changed Date: ([^\n]+).*
 \\2 ${prefix}_WC_LAST_CHANGED_DATE ${${prefix}_WC_INFO})

 ENDIF(NOT ${Subversion_svn_info_result} EQUAL 0)

 # restore the previous LC_ALL
 SET(ENV{LC_ALL} ${_Subversion_SAVED_LC_ALL})

   ENDMACRO(Subversion_WC_INFO)


 All the work you need is in the EXECUTE_PROCESS. Replace the
 subversion commands with git commands and fixup the output.

 John
   

-- 
Regards,
-Clark

___
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] Building a Version Header

2010-07-07 Thread Clark Gaebel
Nice. that works. I'm so sorry to be such a bother, but here's my output
now...

#define PROJECT_VERSION v0.1-345-ga77ede8-dirty


Needless to say, that's bad :(

How would I go about removing that trailing newline?

On 07/07/10 23:49, John Drescher wrote:
 On Wed, Jul 7, 2010 at 11:43 PM, Clark Gaebel cg.wowus...@gmail.com wrote:
   
 Okay, I've almost got it. How do I make configure_file generate
 something like...

 source:
 #cmakedefine VERSION

 
 Some thing like

 Version.h.in
 #define VERSION @PROJECT_VERSION@


 Try to look at my first example for usage.

 John
   

-- 
Regards,
-Clark

___
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] Building a Version Header

2010-07-07 Thread Clark Gaebel
Oh my god you're a genius.

Thank you so much, kind sir! It works now!

On 07/08/10 00:00, John Drescher wrote:
 On Wed, Jul 7, 2010 at 11:58 PM, John Drescher dresche...@gmail.com wrote:
   
 Nice. that works. I'm so sorry to be such a bother, but here's my output
 now...

 #define PROJECT_VERSION v0.1-345-ga77ede8-dirty
 

 Needless to say, that's bad :(

 How would I go about removing that trailing newline?

   
 
 Wait a minute did you use

 OUTPUT_STRIP_TRAILING_WHITESPACE

 in your

 EXECUTE_PROCESS

 ?

 John
   

-- 
Regards,
-Clark

___
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] Non-build output

2010-06-20 Thread Clark Gaebel
How would I go about placing a text file in the same directory as a
target's output?

For example, let's say I have a target called foo, which creates an
executable. foo has a config file called foo.conf that should always
go in the same directory. At the moment, it resides in the src/
directory for the foo target. How would I get it to automatically copy
into the same directory as the foo executable as part of the build process?

For bonus points, how would this interact with make install?

Regards,
  -- Clark
___
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] Non-build output

2010-06-20 Thread Clark Gaebel
I'm doing exclusively out-of-source builds, so this is perfect. Thank you!

Regards,
  -- Clark

On 06/20/10 16:31, Eric Noulard wrote:
 2010/6/20 Clark Gaebel cg.wowus...@gmail.com:
   
 How would I go about placing a text file in the same directory as a
 target's output?

 For example, let's say I have a target called foo, which creates an
 executable. foo has a config file called foo.conf that should always
 go in the same directory. At the moment, it resides in the src/
 directory for the foo target. How would I get it to automatically copy
 into the same directory as the foo executable as part of the build process?

 For bonus points, how would this interact with make install?
 
 Concerning install:

 Your target foo may be installed with
 install(TARGETS foo DESTINATION where/you/want)

 Your config file with
 install(FILE foo.conf DESTINATION where/you/want)

 Now if you want to put the foo.conf near to foo **in the build tree**
 **and assuming foo.conf is in the same source dir as foo sources**
 you may do:
 configure_file(foo.conf foo.conf COPYONLY)

 this should copy foo.conf from source tree to binary tree.
 It may be a problem if you usually do in-source build so you may
 a) rename foo.conf to foo.conf.in in the source
 b) do
configure_file(foo.conf.in foo.conf COPYONLY)


   

-- 
Regards,
-Clark

___
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] Shipping Config Files

2010-06-18 Thread Clark Gaebel
What would I need to add to my CMakeLists.txt to make sure that a config
file in the src/ directory gets copied to the build output directory,
and the install directory when make install is run?

-- 
Regards,
-Clark

___
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] Using Valgrind on all tests

2010-06-07 Thread Clark Gaebel
This is almost perfect for my needs with a bit of trivial tweaking. I
wish support was built-in to cmake just like valgrind-on-nightly-test
was. Oh well.

Thank you so much,
-Clark

On 06/07/10 17:46, Ben Boeckel wrote:
 Clark Gaebel cg.wowus...@gmail.com wrote:
   
 Hello,

 I've currently set up CMake and CTest for my building and testing needs,
 but CDash just isn't for me. How do I set up CTest to run all the tests
 in Valgrind? Again, I don't want to use CDash - just CTest.

 Also, it'd be great if I get output on leaks, and silence when
 everything's alright.
 
 I also wanted this, and I ended up writing my own targets for it (it
 includes other stuff such as callgrind and actual handling of the tests
 themselves). The most recent iteration of it is available at:

 git clone git://chasmd.org/chasmd.git

 The cmake/test.cmake file is the one with the macros to create the
 targets and example usage is in the test/ directory.

 The output is dumped to files for easier reference rather than to the
 terminal, but I'm sure a target that greps the logs for important
 strings and errors on that wouldn't be hard to make.

 Hope this helps.

 --Ben

 ___
 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
   

-- 
Regards,
-Clark

___
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] Using Valgrind on all tests

2010-06-06 Thread Clark Gaebel
Hello,

I've currently set up CMake and CTest for my building and testing needs,
but CDash just isn't for me. How do I set up CTest to run all the tests
in Valgrind? Again, I don't want to use CDash - just CTest.

Also, it'd be great if I get output on leaks, and silence when
everything's alright.

-- 
Regards,
-Clark

___
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] Enabling compiler flags for one file ONLY.

2010-06-01 Thread Clark Gaebel
I have a massive .cpp file that has been autogenerated ahead of time.
However, whenever I build it, according to gcc timing information, it
spends all its time in variable tracking. Therefore, I would like to
enable the flag -fno-var-tracking for that file only (having variable
debug information is useful!).

How can I do this?
___
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] Trying to link my project with Boost.Thread using CMake

2010-05-23 Thread Clark Gaebel
When I link Boost.Thread to my boost_test executable, it gives me

|make[2]: *** No rule to make target `/usr/lib64/libboost_thread-mt.so', needed 
by `gogo/test/test_boost'.  Stop.
|

when I |make| it. Here's the offending CMake code, what am I doing wrong?

|add_executable(boost_test boost_test.cpp)
add_test(boost_test boost_test)

# Boost auto-links for MSVC, so we exclude it.
if(CMAKE_COMPILER_IS_GNUCXX)
target_link_libraries(test_boost #LINK_INTERFACE_LIBRARIES
${Boost_THREAD_LIBRARY}
)
endif()|

-- 
Regards,
-Clark

___
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