Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake: developer experience improvements #297

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
cmake_minimum_required(VERSION 3.12.4)
cmake_minimum_required(VERSION 3.13)

project(lv_drivers HOMEPAGE_URL https://github.com/lvgl/lv_drivers/)

# Option to set the project as bundled.
# If bundled, the installation steps are skipped because lv_drivers are linked
# directly with any dependant targets.
option( LV_DRIVERS_BUNDLED "Set lv_drivers as bundled (disables install)" OFF )

# Option to build as shared library (as opposed to static), default: OFF
option(BUILD_SHARED_LIBS "Build shared as library (as opposed to static)" OFF)

Expand All @@ -22,6 +27,13 @@ find_package(PkgConfig)
pkg_check_modules(PKG_WAYLAND wayland-client wayland-cursor wayland-protocols xkbcommon)
target_link_libraries(lv_drivers PUBLIC lvgl ${PKG_WAYLAND_LIBRARIES})

option( LV_DRIVERS_USE_SDL "Use SDL2 libraries" OFF )

if( LV_DRIVERS_USE_SDL )
find_package( SDL2 REQUIRED )
target_link_libraries( lv_drivers PRIVATE SDL2::SDL2 )
endif( LV_DRIVERS_USE_SDL )

if("${LIB_INSTALL_DIR}" STREQUAL "")
set(LIB_INSTALL_DIR "lib")
endif()
Expand All @@ -30,15 +42,17 @@ if("${INC_INSTALL_DIR}" STREQUAL "")
set(INC_INSTALL_DIR "include/lvgl/lv_drivers")
endif()

if (NOT LV_DRIVERS_BUNDLED)
install(
DIRECTORY "${CMAKE_SOURCE_DIR}/"
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/"
DESTINATION "${CMAKE_INSTALL_PREFIX}/${INC_INSTALL_DIR}/"
FILES_MATCHING
PATTERN "*.h"
PATTERN ".git*" EXCLUDE
PATTERN "CMakeFiles" EXCLUDE
PATTERN "docs" EXCLUDE
PATTERN "lib" EXCLUDE)
endif()

file(GLOB LV_DRIVERS_PUBLIC_HEADERS "${CMAKE_SOURCE_DIR}/lv_drv_conf.h")

Expand All @@ -50,9 +64,11 @@ set_target_properties(
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
PUBLIC_HEADER "${LV_DRIVERS_PUBLIC_HEADERS}")

if (NOT LV_DRIVERS_BUNDLED)
install(
TARGETS lv_drivers
ARCHIVE DESTINATION "${LIB_INSTALL_DIR}"
LIBRARY DESTINATION "${LIB_INSTALL_DIR}"
RUNTIME DESTINATION "${LIB_INSTALL_DIR}"
PUBLIC_HEADER DESTINATION "${INC_INSTALL_DIR}")
endif()