Skip to content

Commit

Permalink
chore: Improve build system.
Browse files Browse the repository at this point in the history
Signed-off-by: Axel Nana <[email protected]>
  • Loading branch information
na2axl committed Sep 27, 2024
1 parent 4ab8e7a commit a580fd1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$<$<CONFIG:RELEASE>:AM_NO_MEMORY_STATS>")
target_compile_definitions(${build_type} PUBLIC "$<$<CONFIG:RELEASE>:AM_NO_ASSERTS>")

target_link_libraries(${build_type}
PRIVATE
Expand Down
23 changes: 10 additions & 13 deletions cmake/FindAmplitudeAudioSDK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -54,7 +55,7 @@ message(STATUS "Using Amplitude Audio SDK at ${AM_SDK_PATH}")
set(AmplitudeAudioSDK_FOUND TRUE)

set(AMPLITUDE_COMPILE_DEFINITIONS
$<IF:$<CONFIG:Release>,AMPLITUDE_NO_ASSERTS,>
$<IF:$<CONFIG:Release>,AM_NO_ASSERTS,>
$<IF:$<CONFIG:Release>,AM_NO_MEMORY_STATS,>
)

Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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)
Expand All @@ -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()
Original file line number Diff line number Diff line change
Expand Up @@ -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 <cassert> // assert
#define AMPLITUDE_ASSERT(x) assert(x)
#endif // AMPLITUDE_NO_ASSERTS
#endif // AM_NO_ASSERTS

#endif // _AM_CORE_COMMON_PLATFORMS_UNIX_CONFIG_H
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -117,6 +117,6 @@ static AM_INLINE std::string am_wstring_narrow(const std::wstring& str)
#include <cassert> // 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

0 comments on commit a580fd1

Please sign in to comment.