cmake update

1. cmake minimum version updated to 3.18
2. find_package qt updated no need for  -DWITH_QT6
This commit is contained in:
dsm 2023-02-13 21:50:15 +03:00
parent cdafafc07d
commit d8bd72206b
7 changed files with 150 additions and 226 deletions

View File

@ -1,15 +1,24 @@
PROJECT(qucs-suite CXX)
CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
cmake_policy(VERSION 3.0)
cmake_minimum_required(VERSION 3.18)
cmake_policy(VERSION 3.18)
SET(QUCS_NAME "qucs-s")
set(QUCS_NAME "qucs-s")
# Prohibit in-source builds
if("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
message(
FATAL_ERROR
"QUCS-S: You cannot build in a source directory (or any directory with "
"CMakeLists.txt file). Please make a build subdirectory. Feel free to "
"remove CMakeCache.txt and CMakeFiles.")
endif()
file (STRINGS "${qucs-suite_SOURCE_DIR}/VERSION" QUCS_VERSION)
message(STATUS "Configuring Qucs: VERSION ${QUCS_VERSION}")
set(GIT unknown)
IF(EXISTS ${CMAKE_SOURCE_DIR}/../.git )
FIND_PACKAGE(Git)
if(EXISTS ${CMAKE_SOURCE_DIR}/../.git )
find_package(Git)
# Get the latest abbreviated commit hash of the working branch
execute_process(
COMMAND ${GIT_EXECUTABLE} log --pretty=format:%h -n 1u
@ -18,36 +27,32 @@ IF(EXISTS ${CMAKE_SOURCE_DIR}/../.git )
)
set(GIT ${GIT_COMMIT_HASH})
message(STATUS "Found Git repository, last commit hash: ${GIT}")
ENDIF()
endif()
message(STATUS "${PROJECT_NAME} ${CMAKE_INSTALL_PREFIX}
${qucs-suite_BINARY_DIR}" )
message(STATUS "${PROJECT_NAME} ${CMAKE_INSTALL_PREFIX} ${qucs-suite_BINARY_DIR}" )
IF(WITH_QT6)
FIND_PACKAGE( Qt6 COMPONENTS Core Gui Widgets LinguistTools REQUIRED )
ELSE()
FIND_PACKAGE( Qt5 COMPONENTS Core Gui Widgets LinguistTools REQUIRED )
ENDIF()
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Gui Widgets LinguistTools)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets LinguistTools)
ADD_DEFINITIONS(${QT_DEFINITIONS})
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_definitions(${QT_DEFINITIONS})
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
IF (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
ADD_DEFINITIONS(-DQT_NO_DEBUG_OUTPUT)
ENDIF()
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_definitions(QT_NO_DEBUG_OUTPUT)
endif()
ADD_SUBDIRECTORY( qucs )
ADD_SUBDIRECTORY( qucs-activefilter )
ADD_SUBDIRECTORY( qucs-attenuator )
#ADD_SUBDIRECTORY( qucs-doc )
ADD_SUBDIRECTORY( qucs-filter )
ADD_SUBDIRECTORY( library )
ADD_SUBDIRECTORY( qucs-transcalc )
ADD_SUBDIRECTORY( qucs-powercombining )
#ADD_SUBDIRECTORY( examples )
ADD_SUBDIRECTORY( translations )
add_subdirectory( qucs )
add_subdirectory( qucs-activefilter )
add_subdirectory( qucs-attenuator )
#add_subdirectory( qucs-doc )
add_subdirectory( qucs-filter )
add_subdirectory( library )
add_subdirectory( qucs-transcalc )
add_subdirectory( qucs-powercombining )
#add_subdirectory( examples )
add_subdirectory( translations )
INSTALL(DIRECTORY "examples" DESTINATION "share/${QUCS_NAME}")
install(DIRECTORY "examples" DESTINATION "share/${QUCS_NAME}")
#
# Custom uninstall target

View File

@ -1,6 +1,6 @@
PROJECT(qucsactivefilter CXX C)
CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
cmake_policy(VERSION 3.0)
CMAKE_MINIMUM_REQUIRED(VERSION 3.18)
cmake_policy(VERSION 3.18)
SET(QUCS_NAME "qucs-s")
@ -20,7 +20,26 @@ set(PROJECT_DOMAIN_SECOND "org")
add_compile_definitions(HAVE_CONFIG_H)
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
IF(WITH_QT6)
#configure the header config.h
CONFIGURE_FILE (
"${PROJECT_SOURCE_DIR}/../config.h.cmake"
"${PROJECT_BINARY_DIR}/config.h"
)
INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}")
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Gui Widgets Svg SvgWidgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets Svg SvgWidgets)
include_directories(
${Qt${QT_VERSION_MAJOR}Core_INCLUDE_DIRS}
${Qt${QT_VERSION_MAJOR}Gui_INCLUDE_DIRS}
${Qt${QT_VERSION_MAJOR}Widgets_INCLUDE_DIRS}
${Qt${QT_VERSION_MAJOR}Svg_INCLUDE_DIRS}
${Qt${QT_VERSION_MAJOR}SvgWidgets_INCLUDE_DIRS}
)
IF(QT_VERSION_MAJOR EQUAL 6)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
ELSE()
@ -35,40 +54,6 @@ else()
add_compile_options(-Wall -Wextra)
endif()
#configure the header config.h
CONFIGURE_FILE (
"${PROJECT_SOURCE_DIR}/../config.h.cmake"
"${PROJECT_BINARY_DIR}/config.h"
)
INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}")
IF(WITH_QT6)
FIND_PACKAGE( Qt6 COMPONENTS Core Gui Widgets Svg SvgWidgets REQUIRED)
INCLUDE_DIRECTORIES(
${Qt6Core_INCLUDE_DIRS}
${Qt6Widgets_INCLUDE_DIRS}
${Qt6Svg_INCLUDE_DIRS}
${Qt6SvgWidgets_INCLUDE_DIRS}
)
# bug, the find package does not seem to set the QT_LIBRARIES, do it manually
SET(QT_LIBRARIES ${Qt6Core_LIBRARIES} ${Qt6Widgets_LIBRARIES} ${Qt6Svg_LIBRARIES} ${Qt6SvgWidgets_LIBRARIES} )
ELSE(WITH_QT6)
FIND_PACKAGE( Qt5 COMPONENTS Core Gui Widgets Svg REQUIRED)
INCLUDE_DIRECTORIES(
${Qt5Core_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}
${Qt5Svg_INCLUDE_DIRS}
)
# bug, the find package does not seem to set the QT_LIBRARIES, do it manually
SET(QT_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Svg_LIBRARIES} )
ENDIF(WITH_QT6)
ADD_DEFINITIONS(${QT_DEFINITIONS})
SET(QUCS-ACTIVE-FILTER_SRCS
@ -90,13 +75,13 @@ helpdialog.h
)
SET(RESOURCES qucsactivefilter.qrc)
IF(WITH_QT6)
IF(QT_VERSION_MAJOR EQUAL 6)
QT6_WRAP_CPP(QUCS-ACTIVE-FILTER_MOC_SRCS ${QUCS-ACTIVE-FILTER_MOC_HDRS})
QT6_ADD_RESOURCES(RESOURCES_SRCS ${RESOURCES})
ELSE(WITH_QT6)
ELSE()
QT5_WRAP_CPP(QUCS-ACTIVE-FILTER_MOC_SRCS ${QUCS-ACTIVE-FILTER_MOC_HDRS})
QT5_ADD_RESOURCES(RESOURCES_SRCS ${RESOURCES})
ENDIF(WITH_QT6)
ENDIF()
@ -123,7 +108,8 @@ ADD_EXECUTABLE(${QUCS_NAME}activefilter MACOSX_BUNDLE WIN32
${QUCS-ACTIVE-FILTER_MOC_SRCS}
${RESOURCES_SRCS} )
TARGET_LINK_LIBRARIES(${QUCS_NAME}activefilter ${QT_LIBRARIES})
TARGET_LINK_LIBRARIES(${QUCS_NAME}activefilter Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Svg Qt${QT_VERSION_MAJOR}::SvgWidgets)
INSTALL(TARGETS ${QUCS_NAME}activefilter
BUNDLE DESTINATION bin COMPONENT Runtime

View File

@ -1,6 +1,6 @@
PROJECT(qucsattenuator CXX C)
CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
cmake_policy(VERSION 3.0)
CMAKE_MINIMUM_REQUIRED(VERSION 3.18)
cmake_policy(VERSION 3.18)
SET(QUCS_NAME "qucs-s")
@ -27,9 +27,16 @@ CONFIGURE_FILE (
INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}")
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Gui Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets)
include_directories(
${Qt${QT_VERSION_MAJOR}Core_INCLUDE_DIRS}
${Qt${QT_VERSION_MAJOR}Gui_INCLUDE_DIRS}
${Qt${QT_VERSION_MAJOR}Widgets_INCLUDE_DIRS}
)
IF(WITH_QT6)
IF(QT_VERSION_MAJOR EQUAL 6)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
ELSE()
@ -43,25 +50,6 @@ else()
# additional warnings
add_compile_options(-Wall -Wextra)
endif()
IF(WITH_QT6)
FIND_PACKAGE( Qt6 COMPONENTS Core Gui Widgets REQUIRED )
INCLUDE_DIRECTORIES(
${Qt6Core_INCLUDE_DIRS}
${Qt6Widgets_INCLUDE_DIRS}
)
# bug, the find package does not seem to set the QT_LIBRARIES, do it manually
SET(QT_LIBRARIES ${Qt6Core_LIBRARIES} ${Qt6Widgets_LIBRARIES} )
ELSE(WITH_QT6)
FIND_PACKAGE( Qt5 COMPONENTS Core Gui Widgets REQUIRED )
INCLUDE_DIRECTORIES(
${Qt5Core_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}
)
# bug, the find package does not seem to set the QT_LIBRARIES, do it manually
SET(QT_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Widgets_LIBRARIES} )
ENDIF(WITH_QT6)
ADD_DEFINITIONS(${QT_DEFINITIONS})
#ADD_SUBDIRECTORY( bitmaps ) -> added as resources
@ -72,13 +60,13 @@ SET( attenuator_moc_headers qucsattenuator.h )
SET(RESOURCES qucsattenuator.qrc)
IF(WITH_QT6)
if(QT_VERSION_MAJOR EQUAL 6)
QT6_WRAP_CPP( attenuator_moc_sources ${attenuator_moc_headers} )
QT6_ADD_RESOURCES(RESOURCES_SRCS ${RESOURCES})
ELSE(WITH_QT6)
else()
QT5_WRAP_CPP( attenuator_moc_sources ${attenuator_moc_headers} )
QT5_ADD_RESOURCES(RESOURCES_SRCS ${RESOURCES})
ENDIF(WITH_QT6)
endif()
IF(APPLE)
# set information on Info.plist file
@ -103,7 +91,7 @@ ADD_EXECUTABLE( ${QUCS_NAME}attenuator MACOSX_BUNDLE WIN32
${attenuator_moc_sources}
${RESOURCES_SRCS} )
TARGET_LINK_LIBRARIES( ${QUCS_NAME}attenuator ${QT_LIBRARIES} )
TARGET_LINK_LIBRARIES( ${QUCS_NAME}attenuator Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets )
#INSTALL (TARGETS ${QUCS_NAME}attenuator DESTINATION bin)
#

