--- qsampler/trunk/CMakeLists.txt 2020/08/16 11:48:49 3815 +++ qsampler/trunk/CMakeLists.txt 2021/09/27 09:45:24 3997 @@ -1,29 +1,35 @@ -project(QSAMPLER) +cmake_minimum_required (VERSION 3.13) -cmake_minimum_required(VERSION 3.1) +project (qsampler + VERSION 0.9.5 + DESCRIPTION "A LinuxSampler Qt GUI Interface" + LANGUAGES C CXX) -set (VERSION "0.9.0") - -set (CONFIG_VERSION ${VERSION}) +set (CONFIG_VERSION ${PROJECT_VERSION}) execute_process ( COMMAND git describe --tags --dirty --abbrev=6 + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE GIT_DESCRIBE_OUTPUT RESULT_VARIABLE GIT_DESCRIBE_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE) if (GIT_DESCRIBE_RESULT EQUAL 0) set (VERSION "${GIT_DESCRIBE_OUTPUT}") - string (REGEX REPLACE "^[^_]+" "" VERSION "${VERSION}") + string (REGEX REPLACE "^[^0-9]+" "" VERSION "${VERSION}") + string (REGEX REPLACE "^1_" "" VERSION "${VERSION}") string (REGEX REPLACE "^[_vV]+" "" VERSION "${VERSION}") string (REGEX REPLACE "-g" "git." VERSION "${VERSION}") - string (REGEX REPLACE "[_|-]+" "." VERSION "${VERSION}") + string (REGEX REPLACE "[_|-]" "." VERSION "${VERSION}") execute_process ( COMMAND git rev-parse --abbrev-ref HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE GIT_REVPARSE_OUTPUT RESULT_VARIABLE GIT_REVPARSE_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE) if (GIT_REVPARSE_RESULT EQUAL 0 AND NOT GIT_REVPARSE_OUTPUT STREQUAL "master") set (VERSION "${VERSION} [${GIT_REVPARSE_OUTPUT}]") endif () +else () + set (VERSION "${PROJECT_VERSION}") endif () set (PACKAGE_NAME "Qsampler") @@ -32,18 +38,22 @@ set (PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set (PACKAGE_TARNAME "qsampler") +set (ac_version "${PROJECT_VERSION}") +set (ac_prefix "${CMAKE_INSTALL_PREFIX}") + set (CONFIG_BUILD_VERSION "${PACKAGE_VERSION}") -if (CMAKE_BUILD_TYPE) - set (CONFIG_BUILD_TYPE ${CMAKE_BUILD_TYPE}) -else () - set (CONFIG_BUILD_TYPE "release") +if (CONFIG_DEBUG) + set (CMAKE_BUILD_TYPE "Debug") endif () - -set (CONFIG_DEBUG 0) -if (CONFIG_BUILD_TYPE MATCHES "debug") +if (CMAKE_BUILD_TYPE MATCHES "Debug") set (CONFIG_DEBUG 1) endif () +if (CONFIG_DEBUG) + set (CONFIG_BUILD_TYPE "debug") +else () + set (CONFIG_BUILD_TYPE "release") +endif () set (CONFIG_PREFIX "${CMAKE_INSTALL_PREFIX}") @@ -64,19 +74,36 @@ option (CONFIG_STACKTRACE "Enable debugger stack-trace (default=no)" 0) +# Enable Qt6 build preference. +option (CONFIG_QT6 "Enable Qt6 build (default=yes)" 1) + + # Fix for new CMAKE_REQUIRED_LIBRARIES policy. if (POLICY CMP0075) cmake_policy (SET CMP0075 NEW) endif () -# Check for Qt -find_package (Qt5 REQUIRED COMPONENTS Core Gui Widgets) +# Check for Qt... +if (CONFIG_QT6) + find_package (Qt6 QUIET) + if (NOT Qt6_FOUND) + set (CONFIG_QT6 0) + endif () +endif () + +if (CONFIG_QT6) + find_package (QT QUIET NAMES Qt6) +else () + find_package (QT QUIET NAMES Qt5) +endif () + +find_package (Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets) if (CONFIG_XUNIQUE) - find_package (Qt5 REQUIRED COMPONENTS Network) + find_package (Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Network) endif () -find_package (Qt5LinguistTools) +find_package (Qt${QT_VERSION_MAJOR}LinguistTools) include (CheckIncludeFile) include (CheckIncludeFiles) @@ -105,16 +132,16 @@ # Find package modules -find_package (PkgConfig REQUIRED) +include (FindPkgConfig) # Check for LSCP libraries. -pkg_check_modules (LSCP REQUIRED lscp) +pkg_check_modules (LSCP REQUIRED IMPORTED_TARGET lscp) if (LSCP_FOUND) + find_library(LSCP_LIBRARY NAMES ${LSCP_LIBRARIES} HINTS ${LSCP_LIBDIR}) +endif () +if (LSCP_LIBRARY) set (CONFIG_LIBLSCP 1) - include_directories (${LSCP_INCLUDE_DIRS}) - link_directories (${LSCP_LIBRARY_DIRS}) -# link_libraries (${LSCP_LIBRARIES}) - set (CMAKE_REQUIRED_LIBRARIES "${LSCP_LIBRARIES};${CMAKE_REQUIRED_LIBRARIES}") + set (CMAKE_REQUIRED_LIBRARIES "${LSCP_LIBRARY};${CMAKE_REQUIRED_LIBRARIES}") # Check for for instrument_name in lscp_channel_info_t. check_include_file (lscp/client.h HAVE_LSCP_CLIENT_H) if (NOT HAVE_LSCP_CLIENT_H) @@ -182,12 +209,13 @@ # Check for GIG libraries. if (CONFIG_LIBGIG) - pkg_check_modules (GIG gig>=3.3.0) + pkg_check_modules (GIG IMPORTED_TARGET gig>=3.3.0) if (GIG_FOUND) - include_directories (${GIG_INCLUDE_DIRS}) - link_directories (${GIG_LIBRARY_DIRS}) - link_libraries (${GIG_LIBRARIES}) -# set (CMAKE_REQUIRED_LIBRARIES "${GIG_LIBRARIES};${CMAKE_REQUIRED_LIBRARIES}") + find_library(GIG_LIBRARY NAMES ${GIG_LIBRARIES} HINTS ${GIG_LIBDIR}) + endif () + if (GIG_LIBRARY) + set (CONFIG_LIBGIG 1) + #set (CMAKE_REQUIRED_LIBRARIES "${GIG_LIBRARY};${CMAKE_REQUIRED_LIBRARIES}") # liggig supports fast information retrieval. set (CONFIG_LIBGIG_SETAUTOLOAD 1) # Check if libgig/SF.h is available. @@ -221,7 +249,7 @@ endmacro () -message ("\n ${PACKAGE_NAME} ${PACKAGE_VERSION}") +message ("\n ${PACKAGE_NAME} ${PACKAGE_VERSION} (Qt ${QT_VERSION})") message ("\n Build target . . . . . . . . . . . . . . . . . . .: ${CONFIG_BUILD_TYPE}\n") show_option (" LSCP instrument name support . . . . . . . . . . ." CONFIG_INSTRUMENT_NAME) show_option (" LSCP mute/solo support . . . . . . . . . . . . . ." CONFIG_MUTE_SOLO) @@ -243,5 +271,5 @@ message ("") show_option (" Unique/Single instance support . . . . . . . . . ." CONFIG_XUNIQUE) show_option (" Debugger stack-trace (gdb) . . . . . . . . . . . ." CONFIG_STACKTRACE) -message ("\n Install prefix . . . . . . . . . . . . . . . . . .: ${CMAKE_INSTALL_PREFIX}") +message ("\n Install prefix . . . . . . . . . . . . . . . . . .: ${CONFIG_PREFIX}") message ("\nNow type 'make', followed by 'make install' as root.\n")