optinally install demos and libs as well (#5387)

Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>
This commit is contained in:
Ju1He1 2024-02-02 03:24:51 +01:00 committed by GitHub
parent 6ad2bf4deb
commit c1c3580c5a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 291 additions and 2 deletions

1
.gitignore vendored
View File

@ -29,3 +29,4 @@ tests/report/
.idea .idea
*.bak *.bak
tests/test_images/ tests/test_images/
.vs/

116
CMakePresets.json Normal file
View File

@ -0,0 +1,116 @@
{
"version": 3,
"configurePresets": [
{
"name": "_base",
"hidden": true,
"cacheVariables": {
"LV_CONF_SKIP": true
}
},
{
"name": "windows-base",
"inherits": "_base",
"generator": "Visual Studio 17 2022",
"binaryDir": "${sourceDir}/build/${presetName}",
"installDir": "${sourceDir}/build/install/${presetName}",
"cacheVariables": {
"CMAKE_C_COMPILER": "cl.exe",
"CMAKE_CXX_COMPILER": "cl.exe",
"BUILD_SHARED_LIBS": "ON"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
},
"architecture": {
"value": "x64",
"strategy": "external"
}
},
{
"name": "linux-base",
"inherits": "_base",
"displayName": "Linux",
"description": "Setup WSL or native linux",
"generator": "Ninja Multi-Config",
"binaryDir": "${sourceDir}/build/${presetName}",
"installDir": "${sourceDir}/build/${presetName}",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
},
"vendor": {
"microsoft.com/VisualStudioRemoteSettings/CMake/1.0": {
"sourceDir": "$env{HOME}/.vs/$ms{projectDirName}"
}
},
"cacheVariables": {
"BUILD_SHARED_LIBS": "ON"
}
}
],
"buildPresets": [
{
"name": "_base",
"hidden": true,
"jobs": 12
},
{
"name": "windows-base_dbg",
"inherits": "_base",
"displayName": "Debug",
"configurePreset": "windows-base",
"configuration": "Debug"
},
{
"name": "windows-base_rel",
"inherits": "_base",
"displayName": "Release",
"configurePreset": "windows-base",
"configuration": "Release"
},
{
"name": "linux-base_dbg",
"inherits": "_base",
"displayName": "Debug",
"configurePreset": "linux-base",
"configuration": "Debug"
},
{
"name": "linux-base_rel",
"inherits": "_base",
"displayName": "Release",
"configurePreset": "linux-base",
"configuration": "Release"
}
],
"testPresets": [
{
"name": "windows-base_dbg",
"displayName": "Debug",
"configurePreset": "windows-base",
"configuration": "Debug"
},
{
"name": "windows-base_rel",
"displayName": "Release",
"configurePreset": "windows-base",
"configuration": "Release"
},
{
"name": "linux-base_dbg",
"displayName": "Debug",
"configurePreset": "linux-base",
"configuration": "Debug"
},
{
"name": "linux-base_rel",
"displayName": "Release",
"configurePreset": "linux-base",
"configuration": "Release"
}
]
}

View File

@ -0,0 +1,71 @@
.. _build_cmake:
=====
cmake
=====
Overview
********
This project uses CMakePresets to ensure an easy build. Find out more on Cmake Presets here:
https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html
Prerequsites
------------
You need to install
- CMake
- Ninja (for Linux builds). Be sure to Add ninja to your PATH!
How to build this project using cmake
-------------------------------------
The recommended way to build this project is to use the provided CMakePresets.json. This file contains 2 configurations
- a windows (msvc) build using Visual Studio
- a linux (gcc) build using Ninja
More configurations will be added once available.
Build with IDE
--------------
The recommend way for consuming CMakePresets is a CMakePresets aware IDE such as
- VS 2022
- VS Code
- CLion
Simply load this project into your IDE and select your desired preset and you are good to go.
Build with CMake GUI
--------------------
Open this project with CMake GUI and select your desired preset.
When hitting the generate button, CMake will create solution files (for VS) or Ninja Files (for Linux Ninja Build)
The following targets are available.
- lvgl (the actual library, required)
- lvgl_thorvg (an vector grafics extension, optional)
- lvgl_examples (example usages, optional)
- lvgl_demos (some demos, optional)
All optional targets can be disabled by setting the proper cache variables.
If you use cmake to install lvgl 3 folders will be created.
- include/lvgl (contains all public headers)
- bin (contains all binaries (\*.dll))
- lib (contains all precompiled source files (\*.lib))
Build with Command line
-----------------------
You can also build your project using the command line.
Run the follwoing commands
- cmake --preset windows-base
- cmake --build --preset windows-base_dbg
- ctest --preset windows-base_dbg

View File

@ -0,0 +1,10 @@
=============
Build systems
=============
.. toctree::
:maxdepth: 2
make
cmake

View File

@ -0,0 +1,7 @@
.. _build_make:
====
make
====
LVGL can be easily integrated into any Makefile project by adding ``include lvgl/lvgl.mk`` to the main ``Makefile``.

View File

@ -5,7 +5,7 @@ Integration and Drivers
.. toctree:: .. toctree::
:maxdepth: 2 :maxdepth: 2
build/index building/index
chip/index chip/index
driver/index driver/index
framework/index framework/index

View File

@ -35,6 +35,11 @@ if(LV_CONF_PATH)
target_compile_definitions(lvgl PUBLIC LV_CONF_PATH=${LV_CONF_PATH}) target_compile_definitions(lvgl PUBLIC LV_CONF_PATH=${LV_CONF_PATH})
endif() endif()
# Add definition of LV_CONF_SKIP only if needed
if(LV_CONF_SKIP)
target_compile_definitions(lvgl PUBLIC LV_CONF_SKIP=1)
endif()
# Include root and optional parent path of LV_CONF_PATH # Include root and optional parent path of LV_CONF_PATH
target_include_directories(lvgl SYSTEM PUBLIC ${LVGL_ROOT_DIR} ${LV_CONF_DIR}) target_include_directories(lvgl SYSTEM PUBLIC ${LVGL_ROOT_DIR} ${LV_CONF_DIR})
@ -46,6 +51,9 @@ if(NOT LV_CONF_BUILD_DISABLE_THORVG_INTERNAL)
if(LV_CONF_PATH) if(LV_CONF_PATH)
target_compile_definitions(lvgl_thorvg PUBLIC LV_CONF_PATH=${LV_CONF_PATH}) target_compile_definitions(lvgl_thorvg PUBLIC LV_CONF_PATH=${LV_CONF_PATH})
endif() endif()
if(LV_CONF_SKIP)
target_compile_definitions(lvgl_thorvg PUBLIC LV_CONF_SKIP=1)
endif()
endif() endif()
# Build LVGL example library # Build LVGL example library
@ -80,24 +88,45 @@ if("${INC_INSTALL_DIR}" STREQUAL "")
set(INC_INSTALL_DIR "include/lvgl") set(INC_INSTALL_DIR "include/lvgl")
endif() endif()
#Install headers
install( install(
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src" DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src"
DESTINATION "${CMAKE_INSTALL_PREFIX}/${INC_INSTALL_DIR}/" DESTINATION "${CMAKE_INSTALL_PREFIX}/${INC_INSTALL_DIR}/"
FILES_MATCHING FILES_MATCHING
PATTERN "*.h") PATTERN "*.h")
# install example headers
if(NOT LV_CONF_BUILD_DISABLE_EXAMPLES)
install(
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/examples"
DESTINATION "${CMAKE_INSTALL_PREFIX}/${INC_INSTALL_DIR}/"
FILES_MATCHING
PATTERN "*.h")
endif()
# install demo headers
if(NOT LV_CONF_BUILD_DISABLE_DEMOS)
install(
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/demos"
DESTINATION "${CMAKE_INSTALL_PREFIX}/${INC_INSTALL_DIR}/"
FILES_MATCHING
PATTERN "*.h")
endif()
configure_file("${LVGL_ROOT_DIR}/lvgl.pc.in" lvgl.pc @ONLY) configure_file("${LVGL_ROOT_DIR}/lvgl.pc.in" lvgl.pc @ONLY)
install( install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/lvgl.pc" FILES "${CMAKE_CURRENT_BINARY_DIR}/lvgl.pc"
DESTINATION "${LIB_INSTALL_DIR}/pkgconfig/") DESTINATION "${LIB_INSTALL_DIR}/pkgconfig/")
# Install library
set_target_properties( set_target_properties(
lvgl lvgl
PROPERTIES OUTPUT_NAME lvgl PROPERTIES OUTPUT_NAME lvgl
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
PUBLIC_HEADER "${LVGL_PUBLIC_HEADERS}") PUBLIC_HEADER "${LVGL_PUBLIC_HEADERS}")
install( install(
@ -106,3 +135,58 @@ install(
LIBRARY DESTINATION "${LIB_INSTALL_DIR}" LIBRARY DESTINATION "${LIB_INSTALL_DIR}"
RUNTIME DESTINATION "${RUNTIME_INSTALL_DIR}" RUNTIME DESTINATION "${RUNTIME_INSTALL_DIR}"
PUBLIC_HEADER DESTINATION "${INC_INSTALL_DIR}") PUBLIC_HEADER DESTINATION "${INC_INSTALL_DIR}")
# Install library thorvg
if(NOT LV_CONF_BUILD_DISABLE_THORVG_INTERNAL)
set_target_properties(
lvgl_thorvg
PROPERTIES OUTPUT_NAME lvgl_thorvg
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
PUBLIC_HEADER "${LVGL_PUBLIC_HEADERS}")
install(
TARGETS lvgl_thorvg
ARCHIVE DESTINATION "${LIB_INSTALL_DIR}"
LIBRARY DESTINATION "${LIB_INSTALL_DIR}"
RUNTIME DESTINATION "${RUNTIME_INSTALL_DIR}"
PUBLIC_HEADER DESTINATION "${INC_INSTALL_DIR}")
endif()
# Install library demos
if(NOT LV_CONF_BUILD_DISABLE_DEMOS)
set_target_properties(
lvgl_demos
PROPERTIES OUTPUT_NAME lvgl_demos
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
PUBLIC_HEADER "${LVGL_PUBLIC_HEADERS}")
install(
TARGETS lvgl_demos
ARCHIVE DESTINATION "${LIB_INSTALL_DIR}"
LIBRARY DESTINATION "${LIB_INSTALL_DIR}"
RUNTIME DESTINATION "${RUNTIME_INSTALL_DIR}"
PUBLIC_HEADER DESTINATION "${INC_INSTALL_DIR}")
endif()
#install library examples
if(NOT LV_CONF_BUILD_DISABLE_EXAMPLES)
set_target_properties(
lvgl_examples
PROPERTIES OUTPUT_NAME lvgl_examples
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
PUBLIC_HEADER "${LVGL_PUBLIC_HEADERS}")
install(
TARGETS lvgl_examples
ARCHIVE DESTINATION "${LIB_INSTALL_DIR}"
LIBRARY DESTINATION "${LIB_INSTALL_DIR}"
RUNTIME DESTINATION "${RUNTIME_INSTALL_DIR}"
PUBLIC_HEADER DESTINATION "${INC_INSTALL_DIR}")
endif()