0

I'm writing a .cmake file that handles a bunch of stuff and needs access to an executable in a fixed relative path to the .cmake file. In this instance, the orgianization looks like this:

CMakeLists.txt 
   - cmake
       - tools.cmake 
       - bin
           - exectuable.exe

The issue is that tools.cmake is included using include and thus, CMAKE_CURRENT_SOURCE_DIR returns the directory of the CMakeLists.txt. The reason I don't want to hardcode the path is that I want to put the tools.cmake and binary in a separate GIT repository and I don't want to force the user to place it in some specific folder.

Only solution I can come up with right now is to supply a function that sets and stores the path to tools.cmake. That's not really elegant.

Tsyvarev
  • 60,011
  • 17
  • 110
  • 153
ruhig brauner
  • 943
  • 1
  • 13
  • 35

1 Answers1

0

Answered here: https://stackoverflow.com/a/12854575/2532768

CMAKE_JUCE_TOOLS_PATHdoes not return the correct path within functions or macros in tools.cmake but it results in the correct path outside any function. So one can us

set(PATH_TO_TOOLS_CMAKE ${CMAKE_JUCE_TOOLS_PATH})

to store the path while it can be accessed in a variable and than access PATH_TO_TOOLS_CMAKE in functions and macros

ruhig brauner
  • 943
  • 1
  • 13
  • 35