Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CMake][Exp PyROOT] Build libcppyy and libROOTPythonizations with und… #5643

Merged
merged 2 commits into from
Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions bindings/pyroot/cppyy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
# For the licensing terms see $ROOTSYS/LICENSE.
# For the list of contributors see $ROOTSYS/README/CREDITS.

set(CMAKE_SHARED_LIBRARY_SUFFIX ".so")

add_subdirectory(cppyy-backend)
add_subdirectory(CPyCppyy)
add_subdirectory(cppyy)
10 changes: 7 additions & 3 deletions bindings/pyroot/cppyy/CPyCppyy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,17 @@ foreach(val RANGE ${how_many_pythons})
list(GET python_include_dirs ${val} python_include_dir)
list(GET python_under_version_strings ${val} python_under_version_string)
list(GET python_version_strings ${val} python_version_string)
list(GET python_libraries ${val} python_library)

set(libname cppyy${python_under_version_string})

add_library(${libname} SHARED ${headers} ${sources})
# Set the suffix to '.so' and the prefix to 'lib'
set_target_properties(${libname} PROPERTIES ${ROOT_LIBRARY_PROPERTIES})
if(APPLE)
target_link_libraries(${libname} PUBLIC -Wl,-bind_at_load -Wl,-undefined -Wl,dynamic_lookup cppyy_backend${python_under_version_string})
elseif(NOT MSVC)
target_link_libraries(${libname} PUBLIC -Wl,--unresolved-symbols=ignore-all cppyy_backend${python_under_version_string})
endif()

if(NOT MSVC)
target_compile_options(${libname} PRIVATE
Expand Down Expand Up @@ -93,8 +99,6 @@ foreach(val RANGE ${how_many_pythons})
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
)

target_link_libraries(${libname} cppyy_backend${python_under_version_string} ${python_library})

set_property(GLOBAL APPEND PROPERTY ROOT_EXPORTED_TARGETS ${libname})

# Install library
Expand Down
3 changes: 2 additions & 1 deletion bindings/pyroot/cppyy/cppyy-backend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ foreach(val RANGE ${how_many_pythons})
set(libname cppyy_backend${python_under_version_string})

add_library(${libname} SHARED clingwrapper/src/clingwrapper.cxx)

# Set the suffix to '.so' and the prefix to 'lib'
set_target_properties(${libname} PROPERTIES ${ROOT_LIBRARY_PROPERTIES})
target_link_libraries(${libname} Core ${CMAKE_DL_LIBS})

# cppyy uses ROOT headers from binary directory
Expand Down
14 changes: 13 additions & 1 deletion bindings/pyroot/pythonizations/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,14 @@ foreach(val RANGE ${how_many_pythons})

set(libname ROOTPythonizations${python_under_version_string})

ROOT_LINKER_LIBRARY(${libname} ${cpp_sources} DEPENDENCIES Core Tree cppyy${python_under_version_string} CMAKENOEXPORT)
add_library(${libname} SHARED ${cpp_sources})
# Set the suffix to '.so' and the prefix to 'lib'
set_target_properties(${libname} PROPERTIES ${ROOT_LIBRARY_PROPERTIES})
if(APPLE)
target_link_libraries(${libname} PUBLIC -Wl,-bind_at_load -Wl,-undefined -Wl,dynamic_lookup Core Tree cppyy${python_under_version_string})
elseif(NOT MSVC)
target_link_libraries(${libname} PUBLIC -Wl,--unresolved-symbols=ignore-all Core Tree cppyy${python_under_version_string})
endif()

target_include_directories(${libname} PRIVATE ${python_include_dir})

Expand All @@ -116,6 +123,11 @@ foreach(val RANGE ${how_many_pythons})
install(CODE "execute_process(COMMAND ${python_executable} -O -m py_compile ${localruntimedir}/${py_source})")
endforeach()

# Install library
install(TARGETS ${libname} EXPORT ${CMAKE_PROJECT_NAME}Exports
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
endforeach()

# Install Python sources and bytecode
Expand Down
6 changes: 5 additions & 1 deletion bindings/tpython/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ ROOT_STANDARD_LIBRARY_PACKAGE(ROOTTPython
DEPENDENCIES
Core
LIBRARIES
cppyy${PYTHON_UNDER_VERSION_STRING_Development_Main}
cppyy${PYTHON_UNDER_VERSION_STRING_Development_Main}
# We link libTPython against Python libraries to compensate for the fact that libcppyy
# is built with unresolved symbols. If we didn't do this, invoking TPython from C++
# would not work.
${PYTHON_LIBRARIES_Development_Main}
maxgalli marked this conversation as resolved.
Show resolved Hide resolved
)

# Disables warnings originating from deprecated register keyword in Python
Expand Down