[cmake] add RDTK_FORCE_STATIC_BUILD

since rdtk is only used by shadow server add an option to directly link
it with -DRDTK_FORCE_STATIC_BUILD=ON without installing any header or
library
This commit is contained in:
Armin Novak 2023-12-21 10:34:29 +01:00 committed by akallabeth
parent 9a62d05943
commit e8f5f90603
4 changed files with 50 additions and 36 deletions

View File

@ -81,6 +81,11 @@ include(GNUInstallDirsWrapper)
include(CMakePackageConfigHelpers)
include (SetFreeRDPCMakeInstallDir)
option(RDTK_FORCE_STATIC_BUILD "Force RDTK to be build as static libary" OFF)
if (RDTK_FORCE_STATIC_BUILD)
set(BUILD_SHARED_LIBS OFF)
endif()
add_definitions(-DRDTK_EXPORTS)
if (NOT IOS)
@ -109,7 +114,9 @@ add_subdirectory(librdtk)
add_subdirectory(templates)
add_subdirectory(include)
install(EXPORT rdtk DESTINATION ${RDTK_CMAKE_INSTALL_DIR})
if (NOT RDTK_FORCE_STATIC_BUILD)
install(EXPORT rdtk DESTINATION ${RDTK_CMAKE_INSTALL_DIR})
endif()
if(WITH_SAMPLE)
if(WITH_X11)

View File

@ -1,8 +1,10 @@
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
DESTINATION ${RDTK_INCLUDE_DIR}
FILES_MATCHING PATTERN "*.h")
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/
DESTINATION ${RDTK_INCLUDE_DIR}
FILES_MATCHING PATTERN "*.h")
if (NOT RDTK_FORCE_STATIC_BUILD)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
DESTINATION ${RDTK_INCLUDE_DIR}
FILES_MATCHING PATTERN "*.h")
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/
DESTINATION ${RDTK_INCLUDE_DIR}
FILES_MATCHING PATTERN "*.h")
endif()

View File

@ -71,12 +71,14 @@ if(BUILD_TESTING)
add_subdirectory(test)
endif()
install(TARGETS ${MODULE_NAME} COMPONENT libraries EXPORT rdtk
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
if (NOT RDTK_FORCE_STATIC_BUILD)
install(TARGETS ${MODULE_NAME} COMPONENT libraries EXPORT rdtk
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
if (WITH_DEBUG_SYMBOLS AND MSVC AND BUILD_SHARED_LIBS)
get_target_property(OUTPUT_FILENAME ${MODULE_NAME} OUTPUT_NAME)
install(FILES ${CMAKE_PDB_BINARY_DIR}/${OUTPUT_FILENAME}.pdb DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT symbols)
if (WITH_DEBUG_SYMBOLS AND MSVC AND BUILD_SHARED_LIBS)
get_target_property(OUTPUT_FILENAME ${MODULE_NAME} OUTPUT_NAME)
install(FILES ${CMAKE_PDB_BINARY_DIR}/${OUTPUT_FILENAME}.pdb DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT symbols)
endif()
endif()

View File

@ -1,19 +1,21 @@
include (SetFreeRDPCMakeInstallDir)
if (NOT RDTK_FORCE_STATIC_BUILD)
include (SetFreeRDPCMakeInstallDir)
# cmake package
export(PACKAGE rdtk)
# cmake package
export(PACKAGE rdtk)
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/rdtkConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/rdtkConfig.cmake
INSTALL_DESTINATION ${RDTK_CMAKE_INSTALL_DIR}
PATH_VARS RDTK_INCLUDE_DIR)
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/rdtkConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/rdtkConfig.cmake
INSTALL_DESTINATION ${RDTK_CMAKE_INSTALL_DIR}
PATH_VARS RDTK_INCLUDE_DIR)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/rdtkConfigVersion.cmake
VERSION ${RDTK_VERSION}
COMPATIBILITY SameMajorVersion)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/rdtkConfigVersion.cmake
VERSION ${RDTK_VERSION}
COMPATIBILITY SameMajorVersion)
endif()
set(RDTK_BUILD_CONFIG_LIST "")
GET_CMAKE_PROPERTY(res VARIABLES)
@ -30,16 +32,17 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_D
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/buildflags.h.in ${CMAKE_CURRENT_BINARY_DIR}/../include/rdtk/buildflags.h)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/build-config.h.in ${CMAKE_CURRENT_BINARY_DIR}/../include/rdtk/build-config.h)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/../include/rdtk/config.h)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/rdtk.pc.in ${CMAKE_CURRENT_BINARY_DIR}/rdtk${RDTK_VERSION_MAJOR}.pc @ONLY)
set(RDTK_INSTALL_INCLUDE_DIR ${RDTK_INCLUDE_DIR}/rdtk)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/rdtk${RDTK_VERSION_MAJOR}.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/rdtkConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/rdtkConfigVersion.cmake
DESTINATION ${RDTK_CMAKE_INSTALL_DIR})
if (NOT RDTK_FORCE_STATIC_BUILD)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/rdtk.pc.in ${CMAKE_CURRENT_BINARY_DIR}/rdtk${RDTK_VERSION_MAJOR}.pc @ONLY)
set(RDTK_INSTALL_INCLUDE_DIR ${RDTK_INCLUDE_DIR}/rdtk)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/rdtk${RDTK_VERSION_MAJOR}.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/rdtkConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/rdtkConfigVersion.cmake
DESTINATION ${RDTK_CMAKE_INSTALL_DIR})
endif()