From d2bb6cef5f88e983c552776850696ec09ef80ddb Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Wed, 9 Mar 2022 12:30:59 +0100 Subject: [PATCH 1/3] Added `rest-config --prefix` option, updated REST cmake files for better integration into cmake projects --- cmake/scripts/RESTConfig.cmake | 14 +++++++++++-- cmake/thisREST.cmake | 38 ++++++++++++++++------------------ 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/cmake/scripts/RESTConfig.cmake b/cmake/scripts/RESTConfig.cmake index f83a79d24..7733f4ea4 100644 --- a/cmake/scripts/RESTConfig.cmake +++ b/cmake/scripts/RESTConfig.cmake @@ -2,9 +2,17 @@ # This cmake file will enable to find REST from another CMake project via "find_package(REST)" # It will define useful variables such as "REST_PATH" or "REST_LIBRARIES" which makes linking easier -set(REST_PATH $ENV{REST_PATH}) +execute_process(COMMAND rest-config --prefix OUTPUT_VARIABLE REST_PATH) + +set(REST_PATH_ENV $ENV{REST_PATH}) +string(STRIP "${REST_PATH_ENV}" REST_PATH_ENV) +string(STRIP "${REST_PATH}" REST_PATH) + +if (NOT "${REST_PATH_ENV}" STREQUAL "${REST_PATH}") + message(SEND_ERROR "REST installation found at ${REST_PATH} but 'REST_PATH' env variable points to $ENV{REST_PATH}") + set(REST_FOUND False) +endif() -# TODO: I think there is a better way to do this, we shouldn't call 'rest-config' for this execute_process(COMMAND rest-config --libs OUTPUT_VARIABLE REST_LIBRARIES) string(STRIP ${REST_LIBRARIES} REST_LIBRARIES) # It is necessary to strip the whitespaces, or it will give error @@ -13,3 +21,5 @@ string(STRIP ${REST_INCLUDE_DIRS} REST_INCLUDE_DIRS) # It is necessary to strip execute_process(COMMAND rest-config --version OUTPUT_VARIABLE REST_VERSION) string(STRIP ${REST_VERSION} REST_VERSION) # It is necessary to strip the whitespaces, or it will give error + +message(STATUS "REST installation found at: ${REST_PATH}") diff --git a/cmake/thisREST.cmake b/cmake/thisREST.cmake index 269af11f9..84d74adfa 100644 --- a/cmake/thisREST.cmake +++ b/cmake/thisREST.cmake @@ -40,7 +40,6 @@ endif (${REST_GARFIELD} MATCHES "ON") # install thisREST script, sh VERSION install(CODE " - file( WRITE \${CMAKE_INSTALL_PREFIX}/thisREST.sh \"\#!/bin/bash @@ -162,15 +161,13 @@ alias ${mac} \\\"restManager ${m}\\\" endforeach (mac ${rest_macros}) - -#install rest-config +# install rest-config install(CODE " include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/CollectGitInfo.cmake) message(STATUS \"Installing: \${CMAKE_INSTALL_PREFIX}/bin/rest-config\") - file( WRITE \${CMAKE_INSTALL_PREFIX}/bin/rest-config \" @@ -208,7 +205,12 @@ echo ${rest_macros_str} fi if [ $option = \\\"--version\\\" ] ; then -echo \${GIT_TAG} +echo ${GIT_TAG} + +fi + +if [ $option = \\\"--prefix\\\" ] ; then +echo ${CMAKE_INSTALL_PREFIX} fi @@ -250,7 +252,7 @@ echo \\\" Compilation date : ${date} \\\" echo \\\" Official release : \${REST_OFFICIAL_RELEASE} \\\" echo \\\" Clean state : \${GIT_CLEANSTATE} \\\" echo \\\" \\\" -echo \\\" Installed at : $REST_PATH \\\" +echo \\\" Installed at : \${CMAKE_INSTALL_PREFIX} \\\" echo \\\" \\\" echo \\\" REST-for-Physics site : rest-for-physics.github.io \\\" echo \\\" \\\" @@ -264,26 +266,22 @@ fi fi if [ $option = \\\"--help\\\" ] ; then -echo \\\" Usage : \\\" -echo \\\" rest-config [--incdir] : Shows the directory of headers \\\" -echo \\\" rest-config [--libdir] : Shows the directory of library \\\" -echo \\\" rest-config [--libs] : Prints regular REST libraries \\\" -echo \\\" rest-config [--exes] : Prints a list of REST executables with alias \\\" -echo \\\" rest-config [--version] : Prints the version of REST \\\" -echo \\\" rest-config [--welcome] : Prints the welcome message \\\" -echo \\\" rest-config [--flags] : Prints cmake flags defined when installing \\\" +echo \\\" Usage : \\\" +echo \\\" rest-config [--version] : Prints the version of REST \\\" +echo \\\" rest-config [--prefix] : Prints REST installation directory \\\" +echo \\\" rest-config [--incdir] : Shows the directory of headers \\\" +echo \\\" rest-config [--libdir] : Shows the directory of library \\\" +echo \\\" rest-config [--libs] : Prints regular REST libraries \\\" +echo \\\" rest-config [--exes] : Prints a list of REST executables with alias \\\" +echo \\\" rest-config [--welcome] : Prints the welcome message \\\" +echo \\\" rest-config [--flags] : Prints cmake flags defined when installing \\\" echo \\\" rest-config [--release] : Prints 'Yes' if the compilation corresponds with an official git tag. \\\" -echo \\\" rest-config [--clean] : Prints 'Yes' if no local modifications were found during compilation \\\" - +echo \\\" rest-config [--clean] : Prints 'Yes' if no local modifications were found during compilation \\\" fi - fi - - - \" ) " From e6331ea6d980a64392d94800f4380572a2720bf1 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Wed, 9 Mar 2022 12:40:11 +0100 Subject: [PATCH 2/3] RESTConfig.cmake - formatting --- cmake/scripts/RESTConfig.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/scripts/RESTConfig.cmake b/cmake/scripts/RESTConfig.cmake index 7733f4ea4..8c202418c 100644 --- a/cmake/scripts/RESTConfig.cmake +++ b/cmake/scripts/RESTConfig.cmake @@ -11,7 +11,7 @@ string(STRIP "${REST_PATH}" REST_PATH) if (NOT "${REST_PATH_ENV}" STREQUAL "${REST_PATH}") message(SEND_ERROR "REST installation found at ${REST_PATH} but 'REST_PATH' env variable points to $ENV{REST_PATH}") set(REST_FOUND False) -endif() +endif () execute_process(COMMAND rest-config --libs OUTPUT_VARIABLE REST_LIBRARIES) string(STRIP ${REST_LIBRARIES} REST_LIBRARIES) # It is necessary to strip the whitespaces, or it will give error From cc2f3d1fdbbde06355824bd5178125adad0edd9a Mon Sep 17 00:00:00 2001 From: Luis Obis <35803280+lobis@users.noreply.github.com> Date: Thu, 10 Mar 2022 13:29:16 +0100 Subject: [PATCH 3/3] added back backslash --- cmake/thisREST.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/thisREST.cmake b/cmake/thisREST.cmake index 84d74adfa..879a8b08d 100644 --- a/cmake/thisREST.cmake +++ b/cmake/thisREST.cmake @@ -205,7 +205,7 @@ echo ${rest_macros_str} fi if [ $option = \\\"--version\\\" ] ; then -echo ${GIT_TAG} +echo \${GIT_TAG} fi