next up previous contents
Next: Building a server application Up: Compilation Previous: Compilation   Contents

Compilation using cmake

The doc/ExternalExample directory also contains a CMakeFile.txt file which illustrates the cmake way of compiling this simple client/server example:

PROJECT( DIETSIMPLEEXAMPLE )

SET( CMAKE_MODULE_PATH ${DIETSIMPLEEXAMPLE_SOURCE_DIR}/Cmake )
FIND_PACKAGE( Diet )

# On success use the information we just recovered:
INCLUDE_DIRECTORIES( ${DIET_INCLUDE_DIR} )
LINK_DIRECTORIES( ${DIET_LIBRARY_DIR} )

### Define a simple server...
ADD_EXECUTABLE( simple_server simple_server.c )
TARGET_LINK_LIBRARIES( simple_server ${DIET_SERVER_LIBRARIES} )
INSTALL( TARGETS simple_server DESTINATION bin )

### ... and it's associated simple client.
ADD_EXECUTABLE( simple_client simple_client.c )
TARGET_LINK_LIBRARIES( simple_client ${DIET_CLIENT_LIBRARIES} )
INSTALL( TARGETS simple_client DESTINATION bin )

In order to test drive the cmake configuration of this example, and assuming the DIET_HOME points to a directory containing an installation of DIET, simply try:

export DIET_HOME=<path_to_a_DIET_instal_directory>
cd doc/ExternalExample
mkdir Bin
cd Bin
cmake -DDIET_DIR:PATH=$DIET_HOME -DCMAKE_INSTALL_PREFIX:PATH=/tmp/DIETSimple ..
make
make install



DIET Team. 2010-05-26