@@ -65,11 +65,6 @@ endif()
65
65
# ---[ Caffe2 build
66
66
# Note: the folders that are being commented out have not been properly
67
67
# addressed yet.
68
- # TODO(orionr): Enable all of this for Windows DLL when we
69
- # can figure out how to get it to build
70
- if (MSVC AND BUILD_SHARED_LIBS )
71
- add_subdirectory (utils)
72
- else ()
73
68
add_subdirectory (proto)
74
69
add_subdirectory (contrib)
75
70
add_subdirectory (core)
@@ -101,7 +96,6 @@ add_subdirectory(sgd)
101
96
add_subdirectory (share)
102
97
# add_subdirectory(test) # todo: use caffe2_gtest_main instead of gtest_main because we will need to call GlobalInit
103
98
add_subdirectory (transforms)
104
- endif ()
105
99
106
100
# Advanced: if we have white list specified, we will do intersections for all
107
101
# main lib srcs.
@@ -166,16 +160,8 @@ if (FALSE)
166
160
endif ()
167
161
168
162
# ---[ List of libraries to link with
169
- # TODO(orionr): Enable all of this for Windows DLL when we
170
- # can figure out how to get it to build
171
- if (NOT (MSVC AND BUILD_SHARED_LIBS ))
172
163
add_library (caffe2_protos STATIC $<TARGET_OBJECTS:Caffe2_PROTO>)
173
164
add_dependencies (caffe2_protos Caffe2_PROTO)
174
- else ()
175
- # Do not include caffe2 or caffe protos, but rather have it only be
176
- # a library to attach local protobuf.
177
- add_library (caffe2_protos STATIC utils/dummy.cpp)
178
- endif ()
179
165
# If we are going to link protobuf locally inside caffe2 libraries, what we will do is
180
166
# to create a helper static library that always contains libprotobuf source files, and
181
167
# link the caffe2 related dependent libraries to it.
@@ -341,7 +327,7 @@ if(USE_CUDA)
341
327
# NB: This must be target_compile_definitions, not target_compile_options,
342
328
# as the latter is not respected by nvcc
343
329
if (MSVC )
344
- target_compile_definitions (caffe2_gpu PRIVATE "-DCAFFE2_BUILD_MAIN_LIB " )
330
+ target_compile_definitions (caffe2_gpu PRIVATE "-DCAFFE2_CUDA_BUILD_MAIN_LIB " )
345
331
endif ()
346
332
347
333
# Set standard properties on the target
@@ -401,9 +387,6 @@ if ($ENV{WERROR})
401
387
endif ()
402
388
403
389
# ---[ Test binaries.
404
- # TODO(orionr): Enable all of this for Windows DLL when we
405
- # can figure out how to get it to build
406
- if (NOT (MSVC AND BUILD_SHARED_LIBS ))
407
390
if (BUILD_TEST)
408
391
set (Caffe2_ALL_TEST_SRCS ${Caffe2_CPU_TEST_SRCS} )
409
392
if (USE_CUDA)
@@ -414,6 +397,8 @@ if (BUILD_TEST)
414
397
get_filename_component (test_name ${test_src} NAME_WE )
415
398
add_executable (${test_name} "${test_src} " )
416
399
target_link_libraries (${test_name} ${Caffe2_MAIN_LIBS} gtest_main)
400
+ target_include_directories (${test_name} PRIVATE $<INSTALL_INTERFACE:include >)
401
+ target_include_directories (${test_name} PRIVATE ${Caffe2_CPU_INCLUDE} )
417
402
if (${CMAKE_MAJOR_VERSION} .${CMAKE_MINOR_VERSION} GREATER 3.0)
418
403
target_compile_features (${test_name} PRIVATE cxx_range_for)
419
404
endif ()
@@ -429,6 +414,8 @@ if (BUILD_TEST)
429
414
get_filename_component (test_name ${test_src} NAME_WE )
430
415
hip_add_executable(${test_name} "${test_src} " )
431
416
target_link_libraries (${test_name} ${Caffe2_MAIN_LIBS} gtest_main)
417
+ target_include_directories (${test_name} PRIVATE $<INSTALL_INTERFACE:include >)
418
+ target_include_directories (${test_name} PRIVATE ${Caffe2_CPU_INCLUDE} )
432
419
if (${CMAKE_MAJOR_VERSION} .${CMAKE_MINOR_VERSION} GREATER 3.0)
433
420
target_compile_features (${test_name} PRIVATE cxx_range_for)
434
421
endif ()
@@ -439,13 +426,13 @@ if (BUILD_TEST)
439
426
endforeach ()
440
427
endif ()
441
428
endif ()
442
- endif ()
443
429
444
430
set (__aten_test_dir "test/aten" )
445
431
if (NOT USE_ROCM)
446
432
foreach (test_src ${ATen_CPU_TEST_SRCS} )
447
433
get_filename_component (test_name ${test_src} NAME_WE )
448
434
add_executable (${test_name} "${test_src} " )
435
+ target_include_directories (${test_name} PRIVATE $<INSTALL_INTERFACE:include >)
449
436
target_include_directories (${test_name} PRIVATE ${Caffe2_CPU_INCLUDE} )
450
437
target_include_directories (${test_name} SYSTEM PRIVATE ${Caffe2_DEPENDENCY_INCLUDE} )
451
438
target_link_libraries (${test_name} ${Caffe2_MAIN_LIBS} )
@@ -457,6 +444,7 @@ if (NOT USE_ROCM)
457
444
foreach (test_src ${ATen_CUDA_TEST_SRCS} )
458
445
get_filename_component (test_name ${test_src} NAME_WE )
459
446
torch_cuda_based_add_executable(${test_name} "${test_src} " )
447
+ target_include_directories (${test_name} PRIVATE $<INSTALL_INTERFACE:include >)
460
448
target_include_directories (${test_name} PRIVATE ${Caffe2_CPU_INCLUDE} )
461
449
target_include_directories (${test_name} SYSTEM PRIVATE ${Caffe2_DEPENDENCY_INCLUDE} )
462
450
target_link_libraries (${test_name} ${Caffe2_MAIN_LIBS} )
@@ -466,9 +454,6 @@ if (NOT USE_ROCM)
466
454
endif ()
467
455
endif ()
468
456
469
- # TODO(orionr): Enable all of this for Windows DLL when we
470
- # can figure out how to get it to build
471
- if (NOT (MSVC AND BUILD_SHARED_LIBS ))
472
457
if (BUILD_PYTHON)
473
458
# Python site-packages
474
459
# Get canonical directory for python site packages (relative to install
@@ -525,6 +510,9 @@ if (BUILD_PYTHON)
525
510
if (APPLE )
526
511
set_target_properties (caffe2_pybind11_state PROPERTIES LINK_FLAGS "-undefined dynamic_lookup" )
527
512
endif ()
513
+ target_include_directories (caffe2_pybind11_state PRIVATE $<INSTALL_INTERFACE:include >)
514
+ target_include_directories (caffe2_pybind11_state PRIVATE ${Caffe2_CPU_INCLUDE} )
515
+
528
516
target_link_libraries (
529
517
caffe2_pybind11_state caffe2_library)
530
518
if (WIN32 )
@@ -547,6 +535,8 @@ if (BUILD_PYTHON)
547
535
if (APPLE )
548
536
set_target_properties (caffe2_pybind11_state_gpu PROPERTIES LINK_FLAGS "-undefined dynamic_lookup" )
549
537
endif ()
538
+ target_include_directories (caffe2_pybind11_state_gpu PRIVATE $<INSTALL_INTERFACE:include >)
539
+ target_include_directories (caffe2_pybind11_state_gpu PRIVATE ${Caffe2_CPU_INCLUDE} )
550
540
target_link_libraries (
551
541
caffe2_pybind11_state_gpu caffe2_library caffe2_gpu_library)
552
542
if (WIN32 )
@@ -570,6 +560,8 @@ if (BUILD_PYTHON)
570
560
if (APPLE )
571
561
set_target_properties (caffe2_pybind11_state_hip PROPERTIES LINK_FLAGS "-undefined dynamic_lookup" )
572
562
endif ()
563
+ target_include_directories (caffe2_pybind11_state_hip PRIVATE $<INSTALL_INTERFACE:include >)
564
+ target_include_directories (caffe2_pybind11_state_hip PRIVATE ${Caffe2_CPU_INCLUDE} )
573
565
target_link_libraries (
574
566
caffe2_pybind11_state_hip caffe2_library caffe2_hip_library)
575
567
if (WIN32 )
@@ -657,7 +649,6 @@ if (BUILD_PYTHON)
657
649
install (DIRECTORY ${CMAKE_BINARY_DIR} /caffe2 DESTINATION ${PYTHON_LIB_REL_PATH}
658
650
FILES_MATCHING PATTERN "*.py" )
659
651
endif ()
660
- endif ()
661
652
662
653
# Finally, set the Caffe2_MAIN_LIBS variable in the parent scope.
663
654
set (Caffe2_MAIN_LIBS ${Caffe2_MAIN_LIBS} PARENT_SCOPE)
0 commit comments