diff --git a/CMakeLists.txt b/CMakeLists.txt index 16a2319d2..b855cf839 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,8 +72,10 @@ endif() # options. if (EMIL_STANDALONE AND EMIL_HOST_BUILD) set(EMIL_DEFAULTOPT On) + set(EMIL_DEFAULTOPT_INVERTED Off) else() set(EMIL_DEFAULTOPT Off) + set(EMIL_DEFAULTOPT_INVERTED On) endif() # When building EmIL by itself do not exclude any targets from all @@ -90,7 +92,13 @@ option(EMIL_ENABLE_FUZZING "Enable building the fuzzing targets" Off) option(EMIL_ENABLE_DOCKER_TOOLS "Enable shift-left tools (e.g. linters, formatters) that are run using Docker" On) option(EMIL_GENERATE_PACKAGE_CONFIG "Enable generation of package configuration and install files" ${EMIL_HOST_BUILD}) option(EMIL_ENABLE_TRACING "Enable Tracing" On) -option(EMIL_BUILD_ECHO_COMPILERS "Build and install the Protobuf ECHO compilers" ${EMIL_DEFAULTOPT}) +option(EMIL_FETCH_ECHO_COMPILERS "Fetch the Protobuf ECHO compilers from GitHub" ${EMIL_DEFAULTOPT_INVERTED}) +if (NOT EMIL_FETCH_ECHO_COMPILERS) + set(EMIL_DEFAULTOPT_BUILD_ECHO_COMPILERS ${EMIL_DEFAULTOPT}) +else() + set(EMIL_DEFAULTOPT_BUILD_ECHO_COMPILERS Off) +endif() +option(EMIL_BUILD_ECHO_COMPILERS "Build and install the Protobuf ECHO compilers" ${EMIL_DEFAULTOPT_BUILD_ECHO_COMPILERS}) # Enable or disable optional features. option(EMIL_INCLUDE_MBEDTLS "Include MbedTLS as part of EmIL" On) diff --git a/protobuf/echo/protocol_buffer_echo.cmake b/protobuf/echo/protocol_buffer_echo.cmake index cc791230e..178746b37 100644 --- a/protobuf/echo/protocol_buffer_echo.cmake +++ b/protobuf/echo/protocol_buffer_echo.cmake @@ -7,7 +7,7 @@ function(emil_fetch_echo_plugins) # # (See: https://cmake.org/cmake/help/latest/module/FetchContent.html#commands) - if (EMIL_HOST_BUILD AND NOT CMAKE_CROSSCOMPILING) + if (EMIL_HOST_BUILD AND NOT CMAKE_CROSSCOMPILING AND NOT EMIL_FETCH_ECHO_COMPILERS) # In a host build where we are not cross-compiling we use the built echo plug-ins return() endif() diff --git a/protobuf/protoc_echo_plugin/CMakeLists.txt b/protobuf/protoc_echo_plugin/CMakeLists.txt index 71610fabe..7d1b8edee 100644 --- a/protobuf/protoc_echo_plugin/CMakeLists.txt +++ b/protobuf/protoc_echo_plugin/CMakeLists.txt @@ -1,4 +1,4 @@ -if (EMIL_HOST_BUILD) +if (EMIL_HOST_BUILD AND NOT EMIL_FETCH_ECHO_COMPILERS) add_library(protobuf.protoc_echo_plugin_lib ${EMIL_EXCLUDE_FROM_ALL} STATIC) target_compile_definitions(protobuf.protoc_echo_plugin_lib PRIVATE diff --git a/protobuf/protoc_echo_plugin/test/CMakeLists.txt b/protobuf/protoc_echo_plugin/test/CMakeLists.txt index d6d1f9950..b19bcf0fc 100644 --- a/protobuf/protoc_echo_plugin/test/CMakeLists.txt +++ b/protobuf/protoc_echo_plugin/test/CMakeLists.txt @@ -1,5 +1,11 @@ +if (EMIL_FETCH_ECHO_COMPILERS) + set(NOT_EMIL_FETCH_ECHO_COMPILERS false) +else() + set(NOT_EMIL_FETCH_ECHO_COMPILERS true) +endif() + add_executable(protobuf.protoc_echo_plugin_test) -emil_build_for(protobuf.protoc_echo_plugin_test BOOL EMIL_BUILD_TESTS) +emil_build_for(protobuf.protoc_echo_plugin_test BOOL EMIL_BUILD_TESTS PREREQUISITE_BOOL NOT_EMIL_FETCH_ECHO_COMPILERS) emil_add_test(protobuf.protoc_echo_plugin_test) protocol_buffer_echo_cpp(protobuf.protoc_echo_plugin_test ../../echo/test/TestMessages.proto) diff --git a/protobuf/protoc_echo_plugin_csharp/CMakeLists.txt b/protobuf/protoc_echo_plugin_csharp/CMakeLists.txt index 8e6ae63c8..753a02245 100644 --- a/protobuf/protoc_echo_plugin_csharp/CMakeLists.txt +++ b/protobuf/protoc_echo_plugin_csharp/CMakeLists.txt @@ -1,4 +1,4 @@ -if (EMIL_HOST_BUILD AND NOT CMAKE_CROSSCOMPILING) +if (EMIL_HOST_BUILD AND NOT CMAKE_CROSSCOMPILING AND NOT EMIL_FETCH_ECHO_COMPILERS) add_executable(protobuf.protoc_echo_plugin_csharp) emil_build_for(protobuf.protoc_echo_plugin_csharp BOOL EMIL_BUILD_ECHO_COMPILERS) emil_install(protobuf.protoc_echo_plugin_csharp EXPORT emilProtobufTargets DESTINATION bin) diff --git a/protobuf/protoc_echo_plugin_java/CMakeLists.txt b/protobuf/protoc_echo_plugin_java/CMakeLists.txt index 3d1ef6b4a..fae0d444f 100644 --- a/protobuf/protoc_echo_plugin_java/CMakeLists.txt +++ b/protobuf/protoc_echo_plugin_java/CMakeLists.txt @@ -1,4 +1,4 @@ -if (EMIL_HOST_BUILD AND NOT CMAKE_CROSSCOMPILING) +if (EMIL_HOST_BUILD AND NOT CMAKE_CROSSCOMPILING AND NOT EMIL_FETCH_ECHO_COMPILERS) add_executable(protobuf.protoc_echo_plugin_java) emil_build_for(protobuf.protoc_echo_plugin_java BOOL EMIL_BUILD_ECHO_COMPILERS) emil_install(protobuf.protoc_echo_plugin_java EXPORT emilProtobufTargets DESTINATION bin)