Re: [amarok] cmake/modules: Revert FindMySQLAmarok.cmake fix argumets when calling mysql_config

2012-01-24 Thread Matěj Laitl
On 19. 12. 2011 Christophe Giboudeaux wrote:
 On Monday 19 December 2011 00:38:47 Matěj Laitl wrote:
  I tried to solve http://mail.kde.org/pipermail/amarok-devel/2011-
  December/009663.html
  
  Specifically, the problem is that mysql_config (at least 5.1.56)
  doesn't accept --variable=pkgincludedir - it accepts only --include
  argument which returns something like -I/usr/include/mysql
  
  -- Found MySQL: Usage: /usr/bin/mysql_config [OPTIONS]
 
 ok, then it only exists in higher version (the option exists in 5.5.x).
 
 I see two solutions:
 - only rely on find_path(MYSQL_INCLUDE_DIR...), so move it outside the
 else(MYSQLCONFIG_EXECUTABLE) loop  [1]
 
 - Drop FindMysqlAmarok.cmake and use FindAmarok.cmake from kdelibs instead
 (which worked fine here).
 
 I prefer the second solution as the FindMysql from kdelibs is really cleaner
 than the Amarok copy:
 
 - MYSQL_CFLAGS doesn't look that important
 
 - the linked targets gathered with 'mysql_config --libs' are already
 explicitly added in the CMakeLists.txt files (./src/core-
 impl/collections/db/sql/mysqlecollection/CMakeLists.txt, ./src/core-
 impl/collections/db/sql/mysqlservercollection/CMakeLists.txt and some unit
 tests) and the output variable is different if mysql_config is not present:
 
   * with mysql_config, MYSQL_LIBRARIES=-L/usr/lib64 -lmysqlclient -lpthread
 - lz -lm -lrt -lssl -lcrypto -ldl
   * without it, MYSQL_LIBRARIES=/usr/lib64/libmysqlclient.so. The second one
 is enough

Hmm, I've tried dropping FindMySQLAmarok.cmake, but using kdelibs one doesn't 
work for me (you probably don't build tests):
Linking CXX executable ../../../../testsqlcollection
/usr/lib64/mysql/libmysqld.so: undefined reference to `DH_new'
/usr/lib64/mysql/libmysqld.so: undefined reference to `SSL_get_current_cipher'
/usr/lib64/mysql/libmysqld.so: undefined reference to `SSL_CIPHER_get_name'
(...)

I don't know why core mysqlcollection builds fine (probably something else 
pulls OpenSSL? AFAIK undefined symbols are allowed in shared libs, but not 
final 
executables), but apparently the additional entries in MYSQL_LIBRARIES are 
needed. (and I really don't feel like hard-coding them in Amarok) So I will 
commit your patch if no-one disagrees.

Matěj
___
Amarok-devel mailing list
Amarok-devel@kde.org
https://mail.kde.org/mailman/listinfo/amarok-devel


Re: [amarok] cmake/modules: Revert FindMySQLAmarok.cmake fix argumets when calling mysql_config

2011-12-19 Thread Christophe Giboudeaux
On Sunday 18 December 2011 23:27:08 =?utf-8?B?TWF0xJtq?= Laitl wrote:
 On 18. 12. 2011 Christophe Giboudeaux wrote:
  Revert FindMySQLAmarok.cmake fix argumets when calling mysql_config
  This reverts a fix for -Wmissing-include-dirs warnings.
  MYSQL_INCLUDE_DIR must be a path and not contain -Ipath

 Sorry about the incorrect fix, I will build with -Wmissing-include-dirs from
 now on. However I wonder how to fix the original problem.

Your commit doesn't mention the issue you're trying to fix. However, having
the same directory included several times is not an issue (and I'm not aware
of any GCC flag that would throw a warning).


 Would it be legal to remove MYSQL_INCLUDE_DIR entirely and just rely on
 MYSQL_CFLAGS to specify -I/path/to/mysql ?


Well, they don't have the same purpose. MYSQL_CFLAGS is used by the compiler
(used in 'add_definitions..' lines) while MYSQL_INCLUDE_DIR is used by cmake.

Also, if mysql_config is not available, MYSQL_CFLAGS is empty and you can only
count on MYSQL_INCLUDE_DIR.

 E.g. is cmake's include_directories(/dir) just a syntactic sugar for
 add_definitions(-I/dir) or it would break build on non-gcc platforms? I'd
 rather avoid filtering -I out of MYSQL_INCLUDE_DIR in CMakeLists.


Without hint about what you're trying to fix, it's hard to answer this
question.


Christophe


signature.asc
Description: This is a digitally signed message part.
___
Amarok-devel mailing list
Amarok-devel@kde.org
https://mail.kde.org/mailman/listinfo/amarok-devel


Re: [amarok] cmake/modules: Revert FindMySQLAmarok.cmake fix argumets when calling mysql_config

2011-12-19 Thread Matěj Laitl
On 19. 12. 2011 Christophe Giboudeaux wrote:
 I see two solutions:
 - only rely on find_path(MYSQL_INCLUDE_DIR...), so move it outside the
 else(MYSQLCONFIG_EXECUTABLE) loop  [1]
 
 - Drop FindMysqlAmarok.cmake and use FindAmarok.cmake from kdelibs instead
 (which worked fine here).
 
 I prefer the second solution as the FindMysql from kdelibs is really cleaner
 than the Amarok copy:
 
 - MYSQL_CFLAGS doesn't look that important
 
 - the linked targets gathered with 'mysql_config --libs' are already
 explicitly added in the CMakeLists.txt files (./src/core-
 impl/collections/db/sql/mysqlecollection/CMakeLists.txt, ./src/core-
 impl/collections/db/sql/mysqlservercollection/CMakeLists.txt and some unit
 tests) and the output variable is different if mysql_config is not present:
 
   * with mysql_config, MYSQL_LIBRARIES=-L/usr/lib64 -lmysqlclient -lpthread
 - lz -lm -lrt -lssl -lcrypto -ldl
   * without it, MYSQL_LIBRARIES=/usr/lib64/libmysqlclient.so. The second one
 is enough
 
 - the kdelibs FindAmarok has better chances to detect mysql.h under Windows,
 - and it also uses a cleaner way to decide if mysqle is there.

I'd also like to drop FindMysqlAmarok.cmake entirely and use kdelibs one, code 
duplication is never good. Let's do it early in the 2.6 phase to get the most 
testing.

Anyone opposed to me dropping FindMysqlAmarok.cmake in master for now? (can 
always be reverted if problems arise)

Matěj Laitl
___
Amarok-devel mailing list
Amarok-devel@kde.org
https://mail.kde.org/mailman/listinfo/amarok-devel


Re: [amarok] cmake/modules: Revert FindMySQLAmarok.cmake fix argumets when calling mysql_config

2011-12-19 Thread Christophe Giboudeaux
On Monday 19 December 2011 00:38:47 =?utf-8?B?TWF0xJtq?= Laitl wrote:
 On 19. 12. 2011 Christophe Giboudeaux wrote:
  On Sunday 18 December 2011 23:27:08 Matej Laitl wrote:
   Sorry about the incorrect fix, I will build with -Wmissing-include-dirs
   from now on. However I wonder how to fix the original problem.
  
  Your commit doesn't mention the issue you're trying to fix. However,
  having
  the same directory included several times is not an issue (and I'm not
  aware of any GCC flag that would throw a warning).
 
 Ah, I tried to solve http://mail.kde.org/pipermail/amarok-devel/2011-
 December/009663.html
 
 Specifically, the problem is that mysql_config (since at least 5.1.56)
 doesn't accept --variable=pkgincludedir - it accepts only --include
 argument which returns something like -I/usr/include/mysql

 -- Found MySQL: Usage: /usr/bin/mysql_config [OPTIONS]
[cut]

 So I guess we'll have to strip that -I out of `mysql_config --include`. Can
 we safely assume that it is only a single directory?
 

ok, then it only exists in higher version (the option exists in 5.5.x). 

I see two solutions: 
- only rely on find_path(MYSQL_INCLUDE_DIR...), so move it outside the 
else(MYSQLCONFIG_EXECUTABLE) loop  [1]

- Drop FindMysqlAmarok.cmake and use FindAmarok.cmake from kdelibs instead 
(which worked fine here).

I prefer the second solution as the FindMysql from kdelibs is really cleaner 
than the Amarok copy:

- MYSQL_CFLAGS doesn't look that important

- the linked targets gathered with 'mysql_config --libs' are already 
explicitly added in the CMakeLists.txt files (./src/core-
impl/collections/db/sql/mysqlecollection/CMakeLists.txt, ./src/core-
impl/collections/db/sql/mysqlservercollection/CMakeLists.txt and some unit 
tests) and the output variable is different if mysql_config is not present:

  * with mysql_config, MYSQL_LIBRARIES=-L/usr/lib64 -lmysqlclient -lpthread -
lz -lm -lrt -lssl -lcrypto -ldl
  * without it, MYSQL_LIBRARIES=/usr/lib64/libmysqlclient.so. The second one 
is enough

- the kdelibs FindAmarok has better chances to detect mysql.h under Windows,
- and it also uses a cleaner way to decide if mysqle is there.


The first solution is the easy one, the second one needs more testing on 
different platforms/distributions.

Christophe

[1] attached: fixMySQLAmarok.diff
diff --git a/cmake/modules/FindMySQLAmarok.cmake b/cmake/modules/FindMySQLAmarok.cmake
index 74805ca..44a3fb5 100644
--- a/cmake/modules/FindMySQLAmarok.cmake
+++ b/cmake/modules/FindMySQLAmarok.cmake
@@ -16,8 +16,18 @@ if(NOT WIN32)
 find_program(MYSQLCONFIG_EXECUTABLE NAMES mysql_config mysql_config5 PATHS ${BIN_INSTALL_DIR} ~/usr/bin /usr/local/bin)
 endif(NOT WIN32)
 
+find_path(MYSQL_INCLUDE_DIR mysql.h
+/opt/local/include/mysql5/mysql
+/opt/mysql/mysql/include
+/opt/mysqle/include/mysql
+/opt/ports/include/mysql5/mysql
+/usr/include/mysql
+/usr/local/include/mysql
+/usr/mysql/include/mysql
+~/usr/include/mysql
+)
+
 if(MYSQLCONFIG_EXECUTABLE)
-exec_program(${MYSQLCONFIG_EXECUTABLE} ARGS --variable=pkgincludedir RETURN_VALUE _return_VALUE OUTPUT_VARIABLE MYSQL_INCLUDE_DIR)
 exec_program(${MYSQLCONFIG_EXECUTABLE} ARGS --cflags RETURN_VALUE _return_VALUE OUTPUT_VARIABLE MYSQL_CFLAGS)
 exec_program(${MYSQLCONFIG_EXECUTABLE} ARGS --libs RETURN_VALUE _return_VALUE OUTPUT_VARIABLE MYSQL_LIBRARIES)
 exec_program(${MYSQLCONFIG_EXECUTABLE} ARGS --libmysqld-libs RETURN_VALUE _return_VALUE OUTPUT_VARIABLE MYSQL_EMBEDDED_LIBSTEMP)
@@ -49,18 +59,6 @@ if(MYSQLCONFIG_EXECUTABLE)
 
 else(MYSQLCONFIG_EXECUTABLE)
 
-find_path(MYSQL_INCLUDE_DIR mysql.h
-   ~/usr/include/mysql
-   /opt/local/include/mysql5/mysql
-   /opt/mysqle/include/mysql
-   /opt/mysql/mysql/include 
-   /usr/mysql/include/mysql
-   /usr/include/mysql
-   /usr/local/include/mysql
-   /opt/local/include/mysql
-   /opt/ports/include/mysql5/mysql
-)
-
 if(WIN32)
 set(MYSQL_CLIENT_LIBRARY_NAME libmysql)
 else(WIN32)


signature.asc
Description: This is a digitally signed message part.
___
Amarok-devel mailing list
Amarok-devel@kde.org
https://mail.kde.org/mailman/listinfo/amarok-devel


Re: [amarok] cmake/modules: Revert FindMySQLAmarok.cmake fix argumets when calling mysql_config

2011-12-18 Thread Matěj Laitl
On 18. 12. 2011 Christophe Giboudeaux wrote:
 Revert FindMySQLAmarok.cmake fix argumets when calling mysql_config
 This reverts a fix for -Wmissing-include-dirs warnings.
 MYSQL_INCLUDE_DIR must be a path and not contain -Ipath

Sorry about the incorrect fix, I will build with -Wmissing-include-dirs from 
now on. However I wonder how to fix the original problem.

Would it be legal to remove MYSQL_INCLUDE_DIR entirely and just rely on 
MYSQL_CFLAGS to specify -I/path/to/mysql ?

E.g. is cmake's include_directories(/dir) just a syntactic sugar for 
add_definitions(-I/dir) or it would break build on non-gcc platforms? I'd 
rather avoid filtering -I out of MYSQL_INCLUDE_DIR in CMakeLists.

Regards,
Matěj
___
Amarok-devel mailing list
Amarok-devel@kde.org
https://mail.kde.org/mailman/listinfo/amarok-devel


Re: [amarok] cmake/modules: Revert FindMySQLAmarok.cmake fix argumets when calling mysql_config

2011-12-18 Thread Matěj Laitl
On 19. 12. 2011 Christophe Giboudeaux wrote:
 On Sunday 18 December 2011 23:27:08 Matej Laitl wrote:
  Sorry about the incorrect fix, I will build with -Wmissing-include-dirs
  from now on. However I wonder how to fix the original problem.
 
 Your commit doesn't mention the issue you're trying to fix. However, having
 the same directory included several times is not an issue (and I'm not aware
 of any GCC flag that would throw a warning).

Ah, I tried to solve http://mail.kde.org/pipermail/amarok-devel/2011-
December/009663.html

Specifically, the problem is that mysql_config (since at least 5.1.56) doesn't 
accept --variable=pkgincludedir - it accepts only --include argument which 
returns something like -I/usr/include/mysql

-- Found MySQL: Usage: /usr/bin/mysql_config [OPTIONS]
Options:
--cflags [-I/usr/include/mysql -DHAVE_ERRNO_AS_DEFINE=1 -
DUNIV_LINUX -DUNIV_LINUX]
--include[-I/usr/include/mysql]
--libs   [-Wl,-O1 -Wl,--as-needed -rdynamic -L/usr/lib64/mysql 
-lmysqlclient -L/usr//lib64 -lz -lcrypt -lnsl -lm -L/usr/lib64/ -lssl -
lcrypto]
--libs_r [-Wl,-O1 -Wl,--as-needed -rdynamic -L/usr/lib64/mysql 
-lmysqlclient_r -L/usr//lib64 -lz -lpthread -lcrypt -lnsl -lm -lpthread -
L/usr/lib64/ -lssl -lcrypto]
--plugindir  [/usr/lib64/mysql/plugin]
--socket [/var/run/mysqld/mysqld.sock]
--port   [0]
--version[5.1.56]
--libmysqld-libs [-Wl,-O1 -Wl,--as-needed -rdynamic -L/usr/lib64/mysql 
-lmysqld -ldl -L/usr//lib64 -lz -lpthread -lcrypt -lnsl -lm -lpthread -lrt -
L/usr/lib64/ -lssl -lcrypto], -Wl,-O1 -Wl,--as-needed -rdynamic -
L/usr/lib64/mysql -lmysqlclient -L/usr//lib64 -lz -lcrypt -lnsl -lm -
L/usr/lib64/ -lssl -lcrypto

(they you get even longer and *nicer* -Wmissing-include-dirs warnings)

  Would it be legal to remove MYSQL_INCLUDE_DIR entirely and just rely on
  MYSQL_CFLAGS to specify -I/path/to/mysql ?
 
 Well, they don't have the same purpose. MYSQL_CFLAGS is used by the compiler
 (used in 'add_definitions..' lines) while MYSQL_INCLUDE_DIR is used by
 cmake.

...used by cmake (just?) to add -I/path to compiler arguments?

 Also, if mysql_config is not available, MYSQL_CFLAGS is empty and you can
 only count on MYSQL_INCLUDE_DIR.

Ah, I see.

  E.g. is cmake's include_directories(/dir) just a syntactic sugar for
  add_definitions(-I/dir) or it would break build on non-gcc platforms?
  I'd
  rather avoid filtering -I out of MYSQL_INCLUDE_DIR in CMakeLists.
 
 Without hint about what you're trying to fix, it's hard to answer this
 question.

So I guess we'll have to strip that -I out of `mysql_config --include`. Can we 
safely assume that it is only a single directory?

Regards,
Matěj
___
Amarok-devel mailing list
Amarok-devel@kde.org
https://mail.kde.org/mailman/listinfo/amarok-devel