Skip to content

Commit 32b8eb8

Browse files
committed
Merge pull request #226 from correa/cmake-cleanup
Include internal zlib as build option and use standard Find_Package for OpenSSL.
2 parents 934e896 + c659f89 commit 32b8eb8

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

CMakeLists.txt

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -319,15 +319,22 @@ if(USE_STATIC_BOOST)
319319
else(USE_STATIC_BOOST)
320320
message(STATUS "Linking against boost dynamic libraries")
321321
endif(USE_STATIC_BOOST)
322-
323-
FIND_PACKAGE(ZLIB)
324-
IF(ZLIB_FOUND)
325-
MESSAGE(STATUS "ZLIB libraries found at: ${ZLIB_LIBRARIES}")
326-
MESSAGE(STATUS "ZLIB includes found at: ${ZLIB_INCLUDE_DIRS}")
327-
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS})
328-
else()
329-
MESSAGE(FATAL_ERROR "ZLIB not found on your system, see install.txt how to get them installed. (for example 'sudo apt-get install zlib1g-dev')")
330-
ENDIF(ZLIB_FOUND)
322+
include_directories(${Boost_INCLUDE_DIRS})
323+
324+
option(USE_BUILTIN_ZLIB "Use builtin zlib library" NO)
325+
if(USE_BUILTIN_ZLIB)
326+
add_subdirectory (zlib)
327+
include_directories(${ZLIB_INCLUDE_DIRS})
328+
else(USE_BUILTIN_ZLIB)
329+
find_package(ZLIB REQUIRED)
330+
if(ZLIB_FOUND)
331+
MESSAGE(STATUS "ZLIB libraries found at: ${ZLIB_LIBRARIES}")
332+
MESSAGE(STATUS "ZLIB includes found at: ${ZLIB_INCLUDE_DIRS}")
333+
include_directories(${ZLIB_INCLUDE_DIRS})
334+
else()
335+
MESSAGE(FATAL_ERROR "ZLIB not found on your system, see install.txt how to get them installed. (for example 'sudo apt-get install zlib1g-dev')")
336+
endif(ZLIB_FOUND)
337+
endif(USE_BUILTIN_ZLIB)
331338

332339
FIND_PACKAGE(CURL)
333340
IF(CURL_FOUND)
@@ -357,31 +364,22 @@ ENDIF(LIBUSB_FOUND)
357364
#
358365
# Find MD5/RMD160/SHA library
359366
#
360-
find_path(OPENSSL_INCLUDE_DIR openssl/ssl.h)
361-
find_library(OPENSSL_LIBRARY ssl)
367+
find_package(OpenSSL)
362368
if(NOT OPENSSL_INCLUDE_DIR)
363369
message(SEND_ERROR "Failed to find openssl include files (ssl.h), no HTTPS support")
364370
endif()
365-
if(NOT OPENSSL_LIBRARY)
371+
if(NOT OPENSSL_FOUND)
366372
message(SEND_ERROR "Failed to find the openssl library, no HTTPS support")
373+
find_library(MD_LIBRARY NAMES md)
374+
if(MD_LIBRARY)
375+
target_link_libraries(domoticz ${MD_LIBRARY})
376+
endif(MD_LIBRARY)
367377
else()
368378
add_definitions(-DNS_ENABLE_SSL)
369-
target_link_libraries(domoticz ${OPENSSL_LIBRARY})
379+
include_directories(${OPENSSL_INCLUDE_DIR})
380+
target_link_libraries(domoticz ${OPENSSL_LIBRARIES})
370381
endif()
371382

372-
FIND_LIBRARY(CRYPTO_LIBRARY NAMES crypto)
373-
IF(CRYPTO_LIBRARY)
374-
MESSAGE(STATUS "Crypto library found at: ${CRYPTO_LIBRARY}")
375-
target_link_libraries(domoticz ${CRYPTO_LIBRARY})
376-
ELSE(CRYPTO_LIBRARY)
377-
IF(NOT OPENSSL_FOUND)
378-
FIND_LIBRARY(MD_LIBRARY NAMES md)
379-
IF(MD_LIBRARY)
380-
LIST(APPEND ADDITIONAL_LIBS ${MD_LIBRARY})
381-
ENDIF(MD_LIBRARY)
382-
ENDIF(NOT OPENSSL_FOUND)
383-
ENDIF(CRYPTO_LIBRARY)
384-
385383
## support lua popen on Linux platforms
386384
#IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
387385
# SET(OperatingSystem "Linux")

0 commit comments

Comments
 (0)