# Referencing file in CMake function shipped via \*Config.cmake

**URL:** https://discourse.cmake.org/t/referencing-file-in-cmake-function-shipped-via-config-cmake/2447
**Category:** Usage
**Created:** [December 30, 2020, 8:04pm UTC](https://discourse.cmake.org/t/referencing-file-in-cmake-function-shipped-via-config-cmake/2447 "2020-12-30T20:04:14Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Nicholas\_Yue](https://discourse.cmake.org/user_avatar/discourse.cmake.org/nicholas_yue/32/464_2.png) [@Nicholas\_Yue](https://discourse.cmake.org/u/Nicholas_Yue)
#### Post date: [December 30, 2020, 8:04pm UTC](https://discourse.cmake.org/t/referencing-file-in-cmake-function-shipped-via-config-cmake/2447/1 "2020-12-30T20:04:14Z")

</div>

Hi

I am planning to ship a convenience CMake function for developers as part of the \*Config.cmake file.

That function depends on a python script.

```auto
  function(myfunction)
	...
	set(_command Python::Interpreter "WHAT TO PUT HERE"/myscript.py)
	...
	... use ${_command}

```

and where to place the myscript.py file.

Cheers

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [December 30, 2020, 8:36pm UTC](https://discourse.cmake.org/t/referencing-file-in-cmake-function-shipped-via-config-cmake/2447/2 "2020-12-30T20:36:04Z")

</div>

Here’s what I usually do:

```cmake
set(_MyPackage_utils_dir "${CMAKE_CURRENT_FILE_DIR}")

function (MyPackage_some_api)
  if (NOT DEFINED _MyPackage_utils_dir)
    if (CMAKE_VERSION VERSION_LESS "3.17")
      message(FATAL_ERROR "Called outside of `find_package(MyPackage)` scope")
    endif ()
    set(_MyPackage_utils_dir "${CMAKE_CURRENT_FUNCTION_LIST_DIR}")
  endif ()
  …
endfunction ()

```

If you want to require that consumers of your package have at least 3.17, you can just assume that `CMAKE_CURRENT_FUNCTION_LIST_DIR` is available.
