Skip to content

Commit

Permalink
[zimpl] New port (microsoft#35053)
Browse files Browse the repository at this point in the history
* [zimpl] New port

* Fix msvc

* MSVC needs pcre2

* Fix MSVC runtime

* Fix msvc and mingw
  • Loading branch information
dg0yt authored Nov 16, 2023
1 parent b61706e commit 67e8618
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ports/zimpl/libm.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/zimpl/CMakeLists.txt b/zimpl/CMakeLists.txt
index 7cf9d85..07fa187 100644
--- a/zimpl/CMakeLists.txt
+++ b/zimpl/CMakeLists.txt
@@ -151,6 +151,8 @@ include(CheckSymbolExists)
find_library(libm m)
if(NOT libm)
set(libm "")
+else()
+ set(libm m)
endif()

set(libs ${libs} ${libm})
48 changes: 48 additions & 0 deletions ports/zimpl/msvc.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
diff --git a/zimpl/CMakeLists.txt b/zimpl/CMakeLists.txt
index 7cf9d85..85d33a7 100644
--- a/zimpl/CMakeLists.txt
+++ b/zimpl/CMakeLists.txt
@@ -4,7 +4,7 @@ project(ZIMPL
VERSION 3.5.3
LANGUAGES C)

-if(CMAKE_BUILD_TYPE STREQUAL "Debug")
+if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT WIN32)
# if changing these flags, also update GCCWARN/GXXWARN in make/make.project
set(ADD_C_FLAGS -Wall -Wextra -Wno-unknown-pragmas -Wpointer-arith -Wcast-align -Wwrite-strings -Winline -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-noreturn -Wmissing-declarations -fno-omit-frame-pointer)

@@ -112,7 +112,6 @@ if(MSVC)
)

foreach(variable ${variables})
- string(REGEX REPLACE "/M[T,D][ d]" "" ${variable} "${${variable}}")
# message("${variable} = ${${variable}}")
endforeach()
endif()
@@ -128,9 +127,11 @@ if(ZLIB_FOUND)
include_directories(${ZLIB_INCLUDE_DIRS})
else()
add_definitions(-DWITHOUT_ZLIB)
+endif()

- # look for pcre if ZLIB could not be found
- find_package(PCRE)
+if(WIN32)
+ find_package(PCRE NAMES pcre2 REQUIRED)
+ set(PCRE_LIBRARIES "$<TARGET_NAME:PCRE2::POSIX>")
if(PCRE_FOUND)
add_definitions(-DWITH_PCRE)
add_definitions(-DPCRE2_STATIC)
diff --git a/zimpl/zimpl-config.cmake.in b/zimpl/zimpl-config.cmake.in
index b653f0c..946f6f2 100644
--- a/zimpl/zimpl-config.cmake.in
+++ b/zimpl/zimpl-config.cmake.in
@@ -1,3 +1,8 @@
+if(WIN32)
+ include(CMakeFindDependencyMacro)
+ find_dependency(pcre2)
+endif()
+
if(NOT TARGET libzimpl)
include("${CMAKE_CURRENT_LIST_DIR}/zimpl-targets.cmake")
endif()
40 changes: 40 additions & 0 deletions ports/zimpl/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)

# The latest version of ZIMPL is included in the SCIP Optimization Suite.
set(scipoptsuite_version 8.0.4)
vcpkg_download_distfile(ARCHIVE
URLS "https://scipopt.org/download/release/scipoptsuite-${scipoptsuite_version}.tgz"
SHA512 46b56b3a4a5fcb4d6d53b5ffd9320bdf37fb55b9b8450a065312aa1e4f88863d3c563a495cf2622ef70a80132149c7b8f36cdb9a9e43906f4cfcafcb9dd6d606
FILENAME "scipoptsuite-${scipoptsuite_version}.tgz"
)
vcpkg_extract_source_archive(
SOURCE_PATH
ARCHIVE "${ARCHIVE}"
PATCHES
libm.diff
msvc.diff
)

vcpkg_find_acquire_program(BISON)
vcpkg_find_acquire_program(FLEX)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}/zimpl"
OPTIONS
-DBREW=false
"-DBISON_EXECUTABLE=${BISON}"
"-DFLEX_EXECUTABLE=${FLEX}"
-DCMAKE_REQUIRE_FIND_PACKAGE_ZLIB=1
MAYBE_UNUSED_VARIABLES
BREW
)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/zimpl)
vcpkg_copy_tools(TOOL_NAMES zimpl AUTO_CLEAN)

vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/zimpl/zimpl-config.cmake" "../../../include" "../../include")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/zimpl/mmlparse2.h" "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/src/zimpl/" "")

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/zimpl/LICENSE")
24 changes: 24 additions & 0 deletions ports/zimpl/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "zimpl",
"version": "3.5.3",
"description": "Zuse Institut Mathematical Programming Language",
"homepage": "http://zimpl.zib.de/",
"license": "LGPL-3.0-or-later",
"supports": "!uwp",
"dependencies": [
"gmp",
{
"name": "pcre2",
"platform": "windows"
},
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
},
"zlib"
]
}
4 changes: 4 additions & 0 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -9300,6 +9300,10 @@
"baseline": "1.0.0",
"port-version": 1
},
"zimpl": {
"baseline": "3.5.3",
"port-version": 0
},
"zint": {
"baseline": "2.12.0",
"port-version": 1
Expand Down
9 changes: 9 additions & 0 deletions versions/z-/zimpl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "6598ebbe8c537c546a9cc0d71c8fd9e0a4dd6b94",
"version": "3.5.3",
"port-version": 0
}
]
}

0 comments on commit 67e8618

Please sign in to comment.