Project

General

Profile

Actions

Bug #3181

closed

Meson / CMake build issues

Added by brad@comstyle.com over 1 year ago. Updated over 1 year ago.

Status:
Fixed
Priority:
Normal
Category:
-
Target version:
ASK QUESTIONS IN Forums:
No

Description

Trying out Meson I noticed it does not install the man pages.

Trying out CMake I see there is not an equivalent of the lua_version
option to select a specific release of Lua. As well as the following error..

CMake Error at CMakeLists.txt:26 (add_subdirectory):
The source directory

/home/ports/pobj/lighttpd-1.4.68/lighttpd-1.4.68/doc
does not contain a CMakeLists.txt file.
Actions #1

Updated by gstrauss over 1 year ago

  • Status changed from New to Patch Pending

Trying out Meson I noticed it does not install the man pages.

This is known. Nobody has added the feature yet.

CMake Error at CMakeLists.txt:26 (add_subdirectory):

/home/ports/pobj/lighttpd-1.4.68/lighttpd-1.4.68/doc does not contain a CMakeLists.txt file.

That was added in
https://git.lighttpd.net/lighttpd/lighttpd1.4/commit/f98cc6743821b8bfa342dabb9a7d5a06ce6b93fe
However, it looks like it might not be part of the tar bar. This should fix that (for the next lighttpd release):

--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -3,6 +3,7 @@ dist_man8_MANS=lighttpd.8 lighttpd-angel.8
 GNUMAKEFLAGS=--no-print-directory -s

 EXTRA_DIST= \
+       CMakeLists.txt \
        initscripts.txt \
        newstyle.css \
        oldstyle.css

Actions #2

Updated by gstrauss over 1 year ago

  • Status changed from Patch Pending to Fixed
Actions #3

Updated by brad@comstyle.com over 1 year ago

There was also this part I think you missed..

Trying out CMake I see there is not an equivalent of the lua_version
option to select a specific release of Lua.

Both autoconf and meson have this functionality.

Actions #4

Updated by gstrauss over 1 year ago

Yes, sorry, I overlooked that. I'll see if I can do something similar for cmake.

Actions #5

Updated by brad@comstyle.com over 1 year ago

I figured as much. Thanks.

Actions #6

Updated by brad@comstyle.com over 1 year ago

Another issue I noticed with CMake.

-- found mysql_config: /usr/local/bin/mysql_config
-- Looking for include file mysql.h
-- Looking for include file mysql.h - not found
xconfig(mysql_config MYSQL_LDFLAGS MYSQL_CFLAGS)

set(CMAKE_REQUIRED_INCLUDES /usr/include/mysql)
check_include_files(mysql.h HAVE_MYSQL_H)
set(CMAKE_REQUIRED_INCLUDES)

With the hardcoded path. Instead of using the path that I see would be retrieved via mysql_config.

Actions #7

Updated by gstrauss over 1 year ago

With the removal years ago of mod_authn_mysql and the requirement to specify --with-mysql or equivalent to build lighttpd modules which depend on mysql, this patch is probably simpler:

--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -333,15 +333,8 @@ endif()

 if(WITH_MYSQL)
        xconfig(mysql_config MYSQL_LDFLAGS MYSQL_CFLAGS)
-
-       set(CMAKE_REQUIRED_INCLUDES /usr/include/mysql)
-       check_include_files(mysql.h HAVE_MYSQL_H)
-       set(CMAKE_REQUIRED_INCLUDES)
-       if(HAVE_MYSQL_H)
-               check_library_exists(mysqlclient mysql_real_connect "" HAVE_MYSQL)
-       endif()
+       check_library_exists(mysqlclient mysql_real_connect "" HAVE_MYSQL)
 else()
-       unset(HAVE_MYSQL_H)
        unset(HAVE_MYSQL)
 endif()

@@ -1003,7 +996,7 @@ if(WITH_MAXMINDDB)
        target_link_libraries(mod_maxminddb maxminddb)
 endif()

-if(HAVE_MYSQL_H AND HAVE_MYSQL)
+if(HAVE_MYSQL)
        add_and_install_library(mod_vhostdb_mysql "mod_vhostdb_mysql.c")
        target_link_libraries(mod_vhostdb_mysql mysqlclient)
        include_directories(/usr/include/mysql)

Actions #8

Updated by gstrauss over 1 year ago

cmake -DWITH_LUA_VERSION=...

--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -37,6 +37,7 @@ option(WITH_KRB5 "with Kerberos5-support for mod_auth [default: off]")
 option(WITH_LDAP "with LDAP-support for mod_auth mod_vhostdb_ldap [default: off]")
 option(WITH_PAM "with PAM-support for mod_auth [default: off]")
 option(WITH_LUA "with lua for mod_magnet [default: off]")
