From ce9c5af1408693c768666ed9619abe1ee6955917 Mon Sep 17 00:00:00 2001 From: Khalil Estell Date: Mon, 16 Oct 2023 19:19:36 -0700 Subject: [PATCH] :sparkles: Use buildenv in demos :arrow_up: version 2.2.0 --- README.md | 8 ++++---- cmake/build.cmake | 25 ++++++++++++++++++++++--- conanfile.py | 2 +- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c15d6c0..93273ea 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ applications `conanfile.py`: ```python def build_requirements(self): - self.tool_requires("libhal-cmake-util/1.0.0") + self.tool_requires("libhal-cmake-util/2.2.0") ``` **NOTE**: the `tool_requires` line can also go in the `requirements()` method or @@ -26,7 +26,7 @@ these options in the `tool_requires` function. ```python def build_requirements(self): - self.tool_requires("libhal-cmake-util/1.0.0", + self.tool_requires("libhal-cmake-util/2.2.0", options={ "add_build_outputs": True, "optimize_debug_build": True, @@ -132,7 +132,7 @@ as a package. In conan, add this to your `build_requirements()` method: ```python def build_requirements(self): - self.tool_requires("libhal-cmake-util/2.1.0") + self.tool_requires("libhal-cmake-util/2.2.0") self.test_requires("boost-ext-ut/1.1.9") ``` @@ -186,7 +186,7 @@ as a package. In conan, add this to your `build_requirements()` method: ```python def build_requirements(self): - self.tool_requires("libhal-cmake-util/1.1.0") + self.tool_requires("libhal-cmake-util/2.2.0") self.test_requires("boost-ext-ut/1.1.9") ``` diff --git a/cmake/build.cmake b/cmake/build.cmake index 21ea78f..45855b6 100644 --- a/cmake/build.cmake +++ b/cmake/build.cmake @@ -215,11 +215,25 @@ function(libhal_build_demos) "${multi_value_args}" ${ARGN}) + if(NOT DEFINED ENV{LIBHAL_PLATFORM} OR + NOT DEFINED ENV{LIBHAL_PLATFORM_LIBRARY}) + message(FATAL_ERROR + "Both LIBHAL_PLATFORM and LIBHAL_PLATFORM_LIBRARY environment variables " + "must be defined. Make sure you are using the correct profile!") + endif() + + set(platform_link_library libhal::$ENV{LIBHAL_PLATFORM_LIBRARY}) + + find_package(libhal-$ENV{LIBHAL_PLATFORM_LIBRARY} REQUIRED) + foreach(PACKAGE ${DEMO_ARGS_PACKAGES}) find_package(${PACKAGE} REQUIRED) endforeach() - add_library(startup_code main.cpp ${DEMO_ARGS_SOURCES}) + add_library(startup_code + main.cpp + platforms/$ENV{LIBHAL_PLATFORM}.cpp + ${DEMO_ARGS_SOURCES}) target_compile_features(startup_code PRIVATE cxx_std_20) target_include_directories(startup_code PUBLIC ${DEMO_ARGS_INCLUDES}) target_compile_options(startup_code PRIVATE @@ -229,7 +243,10 @@ function(libhal_build_demos) -Wextra -Wshadow ) - target_link_libraries(startup_code PRIVATE ${DEMO_ARGS_LINK_LIBRARIES}) + target_link_libraries(startup_code PRIVATE + ${DEMO_ARGS_LINK_LIBRARIES} + ${platform_link_library} + ) if(NOT ${DEMO_ARGS_DISABLE_CLANG_TIDY}) _libhal_add_clang_tidy_check(startup_code) @@ -250,7 +267,9 @@ function(libhal_build_demos) ) target_link_libraries(${elf} PRIVATE startup_code - ${DEMO_ARGS_LINK_LIBRARIES}) + ${DEMO_ARGS_LINK_LIBRARIES} + ${platform_link_library} + ) if(${CMAKE_CROSSCOMPILING}) _libhal_using_picolibc(using_picolibc) diff --git a/conanfile.py b/conanfile.py index 54c93e0..237a39c 100644 --- a/conanfile.py +++ b/conanfile.py @@ -23,7 +23,7 @@ class libhal_cmake_util_conan(ConanFile): name = "libhal-cmake-util" - version = "2.1.1" + version = "2.2.0" license = "Apache-2.0" url = "https://github.com/conan-io/conan-center-index" homepage = "https://libhal.github.io/libhal-armcortex"