[CMake] cmakepp: Expression Syntax

2015-04-20 Thread Tobias Becker
Hi All,

I've update my open source project to offer an alternative CMake syntax
which is still a bit Beta.
If your interested here is the Blog Post:
http://thetoeb.de/2015/04/20/cmakepp-expression-syntax/

It allows you to use nested function calls with return values and is
integrable into cmake quite nicely: It can be used as a replacement for
cmake_parse_arguments.

It is written in pure cmake code, does not require any other dependencies
and works from CMake version 2.8.12 upwards

Please feel free to use it to your liking :)


Cheers
Tobi
-- 

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

[CMake] Return Values , Dynamic Calls and Exceptions in CMake

2015-04-04 Thread Tobias Becker
Hi All,

I wanted to share my blog post on Return Values, Dynamic Calls and
Exceptions in CMake with you:
http://thetoeb.de/2015/04/04/cmakepp-dynamic-calls-return-values-and-exceptions/

cmakepp is pure cmake, open source (MIT License) project which gives you 
1000 extra functions and utilities.  If you have questions or suggestions
I'd be happy for any feedback.


Cheers

Tobi
-- 

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

[CMake] (no subject)

2015-03-19 Thread Tobias Becker
I have written a cmake tool which allows you to modify CMakeLists files
from the command line. It is written in pure cmake leverages my cmake token
parser/ reflection functions which I added to cmakepp (a free, universial,
open source, pure cmake function library)

http://thetoeb.de/2015/03/19/cmakepp-reflecting-and-manipulating-cmakelists/

If anyone is interested and has suggestion visit me on
https://github.com/toeb/cmakepp



Cheers
Tobi
-- 

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] load_command not scriptable

2015-02-25 Thread Tobias Becker
Thanks for the Answer!
I actually do not want to alter CMake in any way (and I don't want to
create a custom cmake executable) if possible.  load_command would have
been perfekt.

I am losing alot of performance in my map_set() map_get() etc functions
which translate down to set_property(GLOBAL...) and get_property(GLOBAL)
I am further losing especially much performance when using my eval()
function which dynamically runs cmake code and on which alot of my lib is
based as it is the basis for dynamic method calls, objectsinheritance,
callbacks, events etc.

I have already condensed down my functions to work with the minimal cmake
script statements possible the only way to further improve is by creating a
C/C++ cmake command.  The problem is: I have so many function calls that
the time it takes is not negligable any more

I guess the only viable and platform independent solution is - as you wrote
- to create a cmake with some custom command which replaces the users
current cmake.


Performance Comparison (cmake code):

  timer_start(t1)
  foreach(i RANGE 0 1)
map_set(asd ${i} ${i})
  endforeach()
  timer_print_elapsed(t1)

  ## almost equivalent code
  timer_start(t2)
  foreach(i RANGE 0 1)
set_property(GLOBAL PROPERTY asd.${i} ${I})
set_property(GLOBAL APPEND PROPERTY asd ${i})
  endforeach()
  timer_print_elapsed(t2)


  timer_start(t3)
  foreach(i RANGE 0 1)
eval()
  endforeach()
  timer_print_elapsed(t3)


output:

t1: 2038 ms
t2: 204 ms
t3: 9424 ms


On Wed, Feb 25, 2015 at 1:21 PM, David Cole dlrd...@aol.com wrote:

 You could patch the executable to make cmLoadCommandCommand return
 true from IsScriptable... but if you're going to the trouble of
 patching CMake anyhow, why not simply build your loadable command
 directly into CMake...?

 The other thing might be to mention specifically what the performance
 problem is on the mailing list here to see if anybody has any ideas
 how we could make things faster. And totally preclude your need to
 load an additional command in the first place.

 Or profile it and submit a patch to improve the performance in this
 situation.


 HTH,
 David C.



 On Wed, Feb 25, 2015 at 5:46 AM, Tobias Becker becker.t...@gmail.com
 wrote:
  Hi
 
  I've been working on an open source project which provides alot of extra
  cmake (in pure cmake) https://github.com/toeb/cmakepp.  I am however
 hitting
  a performance bottleneck and want to get around that by using
 load_command
  (I know it is discouraged) however I have the problem that it is not
  scriptable and all of my functions need to be available in script mode.
 
  Is there a way to load compiled commands into cmake after it was
 compiled?
  (I have even thinking about patching the executable to make
  cmLoadCommandCommand return true in its IsScriptable method)
 
  But there should be a simple way?
 
 
  Cheers,
 
  Tobias
 
  --
 
  Powered by www.kitware.com
 
  Please keep messages on-topic and check the CMake FAQ at:
  http://www.cmake.org/Wiki/CMake_FAQ
 
  Kitware offers various services to support the CMake community. For more
  information on each offering, please visit:
 
  CMake Support: http://cmake.org/cmake/help/support.html
  CMake Consulting: http://cmake.org/cmake/help/consulting.html
  CMake Training Courses: http://cmake.org/cmake/help/training.html
 
  Visit other Kitware open-source projects at
  http://www.kitware.com/opensource/opensource.html
 
  Follow this link to subscribe/unsubscribe:
  http://public.kitware.com/mailman/listinfo/cmake

-- 

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

[CMake] load_command not scriptable

2015-02-25 Thread Tobias Becker
Hi

I've been working on an open source project which provides alot of extra
cmake (in pure cmake) https://github.com/toeb/cmakepp.  I am however
hitting a performance bottleneck and want to get around that by using
load_command  (I know it is discouraged) however I have the problem that it
is not scriptable and all of my functions need to be available in script
mode.

Is there a way to load compiled commands into cmake after it was compiled?
 (I have even thinking about patching the executable to make
cmLoadCommandCommand return true in its IsScriptable method)

But there should be a simple way?


Cheers,

Tobias
-- 

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

[CMake] Discuss Adding return values/dynamic function invokation to cmake

2015-01-11 Thread Tobias Becker
Hi All,


I've been thinking aboutallowing return values/ function evaluation in the
cmake script language.  Especially if there are any downsides e.g.
compatibility issues/language inconsistency.

What I mean is the following syntax:
```
function(func1)
 return(1)
endfunction()

function(add lhs rhs)
 math(EXPR res ${lhs} + ${rhs})
 return(${res})
endfunction()

set(result  ${func1()}) # checks to see if function is defined and if so
invokes it idicated by parenthesis
assert(${result} EQUAL 1)

set(result ${add(${func1()} 2}) # inner function is evaluated first and
result is pasted in outer function
assert(${result} EQUAL 3)

message(INFO ${add(1 3)}) # -- prints 4

set(function_name add)
message(INFO ${function_name}(3 5)}) # -- prints 8
```

This could replace generator expressions with a cleaner and more general
alternative and also it would allow cmake to become much easier to use.

I'd also like to know if someone could point me to where in the cmake
codebase the ${} evaluation expression is actually processed.

If you have any critique of this idea then I would also be happy - else
I'll try to fork cmake and implement this.



Cheers!

Tobias
-- 

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

[CMake] Parallel Processes in CMake

2014-12-16 Thread Tobias Becker
Hi

 I Implemented support for parallel processes based on bash xor powershell.
If you have long running processes in CMake you might want to check it out
and try it at http://thetoeb.de/2014/12/16/parallel-processes-cmake/  resp.
https://github.com/toeb/oo-cmake


the gist ist:
```
# these to processes run concurrently
start_process(COMMAND ping cmake.org)
ans(handle1)
start_process(COMMAND ping github.org)
ans(handle2)

set(handles ${handle1} ${handle2})
## waits until all processes are terminated
process_wait_all(${handles})

## prints the standard output stream of both processes to the console
foreach(handle ${handles}
 process_stdout(${handle})
 ans(stdout)

 message(STATUS ${stdout})
endforeach()
```

Tell me if you like it (or if you don't want me to shamelessly plug my Blog
posts on this mailing list) :)


Cheers!

Tobias
-- 

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

[CMake] CMake and the Filesystem

2014-11-27 Thread Tobias Becker
Hi!

I've been continuing work on my enhancement suite for cmake. And just
finished documenting and writing up some things about paths and filesystem
handling using a couple of self developed functions. Also convenience
functions for git, hg and svn.


If your interested you can look at my blog post
http://thetoeb.de/2014/11/27/cmake-filesystem/
or directly at the github repository https://github.com/toeb/oo-cmake



Cheers!

Tobias
-- 

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

[CMake] CTest integration in Visual Studio TestExplorer

2014-11-22 Thread Tobias Becker
So I tried my luck with creating an extension for Visual Studio that allows
you to use the Test Explorer to discover and run your CTests.  You can
download it in the visual studio gallery. Read about it on
http://thetoeb.de/2014/11/22/ctest-integration-visualstudio/ .

I'd be happy if anyone wanted to give me feedback or contribute on
https://github.com/toeb/CTestTestAdapter ;)

Sorry for the shameless plug (but hey - its free)


Kind Regards,

Tobias
-- 

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

[CMake] Useful extensions for CMake blog post

2014-09-05 Thread Tobias Becker
Hi,

I thought you might enjoy 400 extra functions for doing more complicated
things with cmake (also comes with an interactive cmake console which is
implemented in pure cmake).
Some features:
* maps,(structural variables)
* object oriented programming with cmake language (prototypical inheritance)
* extended list functionality (like slice, push, pop, ...)
* lambdas
* dynamic functions (call functions without knowing its name)
* ...
Here is the link: http://thetoeb.de/2014/09/05/useful-extensions-for-cmake/

I'm sharing these functions (a lot of time went into them) and hope someone
might find them useful.  If you have suggestions you can write them into
github or as a comment on the blog. They tested and are part of a pure
cmake package manager which I'm still working on.

Kind Regards,

