Re: [CMake] Question about variables, cache, and scope

2011-10-10 Thread Bill Hoffman

On 10/10/2011 3:52 PM, Robert Dailey wrote:

Yes, this works perfectly.

It's a bit disappointing that cache variables are, for all intents and
purposes, read-only in functions. The property approach is a bit more
verbose but it functions! I think 'set' needs a new override
specifically for cases like this. Something similar to "PARENT_SCOPE",
but something like "CACHE_SCOPE", that forces CMake to first check for
the existance of a cache variable with that name, and it would take
precedence over any identically named variable in function scope.

On another note, you'd think this would work too but it doesn't:

set( project_count ${new_count} CACHE INTERNAL FORCE )



This works:

set( project_count 0 CACHE INTERNAL "")
function( define_project )
   math( EXPR count "${project_count}+1" )
   set( project_count ${count} CACHE INTERNAL "")
endfunction()
define_project()
message(${project_count})
define_project()
message(${project_count})
define_project()
message(${project_count})

It prints out
1
2
3

-Bill
--
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] Question about variables, cache, and scope

2011-10-10 Thread Robert Dailey
Yes, this works perfectly.

It's a bit disappointing that cache variables are, for all intents and
purposes, read-only in functions. The property approach is a bit more
verbose but it functions! I think 'set' needs a new override specifically
for cases like this. Something similar to "PARENT_SCOPE", but something like
"CACHE_SCOPE", that forces CMake to first check for the existance of a cache
variable with that name, and it would take precedence over any identically
named variable in function scope.

On another note, you'd think this would work too but it doesn't:

set( project_count ${new_count} CACHE INTERNAL FORCE )

Thanks!

-
Robert Dailey


On Mon, Oct 10, 2011 at 2:01 PM, Glenn Coombs wrote:

> Calling a function pushs a new variable scope.  All variables visible in
> the callers scope are copied into the new scope but changes by default only
> affect the callee scope.  You could try using the PARENT_SCOPE option to the
> set command but I'm not sure that will achieve what you want as it only gets
> you to the next scope whereas you really want a global variable.
>
> You can use properties instead of variables as those are explicitly
> scoped.  So something like this:
>
> set_property(GLOBAL PROPERTY project_count "0")
>
> function( define_project ... )
>get_property(old_count GLOBAL PROPERTY project_count)
>math( EXPR new_count "${old_count}+1" )
>set_property(GLOBAL PROPERTY project_count "${new_count}"
> endfunction()
>
> will probably work.
>
> --
> Glenn
>
>
> On 10 October 2011 17:11, Robert Dailey  wrote:
>
>> I have a function that I define in my top-most CMakeLists.txt file (on
>> Windows using CMake version 2.8.6) called define_project() that calls
>> add_executable, sets up compile defintions, etc etc.
>>
>> For each time define_project() is called *anywhere* in the directory
>> hierarchy, I need to increment a global "project_count" variable to keep
>> track of how many projects were created and print that at the very end of
>> the root CMakeLists.txt file.
>>
>> So far my attempts at this have been unsuccessful. I tried creating a
>> cache variable in the root script:
>>
>> set( project_count 0 CACHE INTERNAL "" )
>>
>> Then inside of my function, I do this:
>>
>> function( define_project ... )
>>math( EXPR count "${project_count}+1" )
>>set( project_count ${count} )
>> endfunction()
>>
>> However, 'project_count' is always 0 each time that the function is
>> executed.
>>
>> How can I make this work?
>>
>> -
>> Robert Dailey
>>
>> --
>> 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] Question about variables, cache, and scope

2011-10-10 Thread Glenn Coombs
Calling a function pushs a new variable scope.  All variables visible in the
callers scope are copied into the new scope but changes by default only
affect the callee scope.  You could try using the PARENT_SCOPE option to the
set command but I'm not sure that will achieve what you want as it only gets
you to the next scope whereas you really want a global variable.

You can use properties instead of variables as those are explicitly scoped.
So something like this:

set_property(GLOBAL PROPERTY project_count "0")

