ExternalProject Premature Completion

Hi CMake Community,

I’m currently trying to add crashpad as a dependency to my C++ project. I have chosen to gather all the dependencies from chromium needed to build my project, and even go as far to commit some binaries into the repo for easy of use of the people who use this project. So far, it is all working out as I would like. Though, I am having a problem with ExternalProject specifically on a Visual Studio generator.

The following code section is posted for context of what I am trying to do.

include(ExternalProject)
include(FetchContent)
FetchContent_Declare(depot_tools
	GIT_REPOSITORY https://chromium.googlesource.com/chromium/tools/depot_tools.git
	GIT_PROGRESS TRUE
	GIT_SHALLOW TRUE)
FetchContent_MakeAvailable(depot_tools)
FetchContent_GetProperties(depot_tools SOURCE_DIR DEPOT_TOOLS_DIR)

# Discover binaries within depot tools
list(APPEND CMAKE_PROGRAM_PATH ${DEPOT_TOOLS_DIR})
find_program(EXE_DEPOT_GN gn)
find_program(EXE_DEPOT_NINJA ninja)

# Crashpad source and build folders
set(SOURCE_DIR ${PROJECT_SOURCE_DIR}/lib/crashpad/crashpad)
set(BINARY_DIR ${PROJECT_BINARY_DIR}/gn_crashpad)

# Shotening large section that gets passed into BYPRODUCTS
list(APPEND OUTPUT_LIBS ...)

ExternalProject_Add(crashpad_init
    PREFIX  ${BINARY_DIR}
    SOURCE_DIR ${SOURCE_DIR}
    BINARY_DIR ${BINARY_DIR}

    # Disable all commands, to prefer steps.
    DOWNLOAD_COMMAND ""
    CONFIGURE_COMMAND ""
    BUILD_COMMAND ""
    INSTALL_COMMAND ""
    TEST_COMMAND "")

All that works exactly as I would like it to. Here is the problem I am experiencing, and I’ve made it as simple as I could where the issue still presents.

ExternalProject_Add_Step(crashpad_init step1
	ALWAYS 1
	COMMAND echo step1)

ExternalProject_Add_Step(crashpad_init step2
	ALWAYS 1
	DEPENDS step1
	COMMAND echo step2)

ExternalProject_Add_Step(crashpad_init step3
	ALWAYS 1
	DEPENDS step2
	COMMAND echo step3)

When the crashpad_init target is run, it runs as expected where it will go step1, step2, step3. Here is the output I get:

1>------ Build started: Project: crashpad_init, Configuration: Debug x64 ------
1>Performing step1 step for 'crashpad_init'
1>step1
1>Performing step2 step for 'crashpad_init'
1>step2
1>Performing step3 step for 'crashpad_init'
1>step3
1>Completed 'crashpad_init'
========== Build: 1 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========

But, when I make a small change step 1 to the following to instead execute a configuration step…

ExternalProject_Add_Step(crashpad_init step1
	ALWAYS 1
	WORKING_DIRECTORY ${SOURCE_DIR}
	COMMAND ${EXE_DEPOT_GN} gen ${BINARY_DIR})

I get the following output instead:

1>------ Build started: Project: crashpad_init, Configuration: Debug x64 ------
1>Performing step1 step for 'crashpad_init'
1>Done. Made 85 targets from 27 files in 3819ms
========== Build: 1 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========

…and my other two steps don’t execute! When it comes to having multiple steps, this runs just fine on linux, mac, and other non Visual Studio generators on windows. As much as I’d like to, we cannot drop VS support on the build system.

I’ve been writing CMake for a while, but I don’t know if I should interpret this as a bug within CMake, or something wrong with my CMake code. If anyone could help me figure out what’s going on that would be greatly appreciated!

  • Edit 1
    Here is a link to my repository with the repdocuable example if further testing is required. I’ll say ahead of time that I am aware the conditional statement on line 61 will not work for a multi-configuration generator. That’s what I was in the process of fixing when I came across this error.

  • Edit 2
    I am running the latest version of cmake 3.18.1.

Multi-config generators and ExternalProject is weird. I don’t know if this is just some corner case in Visual Studio or not.

Cc: @brad.king @craig.scott