Tobias
-- 

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

[CMake] Object Oriented Programming with CMake Script

2014-02-25 Thread Tobias Becker
For those interested: I have written a pure cmake module which allows
Object Oriented programming in CMake

you can download it through my blog at
http://thetoeb.wordpress.com/2014/02/25/object-oriented-cmake-next-iteration/

I also have a question:  Will CMake script ever support higher language
features like scoped function names, eval, dynamic functions, return values
(the workarounds for these features are costing me alot of performance)?


Here is an example of what you can do with the library:

function(test)
 ### using objects
 ### =
# oo-cmake is very similar to javascript
# I actually used the javascript reference to figure out how things could
be done :)
 # oo-cmake is a pure object oriented language like javascript (only
objects no types per se)
# oo-cmake is currently file based and relies heavily on dynamic functions
so to be upfront about it:
 # oo-cmake is very slow (depending on what your doing)

## creating a object
## =
 obj_new(myobject)
# ${myobject} now is a reference to an object
obj_exists(${myobject} _exists)
 assert(_exists)

## deleting a object
## =
 # oo-cmake does not contains automatic memory management
# you can however remove all objects by calling obj_cleanup
 # (a very crude way of garbage collection) I would suggest calling it at
the end of cmake.
obj_new(object_to_delete)
 obj_delete(${object_to_delete})
# object_to_delete still contains the same reference
# but the object does not exists anymore and the following returns false
 obj_exists(${object_to_delete} _exists)
assert(NOT _exists)


## setting and setting property
 ## ==
obj_new(myobject)
# call obj_set passing the object reference
 # the propertyname 'key1' and the value 'val1'
# everything beyond 'key1' is saved (as a list)
 obj_set(${myobject} key1 val1)
#call obj_get passing the object refernce the result variable and
 # the key which is to be gotten
obj_get(${myobject} theValue key1)
assert(theValue)
 assert(${theValue} STREQUAL val1)


## setting a function and calling it
 ## =
obj_new(obj)
obj_set(${obj} last_name Becker)
 obj_set(${obj} first_name Tobias)
#obj_setfunction accepts any function (cmake command, string function, file
function, unique function (see function tutorial))
 # if you use a cmake function be sure that it will not be overwritten
# the safest way to add a function is to use obj_declarefunction
 # you can either specify the key where it is to be stored or not
# if you do not specify it the name of the function is used
 function(greet result)
# in the function you have read access to all fields of the proeprty
# as will as to 'this' which contains the reference to the object

# this sets the variable ${result} in PARENT_SCOPE (returning values in
cmake)
set(${result} Hello ${first_name} ${last_name}! PARENT_SCOPE)

endfunction()
obj_setfunction(${obj} greet)
obj_callmember(${obj} greet res)
 assert(res)
assert(${res} STREQUAL Hello Tobias Becker!)
# alternatively you can also use obj_declarefunction
 # this is actually the easiest way to define a function in code
obj_declarefunction(${obj} say_goodbye)
 function(${say_goodbye} result)
set(${result} Goodbye ${first_name} ${last_name}! PARENT_SCOPE)
 endfunction()
obj_callmember(${obj} say_goodbye res)
assert(res)
 assert(res STREQUAL Goodbye Tobias Becker!)

## built in methods
## 
 # obj_new creates a object which automatically inherits Object
# Object contains some functions e.g. to_string, print, ...
 #
obj_new(obj)
obj_callmember(${obj} print)

# this prints all members
# ie
#{
# print: [function],
 # to_string: [function],
# __ctor__: [object :object_Y3dVWkChKi],
# __proto__: [object :object_AztQwnKoE7],
 #}


## constructors
## 
 # you can easily define a object type via constructor
function(MyObject)
# declare a function on the prototype (which is accessible for all objects)
 # inheriting from MyObject
obj_declarefunction(${__proto__} myMethod)
function(${myMethod} result)
 set(${result} myMethod: ${myValue} PARENT_SCOPE)
this_set(myNewProperty this is a text ${myValue})
 endfunction()

# set a field for the object
this_set(myValue hello)
 endfunction()

obj_new(obj MyObject)
# type of object will now be MyObject
 obj_gettype(${obj} type)
assert(type)
assert(${type} STREQUAL MyObject)
 # call
obj_callmember(${obj} myMethod res)
assert(res)
 assert(${res} STREQUAL myMethod: hello)
obj_set(${obj} myValue othervalue)
obj_callmember(${obj} myMethod res)
 assert(res)
assert(${res} STREQUAL myMethod: othervalue)
obj_get(${obj} res myNewProperty)
 assert(res)
assert(${res} STREQUAL this is a text othervalue)

## functors
 ## 

## binding a function
## ==
 # you can bind any function to an object without
# setting it as property
# causing the function to get access to 'this'
 # and all defined properties
function(anyfunction)
this_callmember(print)
 endfunction()
obj_new(obj)
obj_bindcall(${obj