Skip to content

Commit e85e551

Browse files
committed
Update
1 parent c90cad7 commit e85e551

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/KNITRO.jl

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,24 @@ else
2525
""")
2626
end
2727

28+
function __init__()
29+
libiomp5 = replace(libknitro, "libknitro" => "libiomp5")
30+
if isfile(libiomp5)
31+
Libdl.dlopen(libiomp5)
32+
end
33+
return
34+
end
35+
36+
has_knitro() = endswith(libknitro, Libdl.dlext)
37+
38+
function knitro_version()
39+
length = 15
40+
release = zeros(Cchar, length)
41+
@ccall libknitro.KN_get_release(length::Cint, release::Ptr{Cchar})::Cint
42+
version_string = GC.@preserve(release, unsafe_string(pointer(release)))
43+
return VersionNumber(split(version_string, " ")[2])
44+
end
45+
2846
@static if isdefined(@__MODULE__, :libknitro)
2947
# deps.jl must define a local installation.
3048
let version = has_knitro() ? knitro_version() : v"15.0.0"
@@ -49,24 +67,6 @@ else
4967
end
5068
end
5169

52-
function __init__()
53-
libiomp5 = replace(libknitro, "libknitro" => "libiomp5")
54-
if isfile(libiomp5)
55-
Libdl.dlopen(libiomp5)
56-
end
57-
return
58-
end
59-
60-
has_knitro() = endswith(libknitro, Libdl.dlext)
61-
62-
function knitro_version()
63-
length = 15
64-
release = zeros(Cchar, length)
65-
KN_get_release(length, release)
66-
version_string = GC.@preserve(release, unsafe_string(pointer(release)))
67-
return VersionNumber(split(version_string, " ")[2])
68-
end
69-
7070
include("libknitro.jl")
7171
include("C_wrapper.jl")
7272

0 commit comments

Comments
 (0)