I'm working on a software project that requires about a dozen external
packages to build our libraries. What is the correct way to define the
dependencies for our targets that depend on these external libraries?
So far I have created FindXXX.cmake files for each external library. These
files set XXX_INCLUDE_DIRS and XXX_LIBRARY or XXX_LIBRARIES. Should I make
a target in our build for XXX?
Example A:
in the root CMakeLists.txt file:
find_package(UnitTest)
add_library(unittest++ STATIC IMPORTED)
set_target_property(IMPORTED_LOCATION ${UnitTest_LIBRARY})
then in a subdirectory foo/CMakeLists.txt
add_executable(test_foo test/Main.cpp test/test_foo.cpp)
add_test(foo test_foo)
target_link_libraries(test_foo foo unittest++)
or should each subdirectory that contains a CMakeLists.txt file that needs
this library to link to an executable explicitly define the library in the
target's target_link_libraries call? Like this....
Example B:
in foo/CMakeLists.txt:
find_package(UnitTest)
add_executable(test_foo test/Main.cpp test/test_foo.cpp)
add_test(foo test_foo)
target_link_libraries(test_foo foo ${UnitTest_LIBRARY})
We've been following Example A, but have run into numerous link problems
because we are using NetCDF, HDF5, ExodusII and a mesh framework package
that depends on all 3. I've looked at two other projects that use CMake:
Trilinos and Yarp. Both follow Example B and since we are having so much
difficulty resolving links at run time, I wanted to know if we are
defining these dependencies correctly.
Thanks for your time.
--
Lori A. Pritchett-Sheats, PhD.
CCS-2, Computational Physics and Methods
Office: 505-665-6675
Fax: 505-665-4972
Los Alamos National Laboratory
P.O. Box 1663
MS D413
Los Alamos, NM 87544
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake