Skip to content

Commit e8cae9e

Browse files
authored
Merge pull request #28198 from traversaro/add-ampl-asl
Add package for ampl-asl C library
2 parents 35af71f + fc66ab9 commit e8cae9e

File tree

5 files changed

+182
-0
lines changed

5 files changed

+182
-0
lines changed

recipes/ampl-asl/22.patch

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
From 7b26c01bbe1586afc19e123ea6d1bb1afd747069 Mon Sep 17 00:00:00 2001
2+
From: Silvio Traversaro <silvio@traversaro.it>
3+
Date: Wed, 13 Nov 2024 19:09:58 +0100
4+
Subject: [PATCH 1/2] Add BUILD_WITH_DEFAULT_MSVC_RUNTIME_LIBRARY option
5+
6+
---
7+
CMakeLists.txt | 4 +++-
8+
1 file changed, 3 insertions(+), 1 deletion(-)
9+
10+
diff --git a/CMakeLists.txt b/CMakeLists.txt
11+
index 899d057..c2db1a5 100644
12+
--- a/CMakeLists.txt
13+
+++ b/CMakeLists.txt
14+
@@ -38,6 +38,8 @@ option(BUILD_MCMODELLARGE "Build the library linked with mcmodel=large flag, use
15+
option(BUILD_LICCHECK_PRINT "Build libraries with licence check flag" OFF)
16+
option(BUILD_DYNRT_LIBS "Build the libraries linked against the dynamic runtime (windows only)" OFF)
17+
option(BUILD_MT_LIBS "Build the multithreaded library" OFF)
18+
+option(BUILD_WITH_DEFAULT_MSVC_RUNTIME_LIBRARY "If ON, do not manually set MSVC_RUNTIME_LIBRARY property" OFF)
19+
+mark_as_advanced(BUILD_WITH_DEFAULT_MSVC_RUNTIME_LIBRARY)
20+
option(BUILD_CPP "Build the cpp interface" OFF)
21+
option(BUILD_F2C "Build the f2c library" OFF)
22+
if (${CMAKE_VERSION} VERSION_LESS "3.9.0")
23+
@@ -346,7 +348,7 @@ macro(createSingleASL name sourcedir sources)
24+
if(NOT WIN32)
25+
target_link_libraries(${name} PRIVATE m)
26+
endif()
27+
- if(MSVC)
28+
+ if(MSVC AND NOT BUILD_WITH_DEFAULT_MSVC_RUNTIME_LIBRARY)
29+
if(${name} MATCHES "dynrt")
30+
set_property(TARGET ${name} PROPERTY
31+
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
32+
33+
From 3e1987ac6eb3ccb017f5ec348a9b6fcc9ccb7826 Mon Sep 17 00:00:00 2001
34+
From: Silvio Traversaro <silvio@traversaro.it>
35+
Date: Wed, 13 Nov 2024 19:32:25 +0100
36+
Subject: [PATCH 2/2] Update CMakeLists.txt
37+
38+
---
39+
CMakeLists.txt | 2 ++
40+
1 file changed, 2 insertions(+)
41+
42+
diff --git a/CMakeLists.txt b/CMakeLists.txt
43+
index c2db1a5..f7891ce 100644
44+
--- a/CMakeLists.txt
45+
+++ b/CMakeLists.txt
46+
@@ -356,6 +356,8 @@ macro(createSingleASL name sourcedir sources)
47+
set_property(TARGET ${name} PROPERTY
48+
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
49+
endif()
50+
+ endif()
51+
+ if(MSVC)
52+
target_compile_options(${name} PRIVATE
53+
/wd4013 /wd4018 /wd4101 /wd4244 /wd4273 /wd4267 /wd4996)
54+
else()

recipes/ampl-asl/bld.bat

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
mkdir build
2+
cd build
3+
4+
cmake %CMAKE_ARGS% ^
5+
-DBUILD_SHARED_LIBS:BOOL=ON ^
6+
-G "Ninja" ^
7+
-DBUILD_TESTING:BOOL=ON ^
8+
-DBUILD_F2C:BOOL=OFF ^
9+
-DBUILD_WITH_DEFAULT_MSVC_RUNTIME_LIBRARY:BOOL=ON ^
10+
-DUSE_LTO:BOOL=OFF ^
11+
%SRC_DIR%
12+
if errorlevel 1 exit 1
13+
14+
:: Build.
15+
cmake --build . --config Release
16+
if errorlevel 1 exit 1
17+
18+
:: Test
19+
ctest --output-on-failure -C Release
20+
if errorlevel 1 exit 1
21+
22+
:: Install.
23+
cmake --build . --config Release --target install
24+
if errorlevel 1 exit 1

recipes/ampl-asl/build.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
3+
rm -rf build
4+
mkdir build
5+
cd build
6+
7+
cmake ${CMAKE_ARGS} -GNinja .. \
8+
-DBUILD_SHARED_LIBS:BOOL=ON \
9+
-DBUILD_TESTING:BOOL=ON \
10+
-DBUILD_F2C:BOOL=OFF \
11+
-DUSE_LTO:BOOL=OFF \
12+
..
13+
14+
cmake --build . --config Release
15+
16+
if [[ ("${CONDA_BUILD_CROSS_COMPILATION:-}" != "1" || "${CROSSCOMPILING_EMULATOR}" != "") ]]; then
17+
ctest --output-on-failure -C Release
18+
fi
19+
20+
cmake --build . --config Release --target install
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
From 2c0d77baf0bc0232ea4d6d05e46c1432aab89b3a Mon Sep 17 00:00:00 2001
2+
From: Silvio Traversaro <silvio@traversaro.it>
3+
Date: Wed, 13 Nov 2024 19:53:48 +0100
4+
Subject: [PATCH] Install library in default location
5+
6+
---
7+
CMakeLists.txt | 2 +-
8+
1 file changed, 1 insertion(+), 1 deletion(-)
9+
10+
diff --git a/CMakeLists.txt b/CMakeLists.txt
11+
index 899d057..521e7b0 100644
12+
--- a/CMakeLists.txt
13+
+++ b/CMakeLists.txt
14+
@@ -464,7 +464,7 @@ if(NOT ASL_SKIP_INSTALL)
15+
install(FILES ${ASL2_HEADERS} ${ASL2_SOURCE_DIR}/opcode.hd ${ASL2_SOURCE_DIR}/r_opn.hd
16+
${GENERATED_INCLUDE_DIR}/stdio1.h ${GENERATED_INCLUDE_DIR}/arith.h
17+
DESTINATION include/asl2 COMPONENT asl)
18+
- install(TARGETS asl asl2 EXPORT ampl-asl-config DESTINATION lib COMPONENT asl)
19+
+ install(TARGETS asl asl2 EXPORT ampl-asl-config COMPONENT asl)
20+
if(BUILD_MT_LIBS)
21+
install(TARGETS asl-mt asl2-mt EXPORT ampl-asl-config DESTINATION lib COMPONENT asl)
22+
endif()

recipes/ampl-asl/meta.yaml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{% set name = "ampl-asl" %}
2+
{% set version = "1.0.0" %}
3+
4+
package:
5+
name: {{ name }}
6+
version: {{ version }}
7+
8+
source:
9+
url: https://github.com/ampl/asl/archive/refs/tags/v{{ version }}.tar.gz
10+
sha256: 28426e67b610874bbf8fd71fae982921aafe42310ef674c86aa6ec1181472ad0
11+
patches:
12+
# Backport https://github.com/ampl/asl/pull/22
13+
- 22.patch
14+
# Ensure that .dll gets installed in <CMAKE_INSTALL_PREFIX>/bin
15+
- install_library_in_default_location.patch
16+
17+
build:
18+
number: 0
19+
run_exports:
20+
# No ABI policy documented
21+
- {{ pin_subpackage(name, max_pin='x.x.x') }}
22+
23+
requirements:
24+
build:
25+
- {{ compiler('c') }}
26+
- {{ stdlib('c') }}
27+
- {{ compiler('cxx') }}
28+
- cmake
29+
- pkg-config
30+
- ninja
31+
run_constrained:
32+
# Earlier version of ampl-mp package vendored ampl-asl,
33+
# and so we need to prevent that they are installed together
34+
# to avoid clobbering
35+
# see https://github.com/conda-forge/ampl-mp-feedstock/issues/25
36+
- ampl-mp >=4.0.0
37+
38+
test:
39+
commands:
40+
- test -f ${PREFIX}/include/asl/asl.h # [not win]
41+
- test -f ${PREFIX}/lib/libasl${SHLIB_EXT} # [not win]
42+
- if not exist %PREFIX%\\Library\\include\\asl\\asl.h exit 1 # [win]
43+
- if not exist %PREFIX%\\Library\\lib\\asl.lib exit 1 # [win]
44+
- if not exist %PREFIX%\\Library\\bin\\asl.dll exit 1 # [win]
45+
- cmake-package-check ampl-asl
46+
requires:
47+
- cmake-package-check
48+
- {{ compiler('c') }}
49+
- {{ compiler('cxx') }}
50+
51+
about:
52+
home: https://github.com/ampl/asl
53+
license: BSD-3-Clause AND SMLNJ
54+
license_file:
55+
- LICENSE
56+
- src/f2c/Notice
57+
summary: ASL (AMPL Solver Library).
58+
59+
extra:
60+
feedstock-name: ampl-asl
61+
recipe-maintainers:
62+
- traversaro

0 commit comments

Comments
 (0)