[cmake] add UWAC_FORCE_STATIC_BUILD

since uwac is only used by wlfreerdp add an option to directly link it
with -DUWAC_FORCE_STATIC_BUILD=ON without installing any header or
library
This commit is contained in:
Armin Novak 2023-12-21 10:28:10 +01:00 committed by akallabeth
parent e8f5f90603
commit e67b6765a1
4 changed files with 50 additions and 33 deletions

View File

@ -54,6 +54,7 @@ if (NOT FREERDP_UNIFIED_BUILD)
endif()
endif()
option(UWAC_FORCE_STATIC_BUILD "Force UWAC to be build as static libary" OFF)
option(UWAC_HAVE_PIXMAN_REGION "Use PIXMAN or FreeRDP for region calculations" "NOT FREERDP_UNIFIED_BUILD")
# Include our extra modules
@ -70,6 +71,13 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "project default" FORCE)
endif()
if (UWAC_FORCE_STATIC_BUILD)
set(BUILD_SHARED_LIBS OFF)
else()
include(SetFreeRDPCMakeInstallDir)
include(CMakePackageConfigHelpers)
endif()
if (NOT IOS)
include(CheckIncludeFiles)
check_include_files(stdbool.h UWAC_HAVE_STDBOOL_H)

View File

@ -15,6 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
if (NOT UWAC_FORCE_STATIC_BUILD)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
DESTINATION ${UWAC_INCLUDE_DIR}
FILES_MATCHING PATTERN "*.h")
@ -22,4 +23,4 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/
DESTINATION ${UWAC_INCLUDE_DIR}
FILES_MATCHING PATTERN "*.h")
endif()

View File

@ -77,7 +77,6 @@ if (WITH_LIBRARY_VERSIONING)
set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${UWAC_VERSION} SOVERSION ${UWAC_API_VERSION})
endif()
target_include_directories(${MODULE_NAME} INTERFACE $<INSTALL_INTERFACE:include/uwac${UWAC_API_VERSION}>)
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS} PRIVATE ${WAYLAND_LIBS} ${XKBCOMMON_LIBS} ${EPOLLSHIM_LIBS})
if (UWAC_HAVE_PIXMAN_REGION)
target_link_libraries(${MODULE_NAME} PRIVATE ${pixman_LINK_LIBRARIES})
@ -85,10 +84,14 @@ else()
target_link_libraries(${MODULE_NAME} PRIVATE freerdp)
endif()
if (NOT UWAC_FORCE_STATIC_BUILD)
target_include_directories(${MODULE_NAME} INTERFACE $<INSTALL_INTERFACE:include/uwac${UWAC_API_VERSION}>)
install(TARGETS ${MODULE_NAME} COMPONENT libraries EXPORT uwac
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "uwac")

View File

@ -1,4 +1,6 @@
set(UWAC_INCLUDE_DIR "include/uwac${UWAC_VERSION_MAJOR}")
if (NOT UWAC_FORCE_STATIC_BUILD)
# cmake package
export(PACKAGE uwac)
@ -21,6 +23,7 @@ install(FILES
DESTINATION ${UWAC_CMAKE_INSTALL_DIR})
install(EXPORT uwac DESTINATION ${UWAC_CMAKE_INSTALL_DIR})
endif()
set(UWAC_BUILD_CONFIG_LIST "")
GET_CMAKE_PROPERTY(res VARIABLES)
@ -35,8 +38,10 @@ configure_file(buildflags.h.in ${CMAKE_CURRENT_BINARY_DIR}/../include/uwac/build
configure_file(build-config.h.in ${CMAKE_CURRENT_BINARY_DIR}/../include/uwac/build-config.h)
configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/../include/uwac/config.h)
if (NOT UWAC_FORCE_STATIC_BUILD)
include(pkg-config-install-prefix)
configure_file(uwac.pc.in ${CMAKE_CURRENT_BINARY_DIR}/uwac${UWAC_VERSION_MAJOR}.pc @ONLY)
set(UWAC_INSTALL_INCLUDE_DIR ${UWAC_INCLUDE_DIR}/uwac)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/uwac${UWAC_VERSION_MAJOR}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endif()