Skip to content

Commit

Permalink
Refactor the cmake compile options a bit
Browse files Browse the repository at this point in the history
A few options (like -DPLATFORM=1 and macos filesystem and warnings)
were starting to be applied multiple places and not consistently.
For instance I had forgotten them on the auv2 build helper. So

1. Make a `clap-wrapper-compile-options` interface which sets up
   all these things
2. Set it as a link dep of the things which need it
3. Fix the build bugs with the auv2 helper from turning on warnings
   there and
4. Add an option to likn with asan, which is still a work in progress
  • Loading branch information
baconpaul committed Sep 11, 2023
1 parent 87ee3da commit 46f12ba
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 24 deletions.
37 changes: 20 additions & 17 deletions cmake/enable_sdks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# make CPM available
include(cmake/CPM.cmake)


if (${CLAP_WRAPPER_DOWNLOAD_DEPENDENCIES})
message(STATUS "clap-wrapper: Downloading dependencies using CPM")

Expand Down Expand Up @@ -247,6 +248,22 @@ if (APPLE)
endif()
endif()


add_library(clap-wrapper-compile-options INTERFACE)
target_compile_options(clap-wrapper-compile-options INTERFACE -D${CLAP_WRAPPER_PLATFORM}=1)
if (APPLE)
target_link_libraries(clap-wrapper-compile-options INTERFACE macos_filesystem_support)
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
target_compile_options(clap-wrapper-compile-options INTERFACE -Wall -Wextra -Wno-unused-parameter -Wpedantic -Werror)
if (${CLAP_WRAPPER_ENABLE_ASAN})
message(STATUS "clap-wrapper: enabling asan build")
target_compile_options(clap-wrapper-compile-options INTERFACE -fsanitize=address -fsanitize=undefined)
target_link_options(clap-wrapper-compile-options INTERFACE -fsanitize=address -fsanitize=undefined)
endif()
endif()


# define libraries
function(target_add_vst3_wrapper)
set(oneValueArgs
Expand Down Expand Up @@ -322,19 +339,11 @@ function(target_add_vst3_wrapper)
target_link_libraries(${V3_TARGET}-clap-wrapper-vst3-lib PUBLIC clap base-sdk-vst3)

# clap-wrapper-extensions are PUBLIC, so a clap linking the library can access the clap-wrapper-extensions
target_compile_definitions(${V3_TARGET}-clap-wrapper-vst3-lib PUBLIC -D${CLAP_WRAPPER_PLATFORM}=1)
target_link_libraries(${V3_TARGET}-clap-wrapper-vst3-lib PUBLIC clap-wrapper-extensions clap-wrapper-shared-detail)
target_link_libraries(${V3_TARGET}-clap-wrapper-vst3-lib PUBLIC clap-wrapper-extensions clap-wrapper-compile-options clap-wrapper-shared-detail)

target_compile_options(${V3_TARGET}-clap-wrapper-vst3-lib PRIVATE
-DCLAP_SUPPORTS_ALL_NOTE_EXPRESSIONS=$<IF:$<BOOL:${V3_SUPPORTS_ALL_NOTE_EXPRESSIONS}>,1,0>
)

if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
target_compile_options(${V3_TARGET}-clap-wrapper-vst3-lib PRIVATE -Wall -Wextra -Wno-unused-parameter -Wpedantic -Werror)
endif()
if (APPLE)
target_link_libraries(${V3_TARGET}-clap-wrapper-vst3-lib PUBLIC macos_filesystem_support)
endif()
endif()


Expand Down Expand Up @@ -588,8 +597,7 @@ if (APPLE)
target_link_libraries(${AUV2_TARGET}-clap-wrapper-auv2-lib INTERFACE clap base-sdk-auv2)

# clap-wrapper-extensions are PUBLIC, so a clap linking the library can access the clap-wrapper-extensions
target_compile_definitions(${AUV2_TARGET}-clap-wrapper-auv2-lib INTERFACE -D${CLAP_WRAPPER_PLATFORM}=1)
target_link_libraries(${AUV2_TARGET}-clap-wrapper-auv2-lib INTERFACE clap-wrapper-extensions clap-wrapper-shared-detail macos_filesystem_support)
target_link_libraries(${AUV2_TARGET}-clap-wrapper-auv2-lib INTERFACE clap-wrapper-extensions clap-wrapper-shared-detail clap-wrapper-compile-options)

endif()

Expand Down Expand Up @@ -653,15 +661,10 @@ add_library(clap-wrapper-shared-detail STATIC
src/detail/clap/fsutil.cpp
src/detail/clap/automation.h
)
target_compile_options(clap-wrapper-shared-detail PUBLIC -D${CLAP_WRAPPER_PLATFORM}=1)
target_link_libraries(clap-wrapper-shared-detail PUBLIC clap clap-wrapper-extensions)
target_link_libraries(clap-wrapper-shared-detail PUBLIC clap clap-wrapper-extensions clap-wrapper-compile-options)
target_include_directories(clap-wrapper-shared-detail PUBLIC libs/fmt)
target_include_directories(clap-wrapper-shared-detail PUBLIC src)

if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
target_compile_options(clap-wrapper-shared-detail PRIVATE -Wall -Wextra -Wno-unused-parameter -Wpedantic -Werror)
endif()


if (APPLE)
target_sources(clap-wrapper-shared-detail PRIVATE
Expand Down
2 changes: 1 addition & 1 deletion src/detail/auv2/auv2_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct ClapBridge

if (_clapid.empty())
{
if (_idx < 0 || _idx >= _library.plugins.size())
if (_idx < 0 || _idx >= (int)_library.plugins.size())
{
std::cout << "[ERROR] cannot load by index" << std::endl;
return;
Expand Down
15 changes: 9 additions & 6 deletions src/detail/auv2/build-helper/build-helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,16 @@ bool buildUnitsFromClap(const std::string &clapfile, const std::string &clapname
clap_plugin_info_as_auv2_t v2inf;
auto res =
loader._pluginFactoryAUv2Info->get_auv2_info(loader._pluginFactoryAUv2Info, idx, &v2inf);
if (v2inf.au_type[0] != 0)
if (res)
{
u.type = v2inf.au_type;
}
if (v2inf.au_subt[0] != 0)
{
u.subt = v2inf.au_subt;
if (v2inf.au_type[0] != 0)
{
u.type = v2inf.au_type;
}
if (v2inf.au_subt[0] != 0)
{
u.subt = v2inf.au_subt;
}
}
}

Expand Down

0 comments on commit 46f12ba

Please sign in to comment.