1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-04-29 15:19:44 +02:00

Fix multi-config builds

Hopefully, this corrects the handling of the different
configs like Debug, Release, etc, when dealing with
multi-config generators.
This commit is contained in:
Leland Lucius 2020-02-06 20:10:29 -06:00
parent 8e8e71116a
commit 2ec12c150b
6 changed files with 84 additions and 27 deletions

View File

@ -214,10 +214,19 @@ macro( def_vars )
endmacro()
# Define the non-install and executable destinations
set( _DEST "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" )
if( CMAKE_BUILD_TYPE )
set( _DEST "${_DEST}/${CMAKE_BUILD_TYPE}" )
endif()
#
# 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( _DEST "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/${CMAKE_BUILD_TYPE}" )
set( _EXEDIR "${_DEST}" )
# Adjust them for the Mac
@ -301,6 +310,15 @@ macro( get_package_interface package )
)
endmacro()
# Set the given property and its config specific brethren to the same value
function( set_target_property_all target property value )
set_target_properties( "${target}" PROPERTIES "${property}" "${value}" )
foreach( type ${CMAKE_CONFIGURATION_TYPES} )
string( TOUPPER "${property}_${type}" prop )
set_target_properties( "${target}" PROPERTIES "${prop}" "${value}" )
endforeach()
endfunction()
# Add our children
add_subdirectory( "cmake-proxies" )
add_subdirectory( "help" )
@ -314,9 +332,14 @@ add_subdirectory( "cmake-proxies/mod-script-pipe" )
# Uncomment what follows for symbol values.
#[[
get_cmake_property(_variableNames VARIABLES)
foreach (_variableName ${_variableNames})
message(STATUS "${_variableName}=${${_variableName}}")
endforeach()
get_cmake_property(_variableNames VARIABLES)
foreach (_variableName ${_variableNames})
message(STATUS "${_variableName}=${${_variableName}}")
endforeach()
#]]
#[[
include(PrintProperties)
print_properties(TARGET "Audacity")
#]]

View File

@ -0,0 +1,49 @@
#
# From https://stackoverflow.com/a/51987470 but modified
#
function(print_properties typ tgt)
message("Properties for ${typ} ${tgt}:")
# Get all propreties that cmake supports
execute_process(COMMAND cmake --help-property-list OUTPUT_VARIABLE CMAKE_PROPERTY_LIST)
# Convert command output into a CMake list
STRING(REGEX REPLACE ";" "\\\\;" CMAKE_PROPERTY_LIST "${CMAKE_PROPERTY_LIST}")
STRING(REGEX REPLACE "\n" ";" CMAKE_PROPERTY_LIST "${CMAKE_PROPERTY_LIST}")
# Fix https://stackoverflow.com/questions/32197663/how-can-i-remove-the-the-location-property-may-not-be-read-from-target-error-i
list(FILTER CMAKE_PROPERTY_LIST EXCLUDE REGEX "^LOCATION$|^LOCATION_|_LOCATION$")
# For some reason, "TYPE" shows up twice - others might too?
list(REMOVE_DUPLICATES CMAKE_PROPERTY_LIST)
# build whitelist by filtering down from CMAKE_PROPERTY_LIST in case cmake is
# a different version, and one of our hardcoded whitelisted properties
# doesn't exist!
unset(CMAKE_WHITELISTED_PROPERTY_LIST)
foreach(prop ${CMAKE_PROPERTY_LIST})
if(prop MATCHES "^(INTERFACE|[_a-z]|IMPORTED_LIBNAME_|MAP_IMPORTED_CONFIG_)|^(COMPATIBLE_INTERFACE_(BOOL|NUMBER_MAX|NUMBER_MIN|STRING)|EXPORT_NAME|IMPORTED(_GLOBAL|_CONFIGURATIONS|_LIBNAME)?|NAME|TYPE|NO_SYSTEM_FROM_IMPORTED)$")
list(APPEND CMAKE_WHITELISTED_PROPERTY_LIST ${prop})
endif()
endforeach()
set(PROP_LIST ${CMAKE_PROPERTY_LIST})
if( typ MATCHES "TARGET" )
get_target_property(target_type ${tgt} TYPE)
if(target_type STREQUAL "INTERFACE_LIBRARY")
set(PROP_LIST ${CMAKE_WHITELISTED_PROPERTY_LIST})
endif()
endif()
foreach (prop ${PROP_LIST})
string(REPLACE "<CONFIG>" "${CMAKE_BUILD_TYPE}" prop ${prop})
get_property(propval ${typ} ${tgt} PROPERTY ${prop} SET)
if (propval)
get_property(propval ${typ} ${tgt} PROPERTY ${prop})
if (NOT propval STREQUAL "propval-NOTFOUND")
message (" ${prop} = ${propval}")
endif()
endif()
endforeach()
endfunction()

View File

@ -5,7 +5,6 @@ list( APPEND SOURCES
PRIVATE
${TARGET_ROOT}/compat.c
${TARGET_ROOT}/crc.c
$<$<STREQUAL:${CMAKE_BUILD_TYPE},Debug>:${TARGET_ROOT}/debug.c>
${TARGET_ROOT}/field.c
${TARGET_ROOT}/file.c
${TARGET_ROOT}/frame.c

View File

@ -27,10 +27,9 @@ list( APPEND LIBRARIES
wxwidgets
)
set_target_property_all( ${TARGET} LIBRARY_OUTPUT_DIRECTORY "${_DEST}/modules" )
set_target_properties( ${TARGET}
PROPERTIES
LIBRARY_OUTPUT_DIRECTORY_${CMAKE_BUILD_TYPE} "${_DEST}/modules"
LIBRARY_OUTPUT_DIRECTORY "${_DEST}/modules"
PREFIX ""
FOLDER "lib-src"
)

View File

@ -30,10 +30,9 @@ list( APPEND LIBRARIES
Audacity
)
set_target_property_all( ${TARGET} LIBRARY_OUTPUT_DIRECTORY "${_DEST}/modules" )
set_target_properties( ${TARGET}
PROPERTIES
LIBRARY_OUTPUT_DIRECTORY_${CMAKE_BUILD_TYPE} "${_DEST}/modules"
LIBRARY_OUTPUT_DIRECTORY "${_DEST}/modules"
PREFIX ""
FOLDER "lib-src"
)

View File

@ -1158,17 +1158,11 @@ elseif( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
${WRAPPER_ROOT}/Wrapper.c
)
set_target_properties(
"Wrapper"
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_${CMAKE_BUILD_TYPE} "${_EXEDIR}"
RUNTIME_OUTPUT_DIRECTORY "${_EXEDIR}"
)
set_target_property_all( "Wrapper" RUNTIME_OUTPUT_DIRECTORY "${_EXEDIR}" )
organize_source( "${WRAPPER_ROOT}" "mac" "${WRAPPER_SOURCES}" )
target_sources( "Wrapper" PRIVATE ${WRAPPER_SOURCES} )
elseif( CMAKE_SYSTEM_NAME MATCHES "Linux" )
set( _EXE "audacity" )
@ -1228,13 +1222,7 @@ elseif( CMAKE_SYSTEM_NAME MATCHES "Linux" )
endif()
set_target_properties(
${TARGET}
PROPERTIES
# Want a lowercase executable
RUNTIME_OUTPUT_NAME_${CMAKE_BUILD_TYPE} audacity
RUNTIME_OUTPUT_NAME ${_EXE}
)
set_target_property_all( ${TARGET} RUNTIME_OUTPUT_NAME ${_EXE} )
find_package (Git)
if (GIT_FOUND)