1. cmake_minimum_required(version 2.8) ///檢查cmake的版本,至少為2.82. project(helloworld) ///工程名為helloworld
# 通過在主工程檔案cmakelists.txt中修改add_subdirectory (lib) 指令來指定乙個編譯輸出位置;
# 指定本工程中靜態庫libhello.so生成的位置,即 build/lib;
add_subdirectory(lib)
3. aux_source_directory(. src_list) ///查詢當前目錄下所有的原始檔並儲存到src_list變數中4.include_directories($/include $/abc) ///將根目錄下的include和abc加入包含目錄列表
5. link_directories($/lib) ///將 ./lib加入編譯器鏈結階段的搜尋目錄列表
6.add_executable(hello $(src_list}) ///使用src_list原始檔列表裡的檔案生成乙個可執行檔案hello
如:add_executable(hello main.cpp base.cpp base.h)
7.add_library(hellostatic$) 使用src_list原始檔列表裡的檔案生成乙個靜態鏈結libhello.a
add_library (base static $)
8.add_library(helloshard$) 使用src_list原始檔列表裡的檔案生成乙個動態鏈結庫libhello.so
9.target_link_libraries(hello a b.a c.so) /// 將若干庫檔案鏈結到目標hello中,target_link_libraries裡的庫檔案的順序符合gcc/g++鏈結順序的規則,即被依賴的庫放在依賴它的庫的後面,如果順序有錯,鏈結時會報錯。
cmake生成平台適應性的解決方案->vs編譯解決方案cmake_minimum_required(version 3.8)
project (tsinghua)
include_directories ($/eigen3)
set (src_list base.cpp )
add_library (base_static static $)
add_executable(hello main.cpp base.cpp base.h)
Linux基本命令學習(複習)
1.ls指令 相對路徑 ls 列出上一級目錄下 ls 和ls列出當前目錄下內容 ls 選項 路徑 ls l 路徑 l 表示list,以詳細的列表展示 ls la 路徑 a all,顯示所有檔案 包括隱藏檔案 列出的表第乙個字元 表示檔案 列出的表第乙個字元 d 表示資料夾 ls lh 路徑 以可讀性...
Linux常用基本命令
命令列操作 history 查詢命令的歷史 alias 關機和重啟 shutdown h now 系統立即關機 shutdown r now 系統立即重啟 rebootnow 系統立即重啟 shutdown h 45 shutdown computer 定時關機 shutdown r 60 定時啟動...
MySQL常用基本命令
1 mysql常用命令 create database name 建立資料庫 use databasename 選擇資料庫 drop database name 直接刪除資料庫,不提醒 show tables 顯示表 describe tablename 表的詳細描述 select 中加上disti...