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
This commit is contained in:
Xavier Del Campo Romero 2025-01-19 06:20:05 +01:00
parent 8d3ca718b5
commit ae4f837d5a
Signed by: xavi
GPG key ID: 84FF3612A9BF43F2

View file

@ -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)