-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathnlopt-static.rb
50 lines (44 loc) · 1.33 KB
/
nlopt-static.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
class NloptStatic < Formula
desc "Free/open-source library for nonlinear optimization"
homepage "https://nlopt.readthedocs.io/"
url "https://github.com/stevengj/nlopt/archive/v2.7.1.tar.gz"
sha256 "db88232fa5cef0ff6e39943fc63ab6074208831dc0031cf1545f6ecd31ae2a1a"
license "LGPL-2.1"
head "https://github.com/stevengj/nlopt.git", branch: "master"
depends_on "cmake" => [:build, :test]
conflicts_with "nlopt", because: "nlopt-static provides dynamic and static libraries"
def install
args = *std_cmake_args + %w[
-DNLOPT_GUILE=OFF
-DNLOPT_MATLAB=OFF
-DNLOPT_OCTAVE=OFF
-DNLOPT_PYTHON=OFF
-DNLOPT_SWIG=OFF
-DNLOPT_TESTS=OFF
]
mkdir "build" do
system "cmake", *args, ".."
system "make"
system "make", "install"
end
args = *args + %w[-DBUILD_SHARED_LIBS=OFF]
mkdir "build_static" do
system "cmake", *args, ".."
system "make"
system "make", "install"
end
pkgshare.install "test/box.c"
end
test do
(testpath/"CMakeLists.txt").write <<~EOS
cmake_minimum_required(VERSION 3.0)
project(box C)
find_package(NLopt REQUIRED)
add_executable(box "#{pkgshare}/box.c")
target_link_libraries(box NLopt::nlopt)
EOS
system "cmake", "."
system "make"
assert_match "found", shell_output("./box")
end
end