Skip to content

Commit

Permalink
build: only build and install protobuf echo compilers when EMIL_BUILD…
Browse files Browse the repository at this point in the history
…_ECHO_COMPILERS is set (#445)

* build: only build and install protobuf echo compilers when EMIL_BUILD_ECHO_COMPILERS is set

* protobuf/protoc_echo_plugin*/CMakeLists: Fix emil_build_for statement

* Install export file, but only whene EMIL_BUILD_ECHO_COMPILERS
  • Loading branch information
richardapeters authored Oct 26, 2023
1 parent 8039f73 commit 3358e45
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 31 deletions.
42 changes: 18 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ option(EMIL_BUILD_TESTS "Enable building the tests" ${EMIL_DEFAULTOPT})
option(EMIL_BUILD_EXAMPLES "Enable building the examples" ${EMIL_DEFAULTOPT})
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_BUILD_ECHO_COMPILERS "Build and install the Protobuf ECHO compilers" ${EMIL_DEFAULTOPT})

# Enable or disable optional features.
option(EMIL_INCLUDE_MBEDTLS "Include MbedTLS as part of EmIL" On)
Expand Down Expand Up @@ -148,18 +148,12 @@ if (EMIL_STANDALONE)
emil_folderize_all_targets()
endif()

if (EMIL_GENERATE_PACKAGE_CONFIG)
if (EMIL_BUILD_ECHO_COMPILERS)
function(generate_export_targets name)
# Generate and install export file
install(EXPORT emil${name}Targets
FILE emil${name}Targets.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/emil
)

# Generate the export targets for the build tree
export(EXPORT emil${name}Targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/emil${name}Targets.cmake"
)
endfunction()

foreach(target IN ITEMS Protobuf)
Expand All @@ -184,20 +178,20 @@ if (EMIL_GENERATE_PACKAGE_CONFIG)
"${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)

set(CPACK_GENERATOR "ZIP;TGZ")
set(CPACK_SOURCE_IGNORE_FILES ".vs/;.git/;build/")
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
set(CPACK_PACKAGE_VENDOR "Koninklijke Philips N.V")
set(CPACK_PACKAGE_DESCRIPTION "${PROJECT_DESCRIPTION}")
set(CPACK_DEBIAN_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
set(CPACK_RPM_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
set(CPACK_PACKAGE_HOMEPAGE_URL "${PROJECT_HOMEPAGE_URL}")
set(CPACK_PACKAGE_MAINTAINER "${CPACK_PACKAGE_VENDOR}")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_PACKAGE_VENDOR}")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")

include(CPack)
endif()

set(CPACK_GENERATOR "ZIP;TGZ")
set(CPACK_SOURCE_IGNORE_FILES ".vs/;.git/;build/")
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
set(CPACK_PACKAGE_VENDOR "Koninklijke Philips N.V")
set(CPACK_PACKAGE_DESCRIPTION "${PROJECT_DESCRIPTION}")
set(CPACK_DEBIAN_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
set(CPACK_RPM_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
set(CPACK_PACKAGE_HOMEPAGE_URL "${PROJECT_HOMEPAGE_URL}")
set(CPACK_PACKAGE_MAINTAINER "${CPACK_PACKAGE_VENDOR}")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_PACKAGE_VENDOR}")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")

include(CPack)
4 changes: 2 additions & 2 deletions protobuf/protoc_echo_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ if (EMIL_HOST_BUILD)

if (NOT CMAKE_CROSSCOMPILING)
add_executable(protobuf.protoc_echo_plugin)
emil_build_for(protobuf.protoc_echo_plugin BOOL EMIL_STANDALONE)
install(TARGETS protobuf.protoc_echo_plugin EXPORT emilProtobufTargets DESTINATION bin)
emil_build_for(protobuf.protoc_echo_plugin BOOL EMIL_BUILD_ECHO_COMPILERS)
emil_install(protobuf.protoc_echo_plugin EXPORT emilProtobufTargets DESTINATION bin)

target_link_libraries(protobuf.protoc_echo_plugin PUBLIC
protobuf.protoc_echo_plugin_lib
Expand Down
4 changes: 2 additions & 2 deletions protobuf/protoc_echo_plugin_csharp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
if (EMIL_HOST_BUILD AND NOT CMAKE_CROSSCOMPILING)
add_executable(protobuf.protoc_echo_plugin_csharp)
emil_build_for(protobuf.protoc_echo_plugin_csharp BOOL EMIL_STANDALONE)
install(TARGETS protobuf.protoc_echo_plugin_csharp EXPORT emilProtobufTargets DESTINATION bin)
emil_build_for(protobuf.protoc_echo_plugin_csharp BOOL EMIL_BUILD_ECHO_COMPILERS)
emil_install(protobuf.protoc_echo_plugin_csharp EXPORT emilProtobufTargets DESTINATION bin)

target_link_libraries(protobuf.protoc_echo_plugin_csharp PUBLIC
protobuf.protoc_echo_plugin_lib
Expand Down
4 changes: 2 additions & 2 deletions protobuf/protoc_echo_plugin_java/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
if (EMIL_HOST_BUILD AND NOT CMAKE_CROSSCOMPILING)
add_executable(protobuf.protoc_echo_plugin_java)
emil_build_for(protobuf.protoc_echo_plugin_java BOOL EMIL_STANDALONE)
install(TARGETS protobuf.protoc_echo_plugin_java EXPORT emilProtobufTargets DESTINATION bin)
emil_build_for(protobuf.protoc_echo_plugin_java BOOL EMIL_BUILD_ECHO_COMPILERS)
emil_install(protobuf.protoc_echo_plugin_java EXPORT emilProtobufTargets DESTINATION bin)

target_link_libraries(protobuf.protoc_echo_plugin_java PUBLIC
protobuf.protoc_echo_plugin_lib
Expand Down
2 changes: 1 addition & 1 deletion services/echo_console/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
if (EMIL_HOST_BUILD)
add_executable(services.echo_console ${EMIL_EXCLUDE_FROM_ALL})
emil_install(services.echo_console EXPORT emilProtobufTargets DESTINATION bin)
emil_install(services.echo_console DESTINATION bin)

target_link_libraries(services.echo_console PUBLIC
args
Expand Down

0 comments on commit 3358e45

Please sign in to comment.