Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH] use TarantoolConfig instead of FindTarantool
@ 2018-07-26 14:39 Konstantin Belyavskiy
  2018-07-31 12:45 ` [tarantool-patches] " Alexander Turenko
  0 siblings, 1 reply; 2+ messages in thread
From: Konstantin Belyavskiy @ 2018-07-26 14:39 UTC (permalink / raw)
  To: tarantool-patches

Use TarantoolConfig.cmake instead of FindTarantool.cmake and
distribute it within tarantool-dev package.
Module, which requires tarantool id its deps now can simply do:
 find_package(Tarantool CONFIG REQUIRED)
and does not obligate to have FindTarantool.cmake any more.
Tested with following modules:
avro-schema, cbench

Proposal for #3147
---
Ticket: https://github.com/tarantool/tarantool/issues/3147
Branch: https://github.com/tarantool/tarantool/tree/kbelyavs/gh-3147-use-tarantoolconfig-instead-findtarantool
 CMakeLists.txt        |  1 +
 TarantoolConfig.cmake | 44 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+)
 create mode 100644 TarantoolConfig.cmake

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d0cae0f01..f3f002f86 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -218,6 +218,7 @@ set(MODULE_LIBSUFFIX "${CMAKE_SHARED_LIBRARY_SUFFIX}")
 
 install(DIRECTORY DESTINATION ${MODULE_LUADIR})
 install(DIRECTORY DESTINATION ${MODULE_LIBDIR})
+install(FILES TarantoolConfig.cmake DESTINATION cmake)
 
 include(cmake/multilib.cmake)
 
diff --git a/TarantoolConfig.cmake b/TarantoolConfig.cmake
new file mode 100644
index 000000000..f0595c5c3
--- /dev/null
+++ b/TarantoolConfig.cmake
@@ -0,0 +1,44 @@
+# Define GNU standard installation directories
+include(GNUInstallDirs)
+
+macro(extract_definition name output input)
+    string(REGEX MATCH "#define[\t ]+${name}[\t ]+\"([^\"]*)\""
+        _t "${input}")
+    string(REGEX REPLACE "#define[\t ]+${name}[\t ]+\"(.*)\"" "\\1"
+        ${output} "${_t}")
+endmacro()
+
+find_path(TARANTOOL_INCLUDE_DIR tarantool/module.h
+  HINTS ENV TARANTOOL_DIR /usr/local/include
+)
+
+if(TARANTOOL_INCLUDE_DIR)
+    set(_config "-")
+    file(READ "${TARANTOOL_INCLUDE_DIR}/tarantool/module.h" _config0)
+    string(REPLACE "\\" "\\\\" _config ${_config0})
+    unset(_config0)
+    extract_definition(PACKAGE_VERSION TARANTOOL_VERSION ${_config})
+    extract_definition(INSTALL_PREFIX _install_prefix ${_config})
+    unset(_config)
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(TARANTOOL
+    REQUIRED_VARS TARANTOOL_INCLUDE_DIR VERSION_VAR TARANTOOL_VERSION)
+if(TARANTOOL_FOUND)
+    set(TARANTOOL_INCLUDE_DIRS "${TARANTOOL_INCLUDE_DIR}"
+                               "${TARANTOOL_INCLUDE_DIR}/tarantool/"
+        CACHE PATH "Include directories for Tarantool")
+    set(TARANTOOL_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/tarantool"
+        CACHE PATH "Directory for storing Lua modules written in Lua")
+    set(TARANTOOL_INSTALL_LUADIR "${CMAKE_INSTALL_DATADIR}/tarantool"
+        CACHE PATH "Directory for storing Lua modules written in C")
+
+    if (NOT TARANTOOL_FIND_QUIETLY AND NOT FIND_TARANTOOL_DETAILS)
+        set(FIND_TARANTOOL_DETAILS ON CACHE INTERNAL "Details about TARANTOOL")
+        message(STATUS "Tarantool LUADIR is ${TARANTOOL_INSTALL_LUADIR}")
+        message(STATUS "Tarantool LIBDIR is ${TARANTOOL_INSTALL_LIBDIR}")
+    endif ()
+endif()
+mark_as_advanced(TARANTOOL_INCLUDE_DIRS TARANTOOL_INSTALL_LIBDIR
+    TARANTOOL_INSTALL_LUADIR)
-- 
2.14.3 (Apple Git-98)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [tarantool-patches] Re: [PATCH] use TarantoolConfig instead of FindTarantool
  2018-07-26 14:39 [tarantool-patches] [PATCH] use TarantoolConfig instead of FindTarantool Konstantin Belyavskiy
@ 2018-07-31 12:45 ` Alexander Turenko
  0 siblings, 0 replies; 2+ messages in thread
From: Alexander Turenko @ 2018-07-31 12:45 UTC (permalink / raw)
  To: Konstantin Belyavskiy; +Cc: tarantool-patches

Hi!

I don't have much knowledge about cmake, but here is my two coins.

WBR, Alexander Turenko.

