Saturday, July 4, 2015

The Mouse and the Moon


© 2015, by Anthony Kosky. All rights reserved.


A long time ago, in a land far away, there lived a small mouse.

Now you’re probably saying to yourself, “That’s not a very interesting start to a story. After all there are mice in almost every place on earth, and mice, or their ancestors, have been around for a hundred million years or more1.”

guinevere.jpg

But this mouse was unusual. Her name was Guinevere and she liked cheese.

Of course now you’re probably saying to yourself “But all mice like cheese,” and you’re right. At least most of them do.

But here’s the thing: Guinevere Really Liked Cheese. I mean she really, really, REALLY liked it. Even other mice thought she was pretty fanatical about it. She had a large burrow with many rooms and tunnels, and it was always full of cheese. There was Havarti in the hallways, Chevre in the cellars, Brie in the bedrooms, Compté in the cupboards an Tomme on the tables. And of course there was chedder: chedder was everywhere. Guinevere collected all the cheese she could find. Once she rolled a whole wheel of mimolette all the way home only to find it was too big to fit in her hole, and it sat outside her front door for a month before she ate enough that she could fit it inside.

But it wasn’t just that she liked to collect and eat cheese - she also studied it. Her thesis on Sheep Cheeses of the Eastern Himalayas was considered by many to be the definitive work on the subject, and her paper entitled “On the Benefits of Washed Rinds” had lead to a small revolution in the manufacture of goat cheese. She had served not once but twice as the keynote speaker at the annual conference of International Mouse Association’s Special Interest Group on Blue Cheese.

One warm, summer evening Guinevere was lying in a field of grass looking up at the sky -- she’d just finished her dinner of Fioré Sardo with a little fresh sheep’s milk cheese for dessert, and was feeling pleasantly drowsy -- when she noticed the moon hanging in the sky. It was aperfect, round, silvery disk, against a backdrop of black pricked with thousands of glittering st ars.
moon.jpg

She remembered a nursery rhyme that her mother had sung to her when she was little.

The moon’s a great big ball of cheese
Hanging in the starry sky
It hangs upon a great cheese tree
Please don’t ask me why.

“But I wonder,” she thought, “what kind of cheese is it.”

At first she thought it might be a giant chevrot. “But surely,” she said to herself, “there aren’t enough goats.” She wondered if the craters might be the holes in a Swiss-cheese; perhaps a huge Gruyere. “But the colour is wrong,” she thought. The more she thought about it, the more puzzled she became, until she decided she just had to find out for herself.
guinevere-moon-1.jpg

First she tried to reach up and grab a piece of the moon, but, even standing on tip toes she couldn’t reach it. “Oh well,” she thought, “I am a mouse after all”. She tried jumping as high as she could. She went to fetch a big block of Jarlsberg from her larder, another of Cheshire, and one of Camembert;  piled them on top of each other, and climbed  to on top of them, but the moon didn’t seem to get any closer. When eventually, tired and frustrated, she gave up, it was nearly morning. “Tomorrow,” she said, “I will get a step ladder’.


The next night Guinevere borrowed a step ladder; she dragged it to the top of the tallest hill she could find; she stood on tip toes; she put a cardboard box on the top step of the ladder; she stood on tip toes again, this time on top of the cardboard box. And yet, try as she might, the moon seemed just as far out of reach as ever.
guinevere-stepladder.jpg


“It’s odd,” she thought as she balanced on the edge of the box one last time, stretching out her paws as far as she possibly could, “but the moon seems a little smaller than it did yesterday”.


The following night Guinevere borrowed a trampoline from a friend.

She jumped. She bounced. She leaped. She went up …
guinevere-up.jpg

and down …
guinevere-down.jpg

and up and down and up and down, getting higher and higher and higher. And yet, she still could not reach the moon.

By the time she was finished she felt quite queasy and dizzy. So much so that she had to make herself a midnight snack - a little Roquefort on a toasted breadcrumb - to settle her tummy. As she nibbled she thought to herself, “The moon really does seem a little smaller tonight, but how could that be?”


