1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-04-30 07:39:42 +02:00

Separate CMake function for pervasive C++ flags, reuse it in modules

This commit is contained in:
Paul Licameli 2020-09-22 13:16:37 -04:00 committed by Leland Lucius
parent 3943d1479f
commit fe8659f435
2 changed files with 23 additions and 9 deletions

View File

@ -204,6 +204,20 @@ macro( check_for_platform_version )
endif()
endmacro()
# To be used to compile all C++ in the application and modules
function( audacity_append_common_compiler_options var )
list( APPEND ${var}
PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/permissive->
$<$<CXX_COMPILER_ID:AppleClang,Clang>:-Wno-underaligned-exception-object>
$<$<CXX_COMPILER_ID:AppleClang,Clang>:-Werror=return-type>
$<$<CXX_COMPILER_ID:AppleClang,Clang>:-Werror=dangling-else>
$<$<CXX_COMPILER_ID:AppleClang,Clang>:-Werror=return-stack-address>
# Yes, CMake will change -D to /D as needed for Windows:
-DWXINTL_NO_GETTEXT_MACRO
)
set( ${var} "${${var}}" PARENT_SCOPE )
endfunction()
# Set up for defining a module target.
# Pass a name and sources, and a list of other targets.
@ -249,10 +263,17 @@ function( audacity_module NAME SOURCES IMPORT_TARGETS
# list( TRANSFORM SOURCES PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/" )
# Compute compilation options.
# Perhaps a another function argument in future to customize this too.
set( OPTIONS )
audacity_append_common_compiler_options( OPTIONS )
organize_source( "${TARGET_ROOT}" "" "${SOURCES}" )
target_sources( ${TARGET} PRIVATE ${SOURCES} )
target_compile_definitions( ${TARGET} PRIVATE ${ADDITIONAL_DEFINES} )
target_compile_options( ${TARGET} ${OPTIONS} )
target_include_directories( ${TARGET} PUBLIC ${TARGET_ROOT} )
target_link_options( ${TARGET} PRIVATE ${LOPTS} )
target_link_libraries( ${TARGET} PUBLIC ${LIBRARIES} )
@ -272,3 +293,4 @@ function( audacity_module NAME SOURCES IMPORT_TARGETS
endforeach()
endif()
endfunction()

View File

@ -1005,7 +1005,6 @@ list( APPEND RESOURCES
list( APPEND DEFINES
PRIVATE
BUILDING_AUDACITY
WXINTL_NO_GETTEXT_MACRO
WXUSINGDLL
CMAKE
$<$<BOOL:${HAVE_LRINT}>:
@ -1024,14 +1023,7 @@ list( APPEND DEFINES
>
)
list( APPEND OPTIONS
PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/permissive->
$<$<CXX_COMPILER_ID:AppleClang,Clang>:-Wno-underaligned-exception-object>
$<$<CXX_COMPILER_ID:AppleClang,Clang>:-Werror=return-type>
$<$<CXX_COMPILER_ID:AppleClang,Clang>:-Werror=dangling-else>
$<$<CXX_COMPILER_ID:AppleClang,Clang>:-Werror=return-stack-address>
)
audacity_append_common_compiler_options( OPTIONS )
list( APPEND LDFLAGS
PRIVATE