aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/ampl-mp
diff options
context:
space:
mode:
Diffstat (limited to 'vcpkg/ports/ampl-mp')
-rw-r--r--vcpkg/ports/ampl-mp/0007-unofficial-export.cmake25
-rw-r--r--vcpkg/ports/ampl-mp/disable-matlab-mex.patch13
-rw-r--r--vcpkg/ports/ampl-mp/fix-arm-build.patch45
-rw-r--r--vcpkg/ports/ampl-mp/fix-build.patch42
-rw-r--r--vcpkg/ports/ampl-mp/fix-dependency-asl.patch28
-rw-r--r--vcpkg/ports/ampl-mp/install-targets.patch23
-rw-r--r--vcpkg/ports/ampl-mp/portfile.cmake50
-rw-r--r--vcpkg/ports/ampl-mp/vcpkg.json23
8 files changed, 249 insertions, 0 deletions
diff --git a/vcpkg/ports/ampl-mp/0007-unofficial-export.cmake b/vcpkg/ports/ampl-mp/0007-unofficial-export.cmake
new file mode 100644
index 0000000..60083a9
--- /dev/null
+++ b/vcpkg/ports/ampl-mp/0007-unofficial-export.cmake
@@ -0,0 +1,25 @@
+
+install(
+ EXPORT unofficial-mp-targets
+ NAMESPACE
+ DESTINATION share/unofficial-mp
+)
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/unofficial-mp-config.cmake.in" [[
+@PACKAGE_INIT@
+include(CMakeFindDependencyMacro)
+find_dependency(ampl-asl CONFIG)
+include("${CMAKE_CURRENT_LIST_DIR}/unofficial-mp-targets.cmake")
+]]
+)
+
+include(CMakePackageConfigHelpers)
+configure_package_config_file("${CMAKE_CURRENT_BINARY_DIR}/unofficial-mp-config.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/unofficial-mp-config.cmake"
+ INSTALL_DESTINATION "share/unofficial-mp"
+)
+
+install(FILES
+ "${CMAKE_CURRENT_BINARY_DIR}/unofficial-mp-config.cmake"
+ DESTINATION "share/unofficial-mp"
+)
diff --git a/vcpkg/ports/ampl-mp/disable-matlab-mex.patch b/vcpkg/ports/ampl-mp/disable-matlab-mex.patch
new file mode 100644
index 0000000..6cfb9cb
--- /dev/null
+++ b/vcpkg/ports/ampl-mp/disable-matlab-mex.patch
@@ -0,0 +1,13 @@
+diff --git a/src/asl/CMakeLists.txt b/src/asl/CMakeLists.txt
+index b7d7ecf..c31a032 100644
+--- a/src/asl/CMakeLists.txt
++++ b/src/asl/CMakeLists.txt
+@@ -59,7 +59,7 @@ endif ()
+
+ target_link_libraries(aslmp ${CMAKE_DL_LIBS})
+
+-find_package(MATLAB)
++set(MATLAB_FOUND)
+ if (MATLAB_FOUND AND MATLAB_BUILD)
+ set(matlab_asl asl)
+ if (MSVC)
diff --git a/vcpkg/ports/ampl-mp/fix-arm-build.patch b/vcpkg/ports/ampl-mp/fix-arm-build.patch
new file mode 100644
index 0000000..99b236c
--- /dev/null
+++ b/vcpkg/ports/ampl-mp/fix-arm-build.patch
@@ -0,0 +1,45 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 92089a3..d4c6762 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -240,4 +240,4 @@
+ set(MP_EXPR_INFO_FILE ${MP_SOURCE_DIR}/src/expr-info.cc)
+-add_executable(gen-expr-info EXCLUDE_FROM_ALL
++add_executable(gen-expr-info
+ src/gen-expr-info.cc $<TARGET_OBJECTS:format>)
+ if (MINGW)
+@@ -257,9 +257,15 @@ if (CMAKE_CROSSCOMPILING)
+ COMMAND ${CMAKE_COMMAND} -E echo
+ "warning: cannot re-generate ${MP_EXPR_INFO_FILE}")
+ else ()
++ if (ARITHCHK_EXEC)
++ add_custom_command(OUTPUT ${MP_EXPR_INFO_FILE}
++ COMMAND ${WINE} ${ARITHCHK_EXEC} ${MP_EXPR_INFO_FILE}
++ DEPENDS gen-expr-info)
++ else()
+ add_custom_command(OUTPUT ${MP_EXPR_INFO_FILE}
+ COMMAND ${WINE} $<TARGET_FILE:gen-expr-info> ${MP_EXPR_INFO_FILE}
+ DEPENDS gen-expr-info)
++ endif()
+ endif ()
+
+ add_prefix(MP_HEADERS include/mp/
+@@ -359,3 +365,4 @@ endif()
+ install(DIRECTORY include/mp DESTINATION include)
+ install(TARGETS mp DESTINATION lib RUNTIME DESTINATION bin)
+ install(FILES LICENSE.rst DESTINATION share/mp)
++install(TARGETS gen-expr-info RUNTIME DESTINATION bin)
+\ No newline at end of file
+diff --git a/src/amplsig/CMakeLists.txt b/src/amplsig/CMakeLists.txt
+index 81312e9..f44c847 100644
+--- a/src/amplsig/CMakeLists.txt
++++ b/src/amplsig/CMakeLists.txt
+@@ -14,6 +14,6 @@ find_library(WS2_32_LIBRARY Ws2_32
+ PATHS ${WIN_LIBRARY_DIR} NO_DEFAULT_PATH)
+ if (WS2_32_LIBRARY)
+ add_ampl_library(amplsig amplsig.cc)
+- message(WS2_32_LIBRARY ${WS2_32_LIBRARY})
+- target_link_libraries(amplsig mp ${WS2_32_LIBRARY})
++ message(WS2_32_LIBRARY ws2_32)
++ target_link_libraries(amplsig mp ws2_32)
+ endif ()
diff --git a/vcpkg/ports/ampl-mp/fix-build.patch b/vcpkg/ports/ampl-mp/fix-build.patch
new file mode 100644
index 0000000..ad371ff
--- /dev/null
+++ b/vcpkg/ports/ampl-mp/fix-build.patch
@@ -0,0 +1,42 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 904cfb1..13f11cb 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -61,6 +61,8 @@ set_cache(BUILD "" STRING
+ if (BUILD)
+ if (BUILD STREQUAL all)
+ set(MP_MODULES all)
++ elseif (BUILD STREQUAL no)
++ set(MP_MODULES)
+ else ()
+ string(REGEX MATCHALL "[^,]+" MP_MODULES "${BUILD}")
+ endif ()
+@@ -200,7 +202,7 @@ function (add_mp_library name)
+ add_dependencies(${name} ${add_mp_library_DEPENDS})
+ endif ()
+ # Add library linked with dynamic runtime.
+- if (MSVC)
++ if (0)
+ add_library(${name}-dynrt ${libtype} EXCLUDE_FROM_ALL
+ ${add_mp_library_UNPARSED_ARGUMENTS} ${dynrt-objects})
+ target_compile_options(${name}-dynrt PUBLIC /MD$<$<CONFIG:Debug>:d>)
+@@ -308,16 +310,17 @@ if (RT_LIBRARY)
+ target_link_libraries(mp ${RT_LIBRARY})
+ endif ()
+
++if (MP_VARIADIC_TEMPLATES)
+ # Check if variadic templates are working and not affected by GCC bug 39653:
+ # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=39653
+ check_cxx_source_compiles("
+ template <class T, class ...Types>
+ struct S { typedef typename S<Types...>::type type; };
+ int main() {}" MP_VARIADIC_TEMPLATES)
+-
+-if (MP_VARIADIC_TEMPLATES)
++ if (MP_VARIADIC_TEMPLATES)
+ add_executable(nl-example src/nl-example.cc)
+ target_link_libraries(nl-example mp)
++ endif()
+ endif ()
+
+ add_subdirectory(doc)
diff --git a/vcpkg/ports/ampl-mp/fix-dependency-asl.patch b/vcpkg/ports/ampl-mp/fix-dependency-asl.patch
new file mode 100644
index 0000000..d5900f9
--- /dev/null
+++ b/vcpkg/ports/ampl-mp/fix-dependency-asl.patch
@@ -0,0 +1,28 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 13f11cb..92089a3 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -323,9 +323,9 @@ check_cxx_source_compiles("
+ endif()
+ endif ()
+
++find_package(ampl-asl CONFIG REQUIRED)
+ add_subdirectory(doc)
+ add_subdirectory(src/amplsig)
+-add_subdirectory(src/asl)
+ add_subdirectory(src/cp)
+ add_subdirectory(solvers)
+
+diff --git a/src/cp/cp.cc b/src/cp/cp.cc
+index d4adc35..ca8f35b 100644
+--- a/src/cp/cp.cc
++++ b/src/cp/cp.cc
+@@ -24,7 +24,7 @@
+ #include <cstring>
+ #include <limits>
+ #include "mp/format.h"
+-#include "funcadd.h"
++#include <asl/funcadd.h>
+
+ namespace {
+ void error(arglist *al, const char *message) {
diff --git a/vcpkg/ports/ampl-mp/install-targets.patch b/vcpkg/ports/ampl-mp/install-targets.patch
new file mode 100644
index 0000000..c4db922
--- /dev/null
+++ b/vcpkg/ports/ampl-mp/install-targets.patch
@@ -0,0 +1,23 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index d4c6762..c7b15b6 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -197,7 +197,7 @@ function (add_mp_library name)
+ target_compile_definitions(${name}
+ PUBLIC ${add_mp_library_COMPILE_DEFINITIONS})
+ target_include_directories(${name}
+- PUBLIC ${add_mp_library_INCLUDE_DIRECTORIES})
++ PUBLIC $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/${add_mp_library_INCLUDE_DIRECTORIES}> $<INSTALL_INTERFACE:include>)
+ if (add_mp_library_DEPENDS)
+ add_dependencies(${name} ${add_mp_library_DEPENDS})
+ endif ()
+@@ -363,6 +363,7 @@ if(BUILD_TESTING)
+ endif()
+
+ install(DIRECTORY include/mp DESTINATION include)
+-install(TARGETS mp DESTINATION lib RUNTIME DESTINATION bin)
++install(TARGETS mp EXPORT unofficial-mp-targets DESTINATION lib RUNTIME DESTINATION bin)
+ install(FILES LICENSE.rst DESTINATION share/mp)
++include(0007-unofficial-export.cmake)
+ install(TARGETS gen-expr-info RUNTIME DESTINATION bin)
+\ No newline at end of file
diff --git a/vcpkg/ports/ampl-mp/portfile.cmake b/vcpkg/ports/ampl-mp/portfile.cmake
new file mode 100644
index 0000000..bf1bff5
--- /dev/null
+++ b/vcpkg/ports/ampl-mp/portfile.cmake
@@ -0,0 +1,50 @@
+vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
+
+vcpkg_from_github(
+ OUT_SOURCE_PATH SOURCE_PATH
+ REPO ampl/mp
+ REF bb7d616605dd23e4a453a834b0fc8c0a2a71b5aa
+ SHA512 558321f700a2ffe9d13f29f7c034825f5644a49c55da8490160d7ee8303484de5f9a636783387cc108bd238cdc3d2afa6b28cafecce73ee7893d792f5293712a
+ HEAD_REF master
+ PATCHES
+ disable-matlab-mex.patch
+ fix-build.patch
+ fix-dependency-asl.patch
+ fix-arm-build.patch # https://github.com/ampl/mp/issues/115
+ install-targets.patch
+)
+file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/0007-unofficial-export.cmake" DESTINATION "${SOURCE_PATH}/")
+
+if (NOT TARGET_TRIPLET STREQUAL HOST_TRIPLET)
+ set(ARITHCHK_EXEC ${CURRENT_HOST_INSTALLED_DIR}/tools/${PORT}/gen-expr-info${VCPKG_HOST_EXECUTABLE_SUFFIX})
+ if (NOT EXISTS "${ARITHCHK_EXEC}")
+ message(FATAL_ERROR "Expected ${ARITHCHK_EXEC} to exist.")
+ endif()
+endif()
+
+vcpkg_cmake_configure(
+ SOURCE_PATH "${SOURCE_PATH}"
+ OPTIONS
+ -DBUILD=no
+ -DBUILD_TESTING=OFF
+ -DMP_VARIADIC_TEMPLATES=OFF
+ -DARITHCHK_EXEC=${ARITHCHK_EXEC}
+)
+
+vcpkg_cmake_install()
+
+vcpkg_copy_pdbs()
+
+vcpkg_copy_tools(TOOL_NAMES gen-expr-info AUTO_CLEAN)
+
+vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-mp)
+
+file(REMOVE_RECURSE
+ "${CURRENT_PACKAGES_DIR}/debug/include"
+ "${CURRENT_PACKAGES_DIR}/debug/share"
+ # remove amplsig.dll and cp.dll, see https://github.com/ampl/mp/issues/130
+ "${CURRENT_PACKAGES_DIR}/debug/bin"
+ "${CURRENT_PACKAGES_DIR}/bin"
+)
+
+configure_file("${SOURCE_PATH}/LICENSE.rst" "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright" COPYONLY)
diff --git a/vcpkg/ports/ampl-mp/vcpkg.json b/vcpkg/ports/ampl-mp/vcpkg.json
new file mode 100644
index 0000000..69fcb61
--- /dev/null
+++ b/vcpkg/ports/ampl-mp/vcpkg.json
@@ -0,0 +1,23 @@
+{
+ "name": "ampl-mp",
+ "version-date": "2020-11-11",
+ "port-version": 5,
+ "description": "An open-source library for mathematical programming",
+ "homepage": "https://github.com/ampl/mp",
+ "supports": "!uwp",
+ "dependencies": [
+ "ampl-asl",
+ {
+ "name": "ampl-mp",
+ "host": true
+ },
+ {
+ "name": "vcpkg-cmake",
+ "host": true
+ },
+ {
+ "name": "vcpkg-cmake-config",
+ "host": true
+ }
+ ]
+}