File nlopt-cmake-3.13.patch of Package nlopt
From 8b3cb5a3c2d76f7f0d6447616ed4df1c9f7cd061 Mon Sep 17 00:00:00 2001
From: Julien Schueller <schueller@phimeca.com>
Date: Tue, 8 Jan 2019 10:05:39 +0100
Subject: [PATCH] CMake: Fix compilation with CMake>=3.13
---
CMakeLists.txt | 4 ++++
src/swig/CMakeLists.txt | 5 ++++-
2 files changed, 8 insertions(+), 1 deletion(-)
Index: nlopt-2.5.0/CMakeLists.txt
===================================================================
--- nlopt-2.5.0.orig/CMakeLists.txt
+++ nlopt-2.5.0/CMakeLists.txt
@@ -77,6 +77,10 @@ if(POLICY CMP0042)
# Set MACOSX_RPATH to ON
cmake_policy(SET CMP0042 NEW)
endif()
+if (POLICY CMP0086)
+ # UseSWIG honors SWIG_MODULE_NAME via -module flag
+ cmake_policy(SET CMP0086 NEW)
+endif ()
include (CheckIncludeFiles)
include (CheckFunctionExists)
Index: nlopt-2.5.0/src/swig/CMakeLists.txt
===================================================================
--- nlopt-2.5.0.orig/src/swig/CMakeLists.txt
+++ nlopt-2.5.0/src/swig/CMakeLists.txt
@@ -31,7 +31,10 @@ if (NUMPY_FOUND AND PYTHONLIBS_FOUND)
swig_link_libraries (nlopt ${PYTHON_LIBRARIES})
endif ()
- set_target_properties (${SWIG_MODULE_nlopt_REAL_NAME} PROPERTIES OUTPUT_NAME _nlopt)
+ set_target_properties (${SWIG_MODULE_nlopt_REAL_NAME} PROPERTIES OUTPUT_NAME nlopt)
+ if (CMAKE_VERSION VERSION_LESS 3.13)
+ set_target_properties (${SWIG_MODULE_nlopt_REAL_NAME} PROPERTIES PREFIX "_")
+ endif ()
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/nlopt.py DESTINATION ${INSTALL_PYTHON_DIR})
install (TARGETS ${SWIG_MODULE_nlopt_REAL_NAME} LIBRARY DESTINATION ${INSTALL_PYTHON_DIR})