From c1407cdca98bb19a12bc36b43b51e0a68f07300d Mon Sep 17 00:00:00 2001 From: Leland Lucius Date: Sun, 5 Jul 2020 13:39:57 -0500 Subject: [PATCH] Force use of our wxWidgets and fix RPATH handling --- CMakeLists.txt | 121 +++++++++------------ cmake-proxies/cmake-modules/CopyLibs.cmake | 110 +++++++++++++++++++ cmake-proxies/lv2/CMakeLists.txt | 2 +- cmake-proxies/wxWidgets/CMakeLists.txt | 30 +++++ help/CMakeLists.txt | 16 +-- images/CMakeLists.txt | 18 +-- locale/CMakeLists.txt | 8 +- modules/CMakeLists.txt | 16 ++- modules/mod-null/CMakeLists.txt | 4 +- modules/mod-nyq-bench/CMakeLists.txt | 4 +- modules/mod-script-pipe/CMakeLists.txt | 4 +- nyquist/CMakeLists.txt | 8 +- plug-ins/CMakeLists.txt | 8 +- src/CMakeLists.txt | 102 ++++++----------- 14 files changed, 278 insertions(+), 173 deletions(-) create mode 100644 cmake-proxies/cmake-modules/CopyLibs.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ff543049..0de53668b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,11 @@ endif() set( topdir "${CMAKE_SOURCE_DIR}" ) set( libsrc "${topdir}/lib-src" ) +# Default build type is Debug +if( NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES ) + set( CMAKE_BUILD_TYPE "Debug" ) +endif() + # Ignore COMPILE_DEFINITIONS_ properties cmake_policy( SET CMP0043 NEW ) @@ -96,11 +101,25 @@ include( CMakePushCheckState ) include( GNUInstallDirs ) include( TestBigEndian ) +# Determine 32-bit or 64-bit target +if( CMAKE_C_COMPILER_ID MATCHES "MSVC" AND CMAKE_VS_PLATFORM_NAME MATCHES "Win64|x64" ) + set( IS_64BIT ON ) +elseif( NOT CMAKE_SIZEOF_VOID_P STREQUAL "4" ) + set( IS_64BIT ON ) +endif() + message( STATUS "Build Info:" ) message( STATUS " Host System: ${CMAKE_HOST_SYSTEM}" ) message( STATUS " Host System Name: ${CMAKE_HOST_SYSTEM_NAME}" ) message( STATUS " Host System Processor: ${CMAKE_HOST_SYSTEM_PROCESSOR}" ) message( STATUS " Host System Version: ${CMAKE_HOST_SYSTEM_VERSION}" ) + +if( IS_64BIT ) + message( STATUS " Host System Architecture: 64-bit" ) +else() + message( STATUS " Host System Architecture: 32-bit" ) +endif() + message( STATUS ) message( STATUS " Compiler: ${CMAKE_CXX_COMPILER}" ) message( STATUS " Compiler Version: ${CMAKE_CXX_COMPILER_VERSION}" ) @@ -176,22 +195,41 @@ if( CMAKE_GENERATOR MATCHES "Visual Studio" ) endif() # Where the final product is stored -set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/audacity ) -set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/audacity ) set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) -# Set up RPATH handling -set( CMAKE_SKIP_BUILD_RPATH FALSE ) -set( CMAKE_BUILD_WITH_INSTALL_RPATH FALSE ) -set( CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}/audacity" ) -set( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE ) -set( CMAKE_MACOSX_RPATH FALSE ) +# Define the non-install and executable paths +if( CMAKE_CONFIGURATION_TYPES ) + set( _DESTDIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}" ) +else() + set( _DESTDIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}" ) +endif() -# the RPATH to be used when installing, but only if it's not a system directory -#list( FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_FULL_LIBDIR}" isSysDir ) -#if( "${isSysDir}" STREQUAL "-1" ) -# set( CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" ) -#endif() +set( _DEST "${_DESTDIR}" ) +set( _PREFIX "${CMAKE_INSTALL_PREFIX}" ) +set( _LIBDIR "${CMAKE_INSTALL_LIBDIR}" ) +set( _DATADIR "${CMAKE_INSTALL_DATADIR}" ) +set( _PKGLIB "${_LIBDIR}/audacity" ) +set( _PKGDATA "${_DATADIR}/audacity/" ) +set( _MANDIR "${CMAKE_INSTALL_MANDIR}" ) +set( _MODDIR "${_DEST}/modules" ) +set( _EXEDIR "${_DEST}" ) + +# Setup RPATH handling +set( CMAKE_BUILD_RPATH "${_DEST}/${_PKGLIB}" ) +set( CMAKE_BUILD_WITH_INSTALL_RPATH FALSE ) +set( CMAKE_INSTALL_RPATH "${_PREFIX}/${_PKGLIB}" ) +set( CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE ) + +# Adjust them for the Mac +if( CMAKE_SYSTEM_NAME MATCHES "Darwin" ) + set( _APPDIR "Audacity.app/Contents" ) + set( _DEST "${_DESTDIR}/${_APPDIR}" ) + set( _EXEDIR "${_DEST}/MacOS" ) + set( _MODDIR "${_DEST}/modules" ) + set( _PKGLIB "${_DEST}/Frameworks" ) + + set( CMAKE_MACOSX_RPATH OFF ) +endif() # Add the math library (if found) to the list of required libraries check_library_exists( m pow "" HAVE_LIBM ) @@ -213,19 +251,6 @@ set( CMAKE_LINK_INTERFACE_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ) # Various common checks whose results are used by the different targets test_big_endian( WORDS_BIGENDIAN ) -# Determine 32-bit or 64-bit target -if( CMAKE_C_COMPILER_ID MATCHES "MSVC" AND CMAKE_VS_PLATFORM_NAME MATCHES "Win64|x64" ) - set( IS_64BIT ON ) -elseif( NOT CMAKE_SIZEOF_VOID_P STREQUAL "4" ) - set( IS_64BIT ON ) -endif() - -if( IS_64BIT ) - message( STATUS "Building for 64-bit target" ) -else() - message( STATUS "Building for 32-bit target" ) -endif() - # Check for compiler flags if( CMAKE_CXX_COMPILER_ID MATCHES "AppleClang|Clang|GNU" ) check_cxx_compiler_flag( "-mmmx" HAVE_MMX ) @@ -333,56 +358,12 @@ check_type_size( "size_t" SIZEOF_SIZE LANGUAGE C ) check_type_size( "wchar_t" SIZEOF_WCHAR LANGUAGE C ) check_type_size( "void*" SIZEOF_POINTER LANGUAGE C ) -# Determine 32-bit or 64-bit target -if( CMAKE_C_COMPILER_ID MATCHES "MSVC" AND CMAKE_VS_PLATFORM_NAME MATCHES "Win64|x64" ) - set( IS_64BIT ON ) -elseif( NOT CMAKE_SIZEOF_VOID_P STREQUAL "4" ) - set( IS_64BIT ON ) -endif() - -if( IS_64BIT ) - message( STATUS "Building for 64-bit target" ) -else() - message( STATUS "Building for 32-bit target" ) -endif() - # We'll be using it if it's available find_package( PkgConfig QUIET ) # Mostly just to make the CMP0072 policy happy find_package( OpenGL QUIET ) -# Define the non-install and executable destinations -# -# If this is a multi-config build system (VS, Xcode), CMAKE_CFG_INTDIR -# will (eventually) resolve to the build type, i.e., Debug, Release, etc. -# and CMAKE_BUILD_TYPE will be empty. -# -# For single-config build systems, CMAKE_CFG_INTDIR will be "." and -# CMAKE_BUILD_TYPE will be something like Debug. -# -# So, in either case we end up with what we want: -# .../bin/Debug// -# or: -# .../bin//Debug -set( _DESTDIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/${CMAKE_BUILD_TYPE}" ) -set( _DEST "${_DESTDIR}" ) -set( _EXEDIR "${_DEST}" ) -string( REGEX REPLACE "/+$" "" _EXEDIR "${_EXEDIR}" ) - -# Adjust them for the Mac -if( CMAKE_SYSTEM_NAME MATCHES "Darwin" ) - set( _DEST "${_DEST}/Audacity.app/Contents" ) - set( _EXEDIR "${_DEST}/MacOS" ) -endif() - -set( _PREFIX "${CMAKE_INSTALL_PREFIX}" ) -set( _LIBDIR "${CMAKE_INSTALL_LIBDIR}/audacity" ) -set( _RPATH "\$ORIGIN/../${_LIBDIR}" ) -set( _DATADIR "${CMAKE_INSTALL_DATADIR}" ) -set( _PKGDATA "${_DATADIR}/audacity/" ) -set( _MANDIR "${CMAKE_INSTALL_MANDIR}" ) - # Precreate the lib and lib64 directories so we can make then the same if( NOT EXISTS "${CMAKE_BINARY_DIR}/lib" ) file( MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) diff --git a/cmake-proxies/cmake-modules/CopyLibs.cmake b/cmake-proxies/cmake-modules/CopyLibs.cmake new file mode 100644 index 000000000..b11b8bc3e --- /dev/null +++ b/cmake-proxies/cmake-modules/CopyLibs.cmake @@ -0,0 +1,110 @@ +# Copy library during build and, on the Mac, modify the dependent +# library paths. +# +# Defines required: +# +# SRC source library name +# DST destination directory +# +message( "==================================================================" ) +message( "Copying wxWidgets libraries:" ) +message( "${SRC} ${DST}" ) +message( "==================================================================" ) + +# list command no longer ignores empty elements. +cmake_policy( SET CMP0007 NEW ) + +function( execute ) + list( POP_FRONT ARGV outlist ) + + execute_process( + COMMAND + ${ARGV} + OUTPUT_VARIABLE + cmd_out +# COMMAND_ECHO STDOUT + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + +#message("OUTPUT\n${cmd_out}") + + # Convert output to list and strip + string( REPLACE "\n" ";" cmd_out "${cmd_out}" ) + list( TRANSFORM cmd_out STRIP ) + + set( ${outlist} ${cmd_out} PARENT_SCOPE ) +endfunction() + +function( gather_libs src ) + if( CMAKE_HOST_SYSTEM_NAME MATCHES "Windows" ) + execute( output cmd /k dumpbin /dependents ${src} ) + + foreach( line ${output} ) + if( line MATCHES "^ *wx.*\\.dll" ) + set( lib ${WXWIN}/${line} ) + + list( APPEND libs ${lib} ) + + gather_libs( ${lib} ) + endif() + endforeach() + elseif( CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin" ) + execute( output otool -L ${src} ) + + get_filename_component( libname "${src}" NAME ) + + if( libname MATCHES ".*dylib" ) + string( PREPEND libname "${DST}/" ) + else() + set( libname "${src}" ) + endif() + + foreach( line ${output} ) + if( line MATCHES "^.*libwx.*\\.dylib " ) + string( REGEX REPLACE "dylib .*" "dylib" line "${line}" ) + if( NOT line STREQUAL "${src}" ) + set( lib ${line} ) + + list( APPEND libs ${lib} ) + + get_filename_component( refname "${lib}" NAME ) + list( APPEND postcmds "sh -c 'install_name_tool -change ${lib} @executable_path/../Frameworks/${refname} ${libname}'" ) + + gather_libs( ${lib} ) + endif() + endif() + endforeach() + elseif( CMAKE_HOST_SYSTEM_NAME MATCHES "Linux" ) + execute( output ldd ${src} ) + + foreach( line ${output} ) + if( line MATCHES ".*libwx.*" ) + string( REGEX REPLACE ".* => (.*) \\(.*$" "\\1" line "${line}" ) + + set( lib ${line} ) + + list( APPEND libs ${lib} ) + + gather_libs( ${lib} ) + endif() + endforeach() + endif() + + set( libs ${libs} PARENT_SCOPE ) + set( postcmds ${postcmds} PARENT_SCOPE ) +endfunction() + +gather_libs( "${SRC}" ) + +list( REMOVE_DUPLICATES libs ) + +file( INSTALL ${libs} DESTINATION ${DST} FOLLOW_SYMLINK_CHAIN ) + +foreach( cmd ${postcmds} ) + execute_process( + COMMAND + sh -c "${cmd}" + COMMAND_ECHO STDOUT + ) +endforeach() + diff --git a/cmake-proxies/lv2/CMakeLists.txt b/cmake-proxies/lv2/CMakeLists.txt index 289688eb9..1bc950cbd 100644 --- a/cmake-proxies/lv2/CMakeLists.txt +++ b/cmake-proxies/lv2/CMakeLists.txt @@ -162,7 +162,7 @@ macro( bld name packages define sources ) set_target_properties( ${name} PROPERTIES - LIBRARY_OUTPUT_DIRECTORY "${_DESTDIR}/${_LIBDIR}" + LIBRARY_OUTPUT_DIRECTORY "${_DEST}/${_PKGLIB}" PREFIX "" ) diff --git a/cmake-proxies/wxWidgets/CMakeLists.txt b/cmake-proxies/wxWidgets/CMakeLists.txt index 94d19ddae..83d590d38 100644 --- a/cmake-proxies/wxWidgets/CMakeLists.txt +++ b/cmake-proxies/wxWidgets/CMakeLists.txt @@ -207,6 +207,36 @@ if( "${wxTOOLKIT}" MATCHES "GTK." ) pkg_check_modules( GLIB REQUIRED IMPORTED_TARGET GLOBAL ${glib} ) endif() +find_file( WXVERSION_H + NAMES + wx/version.h + PATHS + ${INCLUDES} + NO_DEFAULT_PATH +) + +if( NOT WXVERSION_H ) + message( FATAL_ERROR "wxWidgets version.h header not found" ) +endif() + +file( + STRINGS + "${WXVERSION_H}" output + REGEX + "^#define +wxVERSION_STRING +" +) + +string( REGEX MATCHALL "\".+(Audacity).+\"" ours "${output}") +if( NOT ours ) + message( FATAL_ERROR + "\n########################################################################\n" + "Audacity version 3.0.0 or higher requires use of a customized version of " + "wxWidgets. For details:\n" + " https://wiki.audacityteam.org/wiki/Building_for_Distros\n" + "########################################################################\n" + ) +endif() + target_include_directories( ${TARGET} INTERFACE ${INCLUDES} ) target_compile_definitions( ${TARGET} INTERFACE ${DEFINES} ) target_compile_options( ${TARGET} INTERFACE ${COPTS} ) diff --git a/help/CMakeLists.txt b/help/CMakeLists.txt index 43a771466..455aaa1ca 100755 --- a/help/CMakeLists.txt +++ b/help/CMakeLists.txt @@ -34,12 +34,14 @@ add_custom_command( add_custom_target( ${TARGET} DEPENDS "${out}" ) -if( NOT "${CMAKE_GENERATOR}" MATCHES "Xcode|Visual Studio*" ) - install( DIRECTORY "${dst}" OPTIONAL - DESTINATION "${_DATADIR}/audacity/help" ) - install( FILES "${_SRCDIR}/audacity.1" - DESTINATION "${_MANDIR}/man1" ) - install( FILES "${_SRCDIR}/audacity.appdata.xml" - DESTINATION "${_DATADIR}/appdata" ) +if( NOT CMAKE_SYSTEM_NAME MATCHES "Darwin" ) + if( NOT "${CMAKE_GENERATOR}" MATCHES "Visual Studio*") + install( DIRECTORY "${dst}" OPTIONAL + DESTINATION "${_DATADIR}/audacity/help" ) + install( FILES "${_SRCDIR}/audacity.1" + DESTINATION "${_MANDIR}/man1" ) + install( FILES "${_SRCDIR}/audacity.appdata.xml" + DESTINATION "${_DATADIR}/appdata" ) + endif() endif() diff --git a/images/CMakeLists.txt b/images/CMakeLists.txt index fbedb083c..42e86a4f4 100755 --- a/images/CMakeLists.txt +++ b/images/CMakeLists.txt @@ -15,13 +15,15 @@ list( APPEND PIXMAPS ${_SRCDIR}/icons/48x48/audacity.xpm ) -if( NOT "${CMAKE_GENERATOR}" MATCHES "Xcode|Visual Studio*" ) - install( FILES "${_SRCDIR}/audacity.svg" - DESTINATION "${_DATADIR}/icons/hicolor/scalable/apps" ) - install( DIRECTORY "${_SRCDIR}/icons/" - DESTINATION "${_DATADIR}/icons/hicolor" - FILES_MATCHING PATTERN "*.png" ) - install( FILES ${PIXMAPS} - DESTINATION "${_DATADIR}/pixmaps" ) +if( NOT CMAKE_SYSTEM_NAME MATCHES "Darwin" ) + if( NOT "${CMAKE_GENERATOR}" MATCHES "Visual Studio*") + install( FILES "${_SRCDIR}/audacity.svg" + DESTINATION "${_DATADIR}/icons/hicolor/scalable/apps" ) + install( DIRECTORY "${_SRCDIR}/icons/" + DESTINATION "${_DATADIR}/icons/hicolor" + FILES_MATCHING PATTERN "*.png" ) + install( FILES ${PIXMAPS} + DESTINATION "${_DATADIR}/pixmaps" ) + endif() endif() diff --git a/locale/CMakeLists.txt b/locale/CMakeLists.txt index 479c55ab1..86cb5178c 100755 --- a/locale/CMakeLists.txt +++ b/locale/CMakeLists.txt @@ -80,8 +80,10 @@ endforeach() add_custom_target( "${TARGET}" ALL DEPENDS ${OUTPUTS} SOURCES "${SOURCES}" ) -if( NOT "${CMAKE_GENERATOR}" MATCHES "Xcode|Visual Studio*" ) - install( DIRECTORY ${locale}/ - TYPE LOCALE ) +if( NOT CMAKE_SYSTEM_NAME MATCHES "Darwin" ) + if( NOT "${CMAKE_GENERATOR}" MATCHES "Visual Studio*") + install( DIRECTORY ${locale}/ + TYPE LOCALE ) + endif() endif() diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index 1b63df7db..d08dfbd6e 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -1,11 +1,17 @@ # Include the modules that we'll build +if( NOT CMAKE_SYSTEM_NAME MATCHES "Windows" ) add_subdirectory( mod-null ) add_subdirectory( mod-nyq-bench ) -add_subdirectory( mod-script-pipe ) - -if( NOT "${CMAKE_GENERATOR}" MATCHES "Xcode|Visual Studio*" ) - install( DIRECTORY "${_DEST}/modules" - DESTINATION "${_PKGDATA}" ) +endif() + +add_subdirectory( mod-script-pipe ) + + +if( NOT CMAKE_SYSTEM_NAME MATCHES "Darwin" ) + if( NOT "${CMAKE_GENERATOR}" MATCHES "Visual Studio*") + install( DIRECTORY "${_DEST}/modules" + DESTINATION "${_PKGDATA}" ) + endif() endif() diff --git a/modules/mod-null/CMakeLists.txt b/modules/mod-null/CMakeLists.txt index 5768fa65a..376373c66 100644 --- a/modules/mod-null/CMakeLists.txt +++ b/modules/mod-null/CMakeLists.txt @@ -42,11 +42,11 @@ list( APPEND LIBRARIES $<$:wxWidgets> ) -set_target_property_all( ${TARGET} LIBRARY_OUTPUT_DIRECTORY "${_DEST}/modules" ) +set_target_property_all( ${TARGET} LIBRARY_OUTPUT_DIRECTORY "${_MODDIR}" ) set_target_properties( ${TARGET} PROPERTIES PREFIX "" - FOLDER "lib-src" + FOLDER "modules" ) organize_source( "${TARGET_ROOT}" "" "${SOURCES}" ) diff --git a/modules/mod-nyq-bench/CMakeLists.txt b/modules/mod-nyq-bench/CMakeLists.txt index 4ba4807e4..cd9b2d2d8 100644 --- a/modules/mod-nyq-bench/CMakeLists.txt +++ b/modules/mod-nyq-bench/CMakeLists.txt @@ -47,11 +47,11 @@ list( APPEND LIBRARIES $<$:wxWidgets> ) -set_target_property_all( ${TARGET} LIBRARY_OUTPUT_DIRECTORY "${_DEST}/modules" ) +set_target_property_all( ${TARGET} LIBRARY_OUTPUT_DIRECTORY "${_MODDIR}" ) set_target_properties( ${TARGET} PROPERTIES PREFIX "" - FOLDER "lib-src" + FOLDER "modules" ) organize_source( "${TARGET_ROOT}" "" "${SOURCES}" ) diff --git a/modules/mod-script-pipe/CMakeLists.txt b/modules/mod-script-pipe/CMakeLists.txt index 9d6a61929..1af26b5c9 100644 --- a/modules/mod-script-pipe/CMakeLists.txt +++ b/modules/mod-script-pipe/CMakeLists.txt @@ -44,11 +44,11 @@ list( APPEND LIBRARIES $<$:wxWidgets> ) -set_target_property_all( ${TARGET} LIBRARY_OUTPUT_DIRECTORY "${_DEST}/modules" ) +set_target_property_all( ${TARGET} LIBRARY_OUTPUT_DIRECTORY "${_MODDIR}" ) set_target_properties( ${TARGET} PROPERTIES PREFIX "" - FOLDER "lib-src" + FOLDER "modules" ) organize_source( "${TARGET_ROOT}" "" "${SOURCES}" ) diff --git a/nyquist/CMakeLists.txt b/nyquist/CMakeLists.txt index 70b177cd3..0916ab692 100755 --- a/nyquist/CMakeLists.txt +++ b/nyquist/CMakeLists.txt @@ -82,8 +82,10 @@ endforeach() add_custom_target( ${TARGET} ALL DEPENDS ${OUTPUTS} SOURCES ${SOURCES} ) -if( NOT "${CMAKE_GENERATOR}" MATCHES "Xcode|Visual Studio*" ) - install( DIRECTORY "${_DEST}/${TARGET}" - DESTINATION "${_PKGDATA}" ) +if( NOT CMAKE_SYSTEM_NAME MATCHES "Darwin" ) + if( NOT "${CMAKE_GENERATOR}" MATCHES "Visual Studio*") + install( DIRECTORY "${_DEST}/${TARGET}" + DESTINATION "${_PKGDATA}" ) + endif() endif() diff --git a/plug-ins/CMakeLists.txt b/plug-ins/CMakeLists.txt index 4e60c9623..08924f1f8 100755 --- a/plug-ins/CMakeLists.txt +++ b/plug-ins/CMakeLists.txt @@ -59,8 +59,10 @@ endforeach() add_custom_target( ${TARGET} ALL DEPENDS ${OUTPUTS} SOURCES ${SOURCES} ) -if( NOT "${CMAKE_GENERATOR}" MATCHES "Xcode|Visual Studio*" ) - install( DIRECTORY "${_DEST}/${TARGET}" - DESTINATION "${_PKGDATA}" ) +if( NOT CMAKE_SYSTEM_NAME MATCHES "Darwin" ) + if( NOT "${CMAKE_GENERATOR}" MATCHES "Visual Studio*") + install( DIRECTORY "${_DEST}/${TARGET}" + DESTINATION "${_PKGDATA}" ) + endif() endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c72d2a159..daaa42dd6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1011,12 +1011,12 @@ list( APPEND OPTIONS PRIVATE $<$:/permissive-> $<$:-Wno-underaligned-exception-object> -# $<$:-Wl,-rpath -Wl,${_RPATH}> ) list( APPEND LDFLAGS PRIVATE $<$:/MANIFEST:NO> + $<$:-Wl,--disable-new-dtags> ) # @@ -1055,8 +1055,8 @@ list( APPEND LIBRARIES set( BUILDING_AUDACITY YES ) set( INSTALL_PREFIX "${_PREFIX}" ) -set( PKGLIBDIR "${_LIBDIR}" ) -set( LIBDIR "${_LIBDIR}" ) +set( PKGLIBDIR "${_PKGLIBDIR}" ) +set( LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}" ) set( HAVE_GTK ${GTK_FOUND} ) # Do not define these for Windows or Mac until further testing @@ -1100,33 +1100,15 @@ if( CMAKE_SYSTEM_NAME MATCHES "Windows" ) file( TO_NATIVE_PATH "${wxWidgets_LIB_DIR}" libdir ) file( TO_NATIVE_PATH "${_EXEDIR}" exedir ) - # And create the script to copy the WX libs to the exeutable directory - file( WRITE "${_INTDIR}/copy_libs.bat" - "@ECHO OFF - IF NOT %1 EQU xyzzy ( - IF EXIST \"${dlls}\" DEL \"${dlls}\" - CALL %0 xyzzy \"%1\" %2 - FOR /F \"delims=\" %%c IN ('SORT \"${dlls}\"') DO ( - IF NOT EXIST \"%1\"\\%%c ( - xcopy \"${libdir}\"\\%%c \"%1\" - ) - ) - DEL ${dlls} - ) - IF %1 EQU xyzzy ( - FOR /F %%i IN ('DUMPBIN /DEPENDENTS \"%2\"\\%3 ^| findstr /B \"/C: wx\"') DO ( - ECHO %%i >>\"${dlls}\" - CALL %0 xyzzy \"${libdir}\" %%i - ) - )" - ) - - # Add it to the build + # Copy the required wxWidgets libs into the bundle add_custom_command( TARGET ${TARGET} COMMAND - ${_INTDIR}/copy_libs.bat ${exedir} ${AUDACITY_NAME}.exe + ${CMAKE_COMMAND} -D SRC="${_EXEDIR}/Audacity.exe" + -D DST="${_EXEDIR}" + -D WXWIN="${libdir}" + -P ${CMAKE_MODULE_PATH}/CopyLibs.cmake POST_BUILD ) @@ -1206,16 +1188,16 @@ elseif( CMAKE_SYSTEM_NAME MATCHES "Darwin" ) set( HAVE_VISIBILITY 1 ) configure_file( audacity_config.h.in private/configmac.h ) - # Copy the wxWidgets libraries into the bundle - if( "${CMAKE_GENERATOR}" MATCHES "Xcode" ) - add_custom_command( - TARGET - ${TARGET} - COMMAND - sh -c "TARGET_BUILD_DIR=${_DEST} EXECUTABLE_PATH=MacOS/${AUDACITY_NAME} FRAMEWORKS_FOLDER_PATH=Frameworks ${topdir}/mac/scripts/install_wxlibs.sh" - POST_BUILD - ) - endif() + # Copy the required wxWidgets libs into the bundle + add_custom_command( + TARGET + ${TARGET} + COMMAND + ${CMAKE_COMMAND} -D SRC="${_EXEDIR}/Audacity" + -D DST="${_PKGLIB}" + -P ${CMAKE_MODULE_PATH}/CopyLibs.cmake + POST_BUILD + ) # Define the Wrapper target set( WRAPPER_ROOT "${TARGET_ROOT}/../mac" ) @@ -1228,7 +1210,7 @@ elseif( CMAKE_SYSTEM_NAME MATCHES "Darwin" ) organize_source( "${WRAPPER_ROOT}" "mac" "${WRAPPER_SOURCES}" ) else() - set_target_property_all( ${TARGET} RUNTIME_OUTPUT_DIRECTORY "${_DESTDIR}" ) + set_target_property_all( ${TARGET} RUNTIME_OUTPUT_DIRECTORY "${_DEST}" ) # Create the config file set( HAVE_VISIBILITY 1 ) @@ -1275,28 +1257,16 @@ else() # Create the desktop file configure_file( audacity.desktop.in ${_INTDIR}/audacity.desktop ) - # Create the script to copy required wxWidgets libraries - if( ${_OPT}use_wxwidgets STREQUAL "local" ) - file( WRITE "${_INTDIR}/copy_libs.sh" - "for lib in \$(ldd ${_EXEDIR}/${AUDACITY_NAME} | awk '/libwx/{print \$1}') - do - echo \${lib} - ldd ${WXWIN}/lib/\${lib} | awk '/libwx/{print \$1}' - done | sort -u | xargs cp -n -H -t ${_LIBDIR} - rm \${0}" - ) - - # And run it after the build - add_custom_command( - TARGET - ${TARGET} - COMMAND - sh "${_INTDIR}/copy_libs.sh" - WORKING_DIRECTORY - ${WXWIN}/lib - POST_BUILD - ) - endif() + # Copy the required wxWidgets libs into the bundle + add_custom_command( + TARGET + ${TARGET} + COMMAND + ${CMAKE_COMMAND} -D SRC="${_EXEDIR}/audacity" + -D DST="${_DEST}/${_PKGLIB}" + -P ${CMAKE_MODULE_PATH}/CopyLibs.cmake + POST_BUILD + ) endif() set_target_property_all( ${TARGET} RUNTIME_OUTPUT_NAME ${AUDACITY_NAME} ) @@ -1347,17 +1317,15 @@ endif() if( NOT "${CMAKE_GENERATOR}" MATCHES "Xcode|Visual Studio*" ) if( CMAKE_SYSTEM_NAME MATCHES "Darwin" ) - install( FILES "${_DEST}/Info.plist" - DESTINATION "${CMAKE_INSTALL_BINDIR}/Audacity.app/Contents" ) - install( PROGRAMS "${_EXEDIR}/${AUDACITY_NAME}" "${_EXEDIR}/Wrapper" - DESTINATION "${CMAKE_INSTALL_BINDIR}/Audacity.app/Contents/MacOS" ) + install( TARGETS ${TARGET} + DESTINATION "." + RESOURCE DESTINATION "${_APPDIR}/Resources" ) else() - install( PROGRAMS "${_EXEDIR}/${AUDACITY_NAME}" - TYPE BIN ) - install( DIRECTORY "${_DESTDIR}/${_LIBDIR}/" + install( TARGETS ${TARGET} RUNTIME ) + install( DIRECTORY "${_DEST}/${_LIBDIR}/" DESTINATION "${_LIBDIR}" USE_SOURCE_PERMISSIONS - FILES_MATCHING PATTERN "*.so" ) + FILES_MATCHING PATTERN "*.so*" ) install( FILES "${_INTDIR}/audacity.desktop" DESTINATION "${_DATADIR}/applications" ) install( FILES "${topdir}/LICENSE.txt" "${topdir}/README.txt"