| 1 |
cmake_minimum_required(VERSION 3.10) |
| 2 |
|
| 3 |
if (APPLE) |
| 4 |
set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "OSX Architectures") |
| 5 |
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9") |
| 6 |
option(BUILD_FRAMEWORK "Build a Mac OS X framework instead of a shared library" ON) |
| 7 |
endif () |
| 8 |
|
| 9 |
project(SAASound) |
| 10 |
|
| 11 |
if (MSVC) |
| 12 |
add_definitions(-DUNICODE -D_UNICODE) |
| 13 |
endif () |
| 14 |
|
| 15 |
set(EXTERNAL_CLK_HZ "8000000" CACHE STRING "External clock in Hz") |
| 16 |
option(SAAFREQ_FIXED_CLOCKRATE "Use precomputed frequency table, external clock is locked" OFF) |
| 17 |
set(SAMPLE_RATE_HZ "44100" CACHE STRING "Output sample rate in Hz") |
| 18 |
set(DEFAULT_OVERSAMPLE "6" CACHE STRING "Default oversample factor") |
| 19 |
set(DEFAULT_UNBOOSTED_MULTIPLIER "11.3" CACHE STRING "Default scaling factor (before volume boost), not configurable in SAAConfig.cfg") |
| 20 |
set(DEFAULT_BOOST "1" CACHE STRING "Default volume boost multiplier, configurable in SAAConfig.cfg") |
| 21 |
option(DEBUGSAA "Create a text log of all register:value writes as well as a raw PCM output file" OFF) |
| 22 |
set(DEBUG_SAA_REGISTER_LOG "debugsaa.txt" CACHE STRING "Path to register log file (if DEBUGSAA)") |
| 23 |
set(DEBUG_SAA_PCM_LOG "debugsaa.pcm" CACHE STRING "Path to raw PCM output file (if DEBUGSAA)") |
| 24 |
option(USE_CONFIG_FILE "Compile support for loading a config file on startup (SAAsound.cfg)" ON) |
| 25 |
set(CONFIG_FILE_PATH "SAASound.cfg" CACHE STRING "Path to config file (if USE_CONFIG_FILE)") |
| 26 |
|
| 27 |
#include(CheckStructHasMember) |
| 28 |
#CHECK_STRUCT_HAS_MEMBER("struct dirent" d_type dirent.h HAVE_STRUCT_DIRENT_D_TYPE LANGUAGE CXX) |
| 29 |
|
| 30 |
if (MSVC) |
| 31 |
set(RESOURCES resources/SAASound.def) |
| 32 |
endif () |
| 33 |
|
| 34 |
add_library(SAASound SHARED) |
| 35 |
set(API_HEADERS include/SAASound.h) |
| 36 |
target_sources(SAASound |
| 37 |
PRIVATE |
| 38 |
src/defns.h |
| 39 |
src/SAAAmp.cpp |
| 40 |
src/SAAAmp.h |
| 41 |
src/SAADevice.cpp |
| 42 |
src/SAADevice.h |
| 43 |
src/SAAEnv.cpp |
| 44 |
src/SAAEnv.h |
| 45 |
src/SAAFreq.cpp |
| 46 |
src/SAAFreq.h |
| 47 |
src/SAAImpl.cpp |
| 48 |
src/SAAImpl.h |
| 49 |
src/SAANoise.cpp |
| 50 |
src/SAANoise.h |
| 51 |
src/SAASndC.cpp |
| 52 |
src/SAASound.cpp |
| 53 |
src/types.h |
| 54 |
src/SAASndC.h |
| 55 |
${RESOURCES} |
| 56 |
${API_HEADERS} |
| 57 |
) |
| 58 |
|
| 59 |
if (USE_CONFIG_FILE) |
| 60 |
target_sources(SAASound |
| 61 |
PRIVATE |
| 62 |
src/SAAConfig.cpp |
| 63 |
src/SAAConfig.h |
| 64 |
src/minIni/minIni.h |
| 65 |
src/minIni/minIni.c |
| 66 |
src/minIni/minGlue.h |
| 67 |
) |
| 68 |
endif () |
| 69 |
|
| 70 |
set_target_properties(SAASound PROPERTIES |
| 71 |
VERSION 3.5 |
| 72 |
SOVERSION 3 |
| 73 |
CXX_STANDARD 11) |
| 74 |
|
| 75 |
target_include_directories(SAASound PRIVATE |
| 76 |
${CMAKE_BINARY_DIR} |
| 77 |
PUBLIC |
| 78 |
include) |
| 79 |
|
| 80 |
if (APPLE AND BUILD_FRAMEWORK) |
| 81 |
set_target_properties(SAASound PROPERTIES |
| 82 |
OUTPUT_NAME SAASound |
| 83 |
FRAMEWORK TRUE |
| 84 |
FRAMEWORK_VERSION C |
| 85 |
MACOSX_FRAMEWORK_IDENTIFIER com.beermex) |
| 86 |
set_source_files_properties(${API_HEADERS} PROPERTIES |
| 87 |
MACOSX_PACKAGE_LOCATION Headers) |
| 88 |
endif () |
| 89 |
|
| 90 |
configure_file(src/config.h.in ${CMAKE_BINARY_DIR}/saasound_cmake_config.h) |
| 91 |
target_compile_definitions(SAASound PRIVATE HAVE_CONFIG_H=1) |
| 92 |
|
| 93 |
install(TARGETS SAASound |
| 94 |
ARCHIVE DESTINATION lib |
| 95 |
LIBRARY DESTINATION lib |
| 96 |
RUNTIME DESTINATION bin |
| 97 |
FRAMEWORK DESTINATION lib |
| 98 |
PUBLIC_HEADER DESTINATION include) |
| 99 |
|
| 100 |
if (NOT APPLE OR NOT BUILD_FRAMEWORK) |
| 101 |
install(FILES ${API_HEADERS} DESTINATION include) |
| 102 |
endif () |