Skip to content

Commit

Permalink
cmake: Use PROJECT_SOURCE_DIR in cmake
Browse files Browse the repository at this point in the history
When using rdma-core via cmake's add_subdirectory, CMAKE_SOURCE_DIR
points project's root directory, and build fails. This patch replaces
CMAKE_SOURCE_DIR with PROJECT_SOURCE_DIR. It enables builing rdma-core
via add_subdirectory.

Signed-off-by: Wonsup Yoon <pusnow@kaist.ac.kr>
  • Loading branch information
Pusnow committed Feb 7, 2022
1 parent f1a1a46 commit bf67cad
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ set(DISTRO_FLAVOUR "None" CACHE

#-------------------------
# Load CMake components
set(BUILDLIB "${CMAKE_SOURCE_DIR}/buildlib")
set(BUILDLIB "${PROJECT_SOURCE_DIR}/buildlib")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${BUILDLIB}")

include(CMakeParseArguments)
Expand Down Expand Up @@ -759,14 +759,14 @@ if (NO_MAN_PAGES)
message(STATUS " man pages NOT built")
else()
if (NOT PANDOC_FOUND)
if (NOT EXISTS "${CMAKE_SOURCE_DIR}/buildlib/pandoc-prebuilt")
if (NOT EXISTS "${PROJECT_SOURCE_DIR}/buildlib/pandoc-prebuilt")
message(STATUS " pandoc NOT found and NO prebuilt man pages. 'install' disabled")
else()
message(STATUS " pandoc NOT found (using prebuilt man pages)")
endif()
endif()
if (NOT RST2MAN_FOUND)
if (NOT EXISTS "${CMAKE_SOURCE_DIR}/buildlib/pandoc-prebuilt")
if (NOT EXISTS "${PROJECT_SOURCE_DIR}/buildlib/pandoc-prebuilt")
message(STATUS " rst2man NOT found and NO prebuilt man pages. 'install' disabled")
else()
message(STATUS " rst2man NOT found (using prebuilt man pages)")
Expand Down
4 changes: 2 additions & 2 deletions buildlib/RDMA_Sparse.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ int main(int argc,const char *argv[]) {return 0;}
# Replace various glibc headers with our own versions that have embedded sparse annotations.
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "${BUILDLIB}/gen-sparse.py"
"--out" "${BUILD_INCLUDE}/"
"--src" "${CMAKE_SOURCE_DIR}/"
"--src" "${PROJECT_SOURCE_DIR}/"
"--cc" "${CMAKE_C_COMPILER}"
RESULT_VARIABLE retcode)
if(NOT "${retcode}" STREQUAL "0")
message(FATAL_ERROR "glibc header file patching for sparse failed. Review include/*.rej and fix the rejects, then do "
"${BUILDLIB}/gen-sparse.py -out ${BUILD_INCLUDE}/ --src ${CMAKE_SOURCE_DIR}/ --save")
"${BUILDLIB}/gen-sparse.py -out ${BUILD_INCLUDE}/ --src ${PROJECT_SOURCE_DIR}/ --save")
endif()

# Enable endian analysis in sparse
Expand Down
6 changes: 3 additions & 3 deletions buildlib/rdma_functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function(rdma_shared_provider DEST VERSION_SCRIPT SOVERSION VERSION)
install(TARGETS ${DEST} DESTINATION "${CMAKE_INSTALL_LIBDIR}")

