diff --git a/.gitignore b/.gitignore index 7d49d36ef..66281c80e 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ tests/report/ .idea *.bak tests/test_images/ +.vs/ diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 000000000..bd4ff3a37 --- /dev/null +++ b/CMakePresets.json @@ -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" + } + ] +} diff --git a/docs/integration/building/cmake.rst b/docs/integration/building/cmake.rst new file mode 100644 index 000000000..f26497ed6 --- /dev/null +++ b/docs/integration/building/cmake.rst @@ -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 + + diff --git a/docs/integration/building/index.rst b/docs/integration/building/index.rst new file mode 100644 index 000000000..a3a2d71a7 --- /dev/null +++ b/docs/integration/building/index.rst @@ -0,0 +1,10 @@ +============= +Build systems +============= + + +.. toctree:: + :maxdepth: 2 + + make + cmake diff --git a/docs/integration/building/make.rst b/docs/integration/building/make.rst new file mode 100644 index 000000000..900e1a1f9 --- /dev/null +++ b/docs/integration/building/make.rst @@ -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``. diff --git a/docs/integration/index.rst b/docs/integration/index.rst index 1ae69dc7b..f45ce73be 100644 --- a/docs/integration/index.rst +++ b/docs/integration/index.rst @@ -5,7 +5,7 @@ Integration and Drivers .. toctree:: :maxdepth: 2 - build/index + building/index chip/index driver/index framework/index diff --git a/env_support/cmake/custom.cmake b/env_support/cmake/custom.cmake index 0855691ae..62391e05b 100644 --- a/env_support/cmake/custom.cmake +++ b/env_support/cmake/custom.cmake @@ -35,6 +35,11 @@ if(LV_CONF_PATH) target_compile_definitions(lvgl PUBLIC LV_CONF_PATH=${LV_CONF_PATH}) 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 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) target_compile_definitions(lvgl_thorvg PUBLIC LV_CONF_PATH=${LV_CONF_PATH}) endif() + if(LV_CONF_SKIP) + target_compile_definitions(lvgl_thorvg PUBLIC LV_CONF_SKIP=1) + endif() endif() # Build LVGL example library @@ -80,24 +88,45 @@ if("${INC_INSTALL_DIR}" STREQUAL "") set(INC_INSTALL_DIR "include/lvgl") endif() +#Install headers install( DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src" DESTINATION "${CMAKE_INSTALL_PREFIX}/${INC_INSTALL_DIR}/" FILES_MATCHING 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) install( FILES "${CMAKE_CURRENT_BINARY_DIR}/lvgl.pc" DESTINATION "${LIB_INSTALL_DIR}/pkgconfig/") +# Install library set_target_properties( lvgl PROPERTIES OUTPUT_NAME lvgl ARCHIVE_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}") install( @@ -106,3 +135,58 @@ install( LIBRARY DESTINATION "${LIB_INSTALL_DIR}" RUNTIME DESTINATION "${RUNTIME_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() \ No newline at end of file