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

Included FindZeroMQ.cmake only works if ZeroMQ built with Visual Studio IDE #198

Open
rhvonlehe opened this issue Sep 4, 2022 · 1 comment

Comments

@rhvonlehe
Copy link

rhvonlehe commented Sep 4, 2022

In FindZeroMQ.cmake, the below section assumes there will be a variable ${CMAKE_VS_PLATFORM_TOOLSET} defined. If not, the find_library calls fail. I built ZeroMQ with a Visual Studio compiler, but not with the IDE. This leaves ${CMAKE_VS_PLATFORM_TOOLSET} empty. My ZeroMQ library is installed with the filename: libzmq-mt-gd-4_3_5.lib. The finder can't identify this.

My non-azmq project is able to find ZeroMQ just fine, however, by relying on the ZeroMQConfig.cmake that is provided by ZeroMQ and installed alongside the library artifacts.

All it would take to fix this is to add a 3rd line in each of the NAMES section for Windows without the ${CMAKE_VS_PLATFORM_TOOLSET}- to the FindZeroMQ.cmake provided in azmq.

    if (NOT ${CMAKE_CXX_PLATFORM_ID} STREQUAL "Windows")
        find_library(ZeroMQ_LIBRARIES NAMES zmq HINTS ${_ZeroMQ_ROOT}/lib)
    else()
        message("CMAKE_VS_PLATFORM_TOOLSET: ${CMAKE_VS_PLATFORM_TOOLSET}")
        find_library(
            ZeroMQ_LIBRARY_RELEASE
            NAMES
                libzmq
                "libzmq-${CMAKE_VS_PLATFORM_TOOLSET}-mt-${ZeroMQ_VERSION_MAJOR}_${ZeroMQ_VERSION_MINOR}_${ZeroMQ_VERSION_PATCH}"
            HINTS
                ${_ZeroMQ_ROOT}/lib
            )

        find_library(
            ZeroMQ_LIBRARY_DEBUG
            NAMES
                libzmq_d
                "libzmq-${CMAKE_VS_PLATFORM_TOOLSET}-mt-gd-${ZeroMQ_VERSION_MAJOR}_${ZeroMQ_VERSION_MINOR}_${ZeroMQ_VERSION_PATCH}"
            HINTS
                ${_ZeroMQ_ROOT}/lib)

        # On Windows we have to use corresponding version (i.e. Release or Debug) of ZeroMQ because of `errno` CRT global variable
        # See more at http://www.drdobbs.com/avoiding-the-visual-c-runtime-library/184416623
        set(ZeroMQ_LIBRARIES optimized "${ZeroMQ_LIBRARY_RELEASE}" debug "${ZeroMQ_LIBRARY_DEBUG}")
    endif()
@aboseley
Copy link

aboseley commented Dec 1, 2022

@rhvonlehe , please let us know if the updated cmake changes now work better for you

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

No branches or pull requests

2 participants