Skip to content

Commit

Permalink
Fix python install
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <[email protected]>
  • Loading branch information
mjcarroll committed Aug 21, 2023
1 parent 5fc5f84 commit 7aa4667
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
1 change: 1 addition & 0 deletions cmake/gz_msgs_generate.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ function(gz_msgs_generate_messages_impl)
set(${generate_messages_OUTPUT_SOURCES} ${${generate_messages_OUTPUT_SOURCES}} PARENT_SCOPE)
set(${generate_messages_OUTPUT_HEADERS} ${${generate_messages_OUTPUT_HEADERS}} PARENT_SCOPE)
set(${generate_messages_OUTPUT_DETAIL_HEADERS} ${${generate_messages_OUTPUT_DETAIL_HEADERS}} PARENT_SCOPE)
set(${generate_messages_OUTPUT_PYTHON} ${${generate_messages_OUTPUT_PYTHON}} PARENT_SCOPE)
endfunction()

##################################################
Expand Down
43 changes: 22 additions & 21 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,6 @@ gz_msgs_generate_desc_impl(
OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/gz_msgs_gen
OUTPUT_FILENAME "gz-msgs${PROJECT_VERSION_MAJOR}.gz_desc"
)
install(FILES ${PROJECT_BINARY_DIR}/gz_msgs_gen/gz-msgs${PROJECT_VERSION_MAJOR}.gz_desc
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/gz/protos/)

if (NOT GZ_PYTHON_INSTALL_PATH)
find_package(Python3 REQUIRED COMPONENTS Interpreter)
if(USE_SYSTEM_PATHS_FOR_PYTHON_INSTALLATION)
if(USE_DIST_PACKAGES_FOR_PYTHON)
string(REPLACE "site-packages" "dist-packages" GZ_PYTHON_INSTALL_PATH ${Python3_SITELIB})
else()
# Python3_SITELIB might use dist-packages in some platforms
string(REPLACE "dist-packages" "site-packages" GZ_PYTHON_INSTALL_PATH ${Python3_SITELIB})
endif()
else()
# If not a system installation, respect local paths
set(GZ_PYTHON_INSTALL_PATH ${GZ_LIB_INSTALL_DIR}/python)
endif()
endif()
install(FILES ${msgs_python} DESTINATION ${GZ_PYTHON_INSTALL_PATH}/gz/msgs${PROJECT_VERSION_MAJOR})

##################################################
# Build core library
Expand All @@ -87,7 +69,8 @@ gz_create_core_library(SOURCES
src/MessageFactory.cc
src/DynamicFactory.cc
${msgs_sources}
gz-msgs${PROJECT_VERSION_MAJOR}.gz_desc
# Add the dependency on gz_desc file
${PROJECT_BINARY_DIR}/gz_msgs_gen/gz-msgs${PROJECT_VERSION_MAJOR}.gz_desc
)

target_include_directories(${PROJECT_LIBRARY_TARGET_NAME} PUBLIC
Expand All @@ -106,9 +89,27 @@ target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME}
)
target_include_directories(${PROJECT_LIBRARY_TARGET_NAME}
SYSTEM PUBLIC $<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>)
install(FILES ${msgs_headers} DESTINATION ${GZ_INCLUDE_INSTALL_DIR_FULL}/gz/msgs)
install(FILES ${msgs_detail_headers} DESTINATION ${GZ_INCLUDE_INSTALL_DIR_FULL}/gz/msgs/details)

install(FILES ${msgs_headers} DESTINATION ${GZ_INCLUDE_INSTALL_DIR_FULL}/${proto_package_dir})
install(FILES ${msgs_detail_headers} DESTINATION ${GZ_INCLUDE_INSTALL_DIR_FULL}/${proto_package_dir}/details)
install(FILES ${PROJECT_BINARY_DIR}/gz_msgs_gen/gz-msgs${PROJECT_VERSION_MAJOR}.gz_desc
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/gz/protos/)

if (NOT GZ_PYTHON_INSTALL_PATH)
find_package(Python3 REQUIRED COMPONENTS Interpreter)
if(USE_SYSTEM_PATHS_FOR_PYTHON_INSTALLATION)
if(USE_DIST_PACKAGES_FOR_PYTHON)
string(REPLACE "site-packages" "dist-packages" GZ_PYTHON_INSTALL_PATH ${Python3_SITELIB})
else()
# Python3_SITELIB might use dist-packages in some platforms
string(REPLACE "dist-packages" "site-packages" GZ_PYTHON_INSTALL_PATH ${Python3_SITELIB})
endif()
else()
# If not a system installation, respect local paths
set(GZ_PYTHON_INSTALL_PATH ${GZ_LIB_INSTALL_DIR}/python)
endif()
endif()
install(FILES ${msgs_python} DESTINATION ${GZ_PYTHON_INSTALL_PATH}/gz/msgs${PROJECT_VERSION_MAJOR})

##################################################
# Build unit tests
Expand Down
3 changes: 3 additions & 0 deletions core/include/gz/msgs/Utility.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifndef GZ_MSGS_UTILITY_HH_
#define GZ_MSGS_UTILITY_HH_


#include <gz/msgs/convert/AxisAlignedBox.hh>
#include <gz/msgs/convert/Color.hh>
#include <gz/msgs/convert/Inertial.hh>
Expand All @@ -35,4 +36,6 @@
#include <gz/msgs/convert/PixelFormatType.hh>
#include <gz/msgs/convert/ShaderType.hh>

#include <gz/msgs/PointCloudPackedUtils.hh>

#endif // GZ_MSGS_UTILITY_HH_

0 comments on commit 7aa4667

Please sign in to comment.