wgpu/examples/compute/CMakeLists.txt
Aaron Loucks 5ca57374f6 Check power/battery status when selecting adaptors
PowerPreference::Default will now prefer discrete GPUs
when on AC power and will prefer integrated GPUs while
on battery power (i.e. the battery is discharging).
2020-01-12 17:26:54 -05:00

35 lines
1.2 KiB
CMake

cmake_minimum_required(VERSION 3.11b)
project(compute)
set(TARGET_NAME compute)
add_executable(compute main.c ../framework.c)
if(MSVC)
add_definitions(-DWGPU_TARGET=WGPU_TARGET_WINDOWS)
target_compile_options(${TARGET_NAME} PRIVATE /W4)
set(OS_LIBRARIES "userenv" "ws2_32" "Dwmapi" "dbghelp" "d3dcompiler" "D3D12" "D3D11" "DXGI" "setupapi")
elseif(APPLE)
add_definitions(-DWGPU_TARGET=WGPU_TARGET_MACOS)
set(OS_LIBRARIES "-framework Cocoa" "-framework CoreVideo" "-framework IOKit" "-framework QuartzCore")
target_compile_options(${TARGET_NAME} PRIVATE -x objective-c)
else(MSVC)
add_definitions(-DWGPU_TARGET=WGPU_TARGET_LINUX)
target_compile_options(${TARGET_NAME} PRIVATE -Wall -Wextra -pedantic)
endif(MSVC)
find_package(glfw3 3.3 REQUIRED
HINTS "$ENV{GLFW3_INSTALL_DIR}"
)
find_library(WGPU_LIBRARY wgpu_native
HINTS "${CMAKE_CURRENT_SOURCE_DIR}/../../target/debug"
)
target_include_directories(${TARGET_NAME} PUBLIC $ENV{GLFW3_INCLUDE_DIR})
target_include_directories(${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../ffi)
target_include_directories(${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../)
target_link_libraries(${TARGET_NAME} glfw ${WGPU_LIBRARY} ${OS_LIBRARIES})