From ae6130f095c50d3681e117f2153851a6e530b201 Mon Sep 17 00:00:00 2001 From: Christian Burger Date: Sat, 23 Apr 2022 20:34:00 +0200 Subject: [PATCH] cmake: some improvements * not depending on "-dev" packages for the built Debian package * some refactoring in if-clauses and with "quotes" * libvterm dependency: if something is missing, made clear what --- CMakeLists.txt | 2 +- cmake/gsl.cmake | 4 ++-- cmake/libvterm.cmake | 20 +++++++++++++++----- cmake/ncurses.cmake | 4 ++-- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ec101bd..c094603 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,5 +58,5 @@ set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Library for a pseudo terminal where the h set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${CMAKE_PROJECT_HOMEPAGE_URL}) set(CPACK_GENERATOR "DEB" "TGZ") -set(CPACK_DEBIAN_PACKAGE_DEPENDS "libncursesw6 (>=6.2), libvterm-dev (>= 0.1.2)") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "libncursesw6 (>=6.2), libvterm0 (>= 0.1.2)") include(CPack) diff --git a/cmake/gsl.cmake b/cmake/gsl.cmake index bcf5f06..dabc374 100644 --- a/cmake/gsl.cmake +++ b/cmake/gsl.cmake @@ -3,9 +3,9 @@ # @author Christian Burger find_path(GSL_INCLUDE_DIR "gsl/gsl" REQUIRED) -if(GSL_INCLUDE_DIR STREQUAL "GSL_INCLUDE_DIR-NOTFOUND") +if(NOT GSL_INCLUDE_DIR) message(SEND_ERROR "Microsoft GSL not found.") else() - message(STATUS "Microsoft GSL found.") + message(STATUS "Found Microsoft C++ GSL.") include_directories(SYSTEM ${GSL_INCLUDE_DIR}) endif() \ No newline at end of file diff --git a/cmake/libvterm.cmake b/cmake/libvterm.cmake index 88b250b..10cf61d 100644 --- a/cmake/libvterm.cmake +++ b/cmake/libvterm.cmake @@ -12,12 +12,20 @@ # @author Christian Burger -find_library(LIBVTERM_LIBRARY NAMES libvterm.so.0.0.2 vterm) +find_library(LIBVTERM_LIBRARY NAMES "libvterm.so.0.0.2" "vterm") +find_path(LIBVTERM_INCLUDE "vterm.h") -include(ExternalProject) - -if(LIBVTERM_LIBRARY STREQUAL "LIBVTERM_LIBRARY-NOTFOUND") - message(STATUS "libvterm not found — building it") +if(NOT LIBVTERM_LIBRARY) + message(STATUS "Did not find `libvterm.so`.") + set(LIBVTERM_BUILD_IT TRUE) +endif() +if(NOT LIBVTERM_INCLUDE) + message(STATUS "Did not find `vterm.h`.") + set(LIBVTERM_BUILD_IT TRUE) +endif() +if(LIBVTERM_BUILD_IT) + include(ExternalProject) + message(STATUS "Did not find libvterm (see previous error) — building it.") ExternalProject_Add( libvtermProject DOWNLOAD_COMMAND URL "https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/libvterm/0.1.2-2/libvterm_0.1.2.orig.tar.gz" @@ -28,4 +36,6 @@ if(LIBVTERM_LIBRARY STREQUAL "LIBVTERM_LIBRARY-NOTFOUND") ExternalProject_Get_property(libvtermProject SOURCE_DIR) set(LIBVTERM_LIBRARY "${SOURCE_DIR}/.libs/libvterm.a") include_directories(SYSTEM "${SOURCE_DIR}/include") +else() + message(STATUS "Found vterm library.") endif() diff --git a/cmake/ncurses.cmake b/cmake/ncurses.cmake index a811778..fbbbad7 100644 --- a/cmake/ncurses.cmake +++ b/cmake/ncurses.cmake @@ -8,8 +8,8 @@ find_package(Curses 6.2 REQUIRED) include_directories(SYSTEM ${CURSES_INCLUDE_DIRS}) # find C++ interface for ncurses with unicode support -find_library(CURSES_CPP_WIDE_LIBRARY NAMES ncurses++w REQUIRED) +find_library(CURSES_CPP_WIDE_LIBRARY NAMES ncurses++w) if(NOT CURSES_CPP_WIDE_LIBRARY) - message(FATAL_ERROR "C++ interface for ncurses (wide/unicode) not found.") + message(SEND_ERROR "C++ interface for ncurses (wide/unicode) not found.") endif() list(APPEND CURSES_LIBRARIES ${CURSES_CPP_WIDE_LIBRARY}) \ No newline at end of file