# configure files based on target

**URL:** <https://discourse.cmake.org/t/configure-files-based-on-target/14451>\
**Category:** Code\
**Created:** [July 26, 2025, 6:55pm UTC](https://discourse.cmake.org/t/configure-files-based-on-target/14451 "2025-07-26T18:55:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![walliscode](https://discourse.cmake.org/user_avatar/discourse.cmake.org/walliscode/32/5693_2.png) [@walliscode](https://discourse.cmake.org/u/walliscode)\
**Post date:** [July 26, 2025, 6:55pm UTC](https://discourse.cmake.org/t/configure-files-based-on-target/14451/1 "2025-07-26T18:55:05Z")

</div>

I’m storing data for unit tests in its own test\_data/ directory (mimicing the /data in the project directory).

Currently i pass directory paths to the code using getDataDirectory() in a paths.h/paths.cpp.in file and use configure\_file() to resolve getDataDirectory().

For my tests I would like to be able to change the output of getDataDirectory() to the test\_data directory, depending on which target/executable is being built.

Is this possible? best practise? I’m willing to change the general approach if it would make for a more modern approach/cleaner project

cheers
