Thursday, November 11, 2021

[SOLVED] What is the difference between ${CMAKE_CURRENT_LIST_DIR} and . (relative directory)?

Issue

I understand the difference between ${CMAKE_CURRENT_LIST_DIR} and ${CMAKE_CURRENT_SOURCE_DIR}, but I don't understand what the difference is between the former and simply .?

For example, are there any scenarios where

target_include_directories(foo PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

would behave differently than

target_include_directories(imgwarp PRIVATE .)

?


Solution

Simple counterexample: add_custom_command allows you to specify a custom WORKING_DIRECTORY. Passing relative filenames to such a command would be relative to the working directory. Explicitly making them absolute with CMAKE_CURRENT_SOURCE_DIR solves that.



Answered By - Botje