The night after that Guinevere went to the forest. She searched for the tallest tree she could find, an ancient, towering oak. She climbed to the very top, and clutching tightly to the topmost branches with her hind paws, she reached up as high as she possibly could.
guinevere-tree.jpg

This time there was no doubt. Where the moon had been a perfect round circle, it was now an oval, as if someone had been eating away at one side of it, while leaving the other side alone.

“Someone,” she said in shocked disbelief, “is stealing the cheese.”


In the nights that followed Guinevere tried everything she could think of to try to reach the moon. She climbed mountains and towers. She took the biggest ladder she could find and balanced it in the high branches of the oak tree. She even asked a bird to pick her up and fly her there, but the bird said she was too busy looking after her eggs. I’m sure if rocket ships had been invented then, she would have tried one of those too. But she still could not reach the moon.
guinevere-bird.jpg

And yet clearly someone else was able to reach it. For, night after night, it got smaller and smaller, until half the moon had disappeared, like a Crotin that had been chopped straight down the middle.


Guinevere decided she must find out who was stealing the moon, and put a stop to it. She asked everyone she knew. She tried a private detective, Philip Micelow, who promised to investigate but came back empty pawed. She asked all the cheese industry insiders she had as contacts, but she could find no clue.
guinevere-pi.jpg

By now the moon was almost gone, only a thin sliver remained, and Guinevere was getting so worried that she almost lost her appetite. Even a particularly pungent Gorgonzola did little to calm her nerves.

“Perhaps it is the cats,” she thought to herself. “After all, they love to taunt us mice.” But no, she knew that cats had no interest in cheese.

“Maybe it’s the rats,” she thought. “But no: the rats are greedy, and some of them are evil, but none of them are very smart.” No rat would be be able to steal the moon.2

“So it must be a mouse,” she concluded. “But it’s much too much cheese for one mouse to eat, so they must planning on selling it or giving it to other mice.”

And then Guinevere came up with a plan.

“Maybe I can’t find out who stole the moon, or even how they did it. But if I can convince the Mouse Who Stole The Moon, and all the other mice that might want some of it, that it isn’t made of cheese at all, perhaps he will put it back. After all,” she thought, “I do have some influence.”
guinevere-radio-show.jpg
The next morning she phoned a radio talk show. “I’ve just found out,” she said, “that the moon isn’t made out of cheese at all”. Then she typed a long letter and sent it to all the major newspapers.

That night the remaining sliver of moon looked a little bit wider.

The next morning the New Mouse Times published Guinevere's letter in their editorial column. The headline read “Shocking New Scientific Discovery: Composition of the Moon Mostly Rock”.

That night the sliver of moon was a bit wider. “It’s working,” Guenevere thought, “but I must make it stick”. She stayed up late that night trying to come up with a new rhyme. The next morning she went to the school playground and taught it to the little mice playing there.

The moon is just a ball of rock
It’s not a tasty treat
If you bite it you will break your teeth
It isn’t good to eat.

guinevere-playground.jpg
All day the children sang the song to each other. That evening they went home and sang it to their parents and grandparents.

The next day the parents called their  nephews and nieces, cousins, and uncles and aunts. Soon mice everywhere were singing it to their children at bedtime, and the children were singing it to their friends at school next day.
guinevere-bedtime.jpg

In the mean time many important mouse scientists and scholars chimed in, agreeing with Guenevere. They didn’t want to seem left out, so they cited new evidence, trying to pretend they had also been part of the great discovery, or that it was what they had thought all along.
guinevere-lecture.jpg

And every day the moon got a little bigger.

Soon mice everywhere believed that the moon was not made of cheese, and, of course, all the other animals, and the humans, learnt it from the mice. And soon the moon was a full round circle once again.

In fact Guinevere’s plan worked so well that, in a little while people forgot that they’d ever believed that the moon was made of cheese, and started to think it was just a silly story for children. And so it is that, even today, if you were to ask your parents, or your teacher, or a scientist from NASA, what the moon is made of, they’ll probably start talking about rocks, ice and mineral compositions. And, if you tell them it's actually made of cheese, they won't even believe it.
guinevere-moon-2.jpg

But You and I and Guinevere know the truth.




1 http://news.bbc.co.uk/2/hi/sci/tech/1949644.stm



2 The author would like to emphasize that these are the opinions or the character Guinevere and are in no way condoned by the author. Rats are not evil: they are highly misunderstood creatures and are, for the most part, good natured and kind. Now squirrels on the hand...

Wednesday, November 5, 2014

Octopusses




These are some paintings I just finished for Rose and Sophie to have in their rooms.


Sunday, October 12, 2014

The Turtle who was Pink and the Turtle who was Blue

This morning Sophie asked for a poem and I asked which one she wanted, expecting it to be The Jumblies or something else from Edward Lear. Instead she threw me by asking for a poem about a pink turtle and a blue turtle. I was pretty pleased with what I came up with on the spot, and tried to write it down as soon as I had a chance. I was already having trouble remembering it all, but this was as close as I could get.

Once there was a turtle
and she was very blue
She swam down to the ocean floor
and wondered what to do.


There was another turtle
and she was very pink
She swam into a deep dark cave
so she could have a think.


All the other turtles
who saw them said “Who knew
there are turtles who are pink
and others who are blue.”


The blue turtle went swimming
along the coral reef
The turtle who was pink
came swimming underneath.


The turle who was pink said
to the turtle who was blue
“It’s very good to meet you,
and tell me, how are you?”


The turtle who was blue said
to the turtle who was pink,
“You’re a very pretty turtle,”
and she gave a turtle wink.


The turtles said “Let’s marry
and swim to far away”
And the pink and blue turtles
are happy to this day.
turtles-blue-and-pink.jpg


Monday, June 9, 2014

Tygers - Chapter 3

I started wrote this in my journal a while ago, after Rosie wanted another Tiger story at bed time. I intended to add more to it, but never thought of anything good to add, so I figured I'd just throw in some illustrations and leave it as it is.

It was a sunny morning in early Spring. The streams were burbling happily to themselves, glad to be free of the winter ice, and feeling important because they were taking the melted snow water down to the river. The squirrels emerged, bleary eyed, from their tree trunks and tried to remember where they had hidden their nuts. And high in the branches a robin cautiously cleared its throat and tested its voice before commencing its morning song. It was on a morning such as this that two young tigers set out to explore the sights and sounds of Spring.

They had been been walking for about fifteen minutes when the older tiger, Rosie, noticed a scufflement at the base of a moss-covered bush. They went a little closer to investigate a saw a small brown animal snuffling among the roots. It had a black, twitchy nose, two black twinkly eyes, and, covering its back were prickles. The animal paused to look at the two approaching tigers.


"What kind of animal are you?" asked Sophie, the younger tiger, curiously.

"Ah," said the animal impressively, "I is an Erinaceus Europaeus, of the order Erininaceomorpha." Then, as the tigers look confused, it added "What is commonly called an 'edge 'og. And what might you two stripey young ladies be, if I might be so bold as to ask?".

"We're Tigers," said Rosie proudly. "I'm Rosie."

"And I'm Sophie," said Sophie.

"Bernard Tiggiewinkle Esquire. Delighted to make your aquaintance," said the hedge hog."I was named after Saint Tiggiewinkles 'edge 'og 'ospital where I was born," he explained. "Bernard is after Saint," he added.

"Oh," said Rosie. "Why do you keep scratching yourself with your hind leg?"

"Ah," said Bernard Tiggiewinkle, "that would be on account of these 'ere fleas itching something terrible. We 'edge 'ogs 'ave an awful lot of fleas."

Both the tigers took a few steps back.

"Not to worry missies," said the hedgehog. "'Edge 'og fleas is most particular. Not interested in other sorts of animals."

"What are you doing?" asked Sophie curiously.

"Looking for slugs," said Bernard Tiggiewinkle. "They're delicious," he said. "Look here's one."

Bernard held up a large, semi-translucent, wriggling slug that seemed to ooze slime. The two tigers, who had moved closer after hearing that they were safe from hedgehog fleas, took a step back again.