On Thu, Jul 26, 2018 at 05:39:06PM +0300, Konstantin Belyavskiy wrote:
> Use TarantoolConfig.cmake instead of FindTarantool.cmake and
> distribute it within tarantool-dev package.
> Module, which requires tarantool id its deps now can simply do:
>  find_package(Tarantool CONFIG REQUIRED)
> and does not obligate to have FindTarantool.cmake any more.
> Tested with following modules:
> avro-schema, cbench
> 
> Proposal for #3147
> ---
> Ticket: https://github.com/tarantool/tarantool/issues/3147
> Branch: https://github.com/tarantool/tarantool/tree/kbelyavs/gh-3147-use-tarantoolconfig-instead-findtarantool
>  CMakeLists.txt        |  1 +
>  TarantoolConfig.cmake | 44 ++++++++++++++++++++++++++++++++++++++++++++

Shouldn't we place the file in cmake/ or extra/? I guess extra/ is
better choice for files, which don't used during build and just
installed.

We don't install this new file in RPM/Deb developers packages? We
should, I think.

>  2 files changed, 45 insertions(+)
>  create mode 100644 TarantoolConfig.cmake
> 
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index d0cae0f01..f3f002f86 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -218,6 +218,7 @@ set(MODULE_LIBSUFFIX "${CMAKE_SHARED_LIBRARY_SUFFIX}")
>  
>  install(DIRECTORY DESTINATION ${MODULE_LUADIR})
>  install(DIRECTORY DESTINATION ${MODULE_LIBDIR})
> +install(FILES TarantoolConfig.cmake DESTINATION cmake)
>  
>  include(cmake/multilib.cmake)
>  
> diff --git a/TarantoolConfig.cmake b/TarantoolConfig.cmake
> new file mode 100644
> index 000000000..f0595c5c3
> --- /dev/null
> +++ b/TarantoolConfig.cmake
> @@ -0,0 +1,44 @@
> +# Define GNU standard installation directories
> +include(GNUInstallDirs)
> +
> +macro(extract_definition name output input)
> +    string(REGEX MATCH "#define[\t ]+${name}[\t ]+\"([^\"]*)\""
> +        _t "${input}")
> +    string(REGEX REPLACE "#define[\t ]+${name}[\t ]+\"(.*)\"" "\\1"
> +        ${output} "${_t}")
> +endmacro()
> +
> +find_path(TARANTOOL_INCLUDE_DIR tarantool/module.h
> +  HINTS ENV TARANTOOL_DIR /usr/local/include
> +)
> +
> +if(TARANTOOL_INCLUDE_DIR)
> +    set(_config "-")
> +    file(READ "${TARANTOOL_INCLUDE_DIR}/tarantool/module.h" _config0)
> +    string(REPLACE "\\" "\\\\" _config ${_config0})
> +    unset(_config0)
> +    extract_definition(PACKAGE_VERSION TARANTOOL_VERSION ${_config})
> +    extract_definition(INSTALL_PREFIX _install_prefix ${_config})
> +    unset(_config)
> +endif()
> +
> +include(FindPackageHandleStandardArgs)
> +find_package_handle_standard_args(TARANTOOL
> +    REQUIRED_VARS TARANTOOL_INCLUDE_DIR VERSION_VAR TARANTOOL_VERSION)
> +if(TARANTOOL_FOUND)
> +    set(TARANTOOL_INCLUDE_DIRS "${TARANTOOL_INCLUDE_DIR}"
> +                               "${TARANTOOL_INCLUDE_DIR}/tarantool/"
> +        CACHE PATH "Include directories for Tarantool")
> +    set(TARANTOOL_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/tarantool"
> +        CACHE PATH "Directory for storing Lua modules written in Lua")
> +    set(TARANTOOL_INSTALL_LUADIR "${CMAKE_INSTALL_DATADIR}/tarantool"
> +        CACHE PATH "Directory for storing Lua modules written in C")

I understand this is pure copy of FindTarantool.cmake from avro-schema,
but 'in Lua' and 'in C' in descriptions should be swapped.

> +
> +    if (NOT TARANTOOL_FIND_QUIETLY AND NOT FIND_TARANTOOL_DETAILS)
> +        set(FIND_TARANTOOL_DETAILS ON CACHE INTERNAL "Details about TARANTOOL")
> +        message(STATUS "Tarantool LUADIR is ${TARANTOOL_INSTALL_LUADIR}")
> +        message(STATUS "Tarantool LIBDIR is ${TARANTOOL_INSTALL_LIBDIR}")
> +    endif ()
> +endif()
> +mark_as_advanced(TARANTOOL_INCLUDE_DIRS TARANTOOL_INSTALL_LIBDIR
> +    TARANTOOL_INSTALL_LUADIR)
> -- 
> 2.14.3 (Apple Git-98)
> 
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-07-31 12:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-26 14:39 [tarantool-patches] [PATCH] use TarantoolConfig instead of FindTarantool Konstantin Belyavskiy
2018-07-31 12:45 ` [tarantool-patches] " Alexander Turenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox