set(var_name_1 var1) message("var_name is ${var_name_1}")
set(var_name_2 var2) set(${var_name_2} var) #same as set(var2 var) set(${${var_name_2}}_x foo) #same as set(var_x foo) message("var2 is ${var2}") message("var_name_2 is ${var_name_2}") message("var_x is ${var_x}") message("empty var is ${empty_var}")
执行结果如下:
1 2 3 4 5
var_name is var1 var2 is var var_name_2 is var2 var_x is foo empty var is
-- Building for: Visual Studio 152017 -- The C compiler identification is MSVC 19.15.26732.1 -- The CXX compiler identification is MSVC 19.15.26732.1 -- Check for working C compiler: ....../cl.exe -- Check for working C compiler: ....../cl.exe -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler: ....../cl.exe -- Check for working CXX compiler: ....../cl.exe -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done Hello,This is my first cmake project -- Configuring done -- Generating done -- Build files have been written to: ....../build
再来看这个路径下,cmake 生成了一堆文件:
我们成功的使用 cmake 在 Windows 上构建了一个 vs 工程。 当然,如果你的操作系统是 MacOS, 或者 Linux, 结果后有所不同。