Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ endif()

find_package(Torch REQUIRED)

# Generate configuration header
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/src/csrc/include/torchfort_config.h.in
${CMAKE_BINARY_DIR}/include/torchfort_config.h
@ONLY
)

# yaml-cpp
#find_package(yaml-cpp REQUIRED)
find_path(YAML_CPP_INCLUDE_DIR REQUIRED
Expand Down Expand Up @@ -170,6 +177,7 @@ target_include_directories(${PROJECT_NAME}
${CMAKE_CURRENT_SOURCE_DIR}/src/csrc/include
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/csrc/include>
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>
)
target_link_libraries(${PROJECT_NAME} PRIVATE ${TORCH_LIBRARIES})
Expand Down Expand Up @@ -209,6 +217,12 @@ install(
INCLUDES DESTINATION ${CMAKE_INSTALL_PREFIX}/include
)

# Install generated configuration header
install(
FILES ${CMAKE_BINARY_DIR}/include/torchfort_config.h
DESTINATION ${CMAKE_INSTALL_PREFIX}/include
)

# Fortran library and module
if (TORCHFORT_BUILD_FORTRAN)

Expand Down
3 changes: 2 additions & 1 deletion src/csrc/include/torchfort.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
*/

#pragma once
#include "torchfort_config.h"
#include <stdint.h>
#ifdef ENABLE_GPU
#if TORCHFORT_ENABLE_GPU
#include <cuda_runtime.h>
#else
typedef void* cudaStream_t;
Expand Down
22 changes: 22 additions & 0 deletions src/csrc/include/torchfort_config.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2023-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

/* Define to 1 if TorchFort was built with GPU support */
#cmakedefine01 TORCHFORT_ENABLE_GPU

3 changes: 2 additions & 1 deletion src/csrc/include/torchfort_rl.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
*/

#pragma once
#include "torchfort_config.h"
#include "torchfort_enums.h"
#ifdef ENABLE_GPU
#if TORCHFORT_ENABLE_GPU
#include <cuda_runtime.h>
#else
typedef void* cudaStream_t;
Expand Down