【问题标题】:How do I tell cmake to separate the solution and the project?我如何告诉 cmake 将解决方案和项目分开?
【发布时间】:2021-07-15 10:14:20
【问题描述】:

我有一个可以工作的 CMakeList.txt,但它没有将解决方案与项目分开,这很丑陋。我想告诉 cmake 为项目创建一个文件夹。这样我们用 cmake 生成文件夹时会更容易理解。

现在看起来像这样:

可以这样生成吗? :

这是我的 Cmake 列表的样子:

cmake_minimum_required( VERSION 3.1 FATAL_ERROR )
# Create Project
project(PointCloudToRndConvertor)
add_executable( PointCloudToRndConvertor main.cpp )
set_property( DIRECTORY PROPERTY VS_STARTUP_PROJECT "PointCloudToRndConvertor" )

# Find Packages
find_package( PCL 1.9.1 REQUIRED )

if( PCL_FOUND )
  # Additional Include Directories
  # [C/C++]>[General]>[Additional Include Directories]
  include_directories( ${PCL_INCLUDE_DIRS} )

  # Preprocessor Definitions
  # [C/C++]>[Preprocessor]>[Preprocessor Definitions]
  add_definitions( ${PCL_DEFINITIONS} )
  add_definitions( -DPCL_NO_PRECOMPILE )

  # Additional Library Directories
  # [Linker]>[General]>[Additional Library Directories]
  link_directories( ${PCL_LIBRARY_DIRS} )

  # Additional Dependencies
  # [Linker]>[Input]>[Additional Dependencies]
  target_link_libraries( PointCloudToRndConvertor ${PCL_LIBRARIES} )
endif()

【问题讨论】:

    标签: c++ visual-studio cmake


    【解决方案1】:

    您可以通过更改其属性来设置目标假定可见的文件夹:

    set_target_properties(
        yuor_target
        PROPERTIES FOLDER SomeFolderWhereItShouldGo
    )
    

    参考资料:

    【讨论】:

      最近更新 更多