[CMake] Problems building a shared library
Torri, Stephen CIV NSWCDD, W15
stephen.torri at navy.mil
Thu May 27 10:59:34 EDT 2010
I am attempting to build a shared library as a project. In order to explain my project I will use a pseudo project with a similar setup. The library is called TruckInterface with four directories (Wheels, Engine, Frame and Truck). The directories Wheels, Engine and Frame are built as static libraries and Truck is a shared library to be installed.
TruckInterface
|------- Wheels
|------- Engine
|------- Frame
|------- Truck
In the CMakeLists.txt for Wheels, Engine and Frame I have followed the format below:
SET ( HEADERS ..list header files )
SET ( SOURCES ...list source files )
INCLUDE_DIRECTORIES ( ...other directory to look for headers in the project... )
add_library ( <name> STATIC ${SOURCES} ${HEADERS} )
In the CMakeLists.txt for Truck I have
SET ( HEADERS ..list header files )
SET ( SOURCES ...list source files )
INCLUDE_DIRECTORIES ( ...other directory to look for headers in the project... )
add_library ( Truck SHARED ${SOURCES} ${HEADERS} )
link_libraries ( Wheels Engine Frame )
Now my problems that I am coming across, some of which are not cmake's fault:
1. Undefined references even though the code has been declared for member functions
2. Unable to set global compiler flags in the CMakeLists in the TruckInterface directory
3. How to select when I want a debug versus a release build.
My experience is using Automake/Autoconf on Linux and Visual Studio on Windows.
I would appreciate help on points 2 and 3 but would like advice on how to debug point 1.
Stephen
More information about the CMake
mailing list