ncnn閱讀 - CMakeLists.txt
CMAKE_TOOLCHAIN_FILE
This variable is specified on the command line when cross-compiling with CMake. It is the path to a file which is read early in the CMake run and which specifies locations for compilers and toolchain utilities, and other target platform and compiler related information. 指定編譯器,toolchain utilities的路徑,其他目標平臺和編譯器的相關信息。
toolchain utilities 一套編譯工具的集合
比如:make, 編譯器,匯編器,鏈接器等等。
set 將一個CMAKE變量設置為給定值。
set(<variable> <value> [[CACHE <type> <docstring> [FORCE]] | PARENT_SCOPE])
將變量<variable>的值設置為<value>。在<variable>被設置之前,<value>會被展開。如果有CACHE選項,那麽<variable>就會添加到cache中;這時<type>和<docstring>是必需的。<type>被CMake GUI用來選擇一個窗口,讓用戶設置值。<type>可以是下述值中的一個:
FILEPATH = 文件選擇對話框。
PATH = 路徑選擇對話框。
STRING = 任意的字符串。
BOOL = 布爾值選擇復選框。
INTERNAL = 不需要GUI輸入端。(適用於永久保存的變量)。
CMAKE_BINARY_DIR
This is the full path to the top level of the current CMake build tree. For an in-source build, this would be the same as CMAKE_SOURCE_DIR.
養成喜歡進行外部編譯(out-of-source build) 而不是in-source build
out-of-source build一般在源文件的頂層目錄中 新建build目錄
對於命令行可以 cd build
然後 cmake .. -G"MinGW Makefiles"即可
這樣所有的臨時文件 都會放在build目錄下不會和source有任何的瓜噶。
get_filename_component
Get a specific component of a full filename.
get_filename_component(<VAR> <FileName> <COMP> [CACHE])
Set <VAR> to a component of <FileName>, where <COMP> is one of: 將var設置為filename的某一部分
DIRECTORY = Directory without file name
NAME = File name without directory
EXT = File name longest extension (.b.c from d/a.b.c)
NAME_WE = File name without directory or longest extension
ABSOLUTE = Full path to file
REALPATH = Full path to existing file with symlinks resolved
PATH = Legacy alias for DIRECTORY (use for CMake <= 2.8.11)
find_file
https://cmake.org/cmake/help/v3.4/command/find_file.html
message
Display a message to the user.
message([<mode>] "message to display" ...)
The optional <mode> keyword determines the type of message:
(none) = Important information
STATUS = Incidental information 對STATUS的信息用stdout輸出,其他的用stderr數據
WARNING = CMake Warning, continue processing
AUTHOR_WARNING = CMake Warning (dev), continue processing
SEND_ERROR = CMake Error, continue processing,
but skip generation
FATAL_ERROR = CMake Error, stop processing and generation
DEPRECATION = CMake Deprecation Error or Warning if variable
CMAKE_ERROR_DEPRECATED or CMAKE_WARN_DEPRECATED
is enabled, respectively, else no message.
The CMake command-line tool displays STATUS messages on stdout and all other message types on stderr. The CMake GUI displays all messages in its log area. The interactive dialogs (ccmake and CMakeSetup) show STATUS messages one at a time on a status line and other messages in interactive pop-up boxes.
CMake Warning and Error message text displays using a simple markup language. Non-indented text is formatted in line-wrapped paragraphs delimited by newlines. Indented text is considered pre-formatted.
ncnn閱讀 - CMakeLists.txt