[CONC-139] Xcode/OSX build doesn't work because OSX cmake can't create_symlink Created: 2015-09-12  Updated: 2021-02-14  Resolved: 2015-09-18

Status: Closed
Project: MariaDB Connector/C
Component/s: None
Affects Version/s: 2.1
Fix Version/s: 2.2.0

Type: Bug Priority: Major
Reporter: Ken Crossen Assignee: Georg Richter
Resolution: Fixed Votes: 0
Labels: None
Environment:

OSX Yosemite, Xcode 6.4, cmake 3.3, and cmake 3.0.2


Attachments: File macosx.build    

 Description   

downloaded:
mariadb-connector-c-2.1.0-src.tar.gz, extracted
also downloaded:
https://github.com/MariaDB/mariadb-connector-c download zip, extracted

same result for both downloads

cd Documents/MySQL_C++/mariadb-connector-c
export OPENSSL_ROOT_DIR=/Users/Ken/Documents/MySQL_C++/openssl-1.0.2d
cmake -G "Xcode"

Load .xcodeproj file into Xcode

fails on creating symlinks

here's the docs:
http://www.cmake.org/cmake/help/v3.3/manual/cmake.1.html#command-line-tool-mode



 Comments   
Comment by Georg Richter [ 2015-09-17 ]

Could you please attach output of your cmake build, outout of the build and provide version of cmake?

Comment by Ken Crossen [ 2015-09-17 ]

cmake version 3.0.2 and version 3.3.0

same issue

Your build process uses symlinks (according to your makefile to support backward compatibility). To create these symlinks, your build process is using cmake's Command-Line Tool Mode and the command create_symlink. This will work on vanilla Unix but NOT on OSX, as the cmake Command-Line Tool Mode documentation makes not totally clear:

*UNIX-specific Command-Line Tools
The following cmake -E commands are available only on UNIX:

create_symlink <old> <new>
Create a symbolic link <new> naming <old>.*

If you try to do a straight up cmake -G "Unix Makefiles" build, the same thing happens, the build fails on:
COMMAND ${CMAKE_COMMAND} ARGS -E create_symlink libmariadb${CMAKE_SHARED_LIBRARY_SUFFIX} libmysqlclient_r${CMAKE_SHARED_LIBRARY_SUFFIX}

.../mariadb-connector-c-2.1.0-src/libmariadb/CMakeLists.txt line 407, see excerpt below.

  1. There are still several projects which don't make use
  2. of the config program. To make sure these programs can
  3. use mariadb client library we provide libmysql symlinks
    IF(NOT WIN32 AND WITH_MYSQLCOMPAT)
    ADD_CUSTOM_COMMAND(OUTPUT "libmysql${CMAKE_SHARED_LIBRARY_SUFFIX}"
    "libmysqlclient${CMAKE_SHARED_LIBRARY_SUFFIX}"
    "libmysqlclient_r${CMAKE_SHARED_LIBRARY_SUFFIX}"
    "libmysqlclient${CMAKE_STATIC_LIBRARY_SUFFIX}"
    COMMAND ${CMAKE_COMMAND} ARGS -E remove -f libmysql${CMAKE_SHARED_LIBRARY_SUFFIX}
    COMMAND ${CMAKE_COMMAND} ARGS -E create_symlink libmariadb${CMAKE_SHARED_LIBRARY_SUFFIX} libmysql${CMAKE_SHARED_LIBRARY_SUFFIX}
    COMMAND ${CMAKE_COMMAND} ARGS -E remove -f libmysqlclient_r${CMAKE_SHARED_LIBRARY_SUFFIX}
    COMMAND ${CMAKE_COMMAND} ARGS -E create_symlink libmariadb${CMAKE_SHARED_LIBRARY_SUFFIX} libmysqlclient_r${CMAKE_SHARED_LIBRARY_SUFFIX}
    COMMAND ${CMAKE_COMMAND} ARGS -E remove -f libmysqlclient${CMAKE_SHARED_LIBRARY_SUFFIX}
    COMMAND ${CMAKE_COMMAND} ARGS -E create_symlink libmariadb${CMAKE_SHARED_LIBRARY_SUFFIX} libmysqlclient${CMAKE_SHARED_LIBRARY_SUFFIX}
    COMMAND ${CMAKE_COMMAND} ARGS -E remove -f libmysqlclient${CMAKE_STATIC_LIBRARY_SUFFIX}
    COMMAND ${CMAKE_COMMAND} ARGS -E create_symlink libmariadbclient${CMAKE_STATIC_LIBRARY_SUFFIX} libmysqlclient${CMAKE_STATIC_LIBRARY_SUFFIX}
    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/libmariadb
    DEPENDS libmariadb mariadbclient)

ADD_CUSTOM_TARGET(LIBMYSQL_SYMLINKS
ALL
DEPENDS "libmysql${CMAKE_SHARED_LIBRARY_SUFFIX}"
"libmysqlclient_r${CMAKE_SHARED_LIBRARY_SUFFIX}"
"libmysqlclient${CMAKE_SHARED_LIBRARY_SUFFIX}"
"libmysqlclient${CMAKE_STATIC_LIBRARY_SUFFIX}"
VERBATIM)
ENDIF()

Xcode doesn't really produce a listing in the same way as make, but the error message states clearly enough that create_symlink is not an available -E command in cmake.

Comment by Georg Richter [ 2015-09-17 ]

I can't reproduce - see attached log of MacOS build.

Also symlink files are in place:

labrador:cc_2.2 mariadb$ ll libmariadb/*.dylib
-rwxr-xr-x  1 mariadb  staff  449112 Sep 17 20:20 libmariadb/libmariadb.2.dylib*
lrwxr-xr-x  1 mariadb  staff      18 Sep 17 20:20 libmariadb/libmariadb.dylib@ -> libmariadb.2.dylib
lrwxr-xr-x  1 mariadb  staff      16 Sep 17 20:20 libmariadb/libmysql.dylib@ -> libmariadb.dylib
lrwxr-xr-x  1 mariadb  staff      16 Sep 17 20:20 libmariadb/libmysqlclient.dylib@ -> libmariadb.dylib
lrwxr-xr-x  1 mariadb  staff      16 Sep 17 20:20 libmariadb/libmysqlclient_r.dylib@ -> libmariadb.dylib

Comment by Ken Crossen [ 2015-09-18 ]

Using what version of OSX cmake? Or what version of Xcode?

Comment by Georg Richter [ 2015-09-18 ]

Fixed in connector_c_2.2 branch:
Revision 1f71590c05703751bc39aa4157bb895637b1a85c

XCode doesn't seem to understand dependencies when buildiing static/shared libraries only from object files (even add_dependencies doesn't help) and doesn't build them. Just adding an empty file did the trick:

# Xcode doesn't support targets that have only object files,
# so let's add an empty file to keep Xcode happy
IF(CMAKE_GENERATOR MATCHES Xcode)
  FILE(WRITE ${CMAKE_SOURCE_DIR}/libmariadb/empty.c "")
  SET(EMPTY_FILE ${CMAKE_SOURCE_DIR}/libmariadb/empty.c)
ENDIF()
 
ADD_LIBRARY(mariadbclient STATIC $<TARGET_OBJECTS:mariadb_obj> ${EMPTY_FILE} ${EXPORT_LINK})

Generated at Thu Feb 08 03:03:10 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.