How do I share variables between different CMake files, and I show the following examples to illustrate my question:
Main
cmake_minimum_required(VERSION 2.6)
project(test)
set(Var3 "Global variable")
add_subdirectory(${test_SOURCE_DIR}/exe)
add_subdirectory(${test_SOURCE_DIR}/dll)
EXE file
set(Var1 "this is variable 1")
set(Var1 ${Var1} " added to varible 1")
message(STATUS ${Var1})
DLL file
set(Var2 "this is variable 2")
message(STATUS ${Var2})
message(STATUS ${Var1})
message(STATUS ${Var3})
In this example, Var3 can be seen in the CMake files of exe
and dll
as it is defined in Main
. However, Var1, which is defined in exe
, will not be observed in dll
. I was just curious: is there a way to make Var1 defined in exe
observable in dll
?