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

Problem: Add options to control over optional libraries #1186

Merged
merged 1 commit into from
Jun 9, 2019

Conversation

myd7349
Copy link
Contributor

@myd7349 myd7349 commented Jun 9, 2019

This patch also:

  1. Simplify Findlibzmq.cmake
  2. Use both libname and linkname when they are not identical

Related issue: zeromq/czmq#1972

This patch also:
1. Simplify Findlibzmq.cmake
2. Use both libname and linkname when they are not identical

Related issue: zeromq/czmq#1972
@myd7349 myd7349 marked this pull request as ready for review June 9, 2019 09:00
@myd7349
Copy link
Contributor Author

myd7349 commented Jun 9, 2019

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2d2b305a..8100d0cd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -138,7 +138,8 @@ ENDIF (LIBZMQ_FOUND)
 # UUID dependency
 ########################################################################
 find_package(uuid)
-IF (UUID_FOUND)
+option(CZMQ_WITH_UUID "Build czmq with uuid" ${UUID_FOUND})
+IF (CZMQ_WITH_UUID AND UUID_FOUND)
     include_directories(${UUID_INCLUDE_DIRS})
     list(APPEND MORE_LIBRARIES ${UUID_LIBRARIES})
   IF (PC_UUID_FOUND)
@@ -149,13 +150,14 @@ IF (UUID_FOUND)
   ENDIF (PC_UUID_FOUND)
     add_definitions(-DHAVE_UUID)
     list(APPEND OPTIONAL_LIBRARIES ${UUID_LIBRARIES})
-ENDIF (UUID_FOUND)
+ENDIF (CZMQ_WITH_UUID AND UUID_FOUND)
 
 ########################################################################
 # SYSTEMD dependency
 ########################################################################
 find_package(systemd)
-IF (SYSTEMD_FOUND)
+option(CZMQ_WITH_SYSTEMD "Build czmq with systemd" ${SYSTEMD_FOUND})
+IF (CZMQ_WITH_SYSTEMD AND SYSTEMD_FOUND)
     include_directories(${SYSTEMD_INCLUDE_DIRS})
     list(APPEND MORE_LIBRARIES ${SYSTEMD_LIBRARIES})
   IF (PC_SYSTEMD_FOUND)
@@ -166,13 +168,14 @@ IF (SYSTEMD_FOUND)
   ENDIF (PC_SYSTEMD_FOUND)
     add_definitions(-DHAVE_LIBSYSTEMD)
     list(APPEND OPTIONAL_LIBRARIES ${SYSTEMD_LIBRARIES})
-ENDIF (SYSTEMD_FOUND)
+ENDIF (CZMQ_WITH_SYSTEMD AND SYSTEMD_FOUND)
 
 ########################################################################
 # LZ4 dependency
 ########################################################################
 find_package(lz4)
-IF (LZ4_FOUND)
+option(CZMQ_WITH_LZ4 "Build czmq with lz4" ${LZ4_FOUND})
+IF (CZMQ_WITH_LZ4 AND LZ4_FOUND)
     include_directories(${LZ4_INCLUDE_DIRS})
     list(APPEND MORE_LIBRARIES ${LZ4_LIBRARIES})
   IF (PC_LZ4_FOUND)
@@ -183,13 +186,14 @@ IF (LZ4_FOUND)
   ENDIF (PC_LZ4_FOUND)
     add_definitions(-DHAVE_LIBLZ4)
     list(APPEND OPTIONAL_LIBRARIES ${LZ4_LIBRARIES})
-ENDIF (LZ4_FOUND)
+ENDIF (CZMQ_WITH_LZ4 AND LZ4_FOUND)
 
 ########################################################################
 # LIBCURL dependency
 ########################################################################
 find_package(libcurl)
-IF (LIBCURL_FOUND)
+option(CZMQ_WITH_LIBCURL "Build czmq with libcurl" ${LIBCURL_FOUND})
+IF (CZMQ_WITH_LIBCURL AND LIBCURL_FOUND)
     include_directories(${LIBCURL_INCLUDE_DIRS})
     list(APPEND MORE_LIBRARIES ${LIBCURL_LIBRARIES})
   IF (PC_LIBCURL_FOUND)
@@ -200,13 +204,14 @@ IF (LIBCURL_FOUND)
   ENDIF (PC_LIBCURL_FOUND)
     add_definitions(-DHAVE_LIBCURL)
     list(APPEND OPTIONAL_LIBRARIES ${LIBCURL_LIBRARIES})
-ENDIF (LIBCURL_FOUND)
+ENDIF (CZMQ_WITH_LIBCURL AND LIBCURL_FOUND)
 
 ########################################################################
 # LIBMICROHTTPD dependency
 ########################################################################
 find_package(libmicrohttpd)
-IF (LIBMICROHTTPD_FOUND)
+option(CZMQ_WITH_LIBMICROHTTPD "Build czmq with libmicrohttpd" ${LIBMICROHTTPD_FOUND})
+IF (CZMQ_WITH_LIBMICROHTTPD AND LIBMICROHTTPD_FOUND)
     include_directories(${LIBMICROHTTPD_INCLUDE_DIRS})
     list(APPEND MORE_LIBRARIES ${LIBMICROHTTPD_LIBRARIES})
   IF (PC_LIBMICROHTTPD_FOUND)
@@ -217,7 +222,7 @@ IF (LIBMICROHTTPD_FOUND)
   ENDIF (PC_LIBMICROHTTPD_FOUND)
     add_definitions(-DHAVE_LIBMICROHTTPD)
     list(APPEND OPTIONAL_LIBRARIES ${LIBMICROHTTPD_LIBRARIES})
-ENDIF (LIBMICROHTTPD_FOUND)
+ENDIF (CZMQ_WITH_LIBMICROHTTPD AND LIBMICROHTTPD_FOUND)
 
 ########################################################################
 # version

@myd7349
Copy link
Contributor Author

myd7349 commented Jun 9, 2019

Findlibzmq.cmake

diff --git a/Findlibzmq.cmake b/Findlibzmq.cmake
index b8d16d1d..24f996a3 100644
--- a/Findlibzmq.cmake
+++ b/Findlibzmq.cmake
@@ -44,9 +44,6 @@ if (MSVC)
 
     set(_zmq_version ${ZMQ_VERSION_MAJOR}_${ZMQ_VERSION_MINOR}_${ZMQ_VERSION_PATCH})
 
-    set(_zmq_debug_names)
-    set(_zmq_release_names)
-
     set(_zmq_debug_names
         "libzmq${MSVC_TOOLSET}-mt-gd-${_zmq_version}" # Debug, BUILD_SHARED
         "libzmq${MSVC_TOOLSET}-mt-sgd-${_zmq_version}" # Debug, BUILD_STATIC
@@ -61,30 +58,22 @@ if (MSVC)
         "libzmq-mt-s-${_zmq_version}" # Release|RelWithDebInfo|MinSizeRel, BUILD_STATIC
     )
 
-    find_library (ZeroMQ_LIBRARY_DEBUG
+    find_library (LIBZMQ_LIBRARY_DEBUG
         NAMES ${_zmq_debug_names}
     )
 
-    find_library (ZeroMQ_LIBRARY_RELEASE
+    find_library (LIBZMQ_LIBRARY_RELEASE
         NAMES ${_zmq_release_names}
     )
 
-    if (ZeroMQ_LIBRARY_RELEASE AND ZeroMQ_LIBRARY_DEBUG)
-        set(LIBZMQ_LIBRARIES
-            debug ${ZeroMQ_LIBRARY_DEBUG}
-            optimized ${ZeroMQ_LIBRARY_RELEASE}
-        )
-    elseif (ZeroMQ_LIBRARY_RELEASE)
-        set(LIBZMQ_LIBRARIES ${ZeroMQ_LIBRARY_RELEASE})
-    elseif (ZeroMQ_LIBRARY_DEBUG)
-        set(LIBZMQ_LIBRARIES ${ZeroMQ_LIBRARY_DEBUG})
-    endif ()
+    include(SelectLibraryConfigurations)
+    select_library_configurations(LIBZMQ)
 endif ()
 
 if (NOT LIBZMQ_LIBRARIES)
     find_library (
         LIBZMQ_LIBRARIES
-        NAMES zmq libzmq
+        NAMES libzmq zmq
         HINTS ${PC_LIBZMQ_LIBRARY_HINTS}
     )
 endif ()

Findlibcurl.cmake:

diff --git a/Findlibcurl.cmake b/Findlibcurl.cmake
index 4a00c9b7..71014303 100644
--- a/Findlibcurl.cmake
+++ b/Findlibcurl.cmake
@@ -25,7 +25,7 @@ find_path (
 
 find_library (
     LIBCURL_LIBRARIES
-    NAMES curl
+    NAMES libcurl curl
     HINTS ${PC_LIBCURL_LIBRARY_HINTS}
 )

@bluca bluca merged commit a2a817f into zeromq:master Jun 9, 2019
@myd7349 myd7349 deleted the fix-czmq-1972 branch June 9, 2019 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants