Skip to content

Support GRADLE_WRAPPER override in CMake build (similar to aeron project) #1091

@tkohlman

Description

@tkohlman

The aeron project's CMakeList.txt allows the local gradlew script to be overridden by an environment variable. This is useful if you want to specify a different gradle version and/or avoid a download during a build. This feature would be useful in the SBE project as well.

Suggest to add the following in CMakeLists.txt:

if (NOT DEFINED GRADLE_WRAPPER)
    if (MSVC)
        set(GRADLE_WRAPPER "gradlew.bat" CACHE INTERNAL "Location of the Gradle wrapper script")
    else ()
        set(GRADLE_WRAPPER "./gradlew" CACHE INTERNAL "Location of the Gradle wrapper script")
    endif ()
endif ()

And use it in this custom command (also CMakeLists.txt):

add_custom_command(OUTPUT ${SBE_JAR}
    COMMAND ${GRADLE_WRAPPER} assemble -x javadoc --console=plain
    DEPENDS ${SBE_SOURCES}
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    COMMENT "Generating SBE jar"
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions