LLDB finish_swig and Python module installation broken for multi-configuration generators

Starting in r372835 (Fix installing Python modules on systems using /usr/lib), the finish_swig and installation steps using multi-configuration generators (like Visual Studio or XCode) are broken.

The problem is the symlink and install steps look for liblldb and site-packages the wrong directories.

For the symlink, I get this output:

Making symlink from …\bin\liblldb.dll to i:\obj\lib\site-packages\lldb_lldb.pyd

WindowsError: [Error 2] The system cannot find the file specified: ‘…\…\…\bin\liblldb.dll’

Because the cwd is I:\obj\Lib\site-packages\lldb, not the correct I:\obj\Release\Lib\site-packages\lldb. liblldb.dll is in i:\obj\Release\bin, not i:\obj\bin. Also, the link itself should be in i:\obj\Release\lib, not i:\obj\lib.

The problem is the cmake code went from using LLVM_LIBRARY_OUTPUT_INTDIR to CMAKE_BINARY_DIR. CMAKE_BINARY_DIR is not complete for multi-configuration generators – you need to specify the configuration as well.

To fix it, in lldb/CMakeLists.txt change

if(LLDB_BUILD_FRAMEWORK)

set(lldb_python_build_path “${liblldb_build_dir}/LLDB.framework/Resources/Python/lldb”)

else()

set(lldb_python_build_path “${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb”)

endif()

to:

if(LLDB_BUILD_FRAMEWORK)

set(lldb_python_build_path “${liblldb_build_dir}/LLDB.framework/Resources/Python/lldb”)

else()

if(CMAKE_CFG_INTDIR)

use CMAKE_BUILD_TYPE here because CMAKE_CFG_INTDIR is ${Configuration}

using Visual Studio, which won’t work in cmake_install.cmake

because it is a VS variable, not a cmake variable

install(DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${LLDB_PYTHON_RELATIVE_PATH}/

DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}

COMPONENT lldb-scripts)

else()

install(DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/

DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}

COMPONENT lldb-scripts)

endif()

endif()

In the install step we have a similar failure. The install in lldb/CMakeLists.txt again uses CMAKE_BINARY_DIR. To fix it, change:

install(DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/

DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}

COMPONENT lldb-scripts)

to:

if(CMAKE_CFG_INTDIR)

install(DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/

DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}

COMPONENT lldb-scripts)

else()

install(DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/

DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}

COMPONENT lldb-scripts)

endif()

Michal, please try this and see if it still works for the issue you fixed in r372835.

Starting in r372835 (Fix installing Python modules on systems using
/usr/lib), the finish_swig and installation steps using
multi-configuration generators (like Visual Studio or XCode) are
broken.

The problem is the symlink and install steps look for liblldb and
site-packages the wrong directories.

For the symlink, I get this output:
Making symlink from ..\..\..\bin\liblldb.dll to
i:\obj\lib\site-packages\lldb\_lldb.pyd
...
WindowsError: [Error 2] The system cannot find the file specified:
'..\\..\\..\\bin\\liblldb.dll'

Because the cwd is I:\obj\Lib\site-packages\lldb, not the correct
I:\obj\Release\Lib\site-packages\lldb. liblldb.dll is in
i:\obj\Release\bin, not i:\obj\bin. Also, the link itself should be in
i:\obj\Release\lib, not i:\obj\lib.

The problem is the cmake code went from using
LLVM_LIBRARY_OUTPUT_INTDIR to CMAKE_BINARY_DIR. CMAKE_BINARY_DIR is not
complete for multi-configuration generators - you need to specify the
configuration as well.

To fix it, in lldb/CMakeLists.txt change
   if(LLDB_BUILD_FRAMEWORK)
set(lldb_python_build_path
"${liblldb_build_dir}/LLDB.framework/Resources/Python/lldb")
   else()
set(lldb_python_build_path
"${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
   endif()

to:
   if(LLDB_BUILD_FRAMEWORK)
set(lldb_python_build_path
"${liblldb_build_dir}/LLDB.framework/Resources/Python/lldb")
   else()
     if(CMAKE_CFG_INTDIR)

Hm, can't intdir be used in regular builds as well? That'd simplify things.

# use CMAKE_BUILD_TYPE here because CMAKE_CFG_INTDIR is
${Configuration}
       # using Visual Studio, which won't work in cmake_install.cmake
       # because it is a VS variable, not a cmake variable
install(DIRECTORY
${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${LLDB_PYTHON_RELATIVE_PATH}/
               DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
               COMPONENT lldb-scripts)
     else()
   install(DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/
               DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
               COMPONENT lldb-scripts)
     endif()
   endif()

In the install step we have a similar failure. The install in
lldb/CMakeLists.txt again uses CMAKE_BINARY_DIR. To fix it, change:
   install(DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/
             DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
             COMPONENT lldb-scripts)
to:
     if(CMAKE_CFG_INTDIR)
install(DIRECTORY
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/
               DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
               COMPONENT lldb-scripts)
     else()
   install(DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/
               DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
               COMPONENT lldb-scripts)
     endif()

Michal, please try this and see if it still works for the issue you
fixed in r372835.

Thanks for the report. I should be able to test it in 7-8 hours.

Starting in r372835 (Fix installing Python modules on systems using /usr/lib), the finish_swig and installation steps using multi-configuration generators (like Visual Studio or XCode) are broken.

The problem is the symlink and install steps look for liblldb and site-packages the wrong directories.

For the symlink, I get this output:
         Making symlink from ..\..\..\bin\liblldb.dll to i:\obj\lib\site-packages\lldb\_lldb.pyd
...
         WindowsError: [Error 2] The system cannot find the file specified: '..\\..\\..\\bin\\liblldb.dll'

Because the cwd is I:\obj\Lib\site-packages\lldb, not the correct I:\obj\Release\Lib\site-packages\lldb. liblldb.dll is in i:\obj\Release\bin, not i:\obj\bin. Also, the link itself should be in i:\obj\Release\lib, not i:\obj\lib.

The problem is the cmake code went from using LLVM_LIBRARY_OUTPUT_INTDIR to CMAKE_BINARY_DIR. CMAKE_BINARY_DIR is not complete for multi-configuration generators - you need to specify the configuration as well.

[...]

Michal, please try this and see if it still works for the issue you fixed in r372835.

Actually, I see that Haibo has already addressed this 2 days ago. Could
you test if his solution (r374250) works for you?

The build step works with r374250, but the install step fails. It needs CMAKE_CFG_INTDIR added to:
      install(DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/
              DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
              COMPONENT lldb-scripts)