diff --git a/CMakeLists.txt b/CMakeLists.txt index 75e91b9ed..5345128cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -228,6 +228,19 @@ endif() # Set the path for the libraries set(LIBRARY_OUTPUT_PATH "${PROJECT_BINARY_DIR}/lib") +# Don't create an install target if we detect a dependency that is being build without an install target +if (NOT DEFINED TGUI_INSTALL) + if ((DEFINED SDL2_DISABLE_INSTALL AND SDL2_DISABLE_INSTALL) + OR (DEFINED SDL_DISABLE_INSTALL AND SDL_DISABLE_INSTALL) + OR (DEFINED SDL2TTF_INSTALL AND NOT SDL2TTF_INSTALL) + OR (DEFINED SDL3TTF_INSTALL AND NOT SDL3TTF_INSTALL) + OR (DEFINED GLFW_INSTALL AND NOT GLFW_INSTALL)) + set(TGUI_INSTALL OFF) + else() + set(TGUI_INSTALL ON) + endif() +endif() + # Define the macros to link TGUI to its dependencies include(${PROJECT_SOURCE_DIR}/cmake/Dependencies.cmake) @@ -355,46 +368,47 @@ if(TGUI_BUILD_DOC) add_subdirectory(doc) endif() -# Install pkg-config files by default on Linux (and BSD) -tgui_assign_bool(TGUI_INSTALL_PKGCONFIG_DEFAULT TGUI_OS_LINUX) -option(TGUI_INSTALL_PKGCONFIG_FILES "TRUE to automatically install pkg-config files so other projects can find TGUI" ${TGUI_INSTALL_PKGCONFIG_DEFAULT}) +if (TGUI_INSTALL) + # Install pkg-config files by default on Linux (and BSD) + tgui_assign_bool(TGUI_INSTALL_PKGCONFIG_DEFAULT TGUI_OS_LINUX) + option(TGUI_INSTALL_PKGCONFIG_FILES "TRUE to automatically install pkg-config files so other projects can find TGUI" ${TGUI_INSTALL_PKGCONFIG_DEFAULT}) -if (TGUI_INSTALL_PKGCONFIG_FILES) - tgui_set_option(TGUI_PKGCONFIG_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/${TGUI_PKGCONFIG_DIR}" PATH "Install directory for TGUI's pkg-config .pc files") + if (TGUI_INSTALL_PKGCONFIG_FILES) + tgui_set_option(TGUI_PKGCONFIG_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/${TGUI_PKGCONFIG_DIR}" PATH "Install directory for TGUI's pkg-config .pc files") - configure_file("cmake/pkgconfig/tgui.pc.in" "pkgconfig/tgui.pc" @ONLY) - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/tgui.pc" DESTINATION "${TGUI_PKGCONFIG_INSTALL_PREFIX}") -endif() + configure_file("cmake/pkgconfig/tgui.pc.in" "pkgconfig/tgui.pc" @ONLY) + endif() -# Install include files -if(NOT TGUI_BUILD_FRAMEWORK) - install(DIRECTORY include/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - COMPONENT devel - PATTERN "*.in" EXCLUDE) -endif() + # Install include files + if(NOT TGUI_BUILD_FRAMEWORK) + install(DIRECTORY include/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + COMPONENT devel + PATTERN "*.in" EXCLUDE) + endif() -# Install PDB file -if(TGUI_GENERATE_PDB) - # When using a Visual Studio generator, the pdb files are located in Debug and RelWithDebInfo subfolders, but not when - # using single-configuration generators such as NMake Makefiles. - # When using Linker PDB files (i.e. TGUI_SHARED_LIBS=FALSE), CMake 3.13 introduced a generator expression that helps us. - # Linker PDB files are installed next to the dll file (where VS searches them) while compiler PDB files are placed next to the lib file. - if(TGUI_SHARED_LIBS) - install (FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL COMPONENT devel) - else() - # TODO: Find a reliable way to know whether the file has a "-d" postfix instead of trying to install both. OPTIONAL is also required when config is Release. - if (MSVC_IDE) - install(FILES "${PROJECT_BINARY_DIR}/lib/\${CMAKE_INSTALL_CONFIG_NAME}/tgui-s.pdb" DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT devel OPTIONAL) - install(FILES "${PROJECT_BINARY_DIR}/lib/\${CMAKE_INSTALL_CONFIG_NAME}/tgui-s-d.pdb" DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT devel OPTIONAL) + # Install PDB file + if(TGUI_GENERATE_PDB) + # When using a Visual Studio generator, the pdb files are located in Debug and RelWithDebInfo subfolders, but not when + # using single-configuration generators such as NMake Makefiles. + # When using Linker PDB files (i.e. TGUI_SHARED_LIBS=FALSE), CMake 3.13 introduced a generator expression that helps us. + # Linker PDB files are installed next to the dll file (where VS searches them) while compiler PDB files are placed next to the lib file. + if(TGUI_SHARED_LIBS) + install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL COMPONENT devel) else() - install(FILES "${PROJECT_BINARY_DIR}/lib/tgui-s.pdb" DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT devel OPTIONAL) - install(FILES "${PROJECT_BINARY_DIR}/lib/tgui-s-d.pdb" DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT devel OPTIONAL) + # TODO: Find a reliable way to know whether the file has a "-d" postfix instead of trying to install both. OPTIONAL is also required when config is Release. + if (MSVC_IDE) + install(FILES "${PROJECT_BINARY_DIR}/lib/\${CMAKE_INSTALL_CONFIG_NAME}/tgui-s.pdb" DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT devel OPTIONAL) + install(FILES "${PROJECT_BINARY_DIR}/lib/\${CMAKE_INSTALL_CONFIG_NAME}/tgui-s-d.pdb" DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT devel OPTIONAL) + else() + install(FILES "${PROJECT_BINARY_DIR}/lib/tgui-s.pdb" DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT devel OPTIONAL) + install(FILES "${PROJECT_BINARY_DIR}/lib/tgui-s-d.pdb" DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT devel OPTIONAL) + endif() endif() endif() -endif() -# Install miscellaneous files -install(FILES license.txt DESTINATION ${CMAKE_INSTALL_DOCDIR}) -install(FILES README.md DESTINATION ${CMAKE_INSTALL_DOCDIR}) -install(DIRECTORY themes DESTINATION "${TGUI_MISC_INSTALL_PREFIX}") + # Install miscellaneous files + install(FILES license.txt DESTINATION ${CMAKE_INSTALL_DOCDIR}) + install(FILES README.md DESTINATION ${CMAKE_INSTALL_DOCDIR}) + install(DIRECTORY themes DESTINATION "${TGUI_MISC_INSTALL_PREFIX}") +endif() diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake index 607b88bdb..185ad36d2 100644 --- a/cmake/Dependencies.cmake +++ b/cmake/Dependencies.cmake @@ -93,7 +93,7 @@ macro(tgui_add_dependency_sfml component) tgui_find_dependency_sfml(${component} "") # Link to SFML and set include and library search directories - if (SFML_VERSION VERSION_GREATER_EQUAL 3) + if (SFML_VERSION VERSION_GREATER_EQUAL 3 OR TARGET SFML::${component}) # SFML_VERSION can be undefined if target already existed and wasn't searched by TGUI target_link_libraries(tgui PUBLIC SFML::${component}) else() string(TOLOWER ${component} lowercase_component) diff --git a/cmake/Macros.cmake b/cmake/Macros.cmake index e684d915e..8b6cd84fd 100644 --- a/cmake/Macros.cmake +++ b/cmake/Macros.cmake @@ -114,58 +114,6 @@ function(tgui_set_stdlib target) endif() endfunction() -# Generate a TGUIConfig.cmake file (and associated files) -function(tgui_export_target export_name) - include(CMakePackageConfigHelpers) - write_basic_package_version_file("${PROJECT_BINARY_DIR}/TGUIConfigVersion.cmake" - VERSION ${TGUI_VERSION_MAJOR}.${TGUI_VERSION_MINOR}.${TGUI_VERSION_PATCH} - COMPATIBILITY SameMajorVersion) - - if (TGUI_SHARED_LIBS) - set(targets_config_filename TGUISharedTargets.cmake) - else() - set(targets_config_filename TGUIStaticTargets.cmake) - endif() - - export(EXPORT ${export_name} - NAMESPACE TGUI:: - FILE "${PROJECT_BINARY_DIR}/${targets_config_filename}") - - if (TGUI_BUILD_FRAMEWORK) - set(config_package_location "TGUI.framework/Resources/CMake") - else() - set(config_package_location ${CMAKE_INSTALL_LIBDIR}/cmake/TGUI) - endif() - - configure_package_config_file("${PROJECT_SOURCE_DIR}/cmake/TGUIConfig.cmake.in" "${PROJECT_BINARY_DIR}/TGUIConfig.cmake" - INSTALL_DESTINATION "${config_package_location}") - - install(EXPORT ${export_name} - NAMESPACE TGUI:: - FILE ${targets_config_filename} - DESTINATION ${config_package_location}) - - install(FILES "${PROJECT_BINARY_DIR}/TGUIConfig.cmake" - "${PROJECT_BINARY_DIR}/TGUIConfigVersion.cmake" - DESTINATION ${config_package_location} - COMPONENT devel) - - # Install the find modules when they are needed to find our dependencies - if(TGUI_HAS_WINDOW_BACKEND_GLFW AND NOT TGUI_FOUND_GLFW_CONFIG) - install(FILES "${PROJECT_SOURCE_DIR}/cmake/Modules/Findglfw3.cmake" DESTINATION ${config_package_location} COMPONENT devel) - add_custom_command(TARGET tgui POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/cmake/Modules/Findglfw3.cmake" "${PROJECT_BINARY_DIR}/" VERBATIM) - endif() - if((TGUI_HAS_WINDOW_BACKEND_SDL OR TGUI_HAS_FONT_BACKEND_SDL_TTF) AND NOT TGUI_FOUND_SDL2_CONFIG) - install(FILES "${PROJECT_SOURCE_DIR}/cmake/Modules/FindSDL2.cmake" DESTINATION ${config_package_location} COMPONENT devel) - add_custom_command(TARGET tgui POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/cmake/Modules/FindSDL2.cmake" "${PROJECT_BINARY_DIR}/" VERBATIM) - endif() - if(TGUI_HAS_FONT_BACKEND_SDL_TTF AND NOT TGUI_FOUND_SDL2_TTF_CONFIG) - install(FILES "${PROJECT_SOURCE_DIR}/cmake/Modules/FindSDL2_ttf.cmake" DESTINATION ${config_package_location} COMPONENT devel) - add_custom_command(TARGET tgui POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/cmake/Modules/FindSDL2_ttf.cmake" "${PROJECT_BINARY_DIR}/" VERBATIM) - endif() -endfunction() - - # Install the dlls next to the executables (both immediately after building and when installing them somewhere) function(copy_dlls_to_exe post_build_destination install_destination target) if(TGUI_OS_WINDOWS) @@ -207,9 +155,11 @@ function(copy_dlls_to_exe post_build_destination install_destination target) COMMAND ${CMAKE_COMMAND} -E copy "${file_to_copy}" "${post_build_destination}" VERBATIM) - install(FILES "${file_to_copy}" - DESTINATION "${install_destination}" - COMPONENT ${target}) + if (TGUI_INSTALL) + install(FILES "${file_to_copy}" + DESTINATION "${install_destination}" + COMPONENT ${target}) + endif() endforeach() endif() endfunction() diff --git a/examples/android/SDL_RENDERER/app/jni/CMakeLists.txt b/examples/android/SDL_RENDERER/app/jni/CMakeLists.txt index c5e34d505..2eea5c14f 100644 --- a/examples/android/SDL_RENDERER/app/jni/CMakeLists.txt +++ b/examples/android/SDL_RENDERER/app/jni/CMakeLists.txt @@ -17,7 +17,6 @@ add_subdirectory("${TGUI_ROOT_DIR}/../SDL2" ${SDL2_BUILD_DIR}) add_subdirectory("${TGUI_ROOT_DIR}/../SDL2_ttf" ${SDL2_TTF_BUILD_DIR}) # Build TGUI -set(TGUI_SKIP_EXPORT ON) # Workaround for issue when building SDL and TGUI together as subdirectories add_subdirectory("${TGUI_ROOT_DIR}" TGUI-build) # Create the libmain.so library that contains the application's c++ code. diff --git a/examples/android/SDL_TTF_GLES2/app/jni/CMakeLists.txt b/examples/android/SDL_TTF_GLES2/app/jni/CMakeLists.txt index 11aae46e4..849040a6b 100644 --- a/examples/android/SDL_TTF_GLES2/app/jni/CMakeLists.txt +++ b/examples/android/SDL_TTF_GLES2/app/jni/CMakeLists.txt @@ -17,7 +17,6 @@ add_subdirectory("${TGUI_ROOT_DIR}/../SDL2" ${SDL2_BUILD_DIR}) add_subdirectory("${TGUI_ROOT_DIR}/../SDL2_ttf" ${SDL2_TTF_BUILD_DIR}) # Build TGUI -set(TGUI_SKIP_EXPORT ON) # Workaround for issue when building SDL and TGUI together as subdirectories add_subdirectory("${TGUI_ROOT_DIR}" TGUI-build) # Create the libmain.so library that contains the application's c++ code. diff --git a/gui-builder/CMakeLists.txt b/gui-builder/CMakeLists.txt index b8732c7ac..21573462e 100644 --- a/gui-builder/CMakeLists.txt +++ b/gui-builder/CMakeLists.txt @@ -68,27 +68,29 @@ if (TGUI_SHARED_LIBS AND TGUI_OS_LINUX) INSTALL_RPATH "$ORIGIN/${rel_lib_dir}") endif() -# Install a .desktop file on Linux (and its icon) -if (TGUI_OS_LINUX) - set(TGUI_GUI_BUILDER_INSTALL_EXE_PATH "${CMAKE_INSTALL_PREFIX}/${target_install_dir}/gui-builder") - configure_file("${PROJECT_SOURCE_DIR}/cmake/gui-builder/tgui-gui-builder.desktop.in" "tgui-gui-builder.desktop" @ONLY) - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/tgui-gui-builder.desktop" - DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications" +if (TGUI_INSTALL) + # Install a .desktop file on Linux (and its icon) + if (TGUI_OS_LINUX) + set(TGUI_GUI_BUILDER_INSTALL_EXE_PATH "${CMAKE_INSTALL_PREFIX}/${target_install_dir}/gui-builder") + configure_file("${PROJECT_SOURCE_DIR}/cmake/gui-builder/tgui-gui-builder.desktop.in" "tgui-gui-builder.desktop" @ONLY) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/tgui-gui-builder.desktop" + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications" + COMPONENT gui-builder) + install(FILES "${PROJECT_SOURCE_DIR}/cmake/gui-builder/TexusGUI.png" + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/48x48/apps" + COMPONENT gui-builder) + endif() + + # Add the install rule for the executable + install(TARGETS gui-builder + RUNTIME DESTINATION ${target_install_dir} COMPONENT gui-builder + BUNDLE DESTINATION ${target_install_dir} COMPONENT gui-builder) + + # Install the resources next to the gui-builder executable + install(DIRECTORY "${PROJECT_SOURCE_DIR}/gui-builder/resources" + DESTINATION "${target_install_dir}" COMPONENT gui-builder) - install(FILES "${PROJECT_SOURCE_DIR}/cmake/gui-builder/TexusGUI.png" - DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/48x48/apps" + install(DIRECTORY "${PROJECT_SOURCE_DIR}/themes" + DESTINATION "${target_install_dir}" COMPONENT gui-builder) endif() - -# Add the install rule for the executable -install(TARGETS gui-builder - RUNTIME DESTINATION ${target_install_dir} COMPONENT gui-builder - BUNDLE DESTINATION ${target_install_dir} COMPONENT gui-builder) - -# Install the resources next to the gui-builder executable -install(DIRECTORY "${PROJECT_SOURCE_DIR}/gui-builder/resources" - DESTINATION "${target_install_dir}" - COMPONENT gui-builder) -install(DIRECTORY "${PROJECT_SOURCE_DIR}/themes" - DESTINATION "${target_install_dir}" - COMPONENT gui-builder) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 528095932..03750e22c 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -412,18 +412,74 @@ if(NOT TGUI_BUILD_AS_CXX_MODULE AND NOT TGUI_DISABLE_PRECOMPILED_HEADER) target_precompile_headers(tgui PRIVATE "${PROJECT_SOURCE_DIR}/include/TGUI/Widget.hpp") endif() -# Install library -install(TARGETS tgui EXPORT TGUIConfigExport - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT bin - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT devel - FRAMEWORK DESTINATION "." COMPONENT bin -) +if (TGUI_BUILD_FRAMEWORK) + set(config_package_location "TGUI.framework/Resources/CMake") +else() + set(config_package_location ${CMAKE_INSTALL_LIBDIR}/cmake/TGUI) +endif() # Generate the TGUIConfig.cmake file # This had to happen here instead of in the root CMakeLists.txt because otherwise it might try to write to the macOS framework before the framework is installed. -# TODO: CMake 3.13 fixed order of installation, so check if the issue still exists. -# Since the config files relies on variables that are only defined in this scope (via the backend include), caution is required when moving this. -if (NOT TGUI_SKIP_EXPORT) - tgui_export_target(TGUIConfigExport) +# TODO: CMake 3.13 fixed order of installation, so check if the issue still exists. Since the config files relies on variables that are only defined in this scope (via the backend include), caution is required when moving this. +include(CMakePackageConfigHelpers) +configure_package_config_file("${PROJECT_SOURCE_DIR}/cmake/TGUIConfig.cmake.in" + "${PROJECT_BINARY_DIR}/TGUIConfig.cmake" + INSTALL_DESTINATION "${config_package_location}") + +write_basic_package_version_file("${PROJECT_BINARY_DIR}/TGUIConfigVersion.cmake" + VERSION ${TGUI_VERSION_MAJOR}.${TGUI_VERSION_MINOR}.${TGUI_VERSION_PATCH} + COMPATIBILITY SameMajorVersion) + +if (TGUI_SHARED_LIBS) + set(targets_config_filename TGUISharedTargets.cmake) +else() + set(targets_config_filename TGUIStaticTargets.cmake) +endif() + +if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) + # When building TGUI alongside its dependencies, the export is only possible when all dependencies also do the export. + # To keep the code simple, we will never create the config file in our build folder when TGUI is build as a subdirectory. + # At the time of writing, the following dependencies have or lack the export call: + # - Have: SFML 2, SDL 3 + # - Lack: SDL_ttf, FreeType, GLFW, SFML 3 (https://github.com/SFML/SFML/pull/2619) + export(TARGETS tgui + NAMESPACE TGUI:: + FILE "${PROJECT_BINARY_DIR}/${targets_config_filename}") +endif() + +if (TGUI_INSTALL) + # Install library + install(TARGETS tgui EXPORT TGUIConfigExport + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT bin + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT devel + FRAMEWORK DESTINATION "." COMPONENT bin) + + install(EXPORT TGUIConfigExport + NAMESPACE TGUI:: + FILE ${targets_config_filename} + DESTINATION ${config_package_location}) + + install(FILES "${PROJECT_BINARY_DIR}/TGUIConfig.cmake" + "${PROJECT_BINARY_DIR}/TGUIConfigVersion.cmake" + DESTINATION ${config_package_location} + COMPONENT devel) + + # Install the find modules when they are needed to find our dependencies + if(TGUI_HAS_WINDOW_BACKEND_GLFW AND NOT TGUI_FOUND_GLFW_CONFIG) + install(FILES "${PROJECT_SOURCE_DIR}/cmake/Modules/Findglfw3.cmake" DESTINATION ${config_package_location} COMPONENT devel) + add_custom_command(TARGET tgui POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/cmake/Modules/Findglfw3.cmake" "${PROJECT_BINARY_DIR}/" VERBATIM) + endif() + if((TGUI_HAS_WINDOW_BACKEND_SDL OR TGUI_HAS_FONT_BACKEND_SDL_TTF) AND NOT TGUI_FOUND_SDL2_CONFIG) + install(FILES "${PROJECT_SOURCE_DIR}/cmake/Modules/FindSDL2.cmake" DESTINATION ${config_package_location} COMPONENT devel) + add_custom_command(TARGET tgui POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/cmake/Modules/FindSDL2.cmake" "${PROJECT_BINARY_DIR}/" VERBATIM) + endif() + if(TGUI_HAS_FONT_BACKEND_SDL_TTF AND NOT TGUI_FOUND_SDL2_TTF_CONFIG) + install(FILES "${PROJECT_SOURCE_DIR}/cmake/Modules/FindSDL2_ttf.cmake" DESTINATION ${config_package_location} COMPONENT devel) + add_custom_command(TARGET tgui POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/cmake/Modules/FindSDL2_ttf.cmake" "${PROJECT_BINARY_DIR}/" VERBATIM) + endif() + + if (TGUI_INSTALL_PKGCONFIG_FILES) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/tgui.pc" DESTINATION "${TGUI_PKGCONFIG_INSTALL_PREFIX}") + endif() endif() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8a9ec4e60..ec42a63f7 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -202,18 +202,20 @@ if(TGUI_SHARED_LIBS AND TGUI_OS_LINUX) INSTALL_RPATH "$ORIGIN/${rel_lib_dir}") endif() -# Add the install rule for the executable -install(TARGETS tests - RUNTIME DESTINATION ${target_install_dir} COMPONENT tests - BUNDLE DESTINATION ${target_install_dir} COMPONENT tests) - -# Install the resources next to the test executable -install(DIRECTORY "${PROJECT_SOURCE_DIR}/tests/resources" - DESTINATION "${target_install_dir}" - COMPONENT tests) -install(DIRECTORY "${PROJECT_SOURCE_DIR}/tests/expected" - DESTINATION "${target_install_dir}" - COMPONENT tests) -install(DIRECTORY "${PROJECT_SOURCE_DIR}/themes/" - DESTINATION "${target_install_dir}/resources" - COMPONENT tests) +if (TGUI_INSTALL) + # Add the install rule for the executable + install(TARGETS tests + RUNTIME DESTINATION ${target_install_dir} COMPONENT tests + BUNDLE DESTINATION ${target_install_dir} COMPONENT tests) + + # Install the resources next to the test executable + install(DIRECTORY "${PROJECT_SOURCE_DIR}/tests/resources" + DESTINATION "${target_install_dir}" + COMPONENT tests) + install(DIRECTORY "${PROJECT_SOURCE_DIR}/tests/expected" + DESTINATION "${target_install_dir}" + COMPONENT tests) + install(DIRECTORY "${PROJECT_SOURCE_DIR}/themes/" + DESTINATION "${target_install_dir}/resources" + COMPONENT tests) +endif()