From: Julien Schueller Date: Tue, 8 Jan 2019 09:05:39 +0000 (+0100) Subject: CMake: Fix compilation with CMake>=3.13 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=252-g8b3cb5a;p=nlopt.git CMake: Fix compilation with CMake>=3.13 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e40a8b..dba2f68 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,6 +82,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) diff --git a/src/swig/CMakeLists.txt b/src/swig/CMakeLists.txt index cae8060..26429be 100644 --- a/src/swig/CMakeLists.txt +++ b/src/swig/CMakeLists.txt @@ -41,7 +41,10 @@ if (NUMPY_FOUND AND PYTHONLIBS_FOUND) swig_link_libraries (nlopt_python ${nlopt_lib}) target_link_libraries_with_dynamic_lookup (${nlopt_python} ${PYTHON_LIBRARIES}) - set_target_properties (${nlopt_python} PROPERTIES OUTPUT_NAME _nlopt) + set_target_properties (${nlopt_python} PROPERTIES OUTPUT_NAME nlopt) + if (CMAKE_VERSION VERSION_LESS 3.13) + set_target_properties (${nlopt_python} PROPERTIES PREFIX "_") + endif () install (FILES ${CMAKE_CURRENT_BINARY_DIR}/nlopt.py DESTINATION ${INSTALL_PYTHON_DIR}) install (TARGETS ${nlopt_python} LIBRARY DESTINATION ${INSTALL_PYTHON_DIR})