#
# Copyright (c) 2019, NVIDIA CORPORATION.  All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#

project(WaveWorks_example)

cmake_minimum_required(VERSION 3.15)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

#
# Build options
#
option(BUILD_PACKAGE_MODE "Enable to configure installation & packaging." ON)

set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin")
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin")

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

#
# Media
#

include(cmake/download_media.cmake)

#
# Dependencies
#

set(CMAKE_PREFIX_PATH "lib/cmake")

find_package(Vulkan)

find_package(glfw3)
find_package(imgui)
find_package(nvrhi REQUIRED)
find_package(waveworks REQUIRED)
find_package(nvrhi-applib REQUIRED)

#
# General compiler settings
#

if(MSVC)

    # Turn on all warnings
    list(APPEND WW_COMPILER_FLAGS /Wall)

    list(APPEND WW_COMPILER_FLAGS

        # Use warning level recommended for production purposes.
        /W3

        # Treat all compiler warnings as errors.
        #/WX

        # Make sure WinDef.h does not define min and max macros which
        # will conflict with std::min() and std::max().
        /DNOMINMAX

        # Make sure the constants in <math.h> get defined.
        /D_USE_MATH_DEFINES

        # packaged libs are built in release mode
        /D_HAS_ITERATOR_DEBUGGING=0
        /D_ITERATOR_DEBUG_LEVEL=0
    )

    # XXXX force /MT to match the packaged libs - should be fixable
    # by exporting debug versions
    set(CMAKE_CXX_FLAGS_DEBUG "/MD") 

endif()

add_definitions(${WW_COMPILER_FLAGS})

#
# Build example
#

include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include")

add_subdirectory(src)

# copy the waveworks dll to the build folder (could be done as part of package install)
file(INSTALL "${CMAKE_SOURCE_DIR}/bin/NVWaveWorks_shared.dll" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/bin/Debug/")
file(INSTALL "${CMAKE_SOURCE_DIR}/bin/NVWaveWorks_shared.dll" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/bin/Release/")

# XXXX apparently not working
#set_property(TARGET example_d3d11_static PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")

