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

CMake: Refactor Build Folder Structure #22622

Open
wants to merge 2 commits into
base: fs-eire/webgpu-ep
Choose a base branch
from
Open
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
24 changes: 22 additions & 2 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ cmake_policy(SET CMP0104 OLD)
# Enable Hot Reload for MSVC compilers if supported.
cmake_policy(SET CMP0141 NEW)

# Disable subbuild system with CMP0168 NEW
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.30")
cmake_policy(SET CMP0168 NEW)
endif()

# Project
project(onnxruntime C CXX ASM)

Expand Down Expand Up @@ -381,10 +386,22 @@ if (onnxruntime_USE_ROCM)
endif()


get_filename_component(BUILD_DIR_NO_CONFIG "${CMAKE_BINARY_DIR}" DIRECTORY)

# Single output director for all binaries
set(RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin CACHE PATH "Single output directory for all binaries.")

get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if (isMultiConfig)
foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/bin CACHE PATH "Single output directory for all binaries.")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/lib CACHE PATH "Single output directory for all libararies.")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/archive CACHE PATH "Single output directory for all archives.")
endforeach(OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES)
else()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin CACHE PATH "Single output directory for all binaries.")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib CACHE PATH "Single output directory for all libararies.")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/arch CACHE PATH "Single output directory for all librarries." )
endif()

include(FetchContent)

Expand Down Expand Up @@ -631,6 +648,9 @@ if (WIN32)
# Enable warning: data member 'member' will be initialized after data member 'member2' / base class 'base_class'
list(APPEND ORT_WARNING_FLAGS "/w15038")

# This flag helps pass eigen3 build.
list(APPEND ORT_WARNING_FLAGS "/wd4996")

