diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8c3bf19a66d71bba89b3b0b8b8b63678cda8a361..f7eff5c9ea80c94df30e7335a595bfb48d98e2ee 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -41,7 +41,7 @@ windows: - $QTCMake_DIR = "$QT_MSVC_DIR/lib/cmake" - mkdir -Force "build" - cd build - - cmake -G "Visual Studio 17 2022" -A x64 -T host=x64 -DCMAKE_PREFIX_PATH="$QTCMake_DIR" -DCMAKE_INSTALL_PREFIX="C:/opt/x64" -B. -DBUILD_TESTING=OFF .. + - cmake -G "Visual Studio 17 2022" -A x64 -T host=x64 -DCMAKE_PREFIX_PATH="$QTCMake_DIR" -DCMAKE_INSTALL_PREFIX="C:/opt/x64" -B. .. - cmake --build . --config Release - Get-Location - ctest -C Release --output-on-failure diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f574ce1d909be39e4fa0c74bace46ec61c6ab34..4a2bdc01a769310ac9279678750440fa3600d263 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,13 +9,13 @@ include(PreventInSourceBuilds) set(CMAKE_PROJECT_DESCRIPTION # for display in installer "libQCR - Qt Capture & Replay.") -### Options +## Options. if(NOT DEFINED BUILD_SHARED_LIBS) option(BUILD_SHARED_LIBS "Build as shared library" ON) endif() -### Compile flags +## Compile settings. set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) @@ -49,28 +49,62 @@ endif() set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") -### Dependences +## Dependences. find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) -### Installation settings +## Installation settings. configure_file("qcr.pc.in" "qcr.pc" @ONLY) install( FILES "${CMAKE_CURRENT_BINARY_DIR}/qcr.pc" DESTINATION "lib/pkgconfig/") -### Source directories +## Source directories. add_subdirectory(QCR) add_subdirectory(demo) -### Test settings +## Tests. -include(CTest) -if(BUILD_TESTING) # option defined by CTest and enabled by default - add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) # => 'make check' is alias for 'ctest' +if(NOT WIN32) + include(CTest) add_subdirectory(utest) -else() - message(STATUS "Skipping tests") endif() + +## CPack settings. + +include(InstallRequiredSystemLibraries) +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE") +set(CPACK_PACKAGE_VERSION_MAJOR "${QCR_VERSION_MAJOR}") +set(CPACK_PACKAGE_VERSION_MINOR "${QCR_VERSION_MINOR}") +set(CPACK_SOURCE_GENERATOR "TGZ") +include(CPack) + +## Config files. + +include(CMakePackageConfigHelpers) +configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/QCRConfig.cmake" + INSTALL_DESTINATION cmake + NO_SET_AND_CHECK_MACRO + NO_CHECK_REQUIRED_COMPONENTS_MACRO) + +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/QCRConfigVersion.cmake" + VERSION "${QCR_VERSION_MAJOR}.${QCR_VERSION_MINOR}" + COMPATIBILITY AnyNewerVersion) + +install(FILES + "${PROJECT_BINARY_DIR}/QCRConfig.cmake" + "${PROJECT_BINARY_DIR}/QCRConfigVersion.cmake" + DESTINATION cmake) + +## Export targets. + +install(EXPORT QCRTargets + FILE QCRTargets.cmake + DESTINATION cmake) + +export(EXPORT QCRTargets + FILE "${CMAKE_CURRENT_BINARY_DIR}/QCRTargets.cmake") diff --git a/Config.cmake.in b/Config.cmake.in new file mode 100644 index 0000000000000000000000000000000000000000..ac80d572134aaa538a6e75299ed4f0f6626f71b3 --- /dev/null +++ b/Config.cmake.in @@ -0,0 +1,4 @@ +@PACKAGE_INIT@ + +set(QCR_INCLUDE_DIR "@CMAKE_INSTALL_PREFIX@/include") +include("${CMAKE_CURRENT_LIST_DIR}/QCRTargets.cmake") diff --git a/QCR/CMakeLists.txt b/QCR/CMakeLists.txt index 9ff9e61594e37c480a1c6e67b79ef252ad543b86..8a669e06718f7ba4047d16960ea02f531fc6a28b 100644 --- a/QCR/CMakeLists.txt +++ b/QCR/CMakeLists.txt @@ -33,7 +33,8 @@ add_library(${lib} ${sources}) target_include_directories(${lib} PUBLIC - ${CMAKE_SOURCE_DIR} + "$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>" + "$<INSTALL_INTERFACE:include>" ) target_link_libraries(${lib} @@ -50,6 +51,7 @@ set_target_properties( install( TARGETS ${lib} + EXPORT QCRTargets LIBRARY DESTINATION lib RUNTIME DESTINATION lib ARCHIVE DESTINATION lib