Skip to content

Commit

Permalink
✨ Use buildenv in demos
Browse files Browse the repository at this point in the history
⬆️ version 2.2.0
  • Loading branch information
Khalil Estell authored and kammce committed Oct 17, 2023
1 parent 9002db0 commit ce9c5af
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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")
```

Expand Down Expand Up @@ -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")
```

Expand Down
25 changes: 22 additions & 3 deletions cmake/build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit ce9c5af

Please sign in to comment.