【问题标题】:Configuring txx file with CMake for visual studio project使用 CMake 为 Visual Studio 项目配置 txx 文件
【发布时间】:2013-01-17 06:01:45
【问题描述】:

我有一个包含 txx 文件和源文件的项目。我使用了以下 CMake 配置

SET(Main Step6.cpp Step6main.cpp Step6RegionGrowing1.cpp Step6RegionGrowing2.cpp moc_Step6.cpp Step6RegionGrowing.txx) SET(MainH Step6.h)

add_executable(${PROJECT_NAME} ${Main} ${MainH} ) target_link_libraries(${PROJECT_NAME} ${ALL_LIBRARIES})

但我的 sln 文件在标题中显示 txx 文件,并在编译时将其视为文本文件。我检查了一个 cpp 是否包含该 txx 并且当我输入某行只是为了输入一些错误以便我可以检查该 txx 是否正在编译时它没有返回任何错误。 现在我的问题是

  1. 为什么 txx 没有编译?
  2. 当我尝试将其添加为源时,为什么它会出现在标题中?
  3. 为什么 Visual Studio 将其视为文本文件?
  4. 如何编译这个项目?

提前致谢。

【问题讨论】:

    标签: c++ visual-studio-2008 compilation cmake


    【解决方案1】:

    我认为 CMake 会查找文件扩展名以找出 C++ 源文件,并且不将 .txx 扩展名识别为 C++ 源文件扩展名之一。 The CMake documentation 描述了明确设置文件语言的方法。例如

    set_source_files_properties(Step6RegionGrowing.txx PROPERTIES LANGUAGE CXX)
    

    希望对你有帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-14
      • 2010-09-28
      • 1970-01-01
      • 1970-01-01
      • 2020-10-12
      • 2011-03-16
      • 1970-01-01
      相关资源
      最近更新 更多