免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2398 | 回复: 1
打印 上一主题 下一主题

CMake的问题? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-04-27 17:42 |只看该作者 |倒序浏览

大家好,我的单元测试在链接的时候出现错误,信息如下:

Link:
     Creating library D:/source/VenueCode/JNX_OMX_6.x.project/bin/Debug/AcceptanceTests.lib and object D:/source/VenueCode/JNX_OMX_6.x.project/bin/Debug/AcceptanceTests.exp
LINK : fatal error LNK1285: corrupt PDB file 'D:\source\VenueCode\JNX_OMX_6.x.project\bin\Debug\AcceptanceTests.pdb'; delete and rebuild

Build FAILED.

这是一个UT的工程,所以我期望的是生成AcceptanceTests.exe而不是.lib. 下面是我的CMakeLists.txt. 我因为不知道原因在哪里,所以不知道提供的这些信息够不够。


file( GLOB interfacefiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.h *.hpp ../*.h ../*.hpp)
file( GLOB srcfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.h *.hpp *.cpp *.c ../*.h ../*.hpp ../src/*.cpp  ../src/*.c)
file( GLOB mockfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} Mock*.h Mock*.hpp Mock*.cpp Mock*.c )

source_group( "Source" FILES ${srcfiles} )
source_group( "Interface" FILES ${interfacefiles} )
source_group( "Mock Files" FILES ${mockfiles} )

RDFD_LineHandlerTest(AcceptanceTests ${srcfiles} ${interfacefiles} ${mockfiles})
set_property(TARGET AcceptanceTests PROPERTY FOLDER "UnitTests")

target_link_libraries( AcceptanceTests
  Inputs-JNX
  Messages-JNX
  Processing-JNX
  ep.ClosingRuns
  ep.ShellItem
)

多谢!

论坛徽章:
0
2 [报告]
发表于 2012-04-27 18:05 |只看该作者
addd_executable指令生成执行文件

你没贴出完整的。

另外我给你看个例子
  1. cmake_minimum_required(VERSION 2.4.4)
  2. set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)

  3. project(zlib C)

  4. if(NOT DEFINED BUILD_SHARED_LIBS)
  5.     option(BUILD_SHARED_LIBS "Build a shared library form of zlib" ON)
  6. endif()

  7. include(CheckTypeSize)
  8. include(CheckFunctionExists)
  9. include(CheckIncludeFile)
  10. include(CheckCSourceCompiles)
  11. enable_testing()

  12. check_include_file(sys/types.h HAVE_SYS_TYPES_H)
  13. check_include_file(stdint.h    HAVE_STDINT_H)
  14. check_include_file(stddef.h    HAVE_STDDEF_H)

  15. #
  16. # Check to see if we have large file support
  17. #
  18. set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
  19. # We add these other definitions here because CheckTypeSize.cmake
  20. # in CMake 2.4.x does not automatically do so and we want
  21. # compatibility with CMake 2.4.x.
  22. if(HAVE_SYS_TYPES_H)
  23.     list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H)
  24. endif()
  25. if(HAVE_STDINT_H)
  26.     list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H)
  27. endif()
  28. if(HAVE_STDDEF_H)
  29.     list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H)
  30. endif()
  31. check_type_size(off64_t OFF64_T)
  32. if(HAVE_OFF64_T)
  33.    add_definitions(-D_LARGEFILE64_SOURCE=1)
  34. endif()
  35. set(CMAKE_REQUIRED_DEFINITIONS) # clear variable

  36. #
  37. # Check for fseeko
  38. #
  39. check_function_exists(fseeko HAVE_FSEEKO)
  40. if(NOT HAVE_FSEEKO)
  41.     add_definitions(-DNO_FSEEKO)
  42. endif()

  43. #
  44. # Check for unistd.h
  45. #
  46. check_include_file(unistd.h Z_HAVE_UNISTD_H)

  47. if(MSVC)
  48.     set(CMAKE_DEBUG_POSTFIX "d")
  49.     add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
  50.     add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
  51. endif()

  52. if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
  53.     # If we're doing an out of source build and the user has a zconf.h
  54.     # in their source tree...
  55.     if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h)
  56.         message(FATAL_ERROR
  57.             "You must remove ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h "
  58.             "from the source tree.  This file is included with zlib "
  59.             "but CMake generates this file for you automatically "
  60.             "in the build directory.")
  61.   endif()
  62. endif()

  63. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein
  64.                ${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY)
  65. include_directories(${CMAKE_CURRENT_BINARY_DIR})


  66. #============================================================================
  67. # zlib
  68. #============================================================================

  69. set(ZLIB_PUBLIC_HDRS
  70.     ${CMAKE_CURRENT_BINARY_DIR}/zconf.h
  71.     zlib.h
  72. )
  73. set(ZLIB_PRIVATE_HDRS
  74.     crc32.h
  75.     deflate.h
  76.     gzguts.h
  77.     inffast.h
  78.     inffixed.h
  79.     inflate.h
  80.     inftrees.h
  81.     trees.h
  82.     zutil.h
  83. )
  84. set(ZLIB_SRCS
  85.     adler32.c
  86.     compress.c
  87.     crc32.c
  88.     deflate.c
  89.     gzclose.c
  90.     gzlib.c
  91.     gzread.c
  92.     gzwrite.c
  93.     inflate.c
  94.     infback.c
  95.     inftrees.c
  96.     inffast.c
  97.     trees.c
  98.     uncompr.c
  99.     zutil.c
  100.     win32/zlib1.rc
  101. )

  102. # parse the full version number from zlib.h and include in ZLIB_FULL_VERSION
  103. file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents)
  104. string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([0-9A-Za-z.]+)\".*"
  105.     "\\1" ZLIB_FULL_VERSION ${_zlib_h_contents})

  106. if(MINGW)
  107.     # This gets us DLL resource information when compiling on MinGW.
  108.     add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
  109.                        COMMAND windres.exe
  110.                             -D GCC_WINDRES
  111.                             -I ${CMAKE_CURRENT_SOURCE_DIR}
  112.                             -I ${CMAKE_CURRENT_BINARY_DIR}
  113.                             -o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
  114.                             -i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc)
  115.     set(ZLIB_SRCS ${ZLIB_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
  116. endif(MINGW)

  117. add_library(zlib ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
  118. set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)

  119. set_target_properties(zlib PROPERTIES SOVERSION 1)

  120. if(NOT CYGWIN)
  121.     # This property causes shared libraries on Linux to have the full version
  122.     # encoded into their final filename.  We disable this on Cygwin because
  123.     # it causes cygz-${ZLIB_FULL_VERSION}.dll to be created when cygz.dll
  124.     # seems to be the default.
  125.     #
  126.     # This has no effect with MSVC, on that platform the version info for
  127.     # the DLL comes from the resource file win32/zlib1.rc
  128.     set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION})
  129. endif()

  130. if(UNIX)
  131.     # On unix-like platforms the library is almost always called libz
  132.    set_target_properties(zlib PROPERTIES OUTPUT_NAME z)
  133. elseif(BUILD_SHARED_LIBS AND WIN32)
  134.     # Creates zlib1.dll when building shared library version
  135.     set_target_properties(zlib PROPERTIES SUFFIX "1.dll")
  136. endif()

  137. if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
  138.     install(TARGETS zlib
  139.         RUNTIME DESTINATION bin
  140.         ARCHIVE DESTINATION lib
  141.         LIBRARY DESTINATION lib )
  142. endif()
  143. if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
  144.     install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION include)
  145. endif()
  146. if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
  147.     install(FILES zlib.3 DESTINATION share/man/man3)
  148. endif()

  149. #============================================================================
  150. # Example binaries
  151. #============================================================================

  152. add_executable(example example.c)
  153. target_link_libraries(example zlib)
  154. add_test(example example)

  155. add_executable(minigzip minigzip.c)
  156. target_link_libraries(minigzip zlib)

  157. if(HAVE_OFF64_T)
  158.     add_executable(example64 example.c)
  159.     target_link_libraries(example64 zlib)
  160.     set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
  161.     add_test(example64 example64)

  162.     add_executable(minigzip64 minigzip.c)
  163.     target_link_libraries(minigzip64 zlib)
  164.     set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
  165. endif()
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP