chiark / gitweb /
CMake: Fix compilation with CMake>=3.13
authorJulien Schueller <schueller@phimeca.com>
Tue, 8 Jan 2019 09:05:39 +0000 (10:05 +0100)
committerJulien Schueller <schueller@phimeca.com>
Tue, 8 Jan 2019 09:05:39 +0000 (10:05 +0100)
CMakeLists.txt
src/swig/CMakeLists.txt

index 0e40a8b1e244656172bbaeb9d969cfe28ee5fc1c..dba2f688c436b427f3695a7ed457f31194d62840 100644 (file)
@@ -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)
index cae8060722cc312c4111ead6a88b772d54ac88bc..26429be7e2401cdfe3dff92a80c01e816912698d 100644 (file)
@@ -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})