我写了一个CMakeLists.txt包含2个可执行文件(target1和target2)的文件:
ADD_EXECUTABLE(target1 ${CXX_FILES})
TARGET_LINK_LIBRARIES(target1 ${requiredlibs})
ADD_EXECUTABLE(target2 ${CXX_FILES} ${OTHER_CXX_FILES})
TARGET_LINK_LIBRARIES(target2 ${requiredlibs})
Run Code Online (Sandbox Code Playgroud)
现在,每当我在没有任何参数的情况下运行make时,都会重建两个目标.但我想定义target1为默认可执行文件,以便只运行make而不使用任何参数target1.对于建筑target2我会跑make target2.
这可能吗?
在CMake创建的Makefile中,有以下定义:default_target:all
我想我需要一种方法来此设置default_target来target1.
我遇到的另一个问题是make总是重建目标,即使没有更改源文件.