I want to separate my user-defined functions from the main CmakeLists.txt
so they are not in the way of my stuff.
I work in CLion primarily and want to have syntax highlight and code completion, which CLion provides for CMake.
How do I do this?
First you add another file alongside with your main CMakeLists.txt
and name it something like: myfunctions.cmake
.
*.cmake
extension is recognized by CLion and enables CMake syntax highlight and code completion.
Then in your CMakeLists.txt
you add line:
include(myfunctions.cmake)
Now you can use your user-defined functions in your main and all derived (from add_subdirectory) CMakeLists.txt
files. Also you'll get CLion code completion for your user-defined functions as well (it works in CLion 2020.1, but I don't know about older versions)