我们可以将 EXECUTABLE_OUTPUT_PATH 用于 $ {PROJECT_BINARY_DIR} / bin。如何通过SWIG设置生成的python模块的输出路径。
ex,得到以下CMakeLists.txt
FIND_PACKAGE(SWIG)
IF(SWIG_FOUND)
FIND_PACKAGE(PythonLibs)
IF(PYTHONLIBS_FOUND)
INCLUDE(${SWIG_USE_FILE})
EXECUTE_PROCESS( COMMAND python -c "import sys;print"%s.%s"%sys.version_info[0:2]" OUTPUT_VARIABLE PYTHON_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
SET(CMAKE_SWIG_FLAGS "")
SET_SOURCE_FILES_PROPERTIES(partio.i PROPERTIES CPLUSPLUS ON)
SET_SOURCE_FILES_PROPERTIES(partio.i PROPERTIES SWIG_FLAGS "-includeall")
SWIG_ADD_MODULE(partio python partio.i)
SWIG_LINK_LIBRARIES(partio ${PYTHON_LIBRARIES} ${ZLIB_LIBRARY} partio)
SET(PYTHON_DEST "lib64/python${PYTHON_VERSION}/site-packages" )
INSTALL(TARGETS _partio DESTINATION ${PYTHON_DEST})
INSTALL(FILES ${CMAKE_BINARY_DIR}/${outdir}/src/py/partio.py DESTINATION ${PYTHON_DEST})
ENDIF(PYTHONLIBS_FOUND)
ENDIF(SWIG_FOUND)
答案 0 :(得分:4)
另一个特殊变量是 CMAKE_SWIG_OUTDIR,它允许一个 指定写入所有swig的位置 生成的模块(swig -outdir选项)
所以,例如:
set(CMAKE_SWIG_OUTDIR ${CMAKE_CURRENT_BINARY_DIR}/bin)
答案 1 :(得分:1)
我不熟悉CMAKE,但我知道您可以使用SWIG可执行文件的命令行选项设置SWIG的输出路径:
swig.exe -outdir /path/I/want
上面的行可能是 SET(CMAKE_SWIG_FLAGS“”)
您可以在括号中输入所需的命令行选项吗?