# set linker flags to minimize the binary size.
if (MSVC)
foreach(type EXE STATIC SHARED)
Expand Down
5 changes: 4 additions & 1 deletion cmake/external/abseil-cpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ set(ABSL_BUILD_TESTING OFF)
set(ABSL_BUILD_TEST_HELPERS OFF)
set(ABSL_USE_EXTERNAL_GOOGLETEST ON)
if(Patch_FOUND AND WIN32)
set(ABSL_PATCH_COMMAND ${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 < ${PROJECT_SOURCE_DIR}/patches/abseil/absl_windows.patch)
set(ABSL_PATCH_COMMAND ${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 --input=${PROJECT_SOURCE_DIR}/patches/abseil/absl_windows.patch)
else()
set(ABSL_PATCH_COMMAND "")
endif()
Expand All @@ -27,6 +27,9 @@ FetchContent_Declare(
URL ${DEP_URL_abseil_cpp}
URL_HASH SHA1=${DEP_SHA1_abseil_cpp}
PATCH_COMMAND ${ABSL_PATCH_COMMAND}
SOURCE_DIR ${BUILD_DIR_NO_CONFIG}/_deps/abseil_cpp-src
BINARY_DIR ${CMAKE_BINARY_DIR}/deps/abseil_cpp-build
DOWNLOAD_DIR ${BUILD_DIR_NO_CONFIG}/_deps/abseil_cpp-download
FIND_PACKAGE_ARGS 20240722 NAMES absl
)

Expand Down
4 changes: 4 additions & 0 deletions cmake/external/composable_kernel.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ include(FetchContent)
FetchContent_Declare(composable_kernel
URL ${DEP_URL_composable_kernel}
URL_HASH SHA1=${DEP_SHA1_composable_kernel}

SOURCE_DIR ${BUILD_DIR_NO_CONFIG}/_deps/composable_kernel-src
BINARY_DIR ${CMAKE_BINARY_DIR}/deps/composable_kernel-build
DOWNLOAD_DIR ${BUILD_DIR_NO_CONFIG}/_deps/composable_kernel-download
PATCH_COMMAND ${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 < ${PATCH_CLANG} &&
${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 < ${PATCH_GFX12X}
)
Expand Down
3 changes: 3 additions & 0 deletions cmake/external/cudnn_frontend.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ FetchContent_Declare(
cudnn_frontend
URL ${DEP_URL_cudnn_frontend}
URL_HASH SHA1=${DEP_SHA1_cudnn_frontend}
SOURCE_DIR ${BUILD_DIR_NO_CONFIG}/_deps/cudnn_frontend-src
BINARY_DIR ${CMAKE_BINARY_DIR}/deps/cudnn_frontend-build
DOWNLOAD_DIR ${BUILD_DIR_NO_CONFIG}/_deps/cudnn_frontend-download
)

set(CUDNN_FRONTEND_BUILD_SAMPLES OFF)
Expand Down
3 changes: 3 additions & 0 deletions cmake/external/cutlass.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ FetchContent_Declare(
cutlass
URL ${DEP_URL_cutlass}
URL_HASH SHA1=${DEP_SHA1_cutlass}
SOURCE_DIR ${BUILD_DIR_NO_CONFIG}/_deps/cutlass-src
BINARY_DIR ${CMAKE_BINARY_DIR}/deps/cutlass-build
DOWNLOAD_DIR ${BUILD_DIR_NO_CONFIG}/_deps/cutlass-download
)

FetchContent_GetProperties(cutlass)
Expand Down
3 changes: 3 additions & 0 deletions cmake/external/dml.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ FetchContent_Declare(
directx_headers
URL ${DEP_URL_directx_headers}
URL_HASH SHA1=${DEP_SHA1_directx_headers}
SOURCE_DIR ${BUILD_DIR_NO_CONFIG}/_deps/directx_headers-src
BINARY_DIR ${CMAKE_BINARY_DIR}/deps/directx_headers-build
DOWNLOAD_DIR ${BUILD_DIR_NO_CONFIG}/_deps/directx_headers-download
)

FetchContent_Populate(directx_headers)
Expand Down
8 changes: 7 additions & 1 deletion cmake/external/eigen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ else ()
eigen
URL ${DEP_URL_eigen}
URL_HASH SHA1=${DEP_SHA1_eigen}
PATCH_COMMAND ${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 < ${PROJECT_SOURCE_DIR}/patches/eigen/eigen-aix.patch
PATCH_COMMAND ${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 --input=${PROJECT_SOURCE_DIR}/patches/eigen/eigen-aix.patch
SOURCE_DIR ${BUILD_DIR_NO_CONFIG}/_deps/eigen-src
BINARY_DIR ${CMAKE_BINARY_DIR}/deps/eigen-build
DOWNLOAD_DIR ${BUILD_DIR_NO_CONFIG}/_deps/eigen-download
)
else()
FetchContent_Declare(
eigen
URL ${DEP_URL_eigen}
URL_HASH SHA1=${DEP_SHA1_eigen}
SOURCE_DIR ${BUILD_DIR_NO_CONFIG}/_deps/eigen-src
BINARY_DIR ${CMAKE_BINARY_DIR}/deps/eigen-build
DOWNLOAD_DIR ${BUILD_DIR_NO_CONFIG}/_deps/eigen-download
)
endif()

Expand Down
4 changes: 3 additions & 1 deletion cmake/external/extensions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ if (NOT onnxruntime_EXTENSIONS_OVERRIDDEN)
extensions
URL ${DEP_URL_extensions}
URL_HASH SHA1=${DEP_SHA1_extensions}
SOURCE_DIR ${BUILD_DIR_NO_CONFIG}/_deps/extensions-src
BINARY_DIR ${CMAKE_BINARY_DIR}/deps/extensions-build
DOWNLOAD_DIR ${BUILD_DIR_NO_CONFIG}/_deps/extensions-download
)
onnxruntime_fetchcontent_makeavailable(extensions)
else()
Expand All @@ -62,4 +65,3 @@ onnxruntime_add_include_to_target(noexcep_operators ${PROTOBUF_LIB} ${ABSEIL_LIB

add_dependencies(ocos_operators ${onnxruntime_EXTERNAL_DEPENDENCIES})
add_dependencies(ortcustomops ${onnxruntime_EXTERNAL_DEPENDENCIES})

1 change: 0 additions & 1 deletion cmake/external/helper_functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ macro(onnxruntime_fetchcontent_makeavailable)
else()
unset(__cmake_haveFpArgs)
endif()

FetchContent_GetProperties(${__cmake_contentName})
if(NOT ${__cmake_contentNameLower}_POPULATED)
FetchContent_Populate(${__cmake_contentName})
Expand Down
Loading
Loading