@@ -4,6 +4,39 @@ set -eo pipefail
44setReplaceRoot=$( dirname " $( cd " $( dirname " $0 " ) " && pwd) " )
55cd " $setReplaceRoot "
66
7+ # Obtain requested architectures
8+
9+ if [[ -n " $1 " ]]; then
10+ arch=" $1 "
11+ else
12+ arch=" $( uname -m) "
13+ fi
14+
15+ # Set the platform-specific names
16+
17+ if [[ " $( uname -s) " == " Darwin" && " $arch " == " arm64" ]]; then
18+ cmakeArchitectureArg=" -DCMAKE_OSX_ARCHITECTURES=arm64"
19+ libraryResourcesDirName=MacOSX-ARM64
20+ libraryExtension=dylib
21+ elif [[ " $( uname -s) " == " Darwin" && " $arch " == " x86_64" ]]; then
22+ cmakeArchitectureArg=" -DCMAKE_OSX_ARCHITECTURES=x86_64"
23+ libraryResourcesDirName=MacOSX-x86-64
24+ libraryExtension=dylib
25+ elif [[ " $( uname -s) " == " Linux" && " $arch " == " x86_64" ]]; then
26+ libraryResourcesDirName=Linux-x86-64
27+ libraryExtension=so
28+ elif [[ " $OSTYPE " == " msys" && " $( uname -m) " == " x86_64" ]]; then # Windows
29+ libraryResourcesDirName=Windows-x86-64
30+ libraryExtension=dll
31+ else
32+ echo " Operating system unsupported"
33+ exit 1
34+ fi
35+
36+ libraryDir=LibraryResources/$libraryResourcesDirName
37+ echo " LibraryResources directory: $setReplaceRoot /$libraryDir "
38+ echo " Library extension: $libraryExtension "
39+
740# Compute the source hash
841
942sourceFiles=" $( ls libSetReplace/* pp CMakeLists.txt cmake/* scripts/buildLibraryResources.sh) "
@@ -15,7 +48,8 @@ if command -v shasum &>/dev/null; then
1548 for fileToHash in $sourceFiles ; do
1649 shasum -a 256 " $fileToHash "
1750 done
18- uname -sm
51+ uname -s
52+ echo " $arch "
1953 ) " | shasum -a 256 | cut -d\ -f1
2054 ) "
2155elif [[ " $OSTYPE " == " msys" && $( command -v certutil) ]]; then # there is another certutil in macOS
@@ -24,7 +58,8 @@ elif [[ "$OSTYPE" == "msys" && $(command -v certutil) ]]; then # there is anothe
2458 for fileToHash in $sourceFiles ; do
2559 echo " $( certutil -hashfile " $fileToHash " SHA256 | findstr -v " hash" ) " " $fileToHash "
2660 done
27- uname -sm
61+ uname -s
62+ echo " $arch "
2863 ) " > " $TEMP " /libSetReplaceFilesToHash
2964 sha=$( certutil -hashfile " $TEMP " /libSetReplaceFilesToHash SHA256 | findstr -v " hash" )
3065else
@@ -39,30 +74,11 @@ echo "libSetReplace sources hash: $shortSHA"
3974
4075mkdir -p build
4176cd build
42- cmake .. -DSET_REPLACE_ENABLE_ALLWARNINGS=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release
77+ cmake .. -DSET_REPLACE_ENABLE_ALLWARNINGS=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release \
78+ ${cmakeArchitectureArg: +" $cmakeArchitectureArg " }
4379cmake --build . --config Release # Needed for multi-config generators
4480cd ..
4581
46- # Set the platform-specific names
47-
48- if [ " $( uname -sm) " = " Darwin x86_64" ]; then
49- libraryResourcesDirName=MacOSX-x86-64
50- libraryExtension=dylib
51- elif [ " $( uname -sm) " = " Linux x86_64" ]; then
52- libraryResourcesDirName=Linux-x86-64
53- libraryExtension=so
54- elif [[ " $OSTYPE " == " msys" && " $( uname -m) " == " x86_64" ]]; then # Windows
55- libraryResourcesDirName=Windows-x86-64
56- libraryExtension=dll
57- else
58- echo " Operating system unsupported"
59- exit 1
60- fi
61-
62- libraryDir=LibraryResources/$libraryResourcesDirName
63- echo " LibraryResources directory: $setReplaceRoot /$libraryDir "
64- echo " Library extension: $libraryExtension "
65-
6682# Find the compiled library
6783
6884compiledLibrary=build/libSetReplace.$libraryExtension
0 commit comments