Skip to content

Commit

Permalink
[melodic] pass ROS_BUILD_SHARED_LIBS to use visibility control proper…
Browse files Browse the repository at this point in the history
…ly. (#89)

* pass ROS_BUILD_SHARED_LIBS to use visibility control properly.

* check BUILD_SHARED_LIBS value.

* address the feedback.
  • Loading branch information
seanyen authored May 28, 2020
1 parent 0beb01e commit 3ccd1f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 5 additions & 3 deletions cmake/sip_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ def get_sip_dir_flags(config):
' that PyQt5 is installed')


if len(sys.argv) != 8:
print('usage: %s build-dir sip-file output_dir include_dirs libs lib_dirs ldflags' %
if len(sys.argv) != 9:
print('usage: %s build-dir sip-file output_dir include_dirs libs lib_dirs ldflags extra_defines' %
sys.argv[0])
sys.exit(1)

# The SIP build folder, the SIP file, the output directory, the include
# directories, the libraries, the library directories and the linker
# flags.
build_dir, sip_file, output_dir, include_dirs, libs, lib_dirs, ldflags = sys.argv[1:]
build_dir, sip_file, output_dir, include_dirs, libs, lib_dirs, ldflags, extra_defines = sys.argv[1:]

# The name of the SIP build file generated by SIP and used by the build system.
build_file = 'pyqtscripting.sbf'
Expand Down Expand Up @@ -152,6 +152,8 @@ def split_paths(paths):
makefile.extra_lib_dirs.append(lib_dir)
for ldflag in ldflags.split('\\ '):
makefile.LFLAGS.append(ldflag)
for extra_define in extra_defines.split(' '):
makefile.extra_defines.append(extra_define)

# redirect location of generated library
makefile._target = '"%s"' % os.path.join(output_dir, makefile._target)
Expand Down
7 changes: 6 additions & 1 deletion cmake/sip_helper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,19 @@ function(build_sip_binding PROJECT_NAME SIP_FILE)
set(LIBRARY_DIRS ${${PROJECT_NAME}_LIBRARY_DIRS})
set(LDFLAGS_OTHER ${${PROJECT_NAME}_LDFLAGS_OTHER})

set(EXTRA_DEFINES "")
if(DEFINED BUILD_SHARED_LIBS AND BUILD_SHARED_LIBS)
set(EXTRA_DEFINES "ROS_BUILD_SHARED_LIBS")
endif()

# SIP configure doesn't handle build configuration keywords
catkin_filter_libraries_for_build_configuration(LIBRARIES ${${PROJECT_NAME}_LIBRARIES})
# SIP configure doesn't handle CMake targets
catkin_replace_imported_library_targets(LIBRARIES ${LIBRARIES})

add_custom_command(
OUTPUT ${SIP_BUILD_DIR}/Makefile
COMMAND ${PYTHON_EXECUTABLE} ${sip_SIP_CONFIGURE} ${SIP_BUILD_DIR} ${SIP_FILE} ${sip_LIBRARY_DIR} \"${INCLUDE_DIRS}\" \"${LIBRARIES}\" \"${LIBRARY_DIRS}\" \"${LDFLAGS_OTHER}\"
COMMAND ${PYTHON_EXECUTABLE} ${sip_SIP_CONFIGURE} ${SIP_BUILD_DIR} ${SIP_FILE} ${sip_LIBRARY_DIR} \"${INCLUDE_DIRS}\" \"${LIBRARIES}\" \"${LIBRARY_DIRS}\" \"${LDFLAGS_OTHER}\" \"${EXTRA_DEFINES}\"
DEPENDS ${sip_SIP_CONFIGURE} ${SIP_FILE} ${sip_DEPENDS}
WORKING_DIRECTORY ${sip_SOURCE_DIR}
COMMENT "Running SIP generator for ${PROJECT_NAME} Python bindings..."
Expand Down

0 comments on commit 3ccd1f2

Please sign in to comment.