[CMake] Dependent Libraries added automatically?

Mike Jackson mike.jackson at bluequartz.net
Fri Sep 26 11:38:44 EDT 2008


I started noticing some warnings when I am linking my project  
executables that bascially says libraries are listed multiple times on  
the link line. Now this is just a warning so I _could_ ignore it but I  
am curios about how cmake is working at this point. Here is what I have:

Library MXADataModel built by CMake.
It depends on Expat, Tiff and HDF5 (which are installed on the local  
filesystem and NOT build by cmake).

I have some Examples that are built in the same project as the  
MXADataModel library. Lets take one of those examples as and "example"..

SET (DATAIMPORT_EXAMPLE_SOURCES
${MXA_SOURCE_DIR}/src/Examples/DataImport/main.cpp
${MXA_SOURCE_DIR}/src/Examples/DataImport/SimpleImportExample.cpp
${MXA_SOURCE_DIR}/src/Examples/DataImport/ExampleImportDelegate.cpp
${MXA_SOURCE_DIR}/src/Examples/DataImport/ 
ExampleImportDelegateFactory.cpp
)
SET (DATAIMPORT_EXAMPLE_HEADERS
   ${MXA_SOURCE_DIR}/src/Examples/DataImport/SimpleImportExample.h
   ${MXA_SOURCE_DIR}/src/Examples/DataImport/ExampleImportDelegate.h
   ${MXA_SOURCE_DIR}/src/Examples/DataImport/ 
ExampleImportDelegateFactory.h
)
source_group(src\\Examples\\DataImport FILES $ 
{DATAIMPORT_EXAMPLE_SOURCES} ${DATAIMPORT_EXAMPLE_HEADERS})
ADD_EXECUTABLE(DataImportExample ${DATAIMPORT_EXAMPLE_SOURCES})
TARGET_LINK_LIBRARIES(DataImportExample ${MXADATAMODEL_LIB_NAME} )



MXADATAMODEL_LIB_NAME is the name of the MXADataModel library that is  
built earlier in the project and has dependencies on hdf5, tiff and  
expat.

If I use the code as is then cmake will actually add the tiff, hdf5  
and expat libraries to the link line. Is CMake _supposed_ to do that?  
This is building shared libraries and tiff, expat and hdf5 are all  
dylibs also. Building MXADataModel as a static library shows the same  
behavior.

  This is on OS X 10.5.5 with Xcode 3.1.x tooling generating  
Makefiles. Same thing using Xcode generated targets. So maybe I just  
don't understand how linking works on OS X?

Just wondering if I make changes to the CMake files will it mess up  
windows builds?

Thanks
mike jackson




More information about the CMake mailing list