Clion开发工具配置
MinGW配置
MinGW
将 解压的bin目录,添加到 环境变量的path中。
最好将bin目录下的mingw32-make.exe拷贝一份我make.exe
Clion IDE配置
Clion官网
安装成功clion之后,将 (安装路径)\bin\cmake\win\bin 添加到环境变量的path中。主要是讲CMake添加到环境变量中。
CppCheck
CppCheck官网
[File] => [settings] => [Plugins] 搜索CppCheck 指定安装的cppcheck.exe
googletest
编译googletest
修改CMakeLists.txt 编译动态链接库。
修改: googletest\googlemock\CMakeLists.txt
修改: googletest\googletest\CMakeLists.txt
option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)." OFF)
=> option(BUILD_SHARED_LIBS "Build shared libraries (DLLs). "ON)
编译
命令窗口cmd进入googletest根目录,mkdir build ; cd build
cmake .. -G “MinGW Makefiles” -DCMAKE_CXX_FLAGES=-std=c++11 -DCMAKE_INSTALL_PREFIX=./gtest
make
make install
编译好的googletest文件拷贝到MinGW中。
gtest\lib => MinGW\lib
gtest\bin => MinGW\bin
gtest\include => MinGW\include
Clion项目配置
仅仅需要配置CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
project(test)
set(CMAKE_CXX_STANDARD 11)
# 静态链接库
set(STATIC_LIBS gtest)
# 设置googletest根目录
set(GTEST_HOME "E:\\ThirdPart\\googletest")
include_directories(${GTEST_HOME}/include)
aux_source_directory(. TESTSRC)
add_executable(${PROJECT_NAME} ${TESTSRC})
target_link_libraries(${PROJECT_NAME} ${STATIC_LIBS})