From ae4f837d5a58fbf1674f0a1592c76ee979c5e0c3 Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Sun, 19 Jan 2025 06:20:05 +0100 Subject: [PATCH] CMakeLists.txt: Fix undefined behaviour on EXISTS According to the documentation [1], EXISTS only has well-defined behaviour when an absolute path is given. This fixes a bug where re-configuring the project would fail because CMake would inadverently jump to the invalid branch. [1]: https://cmake.org/cmake/help/latest/command/if.html#exists --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 134f101bb..e2357126a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,7 @@ if(SD_ASSUME_DATADIR) set(SD_DATADIR_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/games/speed-dreams-2) set(SD_DATADIR_ABS ${SD_DATADIR_INSTALL_PREFIX}) message(STATUS "Data directory: ${SD_DATADIR_ABS} (assumed)") -elseif(EXISTS speed-dreams-data/CMakeLists.txt) +elseif(EXISTS ${CMAKE_CURRENT_LIST_DIR}/speed-dreams-data/CMakeLists.txt) add_subdirectory(speed-dreams-data) set(SD_DATADIR ${CMAKE_INSTALL_DATADIR}/games/speed-dreams-2) set(SD_DATADIR_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/games/speed-dreams-2)