宏定义
message(STATUS "PROJECT_NAME: " ${PROJECT_NAME}) #项目名称
message(STATUS "PROJECT_SOURCE_DIR: " ${PROJECT_SOURCE_DIR})
message(STATUS "PROJECT_BINARY_DIR: " ${PROJECT_BINARY_DIR})
message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR})
message(STATUS "CMAKE_CURRENT_BINARY_DIR:" ${CMAKE_CURRENT_BINARY_DIR})
message(STATUS "CMAKE_CURRENT_LIST_DIR: " ${CMAKE_CURRENT_LIST_DIR})
message(STATUS "CMAKE_CURRENT_LIST_LINE: " ${CMAKE_CURRENT_LIST_LINE})
-- PROJECT_NAME: hello_library
-- PROJECT_SOURCE_DIR: F:/cmake_vs/CMakeProject
-- PROJECT_BINARY_DIR: F:/cmake_vs/CMakeProject/build
-- CMAKE_CURRENT_SOURCE_DIR: F:/cmake_vs/CMakeProject
-- CMAKE_CURRENT_BINARY_DIR��F:/cmake_vs/CMakeProject/build
-- CMAKE_CURRENT_LIST_DIR: F:/cmake_vs/CMakeProject
-- CMAKE_CURRENT_LIST_LINE: 38
PROJECT_BINARY_DIR和PROJECT_SOURCE_DIR
也就是当前源码的目录
? ? ? 如果执行cmake的时候,并不在源码的路径的话,比如 cmake ../src 这样的好处是cmake生成的文件和编译出来的东西,就不放在源码路径下了,保证了源码路径的干净整洁。
比如
可以在src的同级目录下建立build目录。然后在build目录下执行cmake ../src。
这样编译出来的东西和cmake生成的东西,都放到了build目录下了。并且
PROJECT_BINARY_DIR = 全路径/build
PROJECT_SOURCE_DIR = 全路径/src
输出路径
CMAKE_ARCHIVE_OUTPUT_DIRECTORY:默认存放静态库的文件夹位置;
CMAKE_LIBRARY_OUTPUT_DIRECTORY:默认存放动态库的文件夹位置;
LIBRARY_OUTPUT_PATH:默认存放库文件的位置,如果产生的是静态库并且没有指定 CMAKE_ARCHIVE_OUTPUT_DIRECTORY 则存放在该目录下,动态库也类似;
CMAKE_RUNTIME_OUTPUT_DIRECTORY:存放可执行软件的目录;
#有问题
#message("EXECUTABLE_OUTPUT_PATH: ${EXECUTABLE_OUTPUT_PATH}")
#set(EXECUTABLE_OUTPUT_PATH ${OUT_PUT_DIR}) #exe可执行文件
#message("EXECUTABLE_OUTPUT_PATH: ${EXECUTABLE_OUTPUT_PATH}")
?
|