Skip to content

Commit

Permalink
Merge 330ad7a into c468fc0
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Sep 27, 2019
2 parents c468fc0 + 330ad7a commit d31fe01
Showing 1 changed file with 17 additions and 40 deletions.
57 changes: 17 additions & 40 deletions cmake/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,19 @@ endmacro()
#===============================================================================

macro(strip_file PROJECT_TARGET FILENAME)
# Strip the given file of all its local symbols
# Strip the given file of all its local symbols, if we are in release mode
# Note: to strip QScintilla and Qwt when building them on Linux results in
# an error due to patchelf having been used on them. So, we use a
# wrapper that ignores errors and returns 0, so that our build doesn't
# break...

if("${PROJECT_TARGET}" STREQUAL "DIRECT")
execute_process(COMMAND ${CMAKE_SOURCE_DIR}/scripts/strip -x ${FILENAME})
else()
add_custom_command(TARGET ${PROJECT_TARGET} POST_BUILD
COMMAND ${CMAKE_SOURCE_DIR}/scripts/strip -x ${FILENAME})
if(RELEASE_MODE)
if("${PROJECT_TARGET}" STREQUAL "DIRECT")
execute_process(COMMAND ${CMAKE_SOURCE_DIR}/scripts/strip -x ${FILENAME})
else()
add_custom_command(TARGET ${PROJECT_TARGET} POST_BUILD
COMMAND ${CMAKE_SOURCE_DIR}/scripts/strip -x ${FILENAME})
endif()
endif()
endmacro()

Expand Down Expand Up @@ -316,7 +318,7 @@ macro(add_plugin PLUGIN_NAME)

# Strip the external library of all its local symbols, if possible

if(NOT WIN32 AND RELEASE_MODE)
if(NOT WIN32)
strip_file(${COPY_TARGET} ${FULL_DEST_EXTERNAL_BINARIES_DIR}/${ARG_EXTERNAL_BINARY})
endif()

Expand Down Expand Up @@ -554,7 +556,7 @@ macro(add_plugin PLUGIN_NAME)
COMMAND ${CMAKE_COMMAND} -E copy ${PLUGIN_BUILD_DIR}/${TEST_FILENAME}
${DEST_TESTS_DIR}/${TEST_FILENAME})

# Clean up our plugin's tests, if we are on macOS, our make sure
# Clean up our plugin's tests, if we are on macOS, or make sure
# that it uses RPATH rather than RUNPATH on Linux

if(APPLE)
Expand Down Expand Up @@ -711,9 +713,7 @@ macro(linux_deploy_qt_library PROJECT_TARGET DIRNAME FILENAME)

# Strip the Qt library of all its local symbols

if(RELEASE_MODE)
strip_file(${PROJECT_TARGET} ${PROJECT_BUILD_DIR}/lib/${FILENAME})
endif()
strip_file(${PROJECT_TARGET} ${PROJECT_BUILD_DIR}/lib/${FILENAME})

# Deploy the Qt library

Expand All @@ -739,9 +739,7 @@ macro(linux_deploy_qt_plugin PLUGIN_CATEGORY)

# Strip the Qt plugin of all its local symbols

if(RELEASE_MODE)
strip_file(DIRECT ${PROJECT_BUILD_DIR}/${PLUGIN_DEST_DIRNAME}/${PLUGIN_FILENAME})
endif()
strip_file(DIRECT ${PROJECT_BUILD_DIR}/${PLUGIN_DEST_DIRNAME}/${PLUGIN_FILENAME})

# Deploy the Qt plugin

Expand Down Expand Up @@ -771,45 +769,24 @@ endmacro()

#===============================================================================

macro(macos_clean_up_file PROJECT_TARGET DIRNAME FILENAME)
# Strip the file of all its local symbols

set(FULL_FILENAME ${DIRNAME}/${FILENAME})

if(RELEASE_MODE)
strip_file(${PROJECT_TARGET} ${FULL_FILENAME})
endif()

# Clean up the file's id

if("${PROJECT_TARGET}" STREQUAL "DIRECT")
execute_process(COMMAND install_name_tool -id @rpath/${FILENAME} ${FULL_FILENAME})
else()
add_custom_command(TARGET ${PROJECT_TARGET} POST_BUILD
COMMAND install_name_tool -id @rpath/${FILENAME} ${FULL_FILENAME})
endif()
endmacro()

#===============================================================================

macro(macos_clean_up_file_with_qt_dependencies PROJECT_TARGET DIRNAME FILENAME)
# Clean up the file
# Strip the file of all its local symbols

macos_clean_up_file(${PROJECT_TARGET} ${DIRNAME} ${FILENAME})
strip_file(${PROJECT_TARGET} ${DIRNAME}/${FILENAME})

# Make sure that the file refers to our embedded copy of the Qt libraries

foreach(MACOS_QT_LIBRARY ${MACOS_QT_LIBRARIES})
set(MACOS_QT_LIBRARY_FILENAME ${MACOS_QT_LIBRARY}.framework/Versions/${QT_VERSION_MAJOR}/${MACOS_QT_LIBRARY})

set(OLD_REFERENCE ${QT_LIBRARY_DIR}/${MACOS_QT_LIBRARY_FILENAME})
set(OLD_REFERENCE @rpath/${MACOS_QT_LIBRARY_FILENAME}_debug)
set(NEW_REFERENCE @rpath/${MACOS_QT_LIBRARY_FILENAME})

if("${PROJECT_TARGET}" STREQUAL "DIRECT")
execute_process(COMMAND install_name_tool -change ${OLD_REFERENCE} ${NEW_REFERENCE} ${FULL_FILENAME})
execute_process(COMMAND install_name_tool -change ${OLD_REFERENCE} ${NEW_REFERENCE} ${DIRNAME}/${FILENAME})
else()
add_custom_command(TARGET ${PROJECT_TARGET} POST_BUILD
COMMAND install_name_tool -change ${OLD_REFERENCE} ${NEW_REFERENCE} ${FULL_FILENAME})
COMMAND install_name_tool -change ${OLD_REFERENCE} ${NEW_REFERENCE} ${DIRNAME}/${FILENAME})
endif()
endforeach()
endmacro()
Expand Down

0 comments on commit d31fe01

Please sign in to comment.