function( define_project ... )
   get_property(old_count GLOBAL PROPERTY project_count)
   math( EXPR new_count "${old_count}+1" )
   set_property(GLOBAL PROPERTY project_count "${new_count}"
endfunction()

will probably work.

--
Glenn


On 10 October 2011 17:11, Robert Dailey  wrote:

> I have a function that I define in my top-most CMakeLists.txt file (on
> Windows using CMake version 2.8.6) called define_project() that calls
> add_executable, sets up compile defintions, etc etc.
>
> For each time define_project() is called *anywhere* in the directory
> hierarchy, I need to increment a global "project_count" variable to keep
> track of how many projects were created and print that at the very end of
> the root CMakeLists.txt file.
>
> So far my attempts at this have been unsuccessful. I tried creating a cache
> variable in the root script:
>
> set( project_count 0 CACHE INTERNAL "" )
>
> Then inside of my function, I do this:
>
> function( define_project ... )
>math( EXPR count "${project_count}+1" )
>set( project_count ${count} )
> endfunction()
>
> However, 'project_count' is always 0 each time that the function is
> executed.
>
> How can I make this work?
>
> -
> Robert Dailey
>
> --
> 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

[CMake] CTest print output value

2011-10-10 Thread mohamed sahraoui

Hi ,

I would like to generate a txt report  including  
various informations produced by each test execution. 
my ideas was in a second step to post this cover test onto a cdash portal.


My CMakeLists.txt  produce a well formed CTestTestfile.cmake file with the 
following a classical structure :

ADD_TEST(Phase1_oconnell "bin/Linux/toulbar2" 
"/home/validation/default/oconnell.wcsp" "-B=0" "-v" "-e:")
SET_TESTS_PROPERTIES(Phase1_oconnell PROPERTIES  PASS_REGULAR_EXPRESSION 
"Optimum: " TIMEOUT "100")

i would like to catch the stdout line produced by the test execution

the standard output print :
=

Optimum: 328 in 15 backtracks and 15 nodes and 0 seconds.
end.

=

how can i do to  respectively catch foreach test the following informations ;

${Optimum} 
${backtracks}
${nodes}
${seconds}

my ideas is generate a csv files and post it on the dashboard after post 
processing.




report exemple : cat report.txt
test;optimum;backtracks;nodes;seconds;
Phase1_oconnell;328;15;15;0;


thanks ,

sincerely Mohamed 





  --
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] Question about variables, cache, and scope

2011-10-10 Thread Robert Dailey
I have a function that I define in my top-most CMakeLists.txt file (on
Windows using CMake version 2.8.6) called define_project() that calls
add_executable, sets up compile defintions, etc etc.

For each time define_project() is called *anywhere* in the directory
hierarchy, I need to increment a global "project_count" variable to keep
track of how many projects were created and print that at the very end of
the root CMakeLists.txt file.

So far my attempts at this have been unsuccessful. I tried creating a cache
variable in the root script:

set( project_count 0 CACHE INTERNAL "" )

Then inside of my function, I do this:

function( define_project ... )
   math( EXPR count "${project_count}+1" )
   set( project_count ${count} )
endfunction()

However, 'project_count' is always 0 each time that the function is
executed.

How can I make this work?

-
Robert Dailey
--
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] Contribute two new find package implementation.

2011-10-10 Thread Mathias Fröhlich

Hi,

On Monday 10 October 2011, Michael Hertling wrote:
> AFAICS from Mathias' FindRTI1516{,E}.cmake modules, the libraries have
> different names, but their respective header files are named the same:
>
> FIND_LIBRARY(RTI1516_LIBRARY  NAMES rti1516  RTI1516 ...)
> FIND_LIBRARY(RTI1516E_LIBRARY NAMES rti1516e RTI1516E ...)
>
> FIND_PATH(RTI1516_INCLUDE_DIR  NAMES RTI/RTI1516.h ...)
> FIND_PATH(RTI1516E_INCLUDE_DIR NAMES RTI/RTI1516.h ...)
Yes.

> Therefore, the usage of both libraries for the same binary should be
> quite possible as long as they don't violate the one-definition-rule,
> whereas the inclusion of both headers for the same compilation unit
> will require some trickery, e.g. an intermediate header containing
> configured #include directives with the other headers' full paths.
Yes.
Having different include paths for different object files would be sufficient 
to include all in the same application.
Cmake can do this fine.

Greetings

Mathias

-- 
Dr. Mathias Fröhlich, science + computing ag, Software Solutions
Hagellocher Weg 71-75, D-72070 Tuebingen, Germany
Phone: +49 7071 9457-268, Fax: +49 7071 9457-511
-- 
Vorstand/Board of Management:
Dr. Bernd Finkbeiner, Dr. Roland Niemeier, 
Dr. Arno Steitz, Dr. Ingrid Zech
Vorsitzender des Aufsichtsrats/
Chairman of the Supervisory Board:
Philippe Miltin
Sitz/Registered Office: Tuebingen
Registergericht/Registration Court: Stuttgart
Registernummer/Commercial Register No.: HRB 382196 


--
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] not found library with package configuration files and changed CMAKE_INSTALL_PREFIX

2011-10-10 Thread Rolf Eike Beer
> Hei hei,
>
> On Wed, 21 Sep 2011 16:42:37 +0200, Alexander Dahl wrote:
>>> The foo-targets.cmake file contains "foo-shared" as imported target,
>>> and it is this name that must be supplied to TARGET_LINK_LIBRARIES().
>>> Besides, the DESTINATION clause of INSTALL() should be qualified with
>>> ARCHIVE/LIBRARY/RUNTIME/..., and EXPORT must precede DESTINATION then.
>>
>> Did that.
>
> And it only works in Linux (Ubuntu Lucid 10.04 native with CMake 2.8.5
> or cross compiling with ptxdist). On Windows XP with VS 2009 and CMake
> 2.8.5 the following happens:
>
> install(TARGETS ${PROJECT_NAME}-shared EXPORT ${PROJECT_NAME}-targets
> LIBRARY DESTINATION "lib")
> #install(TARGETS ${PROJECT_NAME}-shared EXPORT ${PROJECT_NAME}-targets
> DESTINATION "lib")
> install(EXPORT ${PROJECT_NAME}-targets DESTINATION
> "lib/cmake/${PROJECT_NAME}")
>
> With the first line used it gives the following error:
>
> CMake Error at src/CMakeLists.txt:19 (install):
>   install Library TARGETS given no DESTINATION!

