Skip to content

Commit

Permalink
Fix building with Visual Studio 2019
Browse files Browse the repository at this point in the history
This lets CMake use the best generator for that system, which increases the portability of the library and removing the need for workarounds in different environments
  • Loading branch information
aminya committed Apr 6, 2021
1 parent e2821f0 commit 934b677
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
1 change: 0 additions & 1 deletion binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
}],

['OS == "win"', {
'msbuild_toolset': 'v141',
'libraries': [
'<(PRODUCT_DIR)/../libzmq/lib/libzmq',
'ws2_32.lib',
Expand Down
21 changes: 5 additions & 16 deletions script/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,10 @@ if [ -n "${WINDIR}" ]; then
# Working directory is NAPI temporary build directory.
PATH_PREFIX="${PWD}/libzmq"
ARTIFACT="${PATH_PREFIX}/lib/libzmq.lib"
CMAKE_GENERATOR="Visual Studio 15 2017"
TOOLSET_VERSION="141"

# In Travis CI, Node paths are:
# - C:\ProgramData\nvs\node\<version>\x64\node.exe
# - C:\ProgramData\nvs\node\<version>\x86\node.exe
if [[ "${NODE}" != *"x86"* ]]; then
# Target Windows x64 platform.
CMAKE_GENERATOR="${CMAKE_GENERATOR} Win64"
fi
else
# Working directory is project root.
PATH_PREFIX="${PWD}/build/libzmq"
ARTIFACT="${PATH_PREFIX}/lib/libzmq.a"
CMAKE_GENERATOR="Unix Makefiles"

export MACOSX_DEPLOYMENT_TARGET=10.9
fi

Expand Down Expand Up @@ -57,7 +45,7 @@ else
echo > "${SRC_DIR}/builds/cmake/Modules/ClangFormat.cmake"
fi

cmake -G "${CMAKE_GENERATOR}" \
cmake \
"${BUILD_OPTIONS}" \
-DCMAKE_INSTALL_PREFIX="${PATH_PREFIX}" \
-DCMAKE_INSTALL_LIBDIR=lib \
Expand All @@ -73,9 +61,10 @@ else
--config Release \
--target install \
-- -verbosity:Minimal -maxcpucount
mv \
"${PATH_PREFIX}/lib/libzmq-v${TOOLSET_VERSION}-mt-s-${ZMQ_VERSION//./_}.lib" \
"${PATH_PREFIX}/lib/libzmq.lib"

BuilFile=$(find $PATH_PREFIX/lib/*.lib -type f)
mv "$BuilFile" "${PATH_PREFIX}/lib/libzmq.lib"

else
cmake \
--build .\
Expand Down

0 comments on commit 934b677

Please sign in to comment.