Вывод уведомления о зависимости при компоновке в cmake

Send your patches here
Post Reply
dimka88
Posts: 404
Joined: 13 Oct 2014, 05:51
Contact:

Вывод уведомления о зависимости при компоновке в cmake

Post by dimka88 » 07 Nov 2016, 11:00

Что бы избежать типичных ошибок при компоновке в cmake зависимости от библиотек libpcre и libcrypto, добавил уведомления и цвет, заставляющий обратить внимание на конкретную ошибку.
Image
Image

Code: Select all

--- a/CMakeLists.txt.orig       2016-11-04 19:52:45.000000000 +0300
+++ b/CMakeLists.txt            2016-11-07 13:17:51.000000000 +0300
@@ -24,6 +24,19 @@
        ENDIF (ARCH STREQUAL x86_64)
 ENDIF (NOT DEFINED LIB_SUFFIX)

+#color console example  message(FATAL_ERROR "${Esc}[31m Red Text ${Esc}[m Restore Normal Text")
+string(ASCII 27 Esc)
+
+#Check libpcre
+find_library(PCRE_LIBRARY pcre
+ HINTS ${CMAKE_SOURCE_DIR}/lib/linux/gcc/${BIT}/lib
+ PATHS ${CMAKE_SOURCE_DIR}/lib/linux/gcc/${BIT}/lib
+)
+
+IF(NOT PCRE_LIBRARY)
+  message(FATAL_ERROR "${Esc}[31mRequired libpcre not found.\n Install libpcre3-dev and run cmake again${Esc}[m")
+ENDIF(NOT PCRE_LIBRARY)
+
 IF (EXISTS ${CMAKE_HOME_DIRECTORY}/.git AND NOT IGNORE_GIT)
        EXECUTE_PROCESS(
                COMMAND git log --no-color
@@ -50,6 +63,13 @@
        endif (NOT DEFINED CRYPTO)

        if (CRYPTO STREQUAL OPENSSL)
+               find_library(CRYPTO_LIBRARY ssl
+                       HINTS ${CMAKE_SOURCE_DIR}/lib/linux/gcc/${BIT}/lib
+                       PATHS ${CMAKE_SOURCE_DIR}/lib/linux/gcc/${BIT}/lib
+               )
+               IF(NOT CRYPTO_LIBRARY)
+                        message(FATAL_ERROR "${Esc}[31mRequired libcrypto-0.9.8 or probably later (openssl-0.9.8)  not found.\n Install libssl-dev and run cmake again${Esc}[m")
+               ENDIF(NOT CRYPTO_LIBRARY)
                add_definitions(-DCRYPTO_OPENSSL)
                set(crypto_lib crypto ssl)
        elseif (CRYPTO STREQUAL TOMCRYPT)
Attachments
patch.gz
(675 Bytes) Downloaded 18 times

Dmitry
Администратор
Posts: 949
Joined: 09 Oct 2014, 10:06

Re: Вывод уведомления о зависимости при компоновке в cmake

Post by Dmitry » 27 Mar 2017, 12:57

commit 837f73242956814bf98350d732d8aea0b7b830fa

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest