mirror of
https://github.com/logos-storage/nim-leopard.git
synced 2026-01-04 22:53:07 +00:00
Adds nimleopard_portable_build nimflag to disable native arch in cmake build
This commit is contained in:
parent
dbf40c1897
commit
35c5a33b4f
@ -100,7 +100,33 @@ const
|
||||
|
||||
LeopardExtraLinkerFlags {.strdefine.} = ""
|
||||
|
||||
proc overrideCMakeMarch() =
|
||||
# vendor/leopard/CMakeLists.txt defined "-march=native" explicitly
|
||||
# it provides no means to override this.
|
||||
# Because of this, when we build binaries intended to be delivered
|
||||
# they may contain instructions available on the build system that are
|
||||
# not necessarily available on the user system.
|
||||
# To be able to build portable binaries, we have no choice but
|
||||
# to modify the CMakeLists.txt
|
||||
when defined(nimleopard_portable_build):
|
||||
if defined(windows) or defined(unix):
|
||||
let
|
||||
cmakeFile = joinPath(LeopardDir, "CMakeLists.txt")
|
||||
searchTarget = " -march=native"
|
||||
replaceTarget = " -march=x86-64-v3"
|
||||
|
||||
echo "Applying portable-build override on CMakeLists.txt..."
|
||||
|
||||
try:
|
||||
let replaced = readFile(cmakeFile).replace(searchTarget, replaceTarget)
|
||||
|
||||
writeFile(cmakeFile, replaced)
|
||||
except IOError as err:
|
||||
raiseAssert("Failed to modify CMakeLists.txt for portable build: " & err.msg)
|
||||
|
||||
|
||||
static:
|
||||
overrideCMakeMarch()
|
||||
if defined(windows):
|
||||
func pathUnix2Win(path: string): string =
|
||||
gorge("cygpath -w " & path.strip).strip
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user