-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/**/build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# <pre name="code" class="cpp"><pre name="code" class="cpp">set(CMAKE_C_COMPILER "gcc")#设置C编译器 | ||
# set(CMAKE_C_FLAGS "-g -Wall -I C:\\mingw-4.81\\mingw\\include -L C:\\mingw-4.81\\mingw\\lib")# | ||
|
||
set(CMAKE_CXX_COMPILER "g++")#设置C++编译器 | ||
set(CMAKE_CXX_FLAGS "-g -Wall") | ||
# # -g 和 -Wall 是通用的编译选项,建议在编译调试版本时保留这些选项以便更好地调试代码并捕获潜在错误。这些选项即使设置了环境变量也需要在 CMake 中显式声明 | ||
# # -I C:\\mingw-4.81\\mingw\\include:这个选项指定了一个额外的头文件搜索路径。-I 之后的路径表示在编译时,编译器会额外在这个路径下搜索头文件。 | ||
# # -L C:\\mingw-4.81\\mingw\\lib:这个选项指定了一个额外的库文件搜索路径。-L 之后的路径表示在链接时,编译器会在这个路径下搜索库文件。 | ||
# set(CMAKE_CXX_FLAGS "-g -Wall -I C:\\mingw-4.81\\mingw\\include -L C:\\mingw-4.81\\mingw\\lib") | ||
|
||
PROJECT (HELLO CXX) | ||
SET(SRC_LIST main.cpp) | ||
ADD_EXECUTABLE(hello ${SRC_LIST}) | ||
|
||
MESSAGE(STATUS "This is BINARY dir " ${HELLO_BINARY_DIR}) | ||
MESSAGE(STATUS "This is SOURCE dir " ${HELLO_SOURCE_DIR}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <iostream> | ||
using namespace std; | ||
|
||
int main(){ | ||
cout << "hello word cmake!!!" << endl; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# build | ||
cd build | ||
cmake -G "MinGW Makefiles" .. # 使用mingw32 build 这个项目 | ||
|
||
# make | ||
mingw32-make | ||
./hello.exe # output: hello word cmake!!! | ||
|