diff --git a/cmake/scripts/RESTConfig.cmake b/cmake/scripts/RESTConfig.cmake index f83a79d24..8c202418c 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..879a8b08d 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 \" @@ -212,6 +209,11 @@ echo \${GIT_TAG} fi +if [ $option = \\\"--prefix\\\" ] ; then +echo ${CMAKE_INSTALL_PREFIX} + +fi + if [ $option = \\\"--commit\\\" ] ; then echo \${GIT_COMMIT} @@ -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 - - - \" ) "