Skip to content

Commit 1fc2ffc

Browse files
Include export header conditionally when compiling with CMake
Signed-off-by: Gabriel Cuendet <[email protected]> Signed-off-by: Gabriel Cuendet <[email protected]>
1 parent 592d869 commit 1fc2ffc

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

cpp/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ target_link_libraries(${lib_name}
2929
core
3030
)
3131

32+
target_compile_definitions(${lib_name} PUBLIC "USE_CMAKE_GENERATED_EXPORT_HEADER")
33+
3234
include("GenerateExportHeader")
3335
generate_export_header(${lib_name}
3436
EXPORT_MACRO_NAME TORCHTRT_API

cpp/include/torch_tensorrt/macros.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@
77
*/
88
#pragma once
99

10+
#if defined(USE_CMAKE_GENERATED_EXPORT_HEADER)
11+
#include <torch_tensorrt_export.h>
12+
#else
1013
#if defined(__GNUC__)
1114
#define TORCHTRT_API __attribute__((__visibility__("default")))
1215
#define TORCHTRT_HIDDEN __attribute__((__visibility__("hidden")))
1316
#else
14-
// This can be used also if defined(__GNUC__) but is generated by CMake
15-
// and will be missing when compiling with Bazel
16-
#include <torch_tensorrt_export.h>
17+
#define TORCHTRT_API
18+
#define TORCHTRT_HIDDEN
1719
#endif // defined(__GNUC__)
20+
#endif // defined(USE_CMAKE_GENERATED_EXPORT_HEADER)
1821

1922
// Does this need to be gaurded or something?
2023
#define XSTR(x) #x

0 commit comments

Comments
 (0)