Skip to content

Commit

Permalink
Download NVAPI headers using CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
sasha0552 authored Sep 4, 2024
1 parent cd1b9c8 commit ea15d89
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 69 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ jobs:
method: network
sub-packages: '["cudart", "nvcc", "nvml_dev"]'

- if: runner.os == 'Linux'
name: Install NVAPI headers on Linux
run: ./nvapi.sh

- if: runner.os == 'Windows'
name: Install NVAPI headers on Windows
run: .\nvapi.ps1

- name: Configure project
run: >
cmake
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
build/
nvapi/
nvapi.tar
18 changes: 16 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
# Specify the minimum required version of CMake
cmake_minimum_required(VERSION 3.17)
cmake_minimum_required(VERSION 3.16)

# Include the FetchContent module
include(FetchContent)

# Define the project name and programming language
project(nvidia-pstated C)

# Find the CUDAToolkit package
find_package(CUDAToolkit REQUIRED COMPONENTS nvml)

# Declare the nvapi package
FetchContent_Declare(
nvapi

URL https://download.nvidia.com/XFree86/nvapi-open-source-sdk/R555-OpenSource.tar
URL_HASH SHA256=71339c274a6a633f19b6bd358c7f3045063c6bc106b7dc488aaa7360a6d2b9d7
)

# Download and make the nvapi content available for use
FetchContent_MakeAvailable(nvapi)

# Define the executable target
add_executable(nvidia-pstated
src/main.c
Expand All @@ -16,7 +30,7 @@ add_executable(nvidia-pstated

# Include directories for the target
target_include_directories(nvidia-pstated SYSTEM PRIVATE
nvapi
${nvapi_SOURCE_DIR}/R555-OpenSource
)

# Link libraries
Expand Down
19 changes: 1 addition & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,10 @@ Download the latest version of the executable for your OS from [releases](https:

* CMake
* CUDA toolkit
* Wget (only on Linux)

### Linux
### Building

```sh
# Download NVAPI headers
./nvapi.sh

# Configure
cmake -B build

# Build
cmake --build build
```

### Windows

```sh
# Download NVAPI headers
.\nvapi.ps1

# Configure
cmake -B build

Expand Down
18 changes: 0 additions & 18 deletions nvapi.ps1

This file was deleted.

21 changes: 0 additions & 21 deletions nvapi.sh

This file was deleted.

0 comments on commit ea15d89

Please sign in to comment.