How to skip some targets using commnd line (CMake)

451 views Asked by At

I'm have dependency on Xerces-c++ and for instal target it always builds example executables and documentation. That consumes ~50% of build time (6 mins on my build VM).

My current build command is cmake --build ${proj}\build_${platform} --config RelWithDebInfo --target install --parallel.

How can I skip non essential targets?

It's third party dependency, so I don't want to modify CMakeLists.txt.

1

There are 1 answers

0
Mizux On BEST ANSWER

According to the source there is no option to control the build of samples

add_subdirectory(samples)

ref: https://github.com/apache/xerces-c/blob/master/CMakeLists.txt#L172

But you can patch it !

option(BUILD_SAMPLES "Build samples" ON)
message(STATUS "Build samples: ${BUILD_SAMPLES}")
...
if(BUILD_SAMPLES)
  add_subdirectory(samples)
endif()

note: you can also enable CMP0077 if you have a super build...