After doing configure_file(${CMAKE_SOURCE_DIR}/myconf.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/myconf.cmake) I can open configured myconf.cmake and I can see that CMAKE_SOURCE_DIR is set to a source dir (as it was expected) while MY_VAR is empty (unexpected for me).
Thus I think I have some problems when defining new variables in cmake configuring scripts.
Is there a way to overcome this?
Yeah, the @ONLY argument is important here. Otherwise, ${MY_VAR} gets replaced with the value of ${MY_VAR} from the calling script, which in this case is empty because it hasn’t been set.
Without @ONLY argument in configure_file() cmake tries to replace MY_VAR with the value of MY_VAR in assumption that it was previously set in my project. But it wasnt in my case and it set to an empty (I didn’t think about that)
So I needed to add @ONLY argument and make difference between ${MY_VAR} and @MY_VAR@ in configuration script