diff --git a/CMakeLists.txt b/CMakeLists.txt index 29ca64f..f9a5719 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,8 +29,9 @@ endif() project(QtADS LANGUAGES CXX VERSION ${VERSION_SHORT}) -option(BUILD_STATIC "Build the static library" OFF) -option(BUILD_EXAMPLES "Build the examples" ON) +option(ADS_BUILD_STATIC "Build the static library" OFF) +option(ADS_BUILD_EXAMPLES "Build the examples" ON) +option(ADS_INSTALL "Install library" ON) if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4") set(ads_PlatformDir "x86") @@ -40,7 +41,7 @@ endif() add_subdirectory(src) -if(BUILD_EXAMPLES) +if(ADS_BUILD_EXAMPLES) add_subdirectory(examples) add_subdirectory(demo) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9690be7..9da7c39 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,7 +12,7 @@ if (UNIX AND NOT APPLE) include_directories(${Qt${QT_VERSION_MAJOR}Gui_PRIVATE_INCLUDE_DIRS}) endif() set(CMAKE_INCLUDE_CURRENT_DIR ON) -if(BUILD_STATIC) +if(ADS_BUILD_STATIC) set(CMAKE_STATIC_LIBRARY_SUFFIX "_static${CMAKE_STATIC_LIBRARY_SUFFIX}") endif() set(ads_SRCS @@ -72,7 +72,7 @@ if (UNIX AND NOT APPLE) endif() set(library_name "qt${QT_VERSION_MAJOR}advanceddocking") -if(BUILD_STATIC) +if(ADS_BUILD_STATIC) add_library(${library_name} STATIC ${ads_SRCS} ${ads_HEADERS}) target_compile_definitions( ${library_name} PUBLIC ADS_STATIC) else() @@ -114,42 +114,43 @@ elseif(QT_VERSION_MAJOR STREQUAL "6") CXX_STANDARD_REQUIRED ON) endif() -include(CMakePackageConfigHelpers) -write_basic_package_version_file( - "${library_name}ConfigVersion.cmake" - VERSION ${VERSION_SHORT} - COMPATIBILITY SameMajorVersion -) -install(FILES ${ads_HEADERS} - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${library_name} - COMPONENT headers -) -install(FILES - "${CMAKE_CURRENT_SOURCE_DIR}/../LICENSE" - "${CMAKE_CURRENT_SOURCE_DIR}/../gnu-lgpl-v2.1.md" - DESTINATION license/ads - COMPONENT license -) -install(TARGETS ${library_name} - EXPORT adsTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${library_name} -) - -install(EXPORT adsTargets - FILE adsTargets.cmake - NAMESPACE ads:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${library_name} -) -install(FILES qtadvanceddockingConfig.cmake RENAME ${library_name}Config.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${library_name} -) -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${library_name}ConfigVersion.cmake" - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${library_name} -) +if(ADS_INSTALL) + include(CMakePackageConfigHelpers) + write_basic_package_version_file( + "${library_name}ConfigVersion.cmake" + VERSION ${VERSION_SHORT} + COMPATIBILITY SameMajorVersion + ) + install(FILES ${ads_HEADERS} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${library_name} + COMPONENT headers + ) + install(FILES + "${CMAKE_CURRENT_SOURCE_DIR}/../LICENSE" + "${CMAKE_CURRENT_SOURCE_DIR}/../gnu-lgpl-v2.1.md" + DESTINATION license/ads + COMPONENT license + ) + install(TARGETS ${library_name} + EXPORT adsTargets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${library_name} + ) + install(EXPORT adsTargets + FILE adsTargets.cmake + NAMESPACE ads:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${library_name} + ) + install(FILES qtadvanceddockingConfig.cmake RENAME ${library_name}Config.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${library_name} + ) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${library_name}ConfigVersion.cmake" + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${library_name} + ) +endif() target_include_directories(${library_name} PUBLIC $ $