+option(WITH_LUA_VERSION "specify lua version for mod_magnet")
 # option(WITH_VALGRIND "with internal support for valgrind [default: off]")
 option(WITH_FAM "fam/gamin for reducing number of stat() calls [default: off]")
 option(WITH_LIBDEFLATE "with libdeflate-support for mod_deflate [default: off]")
@@ -757,7 +758,11 @@ else()
 endif()

 if(WITH_LUA)
-       pkg_search_module(LUA REQUIRED lua5.4 lua-5.4 lua5.3 lua-5.3 lua5.2 lua-5.2 lua5.1 lua-5.1 lua)
+       if(WITH_LUA_VERSION)
+               pkg_search_module(LUA REQUIRED ${WITH_LUA_VERSION})
+       else()
+               pkg_search_module(LUA REQUIRED lua5.4 lua-5.4 lua5.3 lua-5.3 lua5.2 lua-5.2 lua5.1 lua-5.1 lua)
+       endif()
        message(STATUS "found lua at: INCDIR: ${LUA_INCLUDE_DIRS} LIBDIR: ${LUA_LIBRARY_DIRS} LDFLAGS: ${LUA_LDFLAGS} CFLAGS: ${LUA_CFLAGS}")
        set(HAVE_LUA_H  1 "Have liblua header")
 else()

Actions #9

Updated by brad@comstyle.com over 1 year ago

That's IMO worse (than fixing the hardcoded path). autoconf will look for libmariadb, then fallback to libmysqlclient and then mysql_config, but the more important part when looking for the libraries is utilizing the pkg-config file. CMake just looks for libmariadb.

Actions #10

Updated by brad@comstyle.com over 1 year ago

The Lua diff works and does as expected. Thanks.

Actions #11

Updated by gstrauss over 1 year ago

That's IMO worse (than fixing the hardcoded path). autoconf will look for libmariadb, then fallback to libmysqlclient and then mysql_config, but the more important part when looking for the libraries is utilizing the pkg-config file. CMake just looks for libmariadb.

The code in lighttpd src/CMakeLists.txt uses a custom macro named XCONFIG defined earlier in src/CMakeLists.txt.
In the case of mysql, the macro looks for mysql_config and uses that. mysql_config is present on my system and configurd to use mariadb.
Maybe the XCONFIG macro could be extended if not sufficient? (Patches welcome.)

Actions #12

Updated by gstrauss over 1 year ago

I think you're referring to the line
check_library_exists(mysqlclient mysql_real_connect "" HAVE_MYSQL)
which did not change in the path other than leading whitespace indenting, so the limitation has not changed.

My Fedora Linux system provides the following for compatibility

/usr/lib64/libmysqlclient_r.so -> libmariadb.so.3
/usr/lib64/libmysqlclient.so -> libmariadb.so.3

Can CMake use ${MYSQL_LDFLAGS} returned from mysql_config --libs when checking for mysql_real_connect?
Alternatively, is the test largely redundant due to the existence (or not) of mysql_config?

Actions #13

Updated by gstrauss over 1 year ago

Would you prefer this?

--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -334,7 +334,9 @@ endif()

 if(WITH_MYSQL)
        xconfig(mysql_config MYSQL_LDFLAGS MYSQL_CFLAGS)
-       check_library_exists(mysqlclient mysql_real_connect "" HAVE_MYSQL)
+       if(MYSQL_LDFLAGS)
+               set(HAVE_MYSQL TRUE)
+       endif()
 else()
        unset(HAVE_MYSQL)
 endif()

Actions #14

Updated by brad@comstyle.com over 1 year ago

With that it finds mysql_config and then does nothing with MYSQL_CFLAGS / MYSQL_LDFLAGS; the module is enabled but the builds fails.

Oh, also staring at the CMake file I noticed this line..

        include_directories(/usr/include/mysql)
Actions #15

Updated by gstrauss over 1 year ago

Sigh. More historical hard-coding of mysqlclient.

--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1003,8 +1005,8 @@ endif()

 if(HAVE_MYSQL)
        add_and_install_library(mod_vhostdb_mysql "mod_vhostdb_mysql.c")
-       target_link_libraries(mod_vhostdb_mysql mysqlclient)
-       include_directories(/usr/include/mysql)
+       add_target_properties(mod_vhostdb_mysql COMPILE_FLAGS ${MYSQL_CFLAGS})
+       target_link_libraries(mod_vhostdb_mysql ${MYSQL_LDFLAGS})
 endif()

 if(HAVE_PGSQL)

(Edit: updated patch above to add use of MYSQL_CFLAGS)

Actions #16

Updated by brad@comstyle.com over 1 year ago

Thank you. The updated bit for CFLAGS handling does the trick.

Actions

Also available in: Atom