diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6fdc043989986b4508b9c9f33c9f926500dc2235..051cf633241da86ec46313444b913d3cec45feac 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -928,8 +928,8 @@ if(ENABLE_SWIG)
       find_package(PythonLibs)
       include_directories(${PYTHON_INCLUDE_DIR})
       set_source_files_properties(Common/gmshpy.i PROPERTIES CPLUSPLUS ON)
-      swig_add_module(gmshpy python Common/gmshpy.i)
-      swig_link_libraries(gmshpy ${PYTHON_LIBRARIES} ${LINK_LIBRARIES} shared)
+      swig_add_module(gmshpy python Common/gmshpy.i ${GMSH_API})
+      swig_link_libraries(gmshpy ${PYTHON_LIBRARIES} shared)
     endif(SWIG_MAJOR_VERSION EQUAL 1)
   endif(SWIG_FOUND)
 endif(ENABLE_SWIG)