Libraries on Windows behave differently because of the .lib/.dll split.
The details are in the install(TARGETS) documentation.

Greetings,

Eike
--
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] Contribute two new find package implementation.

2011-10-10 Thread Mathias Fröhlich

Hi,

On Friday 07 October 2011, Eric Noulard wrote:
> Ok I understand.
> I'll get in touch with Petr to see if he has time to update its
> contribution if he has not I may offer to take over.
Ok, So I am around and can respond to questions more or less timely but I am 
not monitoring the mailing list.

> find_package(RTI)
>would find all of them 1.3, 1516 and 1516e (which is 1516-2010 right?)
>This would define
>   RTI13_FOUND if 1.3 compliant RTI is found
>   RTI1516_FOUND if 1516 compliant RTI is found
>   RTI1516e_FOUND ...
>
> find_package(RTI COMPONENT RTI1516)
>
> would only search for 1516.
>
> find_package(RTI COMPONENT RTI13 RTI1516)
>
> search for 1.3 and 1516 only etc...
Ok, thats fine then.

> Like I said I will contact Petr directly and ask him whether if he wants
> to continue to maintain the CMake FindRTI.cmake, if not I'll take over
> and import your work + the CERTI modification and propose a unified
> version for CMake.
So you are incorporating the contributed files into FindRTI then?
Or do I need to take some actions?

Greetings

Mathias

-- 
Dr. Mathias Fröhlich, science + computing ag, Software Solutions
Hagellocher Weg 71-75, D-72070 Tuebingen, Germany
Phone: +49 7071 9457-268, Fax: +49 7071 9457-511
-- 
Vorstand/Board of Management:
Dr. Bernd Finkbeiner, Dr. Roland Niemeier, 
Dr. Arno Steitz, Dr. Ingrid Zech
Vorsitzender des Aufsichtsrats/
Chairman of the Supervisory Board:
Philippe Miltin
Sitz/Registered Office: Tuebingen
Registergericht/Registration Court: Stuttgart
Registernummer/Commercial Register No.: HRB 382196 


--
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] not found library with package configuration files and changed CMAKE_INSTALL_PREFIX

2011-10-10 Thread Alexander Dahl
Hei hei, 

On Wed, 21 Sep 2011 16:42:37 +0200, Alexander Dahl wrote:
>> The foo-targets.cmake file contains "foo-shared" as imported target,
>> and it is this name that must be supplied to TARGET_LINK_LIBRARIES().
>> Besides, the DESTINATION clause of INSTALL() should be qualified with
>> ARCHIVE/LIBRARY/RUNTIME/..., and EXPORT must precede DESTINATION then.
> 
> Did that.

And it only works in Linux (Ubuntu Lucid 10.04 native with CMake 2.8.5
or cross compiling with ptxdist). On Windows XP with VS 2009 and CMake
2.8.5 the following happens:

install(TARGETS ${PROJECT_NAME}-shared EXPORT ${PROJECT_NAME}-targets
LIBRARY DESTINATION "lib")
#install(TARGETS ${PROJECT_NAME}-shared EXPORT ${PROJECT_NAME}-targets
DESTINATION "lib")
install(EXPORT ${PROJECT_NAME}-targets DESTINATION
"lib/cmake/${PROJECT_NAME}")

With the first line used it gives the following error:

CMake Error at src/CMakeLists.txt:19 (install):
  install Library TARGETS given no DESTINATION!

Commenting in the first line and using the second (removing the LIBRARY
keyword from the line) configure and build works. If someone wants to
reproduce: this is in my forked tree of the iniparser library, you could
get it from GitHub here: https://github.com/LeSpocky/iniparser/tree/work

Greets
Alex

-- 
»With the first link, the chain is forged. The first speech censured,
the first thought forbidden, the first freedom denied, chains us all
irrevocably.« (Jean-Luc Picard, quoting Judge Aaron Satie)
*** GnuPG-FP: 02C8 A590 7FE5 CA5F 3601  D1D5 8FBA 7744 CC87 10D0 ***
--
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] run tests on 5 machines

2011-10-10 Thread Eric Noulard
2011/10/10 Mihai Sandu :
> How can I run tests on 5 machines in same time?
> This is how I run the tests on a machine:
>
> execute_process (COMMAND ssh user@host "ctest -VV -O file.txt -S
> Test.cmake")
>
> and I want to run this command in the same time on 5 machines.

May be you can try pssh:
http://code.google.com/p/parallel-ssh/

-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.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] run tests on 5 machines

2011-10-10 Thread Mihai Sandu
How can I run tests on 5 machines in same time?

This is how I run the tests on a machine:

execute_process (COMMAND ssh user@host "ctest -VV -O file.txt -S Test.cmake")

and I want to run this command in the same time on 5 machines.

Thanks you.
--
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