Skip to content

Commit e01b73b

Browse files
achalshah20Rob Kunkle
authored andcommitted
Stop propagating std flags to downstream gcc/nvcc (pytorch#10098)
Summary: When we directly use -std=c++11, it propagates to the downstream applications. Problems: 1. Gcc flags propagating to nvcc. 2. nvcc flags propagating to nvcc. (Which throws an error like redeclaration of std flag) This PR will fix these propagation issues! Similar problem: FloopCZ/tensorflow_cc#92 CGAL/cgal#2775 Requires: Cmake 3.12 Pull Request resolved: pytorch#10098 Differential Revision: D9187110 Pulled By: ezyang fbshipit-source-id: 0e00e6aa3119c77a5b3ea56992ef3bbfecd71d80
1 parent ad8f897 commit e01b73b

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

caffe2/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,13 @@ target_include_directories(caffe2 PRIVATE ${Caffe2_CPU_INCLUDE})
223223
target_include_directories(caffe2 SYSTEM PRIVATE "${Caffe2_DEPENDENCY_INCLUDE}")
224224
# Set standard properties on the target
225225
aten_set_target_props(caffe2)
226+
227+
if (MSVC)
226228
target_compile_options(caffe2 INTERFACE "-std=c++11")
229+
else()
230+
target_compile_options(caffe2 INTERFACE "$<$<COMPILE_LANGUAGE:CXX>:-std=c++11>")
231+
endif()
232+
227233
target_compile_options(caffe2 PRIVATE "-DCAFFE2_BUILD_MAIN_LIB")
228234
if (MSVC AND NOT BUILD_SHARED_LIBS)
229235
# Note [Supporting both static and dynamic libraries on Window]

cmake/public/threads.cmake

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ if(THREADS_FOUND AND NOT TARGET Threads::Threads)
55
add_library(Threads::Threads INTERFACE IMPORTED)
66

77
if(THREADS_HAVE_PTHREAD_ARG)
8-
set_property(
9-
TARGET Threads::Threads
10-
PROPERTY INTERFACE_COMPILE_OPTIONS "-pthread")
8+
set_property(TARGET Threads::Threads
9+
PROPERTY INTERFACE_COMPILE_OPTIONS "-pthread")
1110
endif()
1211

1312
if(CMAKE_THREAD_LIBS_INIT)
14-
set_property(
15-
TARGET Threads::Threads
16-
PROPERTY INTERFACE_LINK_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}")
13+
set_property(TARGET Threads::Threads
14+
PROPERTY INTERFACE_LINK_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}")
1715
endif()
18-
endif()
16+
endif()

0 commit comments

Comments
 (0)