# Compute a relative symlink from VERBS_PROVIDER_DIR to LIBDIR
execute_process(COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/buildlib/relpath
execute_process(COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/buildlib/relpath
"${CMAKE_INSTALL_FULL_LIBDIR}/lib${DEST}.so.${VERSION}"
"${VERBS_PROVIDER_DIR}"
OUTPUT_VARIABLE DEST_LINK_PATH OUTPUT_STRIP_TRAILING_WHITESPACE
Expand Down Expand Up @@ -284,10 +284,10 @@ function(rdma_finalize_libs)

add_custom_command(
OUTPUT ${OUTPUTS}
COMMAND "${PYTHON_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/buildlib/sanitize_static_lib.py"
COMMAND "${PYTHON_EXECUTABLE}" "${PROJECT_SOURCE_DIR}/buildlib/sanitize_static_lib.py"
--version ${PACKAGE_VERSION}
--ar "${CMAKE_AR}" --nm "${CMAKE_NM}" --objcopy "${CMAKE_OBJCOPY}" ${ARGS}
DEPENDS ${DEPENDS} "${CMAKE_SOURCE_DIR}/buildlib/sanitize_static_lib.py"
DEPENDS ${DEPENDS} "${PROJECT_SOURCE_DIR}/buildlib/sanitize_static_lib.py"
COMMENT "Building distributable static libraries"
VERBATIM)
add_custom_target("make_static" ALL DEPENDS ${OUTPUTS})
Expand Down
6 changes: 3 additions & 3 deletions buildlib/rdma_man.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function(rdma_man_get_prebuilt SRC OUT)
# made the man pages are pre-built and included. This is done via install
# so that ./build.sh never depends on pandoc, only 'ninja install'.
execute_process(
COMMAND "${PYTHON_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/buildlib/pandoc-prebuilt.py" --retrieve "${CMAKE_SOURCE_DIR}" "${SRC}"
COMMAND "${PYTHON_EXECUTABLE}" "${PROJECT_SOURCE_DIR}/buildlib/pandoc-prebuilt.py" --retrieve "${PROJECT_SOURCE_DIR}" "${SRC}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT_VARIABLE OBJ
RESULT_VARIABLE retcode)
Expand All @@ -26,7 +26,7 @@ function(rdma_md_man_page SRC MAN_SECT MANFN)
if (PANDOC_EXECUTABLE)
add_custom_command(
OUTPUT "${OBJ}"
COMMAND "${PYTHON_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/buildlib/pandoc-prebuilt.py" --build "${CMAKE_BINARY_DIR}" --pandoc "${PANDOC_EXECUTABLE}" "${SRC}" "${OBJ}"
COMMAND "${PYTHON_EXECUTABLE}" "${PROJECT_SOURCE_DIR}/buildlib/pandoc-prebuilt.py" --build "${CMAKE_BINARY_DIR}" --pandoc "${PANDOC_EXECUTABLE}" "${SRC}" "${OBJ}"
MAIN_DEPENDENCY "${SRC}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Creating man page ${MANFN}"
Expand All @@ -48,7 +48,7 @@ function(rdma_rst_man_page SRC MAN_SECT MANFN)
if (RST2MAN_EXECUTABLE)
add_custom_command(
OUTPUT "${OBJ}"
COMMAND "${PYTHON_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/buildlib/pandoc-prebuilt.py" --build "${CMAKE_BINARY_DIR}" --rst "${RST2MAN_EXECUTABLE}" "${SRC}" "${OBJ}"
COMMAND "${PYTHON_EXECUTABLE}" "${PROJECT_SOURCE_DIR}/buildlib/pandoc-prebuilt.py" --build "${CMAKE_BINARY_DIR}" --rst "${RST2MAN_EXECUTABLE}" "${SRC}" "${OBJ}"
MAIN_DEPENDENCY "${SRC}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Creating man page ${MANFN}"
Expand Down
4 changes: 2 additions & 2 deletions kernel-headers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ function(rdma_kernel_provider_abi)
set(HDRS ${HDRS} ${OHDR})
add_custom_command(
OUTPUT "${OHDR}"
COMMAND "${PYTHON_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/buildlib/make_abi_structs.py" "${IHDR}" "${OHDR}"
COMMAND "${PYTHON_EXECUTABLE}" "${PROJECT_SOURCE_DIR}/buildlib/make_abi_structs.py" "${IHDR}" "${OHDR}"
MAIN_DEPENDENCY "${IHDR}"
DEPENDS "${CMAKE_SOURCE_DIR}/buildlib/make_abi_structs.py"
DEPENDS "${PROJECT_SOURCE_DIR}/buildlib/make_abi_structs.py"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Creating ABI wrapper ${OHDR}"
)
Expand Down

0 comments on commit bf67cad

Please sign in to comment.