'How to add result of find_library to cmakelist?
Was reading this:
https://discuss.cocos2d-x.org/t/xcode-12-2-errors-when-ios-simulator-with-cocos2d-x-4-0/52203/22
I don't know much about CMake
find_library(libiconv NAMES libiconv)
find_library(libz NAMES libz)
I believe the above lines will find some missing libraries, but to get things to work, I need to add the result to the library list.
How do I add the result ?
Solution 1:[1]
find_library populates the variable which you pass as the first argument with the found library path, if any. So you use this variable in target_link_libraries command. It would be something like this:
find_library(ICONV_LIB NAMES libiconv)
target_link_libraries(YourTarget ${ICONV_LIB})
Also you should get familiar with CMake first because you clearly don't know what you are doing. Both zlib & iconv have find modules so what you really want to do is this:
find_package(ZLIB REQUIRED)
find_package(Iconv REQUIRED)
target_link_libraries(YourTarget Iconv::Iconv ZLIB::ZLIB)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ixSci |
