@@ -19,7 +19,8 @@ function main() {
1919 const src_dir = `zeromq-${ zmq_version } `
2020 const tarball = `zeromq-${ zmq_version } .tar.gz`
2121
22- const CMAKE_BUILD_TYPE = process . env . CMAKE_BUILD_TYPE ?? "Release"
22+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing, @typescript-eslint/strict-boolean-expressions
23+ const CMAKE_BUILD_TYPE = process . env . CMAKE_BUILD_TYPE || "Release"
2324
2425 let build_options : string = ""
2526
@@ -32,10 +33,12 @@ function main() {
3233 }
3334 }
3435
35- build_options += handleArch ( )
36+ build_options += archCMakeOptions ( )
3637
3738 if ( process . platform === "darwin" ) {
38- process . env . MACOSX_DEPLOYMENT_TARGET = "10.15"
39+ const MACOSX_DEPLOYMENT_TARGET = "10.15"
40+ process . env . MACOSX_DEPLOYMENT_TARGET = MACOSX_DEPLOYMENT_TARGET
41+ build_options += ` -DCMAKE_OSX_DEPLOYMENT_TARGET=${ MACOSX_DEPLOYMENT_TARGET } `
3942 }
4043
4144 mkdir ( "-p" , libzmq_build_prefix )
@@ -86,27 +89,40 @@ function main() {
8689
8790main ( )
8891
89- function handleArch ( ) {
90- if ( process . platform !== "win32" ) {
91- // https://cmake.org/cmake/help/latest/variable/CMAKE_GENERATOR_PLATFORM.html
92- // CMAKE_GENERATOR_PLATFORM only supported on Windows
93- return ""
94- }
95-
92+ function archCMakeOptions ( ) {
9693 // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing, @typescript-eslint/strict-boolean-expressions
9794 const arch = ( process . env . ARCH || process . arch ) . toLowerCase ( )
98- let CMAKE_GENERATOR_PLATFORM : string
99- switch ( arch ) {
100- case "x86" :
101- case "ia32" : {
102- CMAKE_GENERATOR_PLATFORM = "win32"
103- break
95+
96+ if ( process . platform === "win32" ) {
97+ // CMAKE_GENERATOR_PLATFORM only supported on Windows
98+ // https://cmake.org/cmake/help/latest/variable/CMAKE_GENERATOR_PLATFORM.html
99+
100+ switch ( arch ) {
101+ case "x86" :
102+ case "ia32" : {
103+ return " -DCMAKE_GENERATOR_PLATFORM=win32"
104+ }
105+ default : {
106+ return ` -DCMAKE_GENERATOR_PLATFORM=${ arch . toUpperCase ( ) } `
107+ }
104108 }
105- default : {
106- CMAKE_GENERATOR_PLATFORM = arch . toUpperCase ( )
107- break
109+ }
110+
111+ if ( process . platform === "darwin" ) {
112+ // handle MacOS Arm
113+ switch ( arch ) {
114+ case "x64" :
115+ case "x86_64" : {
116+ return ""
117+ }
118+ case "arm64" : {
119+ return ` -DCMAKE_OSX_ARCHITECTURES=${ arch } `
120+ }
121+ default : {
122+ return ""
123+ }
108124 }
109125 }
110126
111- return ` -DCMAKE_GENERATOR_PLATFORM= ${ CMAKE_GENERATOR_PLATFORM } `
127+ return ""
112128}
0 commit comments