<div dir="ltr"><span style="color:rgb(0,0,0);font-size:16px">Hello.</span><div style="color:rgb(0,0,0);font-size:16px"><br></div><div style="color:rgb(0,0,0);font-size:16px">In packaging the MongoDB C++ driver with CMake, we hit a snag when a dependency included OS X frameworks in the pkg-config information:</div><div style="color:rgb(0,0,0);font-size:16px"><br></div><div style="color:rgb(0,0,0);font-size:16px"><div><font face="monospace, monospace">$ PKG_CONFIG_PATH=/usr/local/<wbr>custom/mongodb/lib/pkgconfig \</font></div><div><font face="monospace, monospace">    pkg-config --cflags --libs libmongoc-1.0<br></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">-I/usr/local/custom/mongodb/<wbr>include/libmongoc-1.0 -I/usr/local/custom/mongodb/<wbr>include/libbson-1.0 -L/usr/local/custom/mongodb/<wbr>lib -lmongoc-1.0 -framework Security -framework CoreFoundation -lbson-1.0</font></div></div><div style="color:rgb(0,0,0);font-size:16px"><br></div><div style="color:rgb(0,0,0);font-size:16px">We have a custom .cmake module that uses FindPkgConfig with a line like this:</div><div style="color:rgb(0,0,0);font-size:16px"><br></div><div style="color:rgb(0,0,0);font-size:16px"><font face="monospace, monospace">pkg_check_modules(LIBMONGOC REQUIRED libmongoc-1.0>=${LibMongoC_<wbr>FIND_VERSION} )</font></div><div style="color:rgb(0,0,0);font-size:16px"><br></div><div style="color:rgb(0,0,0);font-size:16px">However the resulting LIBMONGOC_LIBRARIES omits the frameworks, pushing them into LIBMONGOC_LDFLAGS_OTHER:</div><div style="color:rgb(0,0,0);font-size:16px"><br></div><div style="color:rgb(0,0,0);font-size:16px"><font face="monospace, monospace">LIBMONGOC_LDFLAGS_OTHER:<wbr>INTERNAL=-framework;Security;-<wbr>framework;CoreFoundation</font></div><div style="color:rgb(0,0,0);font-size:16px"><br></div><div style="color:rgb(0,0,0);font-size:16px">We were able to recover these back into LIBMONGOC_LIBRARIES through this round-about hack:</div><div style="color:rgb(0,0,0);font-size:16px"><br></div><div style="color:rgb(0,0,0);font-size:16px"><div><font face="monospace, monospace">  if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND LIBMONGOC_LDFLAGS_OTHER)</font></div><div><span style="font-family:monospace,monospace">      # "-framework;Security;-<wbr>framework;CoreFoundation" to</span><br></div><div><font face="monospace, monospace">      # "-framework Security;-framework CoreFoundation"</font></div><div><font face="monospace, monospace">      string(REPLACE "-framework;" "-framework " LIBMONGOC_FRAMEWORKS "${LIBMONGOC_LDFLAGS_OTHER}")</font></div><div><font face="monospace, monospace">      list(APPEND LIBMONGOC_LIBRARIES ${LIBMONGOC_FRAMEWORKS})</font></div><div><span style="font-family:monospace,monospace">      set(LIBMONGOC_LIBRARIES ${LIBMONGOC_LIBRARIES} CACHE INTERNAL "")</span><br></div><div><font face="monospace, monospace">  endif()</font></div></div><div style="color:rgb(0,0,0);font-size:16px"><br></div><div style="color:rgb(0,0,0);font-size:16px">This eventually results in adding '-framework Security' etc. to target_link_libraries(), which seems to solve the problem we had experienced.  (Though <a href="http://stackoverflow.com/a/28313304/11800" target="_blank">one SO post</a> said this could produce parse errors, we didn't experience any)</div><div style="color:rgb(0,0,0);font-size:16px"><br></div><div style="color:rgb(0,0,0);font-size:16px">Extensive online searching didn't turn up a standard, well-accepted idiomatic way to handle OS X frameworks from pkg-config.  Have we missed something?  Is this a bug in FindPkgConfig not recognizing OS X framework entries?  What do people suggest?</div><div style="color:rgb(0,0,0);font-size:16px"><br></div><div style="color:rgb(0,0,0);font-size:16px">For reference, my testing used CMake 3.6.2.</div><div style="color:rgb(0,0,0);font-size:16px"><br></div><div style="color:rgb(0,0,0);font-size:16px">Thank you very much,</div><div style="color:rgb(0,0,0);font-size:16px"><br></div><div style="color:rgb(0,0,0);font-size:16px">David Golden</div></div>