Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated CMake for inclusion of REST via find_package #147

Merged
merged 3 commits into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions cmake/scripts/RESTConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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}")
36 changes: 17 additions & 19 deletions cmake/thisREST.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

\"
Expand Down Expand Up @@ -212,6 +209,11 @@ echo \${GIT_TAG}

fi

if [ $option = \\\"--prefix\\\" ] ; then
echo ${CMAKE_INSTALL_PREFIX}

fi

if [ $option = \\\"--commit\\\" ] ; then
echo \${GIT_COMMIT}

Expand Down Expand Up @@ -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 \\\" \\\"
Expand All @@ -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





\"
)
"
Expand Down