PS E:\workspace\structsample\ostack> ls
目录: E:\workspace\structsample\ostack
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2020-07-17 0:10 build
-a---- 2020-07-17 0:04 198 CMakeLists.txt
-a---- 2020-07-15 23:45 147 main.cpp
-a---- 2020-07-15 23:43 740 ostack_array.cpp
-a---- 2020-07-15 23:43 419 ostack_array.h
PS E:\workspace\structsample\ostack> cat .\CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
project(vscode_cmake_Test)
aux_source_directory(. DIR_TOOT_SRCS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
add_executable(${PROJECT_NAME} ${DIR_TOOT_SRCS})
PS E:\workspace\structsample\ostack>
PS E:\workspace\structsample\ostack\build> cmake -G"Unix Makefiles" ../
-- The C compiler identification is GNU 6.3.0
-- The CXX compiler identification is GNU 6.3.0
-- Check for working C compiler: D:/Program Files/MinGW/bin/gcc.exe
-- Check for working C compiler: D:/Program Files/MinGW/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: D:/Program Files/MinGW/bin/c++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: E:/workspace/structsample/ostack/build
PS E:\workspace\structsample\ostack\build> ls
目录: E:\workspace\structsample\ostack\build
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2020-07-17 0:09 CMakeFiles
-a---- 2020-07-17 0:09 15992 CMakeCache.txt
-a---- 2020-07-17 0:09 1451 cmake_install.cmake
-a---- 2020-07-17 0:09 6104 Makefile
PS E:\workspace\structsample\ostack\build> make
Scanning dependencies of target vscode_cmake_Test
[ 33%] Building CXX object CMakeFiles/vscode_cmake_Test.dir/main.cpp.obj
[ 66%] Building CXX object CMakeFiles/vscode_cmake_Test.dir/ostack_array.cpp.obj
[100%] Linking CXX executable vscode_cmake_Test.exe
[100%] Built target vscode_cmake_Test
PS E:\workspace\structsample\ostack\build> ls
目录: E:\workspace\structsample\ostack\build
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2020-07-17 0:10 CMakeFiles
-a---- 2020-07-17 0:09 15992 CMakeCache.txt
-a---- 2020-07-17 0:09 1451 cmake_install.cmake
-a---- 2020-07-17 0:09 6104 Makefile
-a---- 2020-07-17 0:10 65787 vscode_cmake_Test.exe
PS E:\workspace\structsample\ostack\build> .\vscode_cmake_Test.exe
Hello word.
PS E:\workspace\structsample\ostack\build>
最简单的CMake示例
最新推荐文章于 2025-04-30 23:32:48 发布