mirror of
https://github.com/ceph/ceph
synced 2025-03-11 02:39:05 +00:00
cmake: pass LDSHARED env var to distutils
otherwise, the default gcc will be used, and the $CMAKE_C_COMPILER passed to the outer CMakeLists.txt won't kick in. moreover, if the building script (ceph.spec for instance) could set the $PATH, and expect that the CMakeLists.txt will use the toolchain executables in the $PATH to build Ceph, distutils will continue using the default $CC for linking the python bindings, on UNIX it will be gcc in the new shell's $PATH, because we are using `install(CODE "... execute_process( ...))` for installing the python bindings. apparently, this is not expected. because the new shell's $PATH is very likely different from the one changed by the building script. to address this, we should always specify the `$LDSHARED` env var explicitly. also, pass env vars using `ENV{}` instead of the `env` command to workaround the issue of https://cmake.org/pipermail/cmake/2015-December/062216.html, because it's not straightforward to set environment variables with spaces in the them using cmake. and because one cannot use add_custom_target() in the script mode of cmake. this leave me only limited options to fix this issue. Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
parent
e8df19197e
commit
571a786afc
@ -56,7 +56,18 @@ function(distutils_add_cython_module name src)
|
||||
endfunction(distutils_add_cython_module)
|
||||
|
||||
function(distutils_install_cython_module name)
|
||||
get_property(compiler_launcher GLOBAL PROPERTY RULE_LAUNCH_COMPILE)
|
||||
get_property(link_launcher GLOBAL PROPERTY RULE_LAUNCH_LINK)
|
||||
set(PY_CC "${compiler_launcher} ${CMAKE_C_COMPILER}")
|
||||
set(PY_LDSHARED "${link_launcher} ${CMAKE_C_COMPILER} -shared")
|
||||
install(CODE "
|
||||
set(ENV{CC} \"${PY_CC}\")
|
||||
set(ENV{LDSHARED} \"${PY_LDSHARED}\")
|
||||
set(ENV{CPPFLAGS} \"-iquote${CMAKE_SOURCE_DIR}/src/include\")
|
||||
set(ENV{LDFLAGS} \"-L${CMAKE_LIBRARY_OUTPUT_DIRECTORY}\")
|
||||
set(ENV{CYTHON_BUILD_DIR} \"${CMAKE_CURRENT_BINARY_DIR}\")
|
||||
set(ENV{CEPH_LIBDIR} \"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}\")
|
||||
|
||||
set(options --prefix=${CMAKE_INSTALL_PREFIX})
|
||||
if(DEFINED ENV{DESTDIR})
|
||||
if(EXISTS /etc/debian_version)
|
||||
@ -67,12 +78,7 @@ function(distutils_install_cython_module name)
|
||||
list(APPEND options --root=/)
|
||||
endif()
|
||||
execute_process(
|
||||
COMMAND env
|
||||
CYTHON_BUILD_DIR=${CMAKE_CURRENT_BINARY_DIR}
|
||||
CEPH_LIBDIR=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
||||
CC=${CMAKE_C_COMPILER}
|
||||
CPPFLAGS=\"-iquote${CMAKE_SOURCE_DIR}/src/include\"
|
||||
LDFLAGS=\"-L${CMAKE_LIBRARY_OUTPUT_DIRECTORY}\"
|
||||
COMMAND
|
||||
${PYTHON${PYTHON_VERSION}_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/setup.py
|
||||
build --verbose --build-base ${CYTHON_MODULE_DIR}
|
||||
--build-platlib ${CYTHON_MODULE_DIR}/lib.${PYTHON${PYTHON_VERSION}_VERSION_MAJOR}
|
||||
|
Loading…
Reference in New Issue
Block a user