最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c++ - How to set interface and internalPartition flags for custom module files (.cppm) in CMake with Visual Studio? - Stack Over

programmeradmin5浏览0评论

I'm working on a project that uses C++ modules, but instead of using the MS standard *.ixx file extension for module interfaces (as Visual Studio expects), I’m using *.cppm for my module interface files and *.cpp for implementation files. Because of this, I need to explicitly set the /interface and /internalPartition flags for the files in the Visual Studio project settings:

I have a CMake script for the project though, so I'd prefer it if the flags could just be set through CMake instead of the user having to do it manually.

Is it possible to do this somehow? I know about the set_source_files_properties function, but my attempts to set the interface flag did not have any effect:

set_source_files_properties(src/util_zip.cppm PROPERTIES COMPILE_OPTIONS "/interface")
set_source_files_properties(src/util_zip.cppm PROPERTIES COMPILE_FLAGS "/interface")

Any insights or examples would be greatly appreciated!

I'm working on a project that uses C++ modules, but instead of using the MS standard *.ixx file extension for module interfaces (as Visual Studio expects), I’m using *.cppm for my module interface files and *.cpp for implementation files. Because of this, I need to explicitly set the /interface and /internalPartition flags for the files in the Visual Studio project settings:

I have a CMake script for the project though, so I'd prefer it if the flags could just be set through CMake instead of the user having to do it manually.

Is it possible to do this somehow? I know about the set_source_files_properties function, but my attempts to set the interface flag did not have any effect:

set_source_files_properties(src/util_zip.cppm PROPERTIES COMPILE_OPTIONS "/interface")
set_source_files_properties(src/util_zip.cppm PROPERTIES COMPILE_FLAGS "/interface")

Any insights or examples would be greatly appreciated!

Share Improve this question edited Mar 31 at 9:51 prapin 6,8985 gold badges29 silver badges54 bronze badges asked Mar 17 at 8:38 SilverlanSilverlan 2,8115 gold badges36 silver badges69 bronze badges 3
  • cmake./cmake/help/latest/command/… – cpplearner Commented Mar 18 at 6:18
  • If you're referring to the CXX_MODULES file set, I'm already using that, but unfortunately that does not set the /interface flag in Visual Studio. – Silverlan Commented Mar 19 at 10:20
  • From the documentation, it looks like you also needs to use /TP in conjunction with /interface flag so it should be something like set_source_files_properties(src/util_zip.cppm PROPERTIES COMPILE_FLAGS "/interface /TP") – vht981230 Commented Mar 21 at 4:35
Add a comment  | 

1 Answer 1

Reset to default 0

Just putting this as an answer if there are similar future issues. From the documentation, it looks like you also needs to use /TP in conjunction with /interface flag so it should be something like

set_source_files_properties(src/util_zip.cppm PROPERTIES COMPILE_FLAGS "/interface /TP")
发布评论

评论列表(0)

  1. 暂无评论