A minimal CMake Finder Macro for the Google C++ Mocking Framework Mon, Sep 26. 2011
Hi,
If you just want to get started quickly with google's own c++ mocking framework (which also bundles their testing framework), you might find my cmake macro handy (That is, if you are using cmake
). You can download my macro from here:FindGoogleMockMinimal.cmake
It's for those cases where you are just banging out an test executable and need the gmock-all.cc and gtest-all.cc files in order to make your code run. Therefore you just need an unpacked google-mock sourcecode package, and don't have to build it..
Step 1: CMakeLists.txt changes
Here's how your CMakeLists.txt would look like:
As you can see, you only need ${GMOCKMINIMAL_INCLUDE_DIRS} and ${GMOCKMINIMAL_SRC}.
In order to use the CMake Finder Macro you have to first "register" it in your CMake file - f.e. if you put it into a subfolder cmake/Modules, this is the snippet:
Step 2: Configuring cmake
At configuration time, set the variable ${GMOCK_SOURCE_ROOT} to point to the gmock sourcecode.
That's it
Here is the CMake Macro File in all its glory
Once again, the download link: FindGoogleMockMinimal.cmake
Have fun
If you just want to get started quickly with google's own c++ mocking framework (which also bundles their testing framework), you might find my cmake macro handy (That is, if you are using cmake

It's for those cases where you are just banging out an test executable and need the gmock-all.cc and gtest-all.cc files in order to make your code run. Therefore you just need an unpacked google-mock sourcecode package, and don't have to build it..
Step 1: CMakeLists.txt changes
Here's how your CMakeLists.txt would look like:
find_package(GoogleMockMinimal REQUIRED)
INCLUDE_DIRECTORIES(${GMOCKMINIMAL_INCLUDE_DIRS})
FILE(GLOB MY_TEST_SRCS .cpp .h)
ADD_EXECUTABLE(MyTest
${GMOCKMINIMAL_SRC}
${MY_TEST_SRCS}
)
As you can see, you only need ${GMOCKMINIMAL_INCLUDE_DIRS} and ${GMOCKMINIMAL_SRC}.
In order to use the CMake Finder Macro you have to first "register" it in your CMake file - f.e. if you put it into a subfolder cmake/Modules, this is the snippet:
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
Step 2: Configuring cmake
At configuration time, set the variable ${GMOCK_SOURCE_ROOT} to point to the gmock sourcecode.
cmake -DGMOCK_SOURCE_ROOT=/wherever/it/is
That's it
Here is the CMake Macro File in all its glory

#
#
# Locate and configure the Google Mock (and bundled Google Test) libraries for minimal setup
# Tested with google mock version: 1.6, Win32 (VC.NET 2003) & Linux (gcc 4.x.x)
#
# Defines the following variables:
#
# GMOCKMINIMAL_FOUND - Found the Google Mock libraries
# GMOCKMINIMAL_INCLUDE_DIRS - The directories needed for include paths
# GMOCKMINIMAL_SRC - The minimal set off .cc files to use with an executable (mock+test)
#
# Copyright 2011 Amanjit Gill (amanjit.gill@gmx.de)
# Based on a CMake macro from Chandler Carruth
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy
# of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
#
if(GMOCKMINIMAL_INCLUDE_DIRS)
set(GMOCKMINIMAL_FOUND true)
else(GMOCKMINIMAL_INCLUDE_DIRS)
set(GMOCK_SOURCE_ROOT "" CACHE PATH "Source folder for Google Mock")
if(GMOCK_SOURCE_ROOT)
find_path(_GMOCKMINIMAL_INCLUDE_DIR gmock/gmock.h
PATHS "${GMOCK_SOURCE_ROOT}/include"
PATH_SUFFIXES ""
NO_DEFAULT_PATH)
find_path(_GTESTMINIMAL_INCLUDE_DIR gtest/gtest.h
PATHS "${GMOCK_SOURCE_ROOT}/gtest/include"
PATH_SUFFIXES ""
NO_DEFAULT_PATH)
find_file(_GMOCKMINIMAL_SRC /src/gmock-all.cc
PATHS "${GMOCK_SOURCE_ROOT}"
PATH_SUFFIXES ""
NO_DEFAULT_PATH)
find_file(_GTESTMINIMAL_SRC /gtest/src/gtest-all.cc
PATHS "${GMOCK_SOURCE_ROOT}"
PATH_SUFFIXES ""
NO_DEFAULT_PATH)
else(GMOCK_SOURCE_ROOT)
find_path(_GMOCKMINIMAL_INCLUDE_DIR gmock/gmock.h
PATH_SUFFIXES "")
find_path(_GTESTMINIMAL_INCLUDE_DIR gtest/include/gtest.h
PATH_SUFFIXES "")
find_path(_GMOCKMINIMAL_SRC src/gmock-all.cc
PATH_SUFFIXES "")
find_path(_GTESTMINIMAL_SRC gtest/src/gtest-all.cc
PATH_SUFFIXES "")
endif(GMOCK_SOURCE_ROOT)
if(_GMOCKMINIMAL_INCLUDE_DIR)
set(GMOCKMINIMAL_FOUND true)
set(GMOCKMINIMAL_INCLUDE_DIRS ${_GMOCKMINIMAL_INCLUDE_DIR} ${_GTESTMINIMAL_INCLUDE_DIR}
${GMOCK_SOURCE_ROOT} ${GMOCK_SOURCE_ROOT}/gtest CACHE PATH
"Include directories for Google Mock library")
set(GMOCKMINIMAL_SRC ${_GMOCKMINIMAL_SRC} ${_GTESTMINIMAL_SRC} CACHE PATH
"Source paths for Google Mock / Google Test combined cpp file (gmock-all.cc and gtest-all.cc)")
mark_as_advanced(GMOCKMINIMAL_INCLUDE_DIRS)
mark_as_advanced(GMOCKMINIMAL_SRC)
if(NOT GoogleMockMinimal_FIND_QUIETLY)
message(STATUS "Found minimal setup for the Google Mock library: ${GMOCK_SOURCE_ROOT}")
endif(NOT GoogleMockMinimal_FIND_QUIETLY)
else(_GMOCKMINIMAL_INCLUDE_DIR)
if(GoogleMockMinimal_FIND_REQUIRED)
message(FATAL_ERROR "Could not find the Google Mock library")
endif(GoogleMockMinimal_FIND_REQUIRED)
endif(_GMOCKMINIMAL_INCLUDE_DIR)
endif(GMOCKMINIMAL_INCLUDE_DIRS)
Once again, the download link: FindGoogleMockMinimal.cmake
Have fun
Creating ER (Entity-Relation) diagrams with dia sucks!!! Wed, Jul 27. 2011
Relation Types capture relations between two or more Entities.
Reminds me of that VISIO 200x WTF: The shadow property of every shape in a drawing was actually a property of the page setup, and couldn't be changed for an individual object
THAT'S SO ENTERPRISEY
And people actually complain about creating diagrams with MS Office tools.
Hint: At least it works.
Hint to myself: Visio is actually a part of the MS Office suite
Reminds me of that VISIO 200x WTF: The shadow property of every shape in a drawing was actually a property of the page setup, and couldn't be changed for an individual object
THAT'S SO ENTERPRISEY
And people actually complain about creating diagrams with MS Office tools.
Hint: At least it works.
Hint to myself: Visio is actually a part of the MS Office suite
Zim - a really cool desktop wiki Tue, Jul 19. 2011
As a Software Dev, during the lifetime of a software project, you probably are writing some kind of docs, brainstorming etc, documentation...
At least you should
Since you are a developer, this (probably) is you wishlist
• everything should be checked into your VCS
• hence it shouldn't be a blob - a binary
• docs should be editable on multiple platforms
• by multiple users
• hence you would like to diff things
• open file formats.
• be able to use your beloved editor
• still all features of a word processor
Ideally - text files. Actually it's pretty funny. Developers stick to text files while all kind of interactive apps exist for the rest of the world. But we choose independence. Still we would like to have cross references, images, etc..
Zim hits this sweet spot. You get an explorer-like desktop user interface to a wiki that is saved as plain text files on your harddrive. You get the wysiwyg thing, wiki cross-references and export functionality.
Now there's no reason not to document features, requirements and code
Actually I am a huge OneNote Fan and User. I guess that's why I like Zim, too...
At least you should

Since you are a developer, this (probably) is you wishlist
• everything should be checked into your VCS
• hence it shouldn't be a blob - a binary
• docs should be editable on multiple platforms
• by multiple users
• hence you would like to diff things
• open file formats.
• be able to use your beloved editor
• still all features of a word processor
Ideally - text files. Actually it's pretty funny. Developers stick to text files while all kind of interactive apps exist for the rest of the world. But we choose independence. Still we would like to have cross references, images, etc..
Zim hits this sweet spot. You get an explorer-like desktop user interface to a wiki that is saved as plain text files on your harddrive. You get the wysiwyg thing, wiki cross-references and export functionality.
Now there's no reason not to document features, requirements and code

Actually I am a huge OneNote Fan and User. I guess that's why I like Zim, too...
Visualization matters - Non-linear Optimization Wed, Jul 6. 2011
I am right now studying linear and non-linear optimizations while attending a mandatory mathematics course @ Universität in Hagen. Functions from R^2 -> R can be easily visualized - guess that qualifies for a textbook example
... Consider this optimization problem

The visualization contained in the course textbook looks like this

This is a contour plot - but I don't think its helpful to just present this graph. The normal plot and the contour graph made things a lot easier for me - I fired up the XMaxima CAS, and plotted this graph and it's contour graph


From an educational and visual point of view I think it's obvious which one is easier to grasp for a student ...


The visualization contained in the course textbook looks like this
This is a contour plot - but I don't think its helpful to just present this graph. The normal plot and the contour graph made things a lot easier for me - I fired up the XMaxima CAS, and plotted this graph and it's contour graph
From an educational and visual point of view I think it's obvious which one is easier to grasp for a student ...
"Prepare ship for ludicrous speed" ... the /Ox compiler flag Thu, Jun 30. 2011
Reading the Codeproject daily newsletter I found out about a cool C++ article on Codeproject about Image Manipulation using modern C++ features for abstractions that theoretically could be optimized away by the compiler - aka zero cost abstraction..
Anyway I noticed the VC10 code was significantly slower than the g++ code.
So in a comment, I asked about using the /Ox compiler flag (I don't have access to VC10, the last thing I bought was VC7.1)...
... And charts have to be redrawn now, I guess..
(Yeah, I know /O2 still is the preferred choice for most projects...)
Anyway,
C++ 4TW
PS: Do you Remember Spaceballs?.
Anyway I noticed the VC10 code was significantly slower than the g++ code.
So in a comment, I asked about using the /Ox compiler flag (I don't have access to VC10, the last thing I bought was VC7.1)...
... And charts have to be redrawn now, I guess..

(Yeah, I know /O2 still is the preferred choice for most projects...)
Anyway,
C++ 4TW
PS: Do you Remember Spaceballs?.
Fun/Little Gotchas with JDO Typesafe queries.... Mon, Apr 25. 2011
(Update: me happy ... DataNucleus Platform 3.0M4 released ...
"RDBMS : Support JDOQL String.equalsIgnoreCase()")
I have been hacking around with JDO Typesafe for a private litte project - it's pretty nice. Actually, JDO typesafe isn't part of the standard -yet.
I hit an issue with this query utilizing equalsIgnoreCase - I posted a message on the Datanucleus bulletin board
I guess it simply isn't implemented yet
I have to prepare for an exam therefore I didn't have time to take a closer look at the code.
But I did take a glance at the code. All in all, the code quality of the Data Nucleus platform seems to be lightyears ahead of hibernate. Not to mention one other word: bugs.
Another small problem
On the downside, it's pretty hard to get Spring 3.0X support for one particular feature- which is a convenience feature, not critical: org.springframework.orm.jdo.TransactionAwarePersistenceManagerFactoryProxy, mentioned on this page .
Basically, for JDO Typesafe you need a JDOPersistenceManager, not a PersistenceManager - it's a DataNucleus feature right now, not part of the standard yet. This sounds like a solveable problem, with pure OO you can use covariance - but here we are dealing with a proxy thats created with CGlib at runtime, and its built to mimic PersistenceManager (of course!). You can't get away with simply extending TransactionAwarePersistenceManagerFactoryProxy and overriding some methods. Therefore I don't use TransactionAwarePersistenceManagerFactoryProxy - Its convenience anyway.
"RDBMS : Support JDOQL String.equalsIgnoreCase()")
I have been hacking around with JDO Typesafe for a private litte project - it's pretty nice. Actually, JDO typesafe isn't part of the standard -yet.
I hit an issue with this query utilizing equalsIgnoreCase - I posted a message on the Datanucleus bulletin board
I guess it simply isn't implemented yet
I have to prepare for an exam therefore I didn't have time to take a closer look at the code.
But I did take a glance at the code. All in all, the code quality of the Data Nucleus platform seems to be lightyears ahead of hibernate. Not to mention one other word: bugs.
Another small problem
On the downside, it's pretty hard to get Spring 3.0X support for one particular feature- which is a convenience feature, not critical: org.springframework.orm.jdo.TransactionAwarePersistenceManagerFactoryProxy, mentioned on this page .
Basically, for JDO Typesafe you need a JDOPersistenceManager, not a PersistenceManager - it's a DataNucleus feature right now, not part of the standard yet. This sounds like a solveable problem, with pure OO you can use covariance - but here we are dealing with a proxy thats created with CGlib at runtime, and its built to mimic PersistenceManager (of course!). You can't get away with simply extending TransactionAwarePersistenceManagerFactoryProxy and overriding some methods. Therefore I don't use TransactionAwarePersistenceManagerFactoryProxy - Its convenience anyway.
Cleaning up my homepage Sat, Apr 2. 2011
Back to basic, a simple, plain and clean page.
Reason: Small is beautiful. And this blog is powerful enough for dynamic content.
Good bye, old page:

Reason: Small is beautiful. And this blog is powerful enough for dynamic content.
Good bye, old page:

Is the latest Version of Acrobat Reader X leaking GDI Resources? Thu, Feb 24. 2011
Just wo-n-d-er-ing

I also witnessed the classic symptoms of GDI resource exhaution: greyed-out Icons, Areas, Text etc.
I used RAII to solve that problem when I was doing Win32 C++ Programming.
Over and out
I also witnessed the classic symptoms of GDI resource exhaution: greyed-out Icons, Areas, Text etc.
I used RAII to solve that problem when I was doing Win32 C++ Programming.
Over and out
Tuning JVM Params for faster startups (on Linux) Wed, Oct 6. 2010
Development turn-around times for java development can be ridicously high, especially if you add things like grails to the soup.
Setting explicit JVM params such as -Xmx , Permgen size are somehow mandatory. Using 4GB RAM (for web programming, lol) is important, too.
Two other things I consider useful (for the "offiical" Sun Java SDK):
•Use the -client JVM param if you're restarting your app over and over again. This can speed up the startup times because -server is optimized for a JVM that must be running all the time and therefore does some very time consuming JIT operations.
•Tune kernel parameters. I set kernel.shmmax to the amount of available physicial memory (in bytes). I have a thorough understanding of shared memory and its usages cause I come from the C++ world, anyway I don't know all the implications /wrt Java. It made a difference
I am still not really happy with the end results - its far too slow to be funny.
Setting explicit JVM params such as -Xmx , Permgen size are somehow mandatory. Using 4GB RAM (for web programming, lol) is important, too.
Two other things I consider useful (for the "offiical" Sun Java SDK):
•Use the -client JVM param if you're restarting your app over and over again. This can speed up the startup times because -server is optimized for a JVM that must be running all the time and therefore does some very time consuming JIT operations.
•Tune kernel parameters. I set kernel.shmmax to the amount of available physicial memory (in bytes). I have a thorough understanding of shared memory and its usages cause I come from the C++ world, anyway I don't know all the implications /wrt Java. It made a difference
I am still not really happy with the end results - its far too slow to be funny.
Link: A useful introduction to Awk Thu, Sep 30. 2010
Comparing Linear Algebra packages for C++ Thu, Sep 23. 2010
Cool - Wireless healthcare from Qualcomm Mon, Sep 13. 2010
Video:
Via the good folks at netbooknews.de.
Its just funny because I did stuff like this myself a long,long time ago ... 2005 .. Dude time is moving on so fast.. Good old days
Via the good folks at netbooknews.de.
Its just funny because I did stuff like this myself a long,long time ago ... 2005 .. Dude time is moving on so fast.. Good old days

Weird Stuff :-) Sun, Sep 12. 2010
How can I remove GWT from Spring Roo (Stuff that can ruin your day..) Sun, Sep 12. 2010
Lets say you are about to evaluate Spring Roo. Lets start the with the Get Started Guide.
There's this very innocent looking line:
Yeah. Lets say gwt doesn't work for whatever reasons with your configuration.
How do you uninstall/remove gwt?
What does the roo console say?
Well, If anyone has found a simply way to do that, please just comment.
Man thats sooo enterprisey.
Hey, I am used to getting tons of stacktraces on initial plumbing/integration from any combination of OSS java components, and I can handle a lot of them. Some people would describe this job as "java enterprise developer."
But its a sunday, after all...
There's this very innocent looking line:
roo> gwt setup
Yeah. Lets say gwt doesn't work for whatever reasons with your configuration.
How do you uninstall/remove gwt?
What does the roo console say?
roo> hint gwt. Nice but how do I uninstall?
It's easy to create a GWT client in your project.
Just type 'gwt setup' and press ENTER.
Note Roo's GWT support outputs GWT 2.1 applications.
Well, If anyone has found a simply way to do that, please just comment.
Man thats sooo enterprisey.
Hey, I am used to getting tons of stacktraces on initial plumbing/integration from any combination of OSS java components, and I can handle a lot of them. Some people would describe this job as "java enterprise developer."
But its a sunday, after all...
An Audio Interview with Bjarne Stroustrup @ Deutschlandfunk Wed, Sep 1. 2010
"C wurde so konzipiert, dass der Compiler 48 Kilobyte Speicherplatz belegt. Kilobyte, nicht Megabyte!"
"Deshalb hätte der Vater von C, Dennis Ritchie, sicherlich einiges anders gemacht, wenn er 256 Kilobyte gehabt hätte wie ich, als ich mit C++ begann."

The whole interview: A Deutschlandfunk Audio interview with Bjarne Stroustrup
« previous page
(Page 2 of 3, totaling 34 entries)
next page »