Skip to content

Commit 71f2646

Browse files
committed
Fix __FILE__ expansion bug (#164)
1 parent 8b41926 commit 71f2646

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

.github/actions/build/action.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ runs:
99
run: |
1010
mkdir -p ../build
1111
rm -rf ../build/*
12-
cmake -DYDB_SDK_TESTS=On -DYDB_SDK_EXAMPLES=On --preset release
12+
cmake -DYDB_SDK_TESTS=On -DYDB_SDK_EXAMPLES=On -DARCADIA_ROOT="../ydb-cpp-sdk" -DARCADIA_BUILD_ROOT="." --preset release
1313
- name: Build
1414
shell: bash
1515
run: |

CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ set(YDB-CPP-SDK_AVAILABLE_COMPONENTS "" CACHE INTERNAL "")
1818
set(YDB-CPP-SDK_COMPONENT_TARGETS "" CACHE INTERNAL "")
1919
file(READ "src/client/resources/ydb_sdk_version.txt" YDB_SDK_VERSION)
2020

21+
#[=============================================================================[
22+
NOTE: if `ccache` is used with the environment variable `CCACHE_BASEDIR`,
23+
these cached variable should be set manually by passing them to `cmake` as
24+
`-DARCADIA_ROOT=source/path/relative/to/build/dir` and
25+
`-DARCADIA_BUILD_ROOT=.`, because in that case the macro `__FILE__` will be
26+
expanded to a relative path, even if the source code file was specified as
27+
an absolute path, and we have to know the proper prefix of that path.
28+
See details: https://ccache.dev/manual/3.1.html#_compiling_in_different_directories
29+
#]=============================================================================]
30+
set(ARCADIA_ROOT ${YDB_SDK_SOURCE_DIR} CACHE PATH "The source root directory")
31+
set(ARCADIA_BUILD_ROOT ${YDB_SDK_BINARY_DIR} CACHE PATH "The build root directory")
32+
2133
include(GNUInstallDirs)
2234
include(CMakePackageConfigHelpers)
2335

util/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -701,10 +701,10 @@ elseif (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64")
701701
)
702702
endif()
703703

704-
# These definitions are needed to `util/system/src_root.h` works properly
704+
# NOTE: these definitions are needed to `util/system/src_root.h` works properly
705705
target_compile_definitions(yutil PUBLIC
706-
ARCADIA_ROOT=${YDB_SDK_SOURCE_DIR}
707-
ARCADIA_BUILD_ROOT=${YDB_SDK_BINARY_DIR}
706+
ARCADIA_ROOT=${ARCADIA_ROOT}
707+
ARCADIA_BUILD_ROOT=${ARCADIA_BUILD_ROOT}
708708
)
709709

710710
_ydb_sdk_install_targets(TARGETS yutil)

0 commit comments

Comments
 (0)