diff --git a/.github/workflows/ci-cpp-build-windows.yaml b/.github/workflows/ci-cpp-build-windows.yaml index a0449491e471e..6384968741d6d 100644 --- a/.github/workflows/ci-cpp-build-windows.yaml +++ b/.github/workflows/ci-cpp-build-windows.yaml @@ -73,7 +73,7 @@ jobs: run: | cd pulsar-client-cpp && vcpkg install --triplet ${{ matrix.triplet }} - - name: Configure + - name: Configure (default) if: ${{ steps.check_changes.outputs.docs_only != 'true' }} shell: bash run: | @@ -95,4 +95,29 @@ jobs: if [ "$RUNNER_OS" == "Windows" ]; then cd pulsar-client-cpp && \ cmake --build ./build - fi \ No newline at end of file + fi + + - name: Configure (dynamic library only) + if: ${{ steps.check_changes.outputs.docs_only != 'true' }} + shell: bash + run: | + if [ "$RUNNER_OS" == "Windows" ]; then + cd pulsar-client-cpp && \ + cmake \ + -B ./build-1 \ + -G "${{ matrix.generator }}" ${{ matrix.arch }} \ + -DBUILD_PYTHON_WRAPPER=OFF -DBUILD_TESTS=OFF \ + -DVCPKG_TRIPLET=${{ matrix.triplet }} \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_STATIC_LIB=OFF \ + -S . + fi + + - name: Compile + if: ${{ steps.check_changes.outputs.docs_only != 'true' }} + shell: bash + run: | + if [ "$RUNNER_OS" == "Windows" ]; then + cd pulsar-client-cpp && \ + cmake --build ./build-1 + fi diff --git a/pulsar-client-cpp/lib/CMakeLists.txt b/pulsar-client-cpp/lib/CMakeLists.txt index a96e842a65fcc..2e540b2dfd554 100644 --- a/pulsar-client-cpp/lib/CMakeLists.txt +++ b/pulsar-client-cpp/lib/CMakeLists.txt @@ -63,6 +63,10 @@ if (BUILD_DYNAMIC_LIB) set_property(TARGET pulsarShared PROPERTY OUTPUT_NAME ${LIB_NAME_SHARED}) set_property(TARGET pulsarShared PROPERTY VERSION ${LIBRARY_VERSION}) target_link_libraries(pulsarShared ${COMMON_LIBS} ${CMAKE_DL_LIBS}) + if (MSVC) + target_include_directories(pulsarShared PRIVATE ${dlfcn-win32_INCLUDE_DIRS}) + target_link_options(pulsarShared PRIVATE $<$:/NODEFAULTLIB:MSVCRT>) + endif() endif() @@ -87,17 +91,16 @@ endif() if (BUILD_STATIC_LIB) add_library(pulsarStatic STATIC $) - set_property(TARGET pulsarStatic PROPERTY OUTPUT_NAME ${LIB_NAME}) + if (MSVC) + set_property(TARGET pulsarStatic PROPERTY OUTPUT_NAME "${LIB_NAME}-static") + target_include_directories(pulsarStatic PRIVATE ${dlfcn-win32_INCLUDE_DIRS}) + else () + set_property(TARGET pulsarStatic PROPERTY OUTPUT_NAME ${LIB_NAME}) + endif() set_property(TARGET pulsarStatic PROPERTY VERSION ${LIBRARY_VERSION}) target_compile_definitions(pulsarStatic PRIVATE PULSAR_STATIC) endif() -if (MSVC) - target_include_directories(pulsarStatic PRIVATE ${dlfcn-win32_INCLUDE_DIRS}) - target_include_directories(pulsarShared PRIVATE ${dlfcn-win32_INCLUDE_DIRS}) - target_link_options(pulsarShared PRIVATE $<$:/NODEFAULTLIB:MSVCRT>) -endif() - # When linking statically, install a libpulsar.a that contains all the # required dependencies except ssl if (LINK_STATIC AND BUILD_STATIC_LIB)