Skip to content

Failed to build czmq on Windows via CMake #1972

@myd7349

Description

@myd7349

Hey, guys! I am back again.

I am trying to add czmq to vcpkg these days(microsoft/vcpkg#4979). When building czmq with CMake, I encountered several problems.

  1. CMAKE_CURRENT_SOURCE_DIR isn't in CMAKE_MODULE_PATH.

    https://github.com/zeromq/czmq/blob/master/CMakeLists.txt#L19

    so Findlibzmq.cmake, Findlibsodium.cmake, .etc. may not be called.

  2. When built as a static library, libzmq will set an additional compiler flag -DZMQ_STATIC through set_target_properties:

    https://github.com/zeromq/libzmq/blob/master/CMakeLists.txt#L1060

    so if we want to build czmq as a static library on Windows, we should define ZMQ_STATIC manually(Maybe we can define it in Findlibzmq.cmake). Otherwise, the build will fail: undefined reference in mingw when link static library. libzmq#3318

  3. Findlibzmq.cmake is not be able to find libzmq on Windows.

    libzmq dll/lib built with MSVC is named using the Boost convention(something like libzmq-mt-4_3_1.lib, libzmq-mt-4_3_1.dll). So find_library (LIBZMQ_LIBRARIES NAMES zmq HINTS ${PC_LIBZMQ_LIBRARY_HINTS}) will not work.

    Here is a patch for solving this problem: https://bitbucket.org/ignitionrobotics/ign-transport/pull-requests/19/detec-zmq-under-windows-using-a-findzmq/diff

  4. Findlibsodium.cmake will not found libsodium on Windows

    When built with MSVC, libsodium will generate a library named libsodium.dll/lib. In this case, find_library(LIBSODIUM_LIBRARY NAMES sodium) is not able to find the library. I found that find_library(LIBSODIUM_LIBRARY NAMES sodium libsodium) works.

    By the way, Findlibcurl.cmake has this problem too.

  5. Maybe we can add some options like:

    WITH_LIBSODIUM
    WITH_LIBCURL
    WITH_LZ4
    WITH_UUID
    BUILD_TESTS (For example: Create a configuration flag to disable tests. googleapis/google-cloud-cpp#1617)
    BUILD_TOOLS (zmakecret)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions