-
Notifications
You must be signed in to change notification settings - Fork 70
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
Permit building python bindings separately from gz-math library #636
Changes from 4 commits
646de60
d2bae80
a670b65
54978b9
cb32516
63d16a8
b475bdc
06b8ab8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,19 @@ | ||
# Detect if we are doing a standalone build of the bindings, using an external gz-math | ||
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) | ||
cmake_minimum_required(VERSION 3.16) | ||
set(GZ_MATH_VER 8) | ||
project(gz-math${GZ_MATH_VER}-python VERSION ${GZ_MATH_VER}) | ||
find_package(Python3 COMPONENTS Interpreter Development REQUIRED) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice if we can move the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've moved the It's tricky to move the |
||
find_package(pybind11 REQUIRED) | ||
find_package(gz-math${PROJECT_VERSION_MAJOR} REQUIRED) | ||
set(PROJECT_LIBRARY_TARGET_NAME "gz-math${PROJECT_VERSION_MAJOR}::gz-math${PROJECT_VERSION_MAJOR}") | ||
include(GNUInstallDirs) | ||
include(CTest) | ||
if(BUILD_TESTING) | ||
scpeters marked this conversation as resolved.
Show resolved
Hide resolved
|
||
enable_testing() | ||
endif() | ||
endif() | ||
|
||
message(STATUS "Building pybind11 interfaces") | ||
set(BINDINGS_MODULE_NAME "math${PROJECT_VERSION_MAJOR}") | ||
# Split from main extension and converted to pybind11 | ||
|
@@ -81,7 +97,7 @@ if(USE_SYSTEM_PATHS_FOR_PYTHON_INSTALLATION) | |
endif() | ||
else() | ||
# If not a system installation, respect local paths | ||
set(GZ_PYTHON_INSTALL_PATH ${GZ_LIB_INSTALL_DIR}/python) | ||
set(GZ_PYTHON_INSTALL_PATH ${CMAKE_INSTALL_LIBDIR}/python) | ||
endif() | ||
|
||
set(GZ_PYTHON_INSTALL_PATH "${GZ_PYTHON_INSTALL_PATH}/gz") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid about keeping this number in sync with bumps. As a workaround we can put a comment in the main
CMakeLists.txt
pointing to here. In the mid-term, it would be nice to integrate our CMake code to grab the version/name from git directly, probably using something like https://github.com/LecrisUT/CMakeExtraUtils/blob/main/cmake/DynamicVersion.mdThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not a big fan of using git for version information as fails for tarballs. Something a bit ugly but effective could be to grep the major version from the parent folder CMakeLists.txt .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or we could extract the version numbers from package.xml, since we also have a workflow to keep those versions in sync
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prototype for extracting version numbers from package.xml: #639
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've also opened gazebosim/gz-cmake#456 adding the python script from #639 and a cmake helper function. If you don't mind approving this PR for now so we can start to fix CI, I will follow-up by using the gz-cmake helper once it has been merged and released