0
 target_link_libraries(${PROJECT_NAME}
                      serializer
                      iothub_client
                      iothub_client_mqtt_transport
                      umqtt
                      aziotsharedutil
                      ssl
                      crypto
                      curl
                       ssl..... utils)

Hello there , I am working on a project where I have a large set of libraries, and have use it like it (shown above). but instead of hardcoding these libraries explicitly,i want write it in a one line.

now I want to write it in a one line for linking, so specifically, what I have tried in the root level I have created a file called "library.lst" and in this .lst file I am giving the path of that library

               build/src/con/shared/virtual/serializer/serializer.a"
               build/src/con/shared/virtual/iothub_client/iothub_client.a" 
               build/src/con/shared/virtual/umqtt/ umqtt.a"
               build/src/con/shared/virtual/utils/utlis.a
              ## write for every library 
                             

I am placing this .lst file in the folder called "filelist", e.g filelist/Library.lst where it will take all the libraries and will link.

so what I wrote this In each camkelists.txt where this library used by writing
file(STRINGS ${filelist} library) ,

target_link_libraries(${PROJECT NAME} ${library}),

but when I am running this script I an getting the errors like

         "error:- "file strings requires and filename and output variable",

and I also have creates build.sh file where I am giving the path of it "-D"filelist=%FILELISTSPATH%\library.lst"
" so could you please help me here and also need some explanation on it to understand it in a better way.Thanks in advance.

Amit
  • 13
  • 4
  • 1
    Variables are case sensitive. Regardless, if `file(STRINGS ${filelist} Library)` fails that means either the `filelist` variable is not defined or it does evaluate to a path where cmake cannot find a file. Not sure why there are quotes around this command and the next one mentioned in your question though. I'm not sure what exactly you're trying to gain by instead of hardcoding the libs to use in one place hardcoding them in another place. This just means more cmake code is needed and there's more room for error (e.g. by forgetting to make the configuration depend on the file). – fabian Jul 14 '22 at 18:38
  • hi @fabian I have edited my question, but that is the task that where instead of writing then one by one, I thought making list and then use it cmakelists will be easy . – Amit Jul 14 '22 at 20:10
  • As written in the first comment, the error message means that `${filelist}` has wrong content. It is difficult to reconstruct your code based on very vague description. Please, prepare [mcve]: The exact (and full) `CMakeLists.txt` you test, the exact parameters you pass to `cmake` for configure the script, and the exact error message. – Tsyvarev Jul 14 '22 at 22:05

0 Answers0