@@ -12,6 +12,7 @@ option(ALLOW_CUDA "When building the shared library, try to find and use CUDA."
12
12
option (TENSORFLOW_STATIC "Build static library." ON )
13
13
set (TENSORFLOW_TAG "v1.15.0" CACHE STRING "The tensorflow release tag to be checked out (default v1.15.0)." )
14
14
option (SYSTEM_PROTOBUF "Use system protobuf instead of static protobuf from contrib/makefile." OFF )
15
+ set (TARGET_CXX_STANDARD "cxx_std_11" CACHE STRING "C++ standard to be enforced when linking to TensorflowCC targets (e.g., cxx_std_11)." )
15
16
16
17
# -------------
17
18
# CMake Options
@@ -23,6 +24,9 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib")
23
24
include (CMakePackageConfigHelpers )
24
25
set (CMAKECFG_INSTALL_DIR lib/cmake/TensorflowCC )
25
26
27
+ set_property (CACHE TARGET_CXX_STANDARD PROPERTY STRINGS
28
+ "cxx_std_11" "cxx_std_14" "cxx_std_17" "cxx_std_20" )
29
+
26
30
# Configure the build_tensorflow script.
27
31
configure_file ("cmake/build_tensorflow.sh.in" "build_tensorflow.sh" @ONLY )
28
32
@@ -58,10 +62,8 @@ endif()
58
62
59
63
if (TENSORFLOW_SHARED )
60
64
add_library (tensorflow_cc_shared INTERFACE )
61
- target_compile_options (
62
- tensorflow_cc_shared INTERFACE
63
- "$<$<COMPILE_LANGUAGE:CXX>:-std=c++11>"
64
- )
65
+ target_compile_features (tensorflow_cc_shared INTERFACE ${TARGET_CXX_STANDARD} )
66
+
65
67
add_dependencies (
66
68
tensorflow_cc_shared
67
69
tensorflow_shared
@@ -109,10 +111,8 @@ endif()
109
111
110
112
if (TENSORFLOW_STATIC )
111
113
add_library (tensorflow_cc_static INTERFACE )
112
- target_compile_options (
113
- tensorflow_cc_static INTERFACE
114
- "$<$<COMPILE_LANGUAGE:CXX>:-std=c++11>"
115
- )
114
+ target_compile_features (tensorflow_cc_static INTERFACE ${TARGET_CXX_STANDARD} )
115
+
116
116
add_dependencies (
117
117
tensorflow_cc_static
118
118
tensorflow_static
0 commit comments