[CMake] Help including dylib into cmake build for xcode

Frankie Chan frankie.chan at ubisoft.com
Fri May 31 15:12:10 EDT 2013


I ended up writing a macro to find libsqlite3 with this:
macro (FindSQLite3)
# Look for the library.
                # find_path(SQLITE3_INCLUDE_DIR NAMES libsqlite3)

                find_path(SQLITE3_INCLUDE_DIR NAMES sqlite3.h)

                find_library(SQLITE3_LIBRARY NAMES libsqlite3)

                # Handle the QUIETLY and REQUIRED arguments and set SQLITE3_FOUND to TRUE if all listed variables are TRUE.
                include(FindPackageHandleStandardArgs)
                find_package_handle_standard_args(SQLITE3 DEFAULT_MSG SQLITE3_LIBRARY SQLITE3_INCLUDE_DIR)

                # Copy the results to the output variables.
                if (SQLITE3_FOUND)
                               set (SQLITE3_LIBRARIES ${SQLITE3_LIBRARY})
                               set (SQLITE3_INCLUDE_DIRS ${SQLITE3_INCLUDE_DIR})
                               message(SQLite3 Found ${SQLITE3_INCLUDE_DIRS} ${SQLITE3_LIBRARY})
                else (SQLITE3_FOUND)
                               set (SQLITE3_LIBRARIES)
                               set (SQLITE3_INCLUDE_DIRS)
                               message(SQLite3 not Found)
                endif (SQLITE3_FOUND)

                mark_as_advanced (SQLITE3_INCLUDE_DIRS SQLITE3_LIBRARIES)
endmacro()

After I execute my macro:
FindSQLite3()
    if(SQLITE3_FOUND)
      target_link_libraries(${Target} ${SQLITE3_LIBRARIES})

    endif()

I get the following error, i am kinda stumped right now since I am not exactly sure if this is the right approach in linking my project.

  Cannot specify link libraries for target "/usr/lib/libsqlite3.dylib" which
  is not built by this project.

  CMake does not support this but it used to work accidentally and is being
  allowed for compatibility.

  Policy CMP0016 is not set: target_link_libraries() reports error if only
  argument is not a target.  Run "cmake --help-policy CMP0016" for policy
  details.  Use the cmake_policy command to set the policy and suppress this
  warning.
This warning is for project developers.  Use -Wno-dev to suppress it.

From: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] On Behalf Of Frankie Chan
Sent: May-31-13 10:44 AM
To: cmake at cmake.org
Subject: [CMake] Help including dylib into cmake build for xcode

Hi,
I am trying to build an xcode project using cmake, but I am having some problems including dylib (libsqlite3.dylib).

Was using:
target_link_libraries(${Target} libsqlite3.dylib)

but i think i am going about it the wrong way.

Any help would be appreciated

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130531/650a4b36/attachment.htm>


More information about the CMake mailing list