Skip to content

Commit

Permalink
Further refined bela examples build systems
Browse files Browse the repository at this point in the history
  • Loading branch information
faressc committed Aug 26, 2024
1 parent aaf1bbf commit ee1d2b5
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 3 deletions.
27 changes: 25 additions & 2 deletions examples/embedded/bela/bela-benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,39 @@ project (${PROJECT_NAME} VERSION 0.0.1)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)

# Make sure to install the anira library under /root/anira if using the precompiled version of anira or set ANIRA_WITH_INSTALL to ON when adding the anira library as a subdirectory
# Obviously, this benchmark requires the anira library to be build with the benchmark option enabled

################################################################
# Setting up anira
################################################################

# set(ANIRA_WITH_BENCHMARK ON)
# set(ANIRA_WITH_SEMAPHORE OFF)
# set(ANIRA_WITH_ONNXRUNTIME OFF) # Not yet supported
# set(ANIRA_WITH_TFLITE OFF) # Not yet supported
# # In case the libs from anira shall be installed
# # This only works when the anira library is a subdirectory of the project
# set(ANIRA_WITH_INSTALL ON)
# add_subdirectory(anira) # set this to the path of the anira library if its a submodule of your repository
# list(APPEND CMAKE_PREFIX_PATH "/path/to/anira") # Use this if you use the precompiled version of anira
# list(APPEND CMAKE_PREFIX_PATH "anira-0.1.0-bela") # Use this if you use the precompiled version of anira
# find_package(anira REQUIRED)

################################################################
# Adding the executable
################################################################

add_executable(${PROJECT_NAME})

target_sources(${PROJECT_NAME} PRIVATE
defineBelaBenchmark.cpp
main.cpp
)

target_link_libraries(${PROJECT_NAME} anira::anira)
target_link_libraries(${PROJECT_NAME} anira::anira)

################################################################
# Installing the executable
################################################################

include(cmake/install.cmake)
26 changes: 26 additions & 0 deletions examples/embedded/bela/bela-benchmark/cmake/install.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# ==============================================================================
# Install the executable
# ==============================================================================

# for CMAKE_INSTALL_INCLUDEDIR and others definition
include(GNUInstallDirs)

# define the directory where the executable will be installed CMAKE_INSTALL_PREFIX
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-${PROJECT_VERSION}" CACHE PATH "Where the library will be installed to" FORCE)

set(CUSTOM_RPATH "/root/anira/lib")
if (ANIRA_WITH_INSTALL)
list(APPEND CUSTOM_RPATH "$ORIGIN/../lib")
endif()
set_target_properties(${PROJECT_NAME}
PROPERTIES
INSTALL_RPATH "${CUSTOM_RPATH}"
)

# install the target
install(TARGETS ${PROJECT_NAME}
# these get default values from GNUInstallDirs
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}
)
4 changes: 4 additions & 0 deletions examples/embedded/bela/bela-inference/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ find_library(MATHNEON_LIB REQUIRED
# list(APPEND CMAKE_PREFIX_PATH "anira-0.1.0-bela") # Use this if you use the precompiled version of anira
# find_package(anira REQUIRED)

################################################################
# Adding the executable
################################################################

set(EXE_NAME ${PROJECT_NAME})

file(GLOB SRC_FILES *.cpp)
Expand Down
2 changes: 1 addition & 1 deletion examples/embedded/bela/bela-inference/cmake/install.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ set_target_properties(${PROJECT_NAME}
INSTALL_RPATH "${CUSTOM_RPATH}"
)

# install the target and create export-set
# install the target
install(TARGETS ${PROJECT_NAME}
# these get default values from GNUInstallDirs
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
Expand Down

0 comments on commit ee1d2b5

Please sign in to comment.