Changeset View
Changeset View
Standalone View
Standalone View
cmake/Findlibssh.cmake
Show All 26 Lines | |||||
27 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 27 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
28 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 28 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
29 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 29 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
30 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 30 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
31 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 31 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
32 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 32 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
33 | # SUCH DAMAGE. | 33 | # SUCH DAMAGE. | ||
34 | 34 | | |||
35 | # Define an imported target to have compatibility with newer libssh and so | ||||
36 | # we have a single target to use regardless of the code path taken in the | ||||
37 | # finder and the actual libssh version defining the target. | ||||
38 | macro(libssh_ensure_imported_target) | ||||
39 | if(NOT TARGET ssh) | ||||
40 | add_library(ssh SHARED IMPORTED) | ||||
41 | set_target_properties(ssh PROPERTIES | ||||
42 | IMPORTED_LOCATION "${LIBSSH_LIBRARIES}" | ||||
43 | INTERFACE_INCLUDE_DIRECTORIES "${LIBSSH_INCLUDE_DIR}" | ||||
44 | ) | ||||
45 | endif() | ||||
46 | endmacro() | ||||
47 | | ||||
35 | # We prefer the config, but on Ubuntu 18.04 LTS (and to some extent later | 48 | # We prefer the config, but on Ubuntu 18.04 LTS (and to some extent later | ||
36 | # versions it seems) they've not packaged the config properly. So, go for the | 49 | # versions it seems) they've not packaged the config properly. So, go for the | ||
37 | # config by default and fall back to manual lookup iff the config was not found. | 50 | # config by default and fall back to manual lookup iff the config was not found. | ||
38 | # https://bugs.kde.org/show_bug.cgi?id=400291 | 51 | # https://bugs.kde.org/show_bug.cgi?id=400291 | ||
39 | # https://bugs.launchpad.net/ubuntu/+source/libssh/+bug/1800135 | 52 | # https://bugs.launchpad.net/ubuntu/+source/libssh/+bug/1800135 | ||
40 | find_package(libssh ${libssh_FIND_VERSION} NO_MODULE QUIET) | 53 | find_package(libssh ${libssh_FIND_VERSION} NO_MODULE QUIET) | ||
41 | if(libssh_FOUND) | 54 | if(libssh_FOUND) | ||
55 | # Certain versions with config may not have the target, so make sure it's | ||||
56 | # defined. | ||||
57 | libssh_ensure_imported_target() | ||||
42 | return() | 58 | return() | ||
43 | endif() | 59 | endif() | ||
44 | 60 | | |||
45 | find_path(LIBSSH_INCLUDE_DIR | 61 | find_path(LIBSSH_INCLUDE_DIR | ||
46 | NAMES | 62 | NAMES | ||
47 | libssh/libssh.h | 63 | libssh/libssh.h | ||
48 | PATHS | 64 | PATHS | ||
49 | /usr/include | 65 | /usr/include | ||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | 119 | find_package_handle_standard_args(libssh | |||
104 | FOUND_VAR | 120 | FOUND_VAR | ||
105 | LIBSSH_FOUND | 121 | LIBSSH_FOUND | ||
106 | REQUIRED_VARS | 122 | REQUIRED_VARS | ||
107 | LIBSSH_LIBRARIES | 123 | LIBSSH_LIBRARIES | ||
108 | LIBSSH_INCLUDE_DIR | 124 | LIBSSH_INCLUDE_DIR | ||
109 | VERSION_VAR | 125 | VERSION_VAR | ||
110 | LIBSSH_VERSION) | 126 | LIBSSH_VERSION) | ||
111 | 127 | | |||
128 | libssh_ensure_imported_target() | ||||
129 | | ||||
112 | # show the LIBSSH_INCLUDE_DIRS and LIBSSH_LIBRARIES variables only in the advanced view | 130 | # show the LIBSSH_INCLUDE_DIRS and LIBSSH_LIBRARIES variables only in the advanced view | ||
113 | mark_as_advanced(LIBSSH_INCLUDE_DIR LIBSSH_LIBRARIES) | 131 | mark_as_advanced(LIBSSH_INCLUDE_DIR LIBSSH_LIBRARIES) |