简体   繁体   中英

Configuring txx file with CMake for visual studio project

I have a project having txx file along with source files. I used following CMake configuration

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})

But my sln file is showing txx file in headers and treating it as a text file while comiplation. I checked one cpp is including that txx and when I entered some line just to enter some errors so that I can check if that txx is compiling or not it didn't returned any error. Now my question is

  1. Why txx is not compiling?
  2. Why its appearing in header when I am trying to add it as a source?
  3. Why visual studio treating it as a text file?
  4. How to compile this project?

Thanks in advance.

I think CMake looks file extensions to find out C++ source files and does not recognize the .txx extension as one of the C++ source file extensions. The CMake documentation describes way to set the file language explicitely. Eg

set_source_files_properties(Step6RegionGrowing.txx PROPERTIES LANGUAGE CXX)

Hope it helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM