From a580fd1fea93da382e65c9d6ae1fc2e491b7b54e Mon Sep 17 00:00:00 2001 From: Axel Nana Date: Fri, 27 Sep 2024 12:57:18 +0100 Subject: [PATCH] chore: Improve build system. Signed-off-by: Axel Nana --- CMakeLists.txt | 2 ++ cmake/FindAmplitudeAudioSDK.cmake | 23 ++++++++----------- .../Core/Common/Platforms/UNIX/Config.h | 4 ++-- .../Core/Common/Platforms/Windows/Config.h | 4 ++-- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 97a74b7d..2c3f8df8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -489,6 +489,8 @@ foreach (build_type ${AM_BUILDSYSTEM_TYPE}) ) target_compile_definitions(${build_type} PRIVATE AM_BUILDSYSTEM_BUILDING_AMPLITUDE) + target_compile_definitions(${build_type} PUBLIC "$<$:AM_NO_MEMORY_STATS>") + target_compile_definitions(${build_type} PUBLIC "$<$:AM_NO_ASSERTS>") target_link_libraries(${build_type} PRIVATE diff --git a/cmake/FindAmplitudeAudioSDK.cmake b/cmake/FindAmplitudeAudioSDK.cmake index 0040b380..b2c31168 100644 --- a/cmake/FindAmplitudeAudioSDK.cmake +++ b/cmake/FindAmplitudeAudioSDK.cmake @@ -14,6 +14,7 @@ # Amplitude installation path set(AM_SDK_PATH "" CACHE PATH "The path to Amplitude Audio SDK libraries.") +set(AM_SDK_PLATFORM ${VCPKG_TARGET_TRIPLET} CACHE STRING "The platform to use for the Amplitude Audio SDK libraries.") # Check for a known file in the SDK path to verify the path function(is_valid_sdk sdk_path is_valid) @@ -54,7 +55,7 @@ message(STATUS "Using Amplitude Audio SDK at ${AM_SDK_PATH}") set(AmplitudeAudioSDK_FOUND TRUE) set(AMPLITUDE_COMPILE_DEFINITIONS - $,AMPLITUDE_NO_ASSERTS,> + $,AM_NO_ASSERTS,> $,AM_NO_MEMORY_STATS,> ) @@ -63,8 +64,6 @@ get_filename_component(AMPLITUDE_INSTALL_ROOT ${AM_SDK_PATH} DIRECTORY) get_filename_component(AMPLITUDE_FOLDER ${AM_SDK_PATH} NAME) if(WIN32) - set(AMPLITUDE_LIB_OS "win") - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(AMPLITUDE_STATIC_LIB_NAME "libAmplitude.a") set(AMPLITUDE_STATIC_LIB_NAME_DEBUG "libAmplitude_d.a") @@ -77,13 +76,11 @@ if(WIN32) set(AMPLITUDE_SHARED_LIB_NAME_DEBUG "Amplitude_d.dll") endif() elseif(APPLE) - set(AMPLITUDE_LIB_OS "osx") set(AMPLITUDE_STATIC_LIB_NAME "libAmplitude.a") set(AMPLITUDE_STATIC_LIB_NAME_DEBUG "libAmplitude_d.a") set(AMPLITUDE_SHARED_LIB_NAME "libAmplitude.dylib") set(AMPLITUDE_SHARED_LIB_NAME_DEBUG "libAmplitude_d.dylib") else() - set(AMPLITUDE_LIB_OS "linux") set(AMPLITUDE_STATIC_LIB_NAME "libAmplitude.a") set(AMPLITUDE_STATIC_LIB_NAME_DEBUG "libAmplitude_d.a") set(AMPLITUDE_SHARED_LIB_NAME "libAmplitude.so") @@ -92,18 +89,18 @@ endif() add_library(SparkyStudios::Audio::Amplitude::SDK::Static STATIC IMPORTED GLOBAL) set_target_properties(SparkyStudios::Audio::Amplitude::SDK::Static PROPERTIES - IMPORTED_LOCATION "${AM_SDK_PATH}/lib/${AMPLITUDE_LIB_OS}/static/${AMPLITUDE_STATIC_LIB_NAME}" - IMPORTED_LOCATION_DEBUG "${AM_SDK_PATH}/lib/${AMPLITUDE_LIB_OS}/static/${AMPLITUDE_STATIC_LIB_NAME_DEBUG}" + IMPORTED_LOCATION "${AM_SDK_PATH}/lib/${AM_SDK_PLATFORM}/static/${AMPLITUDE_STATIC_LIB_NAME}" + IMPORTED_LOCATION_DEBUG "${AM_SDK_PATH}/lib/${AM_SDK_PLATFORM}/static/${AMPLITUDE_STATIC_LIB_NAME_DEBUG}" INTERFACE_INCLUDE_DIRECTORIES "${AM_SDK_PATH}/include" - INTERFACE_COMPILE_DEFINITIONS "AM_BUILDSYSTEM_STATIC" + INTERFACE_COMPILE_DEFINITIONS "AM_BUILDSYSTEM_STATIC ${AMPLITUDE_COMPILE_DEFINITIONS}" ) add_library(SparkyStudios::Audio::Amplitude::SDK::Shared SHARED IMPORTED GLOBAL) set_target_properties(SparkyStudios::Audio::Amplitude::SDK::Shared PROPERTIES - IMPORTED_LOCATION "${AM_SDK_PATH}/lib/${AMPLITUDE_LIB_OS}/shared/${AMPLITUDE_SHARED_LIB_NAME}" - IMPORTED_LOCATION_DEBUG "${AM_SDK_PATH}/lib/${AMPLITUDE_LIB_OS}/shared/${AMPLITUDE_SHARED_LIB_NAME_DEBUG}" + IMPORTED_LOCATION "${AM_SDK_PATH}/lib/${AM_SDK_PLATFORM}/shared/${AMPLITUDE_SHARED_LIB_NAME}" + IMPORTED_LOCATION_DEBUG "${AM_SDK_PATH}/lib/${AM_SDK_PLATFORM}/shared/${AMPLITUDE_SHARED_LIB_NAME_DEBUG}" INTERFACE_INCLUDE_DIRECTORIES "${AM_SDK_PATH}/include" - INTERFACE_COMPILE_DEFINITIONS "AM_BUILDSYSTEM_SHARED" + INTERFACE_COMPILE_DEFINITIONS "AM_BUILDSYSTEM_SHARED ${AMPLITUDE_COMPILE_DEFINITIONS}" ) if(WIN32) @@ -113,7 +110,7 @@ if(WIN32) endif() set_target_properties(SparkyStudios::Audio::Amplitude::SDK::Shared PROPERTIES - IMPORTED_IMPLIB "${AM_SDK_PATH}/lib/${AMPLITUDE_LIB_OS}/shared/${AMPLITUDE_STATIC_LIB_NAME}" - IMPORTED_IMPLIB_DEBUG "${AM_SDK_PATH}/lib/${AMPLITUDE_LIB_OS}/shared/${AMPLITUDE_STATIC_LIB_NAME_DEBUG}" + IMPORTED_IMPLIB "${AM_SDK_PATH}/lib/${AM_SDK_PLATFORM}/shared/${AMPLITUDE_STATIC_LIB_NAME}" + IMPORTED_IMPLIB_DEBUG "${AM_SDK_PATH}/lib/${AM_SDK_PLATFORM}/shared/${AMPLITUDE_STATIC_LIB_NAME_DEBUG}" ) endif() diff --git a/include/SparkyStudios/Audio/Amplitude/Core/Common/Platforms/UNIX/Config.h b/include/SparkyStudios/Audio/Amplitude/Core/Common/Platforms/UNIX/Config.h index d8845129..bd516945 100644 --- a/include/SparkyStudios/Audio/Amplitude/Core/Common/Platforms/UNIX/Config.h +++ b/include/SparkyStudios/Audio/Amplitude/Core/Common/Platforms/UNIX/Config.h @@ -91,11 +91,11 @@ static AM_INLINE std::string am_wstring_narrow(const std::wstring& str) #endif // AMPLITUDE_ASSERT Config -#ifdef AMPLITUDE_NO_ASSERTS +#ifdef AM_NO_ASSERTS #define AMPLITUDE_ASSERT(x) #else #include // assert #define AMPLITUDE_ASSERT(x) assert(x) -#endif // AMPLITUDE_NO_ASSERTS +#endif // AM_NO_ASSERTS #endif // _AM_CORE_COMMON_PLATFORMS_UNIX_CONFIG_H diff --git a/include/SparkyStudios/Audio/Amplitude/Core/Common/Platforms/Windows/Config.h b/include/SparkyStudios/Audio/Amplitude/Core/Common/Platforms/Windows/Config.h index b8800662..7b946562 100644 --- a/include/SparkyStudios/Audio/Amplitude/Core/Common/Platforms/Windows/Config.h +++ b/include/SparkyStudios/Audio/Amplitude/Core/Common/Platforms/Windows/Config.h @@ -91,7 +91,7 @@ static AM_INLINE std::string am_wstring_narrow(const std::wstring& str) #define AM_STRING_TO_OS_STRING(s) am_string_widen(s).c_str() // AMPLITUDE_ASSERT Config -#ifdef AMPLITUDE_NO_ASSERTS +#ifdef AM_NO_ASSERTS #define AMPLITUDE_ASSERT(x) #else #ifdef _MSC_VER @@ -117,6 +117,6 @@ static AM_INLINE std::string am_wstring_narrow(const std::wstring& str) #include // assert #define AMPLITUDE_ASSERT(x) assert(x) #endif // _MSC_VER -#endif // AMPLITUDE_NO_ASSERTS +#endif // AM_NO_ASSERTS #endif // _AM_CORE_COMMON_PLATFORMS_WINDOWS_CONFIG_H