下面是CMake文档地址: http://www.cmake.org/cmake/help/v2.8.10/cmake.html
command:理解CMake文档关键就是理解他的一些command, 整个CMake的架构就是绕着这些command进行的,他就是整个脚本的框架。
property:具体对象的一些设置 set_property(TARGET myexe PROPERTY LINK_SEARCH_START_STATIC 1)
variable: 环境的一些配置
有了这几个概念,读cmake帮助文件就水到渠成了。
如何优先调用静态库?
Finding static versions of external libraries.
The only way seems to be setting CMAKE_FIND_LIBRARY_SUFFIXES
to contain the desired file suffix(es) (it's a priority list).
61 ###prefer static to dynamic library
62 set(CMAKE_FIND_LIBRARY_SUFFIXES .a${CMAKE_FIND_LIBRARY_SUFFIXES})
CUDA 和 gcc 混编:
70 FILE(GLOB_RECURSE SRC_LIST "src/*.cpp")
71 FOREACH(src ${SRC_LIST})
72 MESSAGE( Find: ${src} )
73 ENDFOREACH(src)
74
75 FILE(GLOB_RECURSE CUDA_SRC_LIST "src/*.cu")
76 FOREACH(src ${CUDA_SRC_LIST})
77 MESSAGE( Find: ${src} )
78 ENDFOREACH(src)
79
80 CUDA_COMPILE(CUDA_TARGETS ${CUDA_SRC_LIST})
81 ADD_EXECUTABLE(${project_name} ${CUDA_TARGETS} ${SRC_LIST})