linux怎么查看本机内存大小
239
2022-11-28
cmakelist.txt编译实例
cmake_minimum_required ( VERSION 3.0 )set ( PROJ_NAME $D{PROJ_NAME_LOWER} )project ( ${PROJ_NAME} )# 1) 指定变量set ( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)# 2) 检查平台 & 生成配置头文件# 3) 源列表AUX_SOURCE_DIRECTORY( ../../common COMMON_LIST )AUX_SOURCE_DIRECTORY( ../../auxproc AUXPROC_LIST )SET ( RES_LIST ../../resource/$D{PROJ_NAME_LOWER}res.rc )set ( SOURCE_LIST ${COMMON_LIST} ${AUXPROC_LIST} ${RES_LIST} )# 3-1) 子目标 CMakeListmessage("found source files below:")foreach( F ${SOURCE_LIST} )message(${F})endforeach(${F})# 4) 确定目标# 4.1) 指定附加的头文件搜索路径与库文件搜索路径# include_directories ( 相对于 CMakeList 的路径 )# link_directories ( 相对于 CMakeList 的路径 )# add_definitions( -DMacro1 -DMacro2 ) 添加预定义编译宏# add_dependencies( target-name depend-target1 depend-target2 ... ) 添加依赖规则set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D$D{PROJ_NAME_UPPER}_CFG_DIAG_USE_MEM_CNTR -D$D{PROJ_NAME_UPPER}_CFG_DIAG_USE_DBG_OUTPUT -D$D{PROJ_NAME_UPPER}_CFG_DIAG_USE_ASSERT")set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D$D{PROJ_NAME_UPPER}_CFG_DIAG_USE_MEM_CNTR -D$D{PROJ_NAME_UPPER}_CFG_DIAG_USE_DBG_OUTPUT -D$D{PROJ_NAME_UPPER}_CFG_DIAG_USE_ASSERT")set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D$D{PROJ_NAME_UPPER}_CFG_DIAG_USE_MEM_CNTR ")set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -D$D{PROJ_NAME_UPPER}_CFG_DIAG_USE_MEM_CNTR ")# 4.2) 指定生成的目标需要链接的库add_library( ${PROJ_NAME} SHARED ${SOURCE_LIST} )#target_link_libraries( ${PROJ_NAME} debug opencl )#target_link_libraries( ${PROJ_NAME} optimized opencl )set_target_properties( ${PROJ_NAME} PROPERTIES DEBUG_OUTPUT_NAME ${PROJ_NAME}d )set_target_properties( ${PROJ_NAME} PROPERTIES RELEASE_OUTPUT_NAME ${PROJ_NAME} )# 5) 复制生成文件install ( TARGETS ${PROJ_NAME} ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/lib CONFIGURATIONS Release Debug )# 将扫描所有 DIRECTORY 下面的子目录,并自动建立相应子目录,将所有符合模式的文件复制进install( FILES ${PROJECT_SOURCE_DIR}/../../common/$D{PROJ_NAME_LOWER}def.h ${PROJECT_SOURCE_DIR}/../../common/$D{PROJ_NAME_LOWER}diag.hxx ${PROJECT_SOURCE_DIR}/../../common/$D{PROJ_NAME_LOWER}sys.hxx DESTINATION ${CMAKE_INSTALL_PREFIX}/include/common )install ( DIRECTORY ${PROJECT_BINARY_DIR}/Debug/ DESTINATION ${CMAKE_INSTALL_PREFIX}/lib FILES_MATCHING PATTERN "$D{PROJ_NAME_LOWER}d.pdb" )install ( DIRECTORY ${PROJECT_BINARY_DIR}/Release/ DESTINATION ${CMAKE_INSTALL_PREFIX}/lib FILES_MATCHING PATTERN "$D{PROJ_NAME_LOWER}.pdb" )
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~