Makefile 如何在cmake的特定目标中包含感兴趣的目录?

Makefile 如何在cmake的特定目标中包含感兴趣的目录?,makefile,cmake,Makefile,Cmake,我有一个关于Cmake的问题。 当调用target“helloAll”时,它会生成子目标Hello和Hello2。 但是每个Hello和Hello2都应该包含其他目录。 add_library()可以包含特定对象,但include_directory不能。 你有什么解决办法吗 非常感谢 add_custom_target( helloAll DEPENDS Hello Hello2 ) #When building Hello include Src/inc include_directori


我有一个关于Cmake的问题。
当调用target“helloAll”时,它会生成子目标Hello和Hello2。
但是每个Hello和Hello2都应该包含其他目录。
add_library()可以包含特定对象,但include_directory不能。
你有什么解决办法吗

非常感谢

add_custom_target( helloAll DEPENDS Hello Hello2 )

#When building Hello include Src/inc
include_directories( Src/inc ) 

#When building Hello include Src/inc2
include_directories( Src/inc2 ) 

add_library( Hello Src/hello )
add_library( Hello2 Src/hello2 )

message(STATUS "CMAKE_INCLUDE_CURRENT_DIR: ${CMAKE_INCLUDE_CURRENT_DIR}")

build_command( buildCommand TARGET helloAll )
message(STATUS "buildCommand: ${buildCommand}")

一个CMakeLists.txt不能有每个include_目录和每个add_关于每个目标的定义。 因此,我编写了几个CMakelists.txt来描述每个include_目录和add_定义。 我不确定这是不是最好的解决办法。但这种方法可以解决这个问题

多谢各位