As an example, we will create camcv, a soft strongly inspired from raspistill. It will allow us later to modify source code and play with OpenCV.

  1. create a new folder in your home directory and copy all raspicam apps source code.

mkdir camcv
cd camcv
cp /opt/vc/userland/host_applications/linux/apps/raspicam/*  .
mv RaspiStill.c camcv.c
Perhaps a chmod is necessary (sudo chmod 777 camcv.c)

2. remove then content of CMakeLists.txt and replace with :
cmake_minimum_required(VERSION 2.8)
project( camcv )
add_executable(camcv RaspiCamControl.c RaspiCLI.c RaspiPreview.c camcv.c)
target_link_libraries(camcv /opt/vc/lib/ /opt/vc/lib/ /opt/vc/lib/ /opt/vc/lib/ /opt/vc/lib/ )

3. delete CMakeFiles directory if it exits
4. Compile & test
cmake .
./camcv -t 1000

5. [optional] Clean file. camcv.c is a long file with a lot of useless lines for us. All these following function could be delete (or commented). Remove of course all call to these functions in the remaining code.
static void dump_status(RASPISTILL_STATE *state)
static int parse_cmdline(int argc, const char **argv, RASPISTILL_STATE *state)
static void display_valid_parameters()
static MMAL_STATUS_T add_exif_tag(RASPISTILL_STATE *state, const char *exif_tag)
static void add_exif_tags(RASPISTILL_STATE *state)
static void store_exif_tag(RASPISTILL_STATE *state, const char *exif_tag)

The existing line default_status(&state); avoid you to parse command line using defaults parameters. Just add a line after this one : 

Recompile and retest. Should work.
At this stage you should watch an old good movie with John Wayne.