cmake使用笔记和Creating CMake Linux projects with Visual Studio

笔记:

cmake -G 查看支持的makefile文件
1、进入目录:
cmake  .
2、window下会生成vs工程。首先需要安装有vs环境。
打开Visual Studio 命令行提示窗口,它会执行加载一些VS的环境变量。
然后才执行下面。
cmake . -G"NMake Makefiles"
会生成window make工程。 下面编译。
nmake 
或者
cmake . -G"MinGW Makefiles"
make


3、linux:
cmake  . 生成makefile工后编译。
make

cmake 静态链接

#Generated by VisualGDB project wizard.
#Note: VisualGDB will automatically update this file when you add new sources to the project.

cmake_minimum_required(VERSION 2.7)
project(sqlcipher_linux)
set(LIBRARIES_FROM_REFERENCES "")
add_executable(sqlcipher_linux crypto.c crypto_cc.c crypto_impl.c crypto_libtomcrypt.c crypto_openssl.c shell.c sqlite3.c)
#target_link_libraries(sqlcipher_linux "${LIBRARIES_FROM_REFERENCES}")
target_link_libraries(sqlcipher_linux "-static" ssl crypto pthread dl )


附上demo:

CMakeLists.txt

#Generated by VisualGDB project wizard.
#Note: VisualGDB will automatically update this file when you add new sources to the project.

cmake_minimum_required(VERSION 2.7)
project(CMakeDemo)
set(LIBRARIES_FROM_REFERENCES "")
add_executable(CMakeDemo CMakeDemo.cpp)
target_link_libraries(CMakeDemo "${LIBRARIES_FROM_REFERENCES}")
CMakeDemo.cpp

#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
	char sz[] = "Hello, World!";	//Hover mouse over "sz" while debugging to see its contents
	cout << sz << endl;	//<================= Put a breakpoint here
	return 0;
}
http://visualgdb.com/tutorials/linux/cmake/

Creating CMake Linux projects with Visual Studio


Before you begin, make sure that VisualGDB 4.3 or later is installed.

  1. Start Visual Studio and open the “New Project” dialog. Select the Linux Project Wizard from VisualGDB folder:01-linuxprj
  2. On the first wizard page ensure that “new project” is selected and then select the “Hello, World (CMake)” sample:02-cmake
  3. On the next page select the Linux computer you want to target and press “Next”. If you have not configured the connection to that computer with VisualGDB yet, follow the generic Linux tutorial to set it up.03-computer
  4. On the next page specify how should the Linux machine access the source code. The easiest way would be to proceed with the default settings of uploading the modified sources to the Linux machine:04-dirs
  5. Press “Finish” to complete the wizard. If this is the first project created on this machine, VisualGDB will cache the include directories from it so that IntelliSense can find all the headers:05-cachedirs
  6. Once the project is created, press Ctrl-Shift-B to build your solution:06-build
  7. You can customize various project settings using one of two ways. First of all, you can edit the CMakeLists.txt file directly. VisualGDB will provide syntax highlighting and basic IntelliSense:07-cmakelists
  8. Second of all you can right-click on the project, select “VisualGDB Project Properties” and go to the CMake page:08-settingsNote that the settings editing GUI will only work for the settings defined in CMakeLists.txt itself, but not in any of the included files.
  9. You can also switch an existing project to CMake by selecting it on the “Project settings” page:09-existingprj
  10. When you are done changing your settings, press F5 or F10 to begin debugging your project:10-debug



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值