190 lines
6.5 KiB
CMake
190 lines
6.5 KiB
CMake
################################################################################
|
|
## Project for working with OpenGL and Qt6 widgets ##
|
|
## ##
|
|
## Author: Shaun Reed | Contact: shaunrd0@gmail.com | URL: www.shaunreed.com ##
|
|
## All Content (c) 2023 Shaun Reed, all rights reserved ##
|
|
################################################################################
|
|
|
|
# Qtk Library
|
|
|
|
# We always build libqtk since the plugins and GUI both depend on it.
|
|
add_subdirectory(qtk)
|
|
install(
|
|
FILES
|
|
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
|
|
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
|
|
COMPONENT qtk_library
|
|
DESTINATION lib/cmake/${PROJECT_NAME}
|
|
)
|
|
install(
|
|
EXPORT qtk_export
|
|
FILE ${PROJECT_NAME}Targets.cmake
|
|
NAMESPACE ${PROJECT_NAME}::
|
|
COMPONENT qtk_library
|
|
DESTINATION lib/cmake/${PROJECT_NAME}
|
|
)
|
|
# System install for qtk_library
|
|
install(
|
|
TARGETS qtk_library
|
|
# Associate qtk_library target with qtk-export
|
|
EXPORT qtk_export
|
|
COMPONENT qtk_library
|
|
FILE_SET HEADERS DESTINATION include
|
|
INCLUDES DESTINATION include
|
|
LIBRARY DESTINATION lib
|
|
ARCHIVE DESTINATION lib
|
|
RUNTIME DESTINATION bin
|
|
)
|
|
|
|
# Qtk Application
|
|
if(QTK_GUI OR QTK_PLUGINS)
|
|
add_subdirectory(app)
|
|
endif()
|
|
|
|
if(QTK_PLUGINS)
|
|
install(
|
|
TARGETS qtk_plugins qtk_library qtk_plugin_library
|
|
COMPONENT qtk_plugins
|
|
LIBRARY DESTINATION "${QTK_PLUGIN_INSTALL_DIR}"
|
|
ARCHIVE DESTINATION "${QTK_PLUGIN_INSTALL_DIR}"
|
|
RUNTIME DESTINATION "${QTK_PLUGIN_INSTALL_DIR}"
|
|
)
|
|
endif()
|
|
|
|
if(QTK_GUI)
|
|
install(
|
|
TARGETS qtk_gui
|
|
COMPONENT qtk_gui
|
|
BUNDLE DESTINATION .
|
|
LIBRARY DESTINATION lib
|
|
ARCHIVE DESTINATION lib
|
|
RUNTIME DESTINATION bin
|
|
)
|
|
|
|
qt_generate_deploy_app_script(
|
|
TARGET qtk_gui
|
|
OUTPUT_SCRIPT QTK_DEPLOY_SCRIPT
|
|
NO_UNSUPPORTED_PLATFORM_ERROR
|
|
)
|
|
install(SCRIPT ${QTK_DEPLOY_SCRIPT} COMPONENT qtk_gui)
|
|
|
|
if(WIN32)
|
|
if(MSVC AND TARGET Qt6::qmake)
|
|
get_target_property(QT6_QMAKE_LOCATION Qt6::qmake IMPORTED_LOCATION)
|
|
execute_process(
|
|
COMMAND "${QT6_QMAKE_LOCATION}" -query QT_INSTALL_PREFIX
|
|
RESULT_VARIABLE return_code
|
|
OUTPUT_VARIABLE QT6_INSTALL_PREFIX
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
)
|
|
file(TO_NATIVE_PATH "${QT6_INSTALL_PREFIX}/bin" QT6_INSTALL_PREFIX)
|
|
|
|
set(VSUSER_FILE "${CMAKE_CURRENT_BINARY_DIR}/qtk_gui.vcxproj.user")
|
|
file(WRITE ${VSUSER_FILE} "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
|
|
file(APPEND ${VSUSER_FILE} "<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n")
|
|
file(APPEND ${VSUSER_FILE} " <PropertyGroup>\n")
|
|
file(APPEND ${VSUSER_FILE} " <LocalDebuggerEnvironment>Path=$(SolutionDir)\\lib\\$(Configuration);${QT6_INSTALL_PREFIX};$(Path)\n")
|
|
file(APPEND ${VSUSER_FILE} "$(LocalDebuggerEnvironment)</LocalDebuggerEnvironment>\n")
|
|
file(APPEND ${VSUSER_FILE} " <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>\n")
|
|
file(APPEND ${VSUSER_FILE} " </PropertyGroup>\n")
|
|
file(APPEND ${VSUSER_FILE} "</Project>\n")
|
|
endif()
|
|
endif()
|
|
endif()
|
|
|
|
write_basic_package_version_file(
|
|
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
|
|
COMPATIBILITY AnyNewerVersion
|
|
)
|
|
configure_package_config_file(
|
|
"${CMAKE_SOURCE_DIR}/cmake/templates/Config.cmake.in"
|
|
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
|
|
INSTALL_DESTINATION lib/cmake/${PROJECT_NAME}
|
|
)
|
|
|
|
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
|
|
set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
|
|
set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
|
|
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
|
|
set(CPACK_PACKAGE_VENDOR "Shaun Reed")
|
|
if (QTK_GUI)
|
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Qt OpenGL 3D graphics renderer.")
|
|
else()
|
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Qt OpenGL 3D graphics library.")
|
|
endif()
|
|
set(CPACK_PACKAGE_HOMEPAGE_URL "https://git.shaunreed.com/shaunrd0/qtk")
|
|
set(CPACK_SOURCE_IGNORE_FILES build*;install;\.git;\.github;\.idea)
|
|
set(CPACK_PACKAGE_DIRECTORY packages/)
|
|
set(CPACK_PACKAGE_CONTACT "shaunreed.com")
|
|
set(CPACK_THREADS 0)
|
|
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Qtk")
|
|
|
|
# Remove any assimp components if defined by submodule.
|
|
if (QTK_SUBMODULES)
|
|
get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS)
|
|
list(FILTER CPACK_COMPONENTS_ALL EXCLUDE REGEX .*assimp.*)
|
|
list(REMOVE_ITEM CPACK_COMPONENTS_ALL Unspecified)
|
|
endif()
|
|
|
|
if(APPLE)
|
|
# OSX
|
|
# Set icon for the splash image used in OSX DMG installers.
|
|
set(CPACK_PACKAGE_ICON "${QTK_RESOURCES}/icons/osx/kilroy_splash.bmp")
|
|
|
|
# Set additional options for the OSX bundle.
|
|
set(CPACK_BUNDLE_NAME ${PROJECT_NAME})
|
|
set(CPACK_BUNDLE_PLIST $<TARGET_BUNDLE_CONTENT_DIR:qtk_gui>/Info.plist)
|
|
set(CPACK_BUNDLE_ICON ${QTK_OSX_ICONS})
|
|
else(UNIX)
|
|
# Linux
|
|
# Install icons for qtk.
|
|
install(FILES ${QTK_RESOURCES}/icons/linux/kilroy-16.png
|
|
DESTINATION /usr/share/icons/hicolor/16x16/apps
|
|
RENAME qtk.png)
|
|
install(FILES ${QTK_RESOURCES}/icons/linux/kilroy-32.png
|
|
DESTINATION /usr/share/icons/hicolor/32x32/apps
|
|
RENAME qtk.png)
|
|
install(FILES ${QTK_RESOURCES}/icons/linux/kilroy-48.png
|
|
DESTINATION /usr/share/icons/hicolor/48x48/apps
|
|
RENAME qtk.png)
|
|
install(FILES ${QTK_RESOURCES}/icons/linux/kilroy-64.png
|
|
DESTINATION /usr/share/icons/hicolor/64x64/apps
|
|
RENAME qtk.png)
|
|
install(FILES ${QTK_RESOURCES}/icons/linux/kilroy-128.png
|
|
DESTINATION /usr/share/icons/hicolor/128x128/apps
|
|
RENAME qtk.png)
|
|
install(FILES ${QTK_RESOURCES}/icons/linux/kilroy-256.png
|
|
DESTINATION /usr/share/icons/hicolor/256x256/apps
|
|
RENAME qtk.png)
|
|
|
|
# Install the desktop file for qtk.
|
|
install(FILES ${QTK_RESOURCES}/qtk.desktop
|
|
DESTINATION /usr/share/applications)
|
|
|
|
# Set additional options for the debian APT package.
|
|
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${CPACK_PACKAGE_HOMEPAGE_URL})
|
|
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
|
|
endif()
|
|
|
|
|
|
# Windows
|
|
set(CPACK_NSIS_MODIFY_PATH ON)
|
|
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
|
|
# https://nsis.sourceforge.io/Reference/CreateShortCut
|
|
set(
|
|
CPACK_NSIS_CREATE_ICONS_EXTRA
|
|
"CreateShortCut '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Qtk.lnk' '$INSTDIR\\\\bin\\\\qtk_gui.exe'"
|
|
)
|
|
set(
|
|
CPACK_NSIS_DELETE_ICONS_EXTRA
|
|
"Delete '$SMPROGRAMS\\\\$START_MENU\\\\Qtk.lnk'"
|
|
)
|
|
|
|
if(WIN32)
|
|
set(CPACK_SOURCE_GENERATOR ZIP)
|
|
else()
|
|
set(CPACK_SOURCE_GENERATOR TGZ)
|
|
endif()
|
|
|
|
include(CPack)
|