"Would you like to try one?" the hedgehog asked Rosie.

"No thank you," Rosie said politely.

"Are you sure? They're fresh. This one looks especially juicy."

"No thank you," said Rosie again.

"What about you, Miss?" said Bernard Tiggiewinkle turning to Sophie. "Very good for you slugs is. Highly nutritious."

"No thank you," said Sophie as politely as she could manage.

"Mighty fine slug this. Don't recall seeing better."

"It's very kind of you," said Sophie, "but I'm really not hungry."

"Ah well," said the hedgehog. "Suit yourself."

"There was a loud slurping noise as the slug disapeared into Bernard Tiggiewinkles mouth. The two twitching antennae were the last part to vanish. There followed by a few minutes of munching and swallowing noises, and then a the hedgehog emitted a soft "burp".

"As I thought," he said to himself. "Mighty fine slug that."

"Well," said Rose politely, "it was a pleasure meeting you Mister Tiggiewinkle."

The hedgehog nodded his head towards them in a formal manner before turning back to the bushes to search for more slugs, and the two tigers continued on their way.

Thursday, February 27, 2014

A Proposal for Assessing the Severity of Medical Conditions

When visiting a doctor, which is something I seem to do a lot more often now that we have small children, I am struck by how often one is asked to quantify things using ill-defined scales or metrics. Most frequently a doctor or nurse will ask you to quantify pain or discomfort on a scale from one to ten. Now a person like me(*) will react by first wondering if this is a linear or a logarithmic scale? Then I wonder what it is it's actually measuring? Is it, for example, the total number of nociceptors firing, or some other measure of brain activity.

Eventually I'm forced to conclude that the scale is in fact an arbitrary judgement, similar to the scoring system for Olympic figure skating, which then begs the question of whether pain should receive a different score if, say, it's inflicted by a Russian or a Korean athlete.

Of course figuring all this out distracts from the task at hand.

In order to avoid such confusion, I'm proposing that the medical community adopts a system of scales based upon more tangible concepts, such as, say, living organisms. If using organisms the comparative values can take into account a variety of factors such as complexity, position on the food chain, and, most importantly, coolness.

For example, a particularly nasty virus has recently been working it's way around my household and I was the last member of my family to succumb. A few days ago, when my wife asked me how I was feeling, I said that on a scale from Amoeba to Bengal Tiger,  I rated as a sea slug. I then went back to bed for the remainder of the morning. 

The following day I felt much better and rated myself, on the same scale, as a pygmy tree shrew. (The highest I seem to be able to get on this particular scale is about Aardvark, before some new blight is bought home from pre-school).

Of course it is quite possible to vary these scales in order to get a more accurate response from the patient. For example if a patient had an interest in architecture, one could ask them to use a scale from porta-potty to The Great Pyramids of Giza, while a chef might use a scale from cheez-wizz  to Piedmontese white truffles. Some experimentation may be necessary in order find the optimal scale for each individual.


(*) I also feel that cheese should be ordered by volume, while my local cheesemongers want me to order by weight and do not seem to be aware of the density of individual cheeses. I've found that the best compromise to this problem is to order by specifying the angle to be cut from a wheel of cheese, which leaves the problem of whether to use degrees or radians.


Sunday, October 20, 2013

Tygers - Chapter 2

When Sophie the Tiger was big enough, she loved to go on adventures with her big sister Rosie. Rosie loved to teach Sophie all the things she’d learnt, like how to prowl, how to growl as ferociously as possible, how to catch fish and which ones are the tastiest, and the best places to lie in the sun on a warm day. Sophie loved to follow Rosie around and try to do whatever she did. But mostly the two sisters loved to be near each other.

One sunny autumn afternoon, after they had spent the morning practicing their ferocious growls on a small family of beetles (or perhaps it was a family of small beetles, I don’t quite recall), and the beetles had gotten so upset that they had scurried into a crack in the ground and refused to emerge until the following spring, Rosie and Sophie were lying on a grassy bank watching the stream flow lazily by, and wondering what to do next.

Rosie lay on her back in the warm grass, feeling the sun on her tummy fur. A mother duck was swimming downstream, leading her family of five fluffy ducklings. She gave a cautions “quack” when she saw Rose and Sophie, and lead her ducklings towards the middle of the river. The last and littlest duckling swam curiously towards the bank. Sophie turned and sniffed at the duckling who paddled away furiously to catch up with his mother and siblings.

“I know,” said Rosie, “Let’s go and look for dinosaur bones.”

Sophie jumped to her paws. “Are there any dinosaurs?” she asked, her ears quivering with excitement. “I’ve never seen one.”

“No,” said Rosie, “the dinosaurs are all gone. But some of their bones have turned into fossils. I learnt about them at pre-school when we went to the Hall of Science.”

“What’s a fussel?” asked Sophie.

“They’re things you dig up,” said Rosie, not being quite sure herself.

“You mean like a carrot?” asked Sophie. “I dug up a carrot once. But I gave it to a bunny rabbit.”

“I think so,” said Rosie. “Only I think you have to dig deeper. More like a potato.”

“Oh,” said Sophie, and thought a little. “They have potatoes at that people-village up in the hills,” she said. “Maybe they grow fussels there too?”

“Yes,” said Rosie. “They’re sure to”, she said. “Come on. Let’s go.”

And so the two tigers headed off together.


Rosie and Sophie walked side by side along the path that ran by the side of the river. After a while the path became narrower and Sophie and Rosie had to walk one in front of the other. They came to a place where a narrow path lead off to the right. There was a post in the ground, and a board nailed to it upon which was written “Little Pig”. Underneath was a smaller board saying “No soliciting”, and underneath that was a piece of note paper, upon which was written, “No Big Bad Wolves”. Rosie turned to Sophie and asked “Shall we see what’s down here?”. Sophie nodded.

The path ended in front of a small brick house. On the porch, a small, pink pig sat in a rocking chair, chewing a piece of grass. “Hello little Tigers,” said the pig.

“Hello,” said Rosie curiously, “Do you live here by yourself?”

The pig explained that his two brothers used to live next door, but that their houses had been demolished due to not meeting the local building codes, and they had moved to Florida, so he was feeling a little lonely. “Would you like some tea?” he asked.

Rosie and Sophie followed the pig into his house. He made a large pot of tea and put out a plate full of scones with a bowl jam and and another of clotted cream.

“We’re looking for dinosaur bones,” said Sophie after she’d finished her fourth scone. “Would you like to come?” she asked, and licked a blob of clotted cream of her nose.

“Oh yes!” said the piggy. “I have a a very good nose for finding things that are buried.”


The two tigers and the pig set off through the forest. The pig put his snout to the ground and sniffed and the tigers followed. They threaded their way between the trees and up a muddy river bank. Suddenly Rosie stopped. “Look!” she called. Sophie came to stand beside her and the pig scurried back to see what she had found.

Rosie pointed with her nose at the mud in front of her. “Tracks,” she said. The other animals peered at the paw prints in the mud.

“What are they?” asked Sophie. “They look like tiger paws, but they’re too small.”

“But they’re much too big for a kitty-cat,” said the piggy.

“Maybe a leopard,” suggested Rosie thoughtfully. “Let’s follow them and see where they lead.”

The two tigers and the pig set off, this time with Rosie in the front. The tracks continued through the trees for a little while longer and then climbed a hill. At the top was a mound of loose earth. The pig sniffed. “There’s something buried underneath,” he said. Sophie and Rose started to dig with their big front paws.

After about ten minutes, Sophie’s claw hit something hard. There was a small metalic “clink” sound. They carefully dug a little further and brushed the dirt away to reveal a large wooden box, fastened with iron straps and hinges. It was too heavy for either tiger to lift by herself, so Rose took one side and Sophie took the other, and together they lifted the chest out of the pit.

Fortunately there was no lock on the box. But the hinges had rusted and creaked loudly as the three animals pushed and pulled at the lid to open it. At last, with one last creak, the like swung open, and inside Rosie and Sophie saw the largest bone they had ever seen. It was a soft mottled white colour, smooth, and several inches longer than Rosie’s tail. Around one end was tied a paper tag on which the words “This dinosaur bone belongs to Baby” were written in large letters, and on the other side of the tag was written just “Baby” in big letters.

“Wow!” said Sophie, licking the tip of her nose.

“We’d better put it back,” said Rosie. “It belongs to someone else.” They put the bone back in the box, lowered it into the pit, and filled it up with earth until it was just as they had found it.

When they were done, Rosie and Sophie noticed that the pig was busy sniffing around the base of a tree and burrowing with his snout. After a minute he came up holding something black and wrinkly between his teeth. “Look!” he cried triumphantly.

“What is it?” asked Rose and Sophie together, coming a bit closer.

“It’s a truffle,” said the pig. “They’re delicious, and only we pigs can find them. C’mon!” And he trotted back to his home, holding the truffle proudly between his teeth, while Rose and Sophie followed curiously behind.

By the time Rose and Sophie reached the pig’s little brick house, he had already put on his apron and put a large pot of water on the stove to boil. The pig made three plates of fresh pasta and put shaved truffles and parmesan cheese on top. The two tigers were so hungry after all the digging they’ed done, that they both licked their plates clean. They both said “Yum!” and thanked the piggy lovingly for his hospitality, and then went on their way, purring softly to themselves.

Thursday, October 3, 2013

Making Visual Studio Solutions, CMake and Cygwin Play Nicely Together

I'm currently involved in development and maintenance of a set of command-line tools for analyzing Affymetrix micro-array data. The tools are developed in C++ and intended to be platform independent (compiled and tested on a couple of different Linux flavors, Windows using Visual C++, and OS X). We're working on version 2.0 which is the first major rewrite in several years.

Previous versions relied on separate Visual Studio solution files for Windows, and makefiles for Linux, which needed to be maintained in parallel. This was a pain, particularly in the Windows world: for Unix/Linux, Make hasn't changed much for decades, and if you learnt to use it in the 80's you'll probably still be able to get by. But, for Visual Studio things can change drastically between versions, so that the solution and project files in VS2008 and 2010 are completely different, and required a major transition. So, in version 2.0 we decided to switch to CMake to generate our build scripts across all platforms.

We've also been using Bamboo to run our continuous integration builds and nightly regression tests. For Linux this meant having Bamboo execute a bash script. So as to make things as uniform as possible between platforms, we opted to use a bash script under cygwin to run the builds and tests on Windows.

I found a number of issues and complications in getting cygwin to work with Visual Studio 2010/2012 solutions and CMake - some I found details of on the web, and others required experimentation to fix. Since there wasn't one place I could go to find out all these things, and much of the information I found was outdated, I'm going to gather them all together in one place as a public service. The intended audience is people who are familiar with CMake and bash, but struggling with getting things working in the Windows world.

Setting environment variables for MSBuild/VC++

