Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

target based external libraries #8421

Merged
merged 6 commits into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions cmake/oneflow.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
10 changes: 10 additions & 0 deletions cmake/util.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
8 changes: 2 additions & 6 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
1 change: 0 additions & 1 deletion external/onetbb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 3 additions & 10 deletions external/robin-hood-hashing/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)