Discussion:
[cmake-developers] Is this warning really needed: "You have called ADD_LIBRARY for library foobar without any source files."?
Erik Sjölund
2015-07-22 12:25:26 UTC
Permalink
Hi,

I think this warning could be removed: "You have called ADD_LIBRARY
for library foobar without any source files. This typically indicates
a problem with your CMakeLists.txt file "

If you have a function that populates sources to a target, let us say
something like this:

function(activate_feature target_name)
target_sources(${target_name} PRIVATE feature.cc)
endfunction()

you would like to be able to do

add_library(foobar SHARED)
activate_feature(foobar)

without any CMake warning.
I've started using that design scheme more and more. That is, to have
a function setting up a target where the target name is given as an
input parameter. The nice thing about it is that I can pass both an
executable target and a shared library target as input to such a
function.
cheers,
Erik Sjölund
--
Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-devel
Brad King
2015-07-22 15:10:07 UTC
Permalink
Post by Erik Sjölund
I think this warning could be removed: "You have called ADD_LIBRARY
for library foobar without any source files. This typically indicates
a problem with your CMakeLists.txt file "
Yes, since we started allowing sources to be modified after the call
this warning no longer makes sense. Instead we need to make sure there
is a proper diagnostic if at generate time no SOURCES are available.
Even if that is already the case we also need to make sure the test
suite covers the errors in Tests/RunCMake somewhere, perhaps in new
Tests/RunCMake/{add_library,add_executable} cases.

Thanks,
-Brad
--
Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listin
Loading...