Mike Jackson wrote:
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?
Yes, cmake automatically chains this stuff.
add_library(a ...)
target_link_library(a b c)
add_executable(foo ...)
target_link_libraries(foo a)
This will cause foo to link to a b c.
With CMake 2.6.2 you can stop this from happening with a target property:
http://www.cmake.org/cmake/help/cmake2.6docs.html#prop_tgt:LINK_INTERFACE_LIBRARIES
-Bill
_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake