From 17c89693811a4aa27db700d8f9f278393c8e0926 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Tue, 18 Feb 2020 20:41:22 +0300 Subject: [quotest] Refactor Cmake files with variable project name Signed-off-by: Alexey Andreev --- CMakeLists.txt | 20 ++++++++++---------- tests/CMakeLists.txt | 8 +++++--- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a17e1f9..9fbf3a9b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -241,9 +241,9 @@ target_link_libraries(${PROJECT_NAME} QtOlm Qt5::Core Qt5::Network Qt5::Gui Qt5: set(TEST_BINARY quotest) add_executable(${TEST_BINARY} ${tests_SRCS}) -target_link_libraries(${TEST_BINARY} Qt5::Core Qt5::Test Quotient) +target_link_libraries(${TEST_BINARY} Qt5::Core Qt5::Test ${PROJECT_NAME}) -configure_file(Quotient.pc.in ${CMAKE_CURRENT_BINARY_DIR}/Quotient.pc @ONLY NEWLINE_STYLE UNIX) +configure_file(${PROJECT_NAME}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc @ONLY NEWLINE_STYLE UNIX) # Installation @@ -259,15 +259,15 @@ include(CMakePackageConfigHelpers) # NB: SameMajorVersion doesn't really work yet, as we're within 0.x trail. # Maybe consider jumping the gun and releasing 1.0, as semver advises? write_basic_package_version_file( - "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/QuotientConfigVersion.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake" COMPATIBILITY SameMajorVersion ) export(PACKAGE ${PROJECT_NAME}) export(EXPORT ${PROJECT_NAME}Targets FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Targets.cmake") -configure_file(cmake/QuotientConfig.cmake - "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/QuotientConfig.cmake" +configure_file(cmake/${PROJECT_NAME}Config.cmake + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake" COPYONLY ) @@ -275,21 +275,21 @@ set(ConfigFilesLocation "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") install(EXPORT ${PROJECT_NAME}Targets FILE ${PROJECT_NAME}Targets.cmake DESTINATION ${ConfigFilesLocation}) -install(FILES cmake/QuotientConfig.cmake - "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/QuotientConfigVersion.cmake" +install(FILES cmake/${PROJECT_NAME}Config.cmake + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake" DESTINATION ${ConfigFilesLocation} ) -install(EXPORT_ANDROID_MK QuotientTargets DESTINATION share/ndk-modules) +install(EXPORT_ANDROID_MK ${PROJECT_NAME}Targets DESTINATION share/ndk-modules) if (WIN32) install(FILES mime/packages/freedesktop.org.xml DESTINATION mime/packages) endif (WIN32) -if (QUOTIENT_INSTALL_TESTS) +if (${PROJECT_NAME}_INSTALL_TESTS) install(TARGETS ${TEST_BINARY} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) endif () if (UNIX AND NOT APPLE) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Quotient.pc + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) endif() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 490a2506..cb8c99f8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -48,7 +48,9 @@ endforeach () find_package(Qt5 5.9 REQUIRED Network Gui Multimedia Test) get_filename_component(Qt5_Prefix "${Qt5_DIR}/../../../.." ABSOLUTE) -find_package(Quotient REQUIRED) +set(LIBRARY_NAME "Quotient") + +find_package(${LIBRARY_NAME} REQUIRED) get_filename_component(Quotient_Prefix "${Quotient_DIR}/../.." ABSOLUTE) message( STATUS "${PROJECT_NAME} configuration:" ) @@ -57,12 +59,12 @@ if (CMAKE_BUILD_TYPE) endif(CMAKE_BUILD_TYPE) message( STATUS " Compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}" ) message( STATUS " Qt: ${Qt5_VERSION} at ${Qt5_Prefix}" ) -message( STATUS " Quotient: ${Quotient_VERSION} at ${Quotient_Prefix}" ) +message( STATUS " ${LIBRARY_NAME}: ${${LIBRARY_NAME}_VERSION} at ${${LIBRARY_NAME}_Prefix}" ) set(example_SRCS quotest.cpp) add_executable(${PROJECT_NAME} ${example_SRCS}) -target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Test Quotient) +target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Test ${LIBRARY_NAME}) # Installation -- cgit v1.2.3