qt creator - CMake Warning: You have called ADD_LIBRARY for library my_src without any source files -
i'm trying call add_library files endings.
the dir structure is:
src   | - cmakelists.txt (1)  | - main.cpp  | - gui       | - cmakelists.txt (2)       | - source , header files   so cc files in gui directory.
(1) cmakelists.txt:
file( glob_recurse my_sources *.cc )  message(status "my_sources = ${my_sources}") add_subdirectory( gui ) add_library( my_src ${my_sources} )  target_link_libraries( my_src   my_gui ) qt5_use_modules( my_src core gui widgets)   (2) cmakelists.txt:
file( glob my_gui_sources *.cc)  add_library( my_gui ${my_gui_sources} ) qt5_use_modules( my_gui core gui widgets)   but keep getting output:
you have called add_library library my_src without source files. typically indicates problem cmakelists.txt file -- my_sources = /home/bla/bla/src/gui/borderlayout.cc;...;/home/bla/bla/my/src/gui/mainwindow.cc -- my_gui_sources = /home/bla/bla/my/src/gui/borderlayout.cc;...;/home/bla/bla/my/src/gui/mainwindow.cc -- configuring done -- generating done -- build files have been written to: /home/bla/bla/my/build   i know don't need add_library in first cmakelists.txt, later will. changed first glob glob_recurse, finds @ least anything.
for reason
file( glob my_gui_sources *.cc *.h)   is not finding file. debug, can print:
message(status "my_gui_sources = ${my_gui_sources}")   probably want use glob_recurse, search in sub-directories:
file( glob_recurse my_gui_sources *.cc *.h)   note don't need add headers files source list.
take care have rerun cmake every time add file project (cmake won't called automatically, thing instead happens if touch 1 of cmake files).
link documentation of command "file"
edit:
the actual problem in first cmakelists.txt file using inconsistent naming variable (note casing important), therefore have change add_library command to:
add_library( my_src ${my_sources} )   note (off records :-) ): fact casing important variable names might confusing because, on other hand, in cmake command names case insensitive. it's weird notice character - (minus) might used part of variable name: using _ (underscore) of time preferable.
Comments
Post a Comment