-- 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, 结果后有所不同。
# The version number set(Hello_VERSION_MAJOR 1) set(Hello_VERSION_MINOR 0) set(the_macro "\"test\"") #configue a header file to pass some of the CMake settings to source code configure_file( "${PROJECT_SOURCE_DIR}/config.h.in" "${PROJECT_BINARY_DIR}/config.h" ) #add the binary tree to the search path for include files so that we will find config.h include_directories("${PROJECT_BINARY_DIR}") add_executable(HelloCMake src_file.cpp)
经过 cmake 以后输出的配置文件 config.h 如下:
1 2 3 4 5
// the configured options and settings #define Hello_VERSION_MAJOR 1 #define Hello_VERSION_MINOR 0