diff --git a/cmake/oneflow.cmake b/cmake/oneflow.cmake index 205224541a2..52bb18ed6b5 100644 --- a/cmake/oneflow.cmake +++ b/cmake/oneflow.cmake @@ -292,11 +292,8 @@ list(APPEND oneflow_third_party_libs LLVMSupportWithHeader) include(op_schema) -get_property(EXTERNAL_INCLUDE_DIRS GLOBAL PROPERTY EXTERNAL_INCLUDE_DIRS) get_property(EXTERNAL_TARGETS GLOBAL PROPERTY EXTERNAL_TARGETS) -target_include_directories(oneflow PRIVATE ${EXTERNAL_INCLUDE_DIRS}) - if(APPLE) set(of_libs -Wl,-force_load oneflow of_op_schema) target_link_libraries(oneflow of_protoobj of_functional_obj ${oneflow_third_party_libs}) diff --git a/cmake/util.cmake b/cmake/util.cmake index a69128f416e..4ab55d6bb55 100644 --- a/cmake/util.cmake +++ b/cmake/util.cmake @@ -287,3 +287,13 @@ function(checkDirAndAppendSlash) endif() endfunction() + +function(mark_targets_as_system) + # TODO(daquexian): update this function once https://gitlab.kitware.com/cmake/cmake/-/merge_requests/7308 + # and its following PRs are merged in cmake v3.25. + foreach(target ${ARGV}) + get_target_property(include_dir ${target} INTERFACE_INCLUDE_DIRECTORIES) + set_target_properties(${target} PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES + "${include_dir}") + endforeach() +endfunction() diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index db603be09b6..4d5f3fae257 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -1,16 +1,12 @@ set(EXTERNAL_TARGETS) -set(EXTERNAL_INCLUDE_DIRS) if (CPU_THREADING_RUNTIME STREQUAL "TBB") add_subdirectory(onetbb) - get_property(TBB_INCLUDE_DIRS GLOBAL PROPERTY TBB_INCLUDE_DIRS) - list(APPEND EXTERNAL_INCLUDE_DIRS ${TBB_INCLUDE_DIRS}) list(APPEND EXTERNAL_TARGETS tbb) endif() add_subdirectory(robin-hood-hashing) -get_property(ROBIN_HOOD_HASHING_INCLUDE_DIR GLOBAL PROPERTY ROBIN_HOOD_HASHING_INCLUDE_DIR) -list(APPEND EXTERNAL_INCLUDE_DIRS ${ROBIN_HOOD_HASHING_INCLUDE_DIR}) +list(APPEND EXTERNAL_TARGETS robin_hood) +mark_targets_as_system(${EXTERNAL_TARGETS}) set_property(GLOBAL PROPERTY EXTERNAL_TARGETS ${EXTERNAL_TARGETS}) -set_property(GLOBAL PROPERTY EXTERNAL_INCLUDE_DIRS ${EXTERNAL_INCLUDE_DIRS}) diff --git a/external/onetbb/CMakeLists.txt b/external/onetbb/CMakeLists.txt index 6d83773e58f..399fab32256 100644 --- a/external/onetbb/CMakeLists.txt +++ b/external/onetbb/CMakeLists.txt @@ -15,7 +15,6 @@ set(BUILD_SHARED_LIBS ON) set(CMAKE_POLICY_DEFAULT_CMP0079 NEW) FetchContent_MakeAvailable(tbb) -set_property(GLOBAL PROPERTY TBB_INCLUDE_DIRS "${tbb_SOURCE_DIR}/include") install(TARGETS tbb tbbmalloc tbbmalloc_proxy COMPONENT OneFlowTBB) install(DIRECTORY ${tbb_SOURCE_DIR}/include DESTINATION ${ONETBB_INSTALL_DIR} COMPONENT OneFlowTBB) diff --git a/external/robin-hood-hashing/CMakeLists.txt b/external/robin-hood-hashing/CMakeLists.txt index e079ad6b36f..d60277a1a1f 100644 --- a/external/robin-hood-hashing/CMakeLists.txt +++ b/external/robin-hood-hashing/CMakeLists.txt @@ -1,14 +1,7 @@ include(FetchContent) FetchContent_Declare( robin_hood_hashing + URL ${ROBIN_HOOD_HASHING_URL} + URL_HASH MD5=${ROBIN_HOOD_HASHING_MD5} ) -FetchContent_GetProperties(robin_hood_hashing) - -if(NOT robin_hood_hashing_POPULATED) - FetchContent_Populate(robin_hood_hashing - URL ${ROBIN_HOOD_HASHING_URL} - URL_HASH MD5=${ROBIN_HOOD_HASHING_MD5} - ) -endif() - -set_property(GLOBAL PROPERTY ROBIN_HOOD_HASHING_INCLUDE_DIR "${robin_hood_hashing_SOURCE_DIR}/src/include") +FetchContent_MakeAvailable(robin_hood_hashing)