View File

@ -1,6 +1,6 @@
PROJECT(qucsfilter CXX C)
CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
cmake_policy(VERSION 3.0)
CMAKE_MINIMUM_REQUIRED(VERSION 3.18)
cmake_policy(VERSION 3.18)
SET(QUCS_NAME "qucs-s")
@ -28,8 +28,16 @@ CONFIGURE_FILE (
INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}")
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Gui Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets)
include_directories(
${Qt${QT_VERSION_MAJOR}Core_INCLUDE_DIRS}
${Qt${QT_VERSION_MAJOR}Gui_INCLUDE_DIRS}
${Qt${QT_VERSION_MAJOR}Widgets_INCLUDE_DIRS}
)
IF(WITH_QT6)
IF(QT_VERSION_MAJOR EQUAL 6)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
ELSE()
@ -44,25 +52,6 @@ else()
add_compile_options(-Wall -Wextra)
endif()
IF(WITH_QT6)
FIND_PACKAGE( Qt6 COMPONENTS Core Gui Widgets REQUIRED)
INCLUDE_DIRECTORIES(
${Qt6Core_INCLUDE_DIRS}
${Qt6Widgets_INCLUDE_DIRS}
)
# bug, the find package does not seem to set the QT_LIBRARIES, do it manually
SET(QT_LIBRARIES ${Qt6Core_LIBRARIES} ${Qt6Widgets_LIBRARIES} )
ELSE(WITH_QT6)
FIND_PACKAGE( Qt5 COMPONENTS Core Gui Widgets REQUIRED)
INCLUDE_DIRECTORIES(
${Qt5Core_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}
)
# bug, the find package does not seem to set the QT_LIBRARIES, do it manually
SET(QT_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Widgets_LIBRARIES} )
ENDIF(WITH_QT6)
ADD_DEFINITIONS(${QT_DEFINITIONS})
SET(QUCS-FILTER_SRCS
@ -105,13 +94,13 @@ SET(QUCS-FILTER_MOC_HDRS
SET(RESOURCES qucsfilter.qrc)
IF(WITH_QT6)
if(QT_VERSION_MAJOR EQUAL 6)
QT6_WRAP_CPP(QUCS-FILTER_MOC_SRCS ${QUCS-FILTER_MOC_HDRS})
QT6_ADD_RESOURCES(RESOURCES_SRCS ${RESOURCES})
ELSE(WITH_QT6)
else()
QT5_WRAP_CPP(QUCS-FILTER_MOC_SRCS ${QUCS-FILTER_MOC_HDRS})
QT5_ADD_RESOURCES(RESOURCES_SRCS ${RESOURCES})
ENDIF(WITH_QT6)
endif()
IF(APPLE)
# set information on Info.plist file
@ -137,7 +126,7 @@ ADD_EXECUTABLE(${QUCS_NAME}filter MACOSX_BUNDLE WIN32
${QUCS-FILTER_MOC_SRCS}
${RESOURCES_SRCS} )
TARGET_LINK_LIBRARIES(${QUCS_NAME}filter ${QT_LIBRARIES})
TARGET_LINK_LIBRARIES(${QUCS_NAME}filter Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets)
INSTALL(TARGETS ${QUCS_NAME}filter
BUNDLE DESTINATION bin COMPONENT Runtime

View File

@ -1,6 +1,6 @@
PROJECT(qucspowercombining CXX C)
CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
cmake_policy(VERSION 3.0)
CMAKE_MINIMUM_REQUIRED(VERSION 3.18)
cmake_policy(VERSION 3.18)
SET(QUCS_NAME "qucs-s")
@ -28,7 +28,18 @@ CONFIGURE_FILE (
INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}")
IF(WITH_QT6)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Gui Widgets Svg SvgWidgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets Svg SvgWidgets)
include_directories(
${Qt${QT_VERSION_MAJOR}Core_INCLUDE_DIRS}
${Qt${QT_VERSION_MAJOR}Gui_INCLUDE_DIRS}
${Qt${QT_VERSION_MAJOR}Widgets_INCLUDE_DIRS}
${Qt${QT_VERSION_MAJOR}Svg_INCLUDE_DIRS}
${Qt${QT_VERSION_MAJOR}SvgWidgets_INCLUDE_DIRS}
)
IF(QT_VERSION_MAJOR EQUAL 6)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
ELSE()
@ -43,28 +54,6 @@ else()
add_compile_options(-Wall -Wextra)
endif()
IF(WITH_QT6)
FIND_PACKAGE( Qt6 COMPONENTS Core Gui Widgets Svg SvgWidgets REQUIRED)
INCLUDE_DIRECTORIES(
${Qt6Core_INCLUDE_DIRS}
${Qt6Widgets_INCLUDE_DIRS}
${Qt6Svg_INCLUDE_DIRS}
${Qt6SvgWidgets_INCLUDE_DIRS}
)
# bug, the find package does not seem to set the QT_LIBRARIES, do it manually
SET(QT_LIBRARIES ${Qt6Core_LIBRARIES} ${Qt6Widgets_LIBRARIES} ${Qt6Svg_LIBRARIES} ${Qt6SvgWidgets_LIBRARIES} )
ELSE(WITH_QT6)
FIND_PACKAGE( Qt5 COMPONENTS Core Gui Widgets Svg REQUIRED)
INCLUDE_DIRECTORIES(
${Qt5Core_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}
${Qt5Svg_INCLUDE_DIRS}
)
# bug, the find package does not seem to set the QT_LIBRARIES, do it manually
SET(QT_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Svg_LIBRARIES} )
ENDIF(WITH_QT6)
ADD_DEFINITIONS(${QT_DEFINITIONS})
SET(QUCS-POWCOMB_SRCS
@ -81,13 +70,13 @@ SET(QUCS-POWCOMB_MOC_HDRS
)
SET(RESOURCES qucspowercombining.qrc)
IF(WITH_QT6)
IF(QT_VERSION_MAJOR EQUAL 6)
QT6_WRAP_CPP(QUCS-POWCOMB_MOC_SRCS ${QUCS-POWCOMB_MOC_HDRS})
QT6_ADD_RESOURCES(RESOURCES_SRCS ${RESOURCES})
ELSE(WITH_QT6)
ELSE()
QT5_WRAP_CPP(QUCS-POWCOMB_MOC_SRCS ${QUCS-POWCOMB_MOC_HDRS})
QT5_ADD_RESOURCES(RESOURCES_SRCS ${RESOURCES})
ENDIF(WITH_QT6)
ENDIF()
IF(APPLE)
# set information on Info.plist file
@ -113,7 +102,8 @@ ADD_EXECUTABLE(${QUCS_NAME}powercombining MACOSX_BUNDLE WIN32
${QUCS-POWCOMB_MOC_SRCS}
${RESOURCES_SRCS} )
TARGET_LINK_LIBRARIES(${QUCS_NAME}powercombining ${QT_LIBRARIES})
TARGET_LINK_LIBRARIES(${QUCS_NAME}powercombining Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Svg Qt${QT_VERSION_MAJOR}::SvgWidgets)
INSTALL(TARGETS ${QUCS_NAME}powercombining
BUNDLE DESTINATION bin COMPONENT Runtime

View File

@ -1,6 +1,6 @@
PROJECT(qucstrans CXX C)
CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
cmake_policy(VERSION 3.0)
CMAKE_MINIMUM_REQUIRED(VERSION 3.18)
cmake_policy(VERSION 3.18)
SET(QUCS_NAME "qucs-s")
@ -27,8 +27,16 @@ CONFIGURE_FILE (
INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}")
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Gui Widgets )
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets )
include_directories(
${Qt${QT_VERSION_MAJOR}Core_INCLUDE_DIRS}
${Qt${QT_VERSION_MAJOR}Gui_INCLUDE_DIRS}
${Qt${QT_VERSION_MAJOR}Widgets_INCLUDE_DIRS}
)
IF(WITH_QT6)
IF(QT_VERSION_MAJOR EQUAL 6)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
ELSE()
@ -43,24 +51,6 @@ else()
add_compile_options(-Wall -Wextra)
endif()
IF(WITH_QT6)
FIND_PACKAGE( Qt6 COMPONENTS Core Gui Widgets REQUIRED)
INCLUDE_DIRECTORIES(
${Qt6Core_INCLUDE_DIRS}
${Qt6Widgets_INCLUDE_DIRS}
)
# bug, the find package does not seem to set the QT_LIBRARIES, do it manually
SET(QT_LIBRARIES ${Qt6Core_LIBRARIES} ${Qt6Widgets_LIBRARIES} )
ELSE(WITH_QT6)
FIND_PACKAGE( Qt5 COMPONENTS Core Gui Widgets REQUIRED)
INCLUDE_DIRECTORIES(
${Qt5Core_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}
)
# bug, the find package does not seem to set the QT_LIBRARIES, do it manually
SET(QT_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Widgets_LIBRARIES} )
ENDIF(WITH_QT6)
ADD_DEFINITIONS(${QT_DEFINITIONS})
SET(QUCSTRANS_SRCS
@ -100,13 +90,13 @@ SET( LIB_SRC
SET(RESOURCES qucstrans_.qrc)
IF(WITH_QT6)
IF(QT_VERSION_MAJOR EQUAL 6)
QT6_WRAP_CPP( QUCSTRANS_MOC_SRCS ${QUCSTRANS_MOC_HDRS} )
QT6_ADD_RESOURCES(RESOURCES_SRCS ${RESOURCES})
ELSE(WITH_QT6)
ELSE()
QT5_WRAP_CPP( QUCSTRANS_MOC_SRCS ${QUCSTRANS_MOC_HDRS} )
QT5_ADD_RESOURCES(RESOURCES_SRCS ${RESOURCES})
ENDIF(WITH_QT6)
ENDIF()
ADD_LIBRARY(transcalc STATIC ${LIB_SRC} )
@ -135,7 +125,7 @@ ADD_EXECUTABLE(${QUCS_NAME}trans MACOSX_BUNDLE WIN32
${QUCSTRANS_MOC_SRCS}
${RESOURCES_SRCS} )
TARGET_LINK_LIBRARIES( ${QUCS_NAME}trans ${QT_LIBRARIES} transcalc )
TARGET_LINK_LIBRARIES( ${QUCS_NAME}trans Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets transcalc )
#INSTALL(TARGETS ${QUCS_NAME}trans DESTINATION bin)

View File

@ -10,8 +10,8 @@
# By default, the prefix is "/usr/local"
PROJECT(qucs-s CXX)
CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
cmake_policy(VERSION 3.0)
CMAKE_MINIMUM_REQUIRED(VERSION 3.18)
cmake_policy(VERSION 3.18)
SET(QUCS_NAME "${PROJECT_NAME}")
@ -26,7 +26,6 @@ set(PROJECT_COPYRIGHT_YEAR "2014")
set(PROJECT_DOMAIN_FIRST "qucs")
set(PROJECT_DOMAIN_SECOND "org")
# If Git hash not defined, try to define it
IF(NOT GIT)
IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../../.git )
@ -53,40 +52,21 @@ endif()
#
add_compile_definitions(HAVE_CONFIG_H)
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
IF(WITH_QT6)
FIND_PACKAGE( Qt6 COMPONENTS Core Gui Widgets Svg Xml PrintSupport REQUIRED)
INCLUDE_DIRECTORIES(
${Qt6Core_INCLUDE_DIRS}
${Qt6Widgets_INCLUDE_DIRS}
${Qt6Svg_INCLUDE_DIRS}
${Qt6Xml_INCLUDE_DIRS}
${Qt6PrintSupport_INCLUDE_DIRS}
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Gui Widgets Svg Xml PrintSupport)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets Svg Xml PrintSupport)
include_directories(
${Qt${QT_VERSION_MAJOR}Core_INCLUDE_DIRS}
${Qt${QT_VERSION_MAJOR}Widgets_INCLUDE_DIRS}
${Qt${QT_VERSION_MAJOR}Svg_INCLUDE_DIRS}
${Qt${QT_VERSION_MAJOR}Xml_INCLUDE_DIRS}
${Qt${QT_VERSION_MAJOR}PrintSupport_INCLUDE_DIRS}
)
# bug, the find package does not seem to set the QT_LIBRARIES, do it manually
SET(QT_LIBRARIES ${Qt6Core_LIBRARIES} ${Qt6Widgets_LIBRARIES} ${Qt6Svg_LIBRARIES} ${Qt6PrintSupport_LIBRARIES} )
ELSE(WITH_QT6)
FIND_PACKAGE( Qt5 COMPONENTS Core Gui Widgets Svg Xml PrintSupport REQUIRED)
INCLUDE_DIRECTORIES(
${Qt5Core_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}
${Qt5Svg_INCLUDE_DIRS}
${Qt5Xml_INCLUDE_DIRS}
${Qt5PrintSupport_INCLUDE_DIRS}
)
# bug, the find package does not seem to set the QT_LIBRARIES, do it manually
SET(QT_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Svg_LIBRARIES} ${Qt5PrintSupport_LIBRARIES} )
ENDIF(WITH_QT6)
#MESSAGE("QT_INCLUDES=[${QT_INCLUDES}]")
#MESSAGE("QT_LIBRARIES=[${QT_LIBRARIES}]")
# configure the header config.h
CONFIGURE_FILE (
"${PROJECT_SOURCE_DIR}/../config.h.cmake"
@ -95,7 +75,7 @@ CONFIGURE_FILE (
INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}")
IF(WITH_QT6)
IF(QT_VERSION_MAJOR EQUAL 6)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
@ -113,13 +93,6 @@ else()
add_compile_options(-Wall -Wextra)
endif()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt6Widgets_EXECUTABLE_COMPILE_FLAGS}")
# For some reason, on Windows QT_LIBRARIES point to static(?) .a libs
# which do not provide the needed symbols. They are found on
# the .dll libraries.
ADD_DEFINITIONS(${QT_DEFINITIONS})
INCLUDE_DIRECTORIES(
${PROJECT_SOURCE_DIR}
#${qucs_SOURCE_DIR}/bitmaps ->no sources here
@ -265,7 +238,10 @@ ADD_EXECUTABLE( ${QUCS_NAME} MACOSX_BUNDLE WIN32
#
# Tell CMake which libraries we need to link our executable against.
#
TARGET_LINK_LIBRARIES( ${QUCS_NAME} components diagrams dialogs paintings extsimkernels spicecomponents qt3_compat ${QT_LIBRARIES} )
TARGET_LINK_LIBRARIES( ${QUCS_NAME}
components diagrams dialogs paintings extsimkernels spicecomponents qt3_compat
Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::Svg Qt${QT_VERSION_MAJOR}::Xml Qt${QT_VERSION_MAJOR}::PrintSupport )
#
# Prepare the installation