cmake_minimum_required(VERSION 3.5)
project(volcontrol)

if(CMAKE_SYSTEM_NAME MATCHES Darwin)
    add_executable(volcontrol volcontrol.cpp macos/volcontrol_impl.cpp)
    target_include_directories(volcontrol PRIVATE ${CMAKE_CURRENT_LIST_DIR}
                                                  macos)
    target_compile_options(volcontrol PRIVATE -Wall -Wextra -Werror -std=c++11)
    target_link_libraries(volcontrol PRIVATE "-framework AudioToolbox"
                                             "-framework CoreAudio"
                                             "-framework CoreFoundation")
elseif(CMAKE_SYSTEM_NAME MATCHES Windows)
    # CMake wrapper around msbuild command on Windows
    add_custom_target(volcontrol_win
                      msbuild volcontrol.vcxproj /property:Configuration=Release /property:Platform=x64
                      WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
    add_custom_target(volcontrol ALL
                      ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_DIR}/x64/Release/volcontrol.exe ${CMAKE_CURRENT_BINARY_DIR}
                      DEPENDS volcontrol_win)
else()
    message(FATAL_ERROR "CMake build of volcontrol not supported on ${CMAKE_SYSTEM_NAME}")
endif()
