문제

I want a part of the CMakeLists.txt file to be ignored when a user calls

make package

I am therefore looking for a variable such as CMAKE_COMMAND or CMAKE_PACKAGING so that I could do

if (CMAKE_COMMAND EQUAL 'package') ...

or

if (CMAKE_PACKAGING) ...

Does this exist? Can it be achieved?

도움이 되었습니까?

해결책

CMake generates make files that contain some "pre-defined" make targets that follow conventions expected by those that use them. Targets such as all, install, package and test.

The 'install' and 'package' make targets typically, by default, depend on the 'all' make target. (So that if you type 'make install' it does a 'make all' first to ensure everything's up to date before the install occurs. Similarly with 'package'.)

What 'make package' actually does is to call cpack under the covers:

/full/path/to/cpack --config ./CPackConfig.cmake

You can see this command line being invoked if you execute:

make package VERBOSE=1

What part of your CMakeLists.txt file do you want to skip in the packaging case? There is no variable such as the one you are looking for, because the packaging does not occur at CMake configure-time; it occurs later, after build time, when the user explicitly invokes 'make package' or 'cpack'.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top