There are a bunch of environment variables needed for running Visual Studio solutions in the command line, which can be set by one of the bat files vcvars*.bat (see http://generally.wordpress.com/2006/11/28/building-visual-studio-solutions-using-msbuild-in-cygwin/), Since were doing 64 bit only, we want the ones called vcvarsx86_amd64.bat. We need to call the right one for the version of Visual Studio we're using:

# Read vcvars.bat file to set Windows tools settings
CMD=/cygdrive/c/Windows/system32/cmd
# VS2012 version
#
${CMD} /c "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\x86_amd64\vcvarsx86_amd64.bat"



Or for Visual Studio 2010:

# VS2010 version

#
${CMD} /c "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64\vcvarsx86_amd64.bat"

Running CMake from cygwin

First we need to pick the appropriate executables for CMake and CPack:

CMAKE="/cygdrive/c/Program Files (x86)/CMake 2.8/bin/cmake.exe"
CTEST="/cygdrive/c/Program Files (x86)/CMake 2.8/bin/ctest.exe"

We're doing an out-of-source build, so we use two environment variables, SRCROOT for the source directory (in our case an svn checkout), and CMAKEROOT for the build directory. We may have to create the CMAKEROOT directory if it's not there already:

# Create cmake directory if not present
if [[ ! -d "${CMAKEROOT}" ]]
then
  mkdir "${CMAKEROOT}"
fi


In order to run CMake we'll need to specify the Generator, and to feed it the source directory in Windows path format. If you do "cmake --help" it will provide a list of available generators. In our case we want "Visual Studio 11 Win64". To get the directory name in the format CMake wants, rather than in cygwin format we use the "cygpath -w" utility.

This next bit is important:

We now come to a particularly annoying and hard to diagnose bug (see http://www.cmake.org/Bug/print_bug_page.php?bug_id=13131): cygwin by default declares certain environment variables like TEMP and TMP. CMake will use certain environment variables, including tmp and temp,  In cygwin this is fine and good, but Windows applications, and particularly MSBuild, do not distinguish between environment variables based on case. So when you run MSBuild after CMake in the cygwin environment, MSBuild will die because it sees that there are multiply defined environment variables.

The worst thing about this is that, once you've encountered the problem, simply undef-ing the relevant variables won't fix it. MSBuild starts some processes the first time it's run and those will continue to break. At this point you have to go into the Task Manager and kill any MSBuild processes before you can contiue. The work around is to undef all the variables before the first call of CMake.

This is the code from our scripts which runs CMake:

# Set the generator - VS2012 version
#
CMAKE_GENERATOR='Visual Studio 11 Win64'
 
# Have to unset some environment variables because of a weird bug with cmake under cygwin
# - see http://www.cmake.org/Bug/print_bug_page.php?bug_id=13131
unset tmp TMP temp TEMP
 
# Now call CMake
cd "${CMAKEROOT}"
"$CMAKE" -G "$CMAKE_GENERATOR" "$(cygpath -w ${SRCROOT})"
cmake_rv=$?
if [ "${cmake_rv}" != 0 ]
then
  echo "CMake encountered errors"
  exit 1
fi


Using MSBuild to build a Visual Studio solution file

CMake should create a .sln file and a bunch of vcxproj files (one for each target). First we need to pick the right MSBuild executable, and also decide on the configuration and platform for our build:

# This maybe system dependent
MSBUILD=/cygdrive/c/Windows/Microsoft.NET/Framework64/v4.0.30319/MSBuild.exe
 
# We're going to do a 64 bit release build
BUILD_CONFIG=Release
PLATFORM=x64

Checking for errors in MSBuild

With Make in the Linux/Unix world, we can check the output value ("$?") to see if the build was successful.  With MSBuild this doesn't necessarily work. Consequently, to check for a successful build we need to generate a log file, and scan the log file for an errors message - the log file should contain the line '0 Error(s)' if it was successful. (In the following the environment variable SLN_FILE is set to the name of the solution file).

MSBUILD_LOG=msbuild.log
"${MSBUILD}" ${SLN_FILE} /fl /property:Configuration=${BUILD_CONFIG};Platform=${PLATFORM}
msbuild_rv=$?
if [ ${msbuild_rv} != 0 ]
then
    echo "MSBuild ${SLN_FILE} exited with status '${msbuild_rv}'"
    exit 1
fi
grep -q '0 Error(s)' ${MSBUILD_LOG}
if [ $? != 0 ]
then
    echo "MSBuild ${SLN_FILE} detected errors"
    exit 1
fi


(The /fl option causes MSBuild to write a log file).

Using MSBuild to build a Project file

Our CMake scripts are configured to create a number of additional custom targets which are not part of the default build target (do not have ALL set), such as a target regression which will update the regression test data and run the regression tests. In Linux these translate to Makefile targets which are not called as part of the default target. In Visual Studio, these give rise to .vcxproj files which are not built by default when one builds the main project .sln file.

To build these we can call MSBuild directly on a project file:

REGRESSION_PROJ_FILE=regression.vcxproj
#
# Build regression project
"${MSBUILD}" ${REGRESSION_PROJ_FILE} /fl /property:Configuration=${BUILD_CONFIG};Platform=${PLATFORM}



And that's all. Hope this is useful to someone out there.