Define new variable in cmake configure script

If I understand correctly, you want to do:

configure_file(${CMAKE_SOURCE_DIR}/myconf.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/myconf.cmake @ONLY)

And:

set(MY_VAR @CMAKE_SOURCE_DIR@) 

message(CMAKE_SOURCE_DIR: @CMAKE_SOURCE_DIR@)
message(MY_VAR: ${MY_VAR})
1 Like