modernized the cmake <-> Qt handling.

This commit is contained in:
suter_a 2021-12-01 15:25:38 +01:00
parent 1aa7ae7f0d
commit 5b94d4d302
8 changed files with 214 additions and 307 deletions

View File

@ -1,9 +1,11 @@
#--- mupp for Qt > 5.0 -------------------------------------------------------- #--- mupp for Qt = 5.x --------------------------------------------------------
#--- Find includes in corresponding build directories ------------------------- #--- Find includes in corresponding build directories -------------------------
set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_INCLUDE_CURRENT_DIR ON)
#--- instruct CMake to run moc automatically when needed ---------------------- #--- instruct CMake to run moc automatically when needed ----------------------
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
#--- deal with the resources --------------------------------------------------
set(CMAKE_AUTORCC ON)
#--- define mupp version ------------------------------------------------------ #--- define mupp version ------------------------------------------------------
set(mupp_VERSION 1.0.0) set(mupp_VERSION 1.0.0)
@ -34,9 +36,6 @@ add_custom_target(
add_subdirectory(plotter) add_subdirectory(plotter)
qt5_add_resources(qrc_mupp.cpp mupp.qrc)
set_property(SOURCE qrc_mupp.cpp PROPERTY SKIP_AUTOMOC ON) # needed for cmake 3.x
set(GENERATED_HEADER_FILES set(GENERATED_HEADER_FILES
mupp_version.h mupp_version.h
) )
@ -55,10 +54,10 @@ if (APPLE)
set(RESOURCE_FILES icons/mupp.icns) set(RESOURCE_FILES icons/mupp.icns)
add_executable(mupp add_executable(mupp
MACOSX_BUNDLE ${GENERATED_HEADER_FILES} ${MUPP_SOURCE_FILES} MACOSX_BUNDLE ${GENERATED_HEADER_FILES} ${MUPP_SOURCE_FILES}
qrc_mupp.cpp ${RESOURCE_FILES} mupp.qrc ${RESOURCE_FILES}
) )
else (APPLE) else (APPLE)
add_executable(mupp ${GENERATED_HEADER_FILES} ${MUPP_SOURCE_FILES} qrc_mupp.cpp) add_executable(mupp ${GENERATED_HEADER_FILES} ${MUPP_SOURCE_FILES} mupp.qrc)
endif (APPLE) endif (APPLE)
#--- check if project source is repo ------------------------------------------ #--- check if project source is repo ------------------------------------------
@ -89,7 +88,7 @@ target_include_directories(mupp
) )
#--- use the Widgets and XML modules from Qt5 --------------------------------- #--- use the Widgets and XML modules from Qt5 ---------------------------------
target_link_libraries(mupp Qt5::Widgets Qt5::Xml) target_link_libraries(mupp PRIVATE Qt5::Widgets Qt5::Xml)
#--- if macOS make an app rather than just a command line executable ---------- #--- if macOS make an app rather than just a command line executable ----------
set_target_properties(mupp PROPERTIES set_target_properties(mupp PROPERTIES

View File

@ -1,4 +1,4 @@
#--- musrStep for Qt > 5.0 ---------------------------------------------------- #--- musrStep for Qt = 5.x ----------------------------------------------------
#--- check if project source is repo ------------------------------------------ #--- check if project source is repo ------------------------------------------
if (IS_GIT_REPO) if (IS_GIT_REPO)
@ -7,6 +7,13 @@ else (IS_GIT_REPO)
set(HAVE_GIT_REV_H "") set(HAVE_GIT_REV_H "")
endif (IS_GIT_REPO) endif (IS_GIT_REPO)
#--- instruct CMake to run moc automatically when needed ----------------------
set(CMAKE_AUTOMOC ON)
#--- deal with the resources --------------------------------------------------
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(qt_libs Qt5::Core Qt5::Widgets Qt5::Svg) set(qt_libs Qt5::Core Qt5::Widgets Qt5::Svg)
set(musrStep_src set(musrStep_src
@ -14,34 +21,17 @@ set(musrStep_src
musrStep.cpp musrStep.cpp
) )
# Instruct CMake to run moc automatically when needed
set(CMAKE_AUTOMOC ON)
#[==[
# as35 currently CMAKE_AUTOUIC -> ON doesn't work since it requires the ui-files
# in the same directory as the cpp-files.
# Create code from a list of Qt designer ui files
set(CMAKE_AUTOUIC ON)
#]==]
set(CMAKE_AUTOUIC OFF)
# add qt/rcc
qt5_add_resources(musrStep_rcc musrStep.qrc)
# remove generated files from automoc and autouic
set_property(SOURCE qrc_musrStep.cpp PROPERTY SKIP_AUTOMOC ON)
set(macosx_icon icons/musrStep.icns) set(macosx_icon icons/musrStep.icns)
if (APPLE) if (APPLE)
add_executable(musrStep MACOSX_BUNDLE add_executable(musrStep MACOSX_BUNDLE
${musrStep_src} ${musrStep_src}
${musrStep_rcc} musrStep.qrc
${macosx_icon} ${macosx_icon}
) )
else (APPLE) else (APPLE)
add_executable(musrStep add_executable(musrStep
${musrStep_src} ${musrStep_src}
${musrStep_rcc} musrStep.qrc
) )
endif (APPLE) endif (APPLE)
@ -59,7 +49,7 @@ target_compile_options(musrStep
"${HAVE_GIT_REV_H}" "${HAVE_GIT_REV_H}"
) )
target_link_libraries(musrStep ${qt_libs}) target_link_libraries(musrStep PRIVATE ${qt_libs})
#--- installation info -------------------------------------------------------- #--- installation info --------------------------------------------------------
if (APPLE) if (APPLE)

View File

@ -1,4 +1,4 @@
#--- musrWiz for Qt > 5.0 ----------------------------------------------------- #--- musrWiz for Qt = 5.x -----------------------------------------------------
#--- check if project source is repo ------------------------------------------ #--- check if project source is repo ------------------------------------------
if (IS_GIT_REPO) if (IS_GIT_REPO)
@ -7,6 +7,13 @@ else (IS_GIT_REPO)
set(HAVE_GIT_REV_H "") set(HAVE_GIT_REV_H "")
endif (IS_GIT_REPO) endif (IS_GIT_REPO)
#--- instruct CMake to run moc automatically when needed ----------------------
set(CMAKE_AUTOMOC ON)
#--- deal with the resources --------------------------------------------------
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(qt_libs Qt5::Core Qt5::Widgets Qt5::Svg Qt5::Xml) set(qt_libs Qt5::Core Qt5::Widgets Qt5::Svg Qt5::Xml)
set(musrWiz_src set(musrWiz_src
@ -18,34 +25,17 @@ set(musrWiz_src
musrWiz.cpp musrWiz.cpp
) )
# Instruct CMake to run moc automatically when needed
set(CMAKE_AUTOMOC ON)
#[==[
# as35 currently CMAKE_AUTOUIC -> ON doesn't work since it requires the ui-files
# in the same directory as the cpp-files.
# Create code from a list of Qt designer ui files
set(CMAKE_AUTOUIC ON)
#]==]
set(CMAKE_AUTOUIC OFF)
# add qt/rcc
qt5_add_resources(musrWiz_rcc musrWiz.qrc)
# remove generated files from automoc and autouic
set_property(SOURCE qrc_musrWiz.cpp PROPERTY SKIP_AUTOMOC ON)
set(macosx_icon icons/musrWiz.icns) set(macosx_icon icons/musrWiz.icns)
if (APPLE) if (APPLE)
add_executable(musrWiz MACOSX_BUNDLE add_executable(musrWiz MACOSX_BUNDLE
${musrWiz_src} ${musrWiz_src}
${musrWiz_rcc} musrWiz.qrc
${macosx_icon} ${macosx_icon}
) )
else (APPLE) else (APPLE)
add_executable(musrWiz add_executable(musrWiz
${musrWiz_src} ${musrWiz_src}
${musrWiz_rcc} musrWiz.qrc
) )
endif (APPLE) endif (APPLE)
@ -63,7 +53,7 @@ target_compile_options(musrWiz
"${HAVE_GIT_REV_H}" "${HAVE_GIT_REV_H}"
) )
target_link_libraries(musrWiz ${qt_libs}) target_link_libraries(musrWiz PRIVATE ${qt_libs})
#--- installation info -------------------------------------------------------- #--- installation info --------------------------------------------------------
if (APPLE) if (APPLE)

View File

@ -1,167 +1,141 @@
#--- musredit for Qt > 5.0 ---------------------------------------------------- #--- musredit for Qt = 5.x ----------------------------------------------------
#--- check if project source is repo ------------------------------------------ #--- check if project source is repo ------------------------------------------
if (IS_GIT_REPO) if (IS_GIT_REPO)
set(HAVE_GIT_REV_H "-DHAVE_GIT_REV_H") set(HAVE_GIT_REV_H "-DHAVE_GIT_REV_H")
else (IS_GIT_REPO) else (IS_GIT_REPO)
set(HAVE_GIT_REV_H "") set(HAVE_GIT_REV_H "")
endif (IS_GIT_REPO) endif (IS_GIT_REPO)
set(qt_libs Qt5::Core Qt5::Widgets Qt5::Network Qt5::Xml Qt5::Svg Qt5::PrintSupport) #--- instruct CMake to run moc automatically when needed ----------------------
set(CMAKE_AUTOMOC ON)
set(musredit_src #--- create code from a list of Qt designer ui files --------------------------
PTextEdit.cpp set(CMAKE_AUTOUIC ON)
PSubTextEdit.cpp #--- add forms to the uic search path -----------------------------------------
PAdmin.cpp set(CMAKE_AUTOUIC_SEARCH_PATHS ${CMAKE_CURRENT_SOURCE_DIR}/forms)
PFindDialog.cpp #--- deal with the resources --------------------------------------------------
PReplaceDialog.cpp set(CMAKE_AUTORCC ON)
PReplaceConfirmationDialog.cpp
PFitOutputHandler.cpp set(CMAKE_INCLUDE_CURRENT_DIR ON)
PDumpOutputHandler.cpp
PPrefsDialog.cpp set(qt_libs Qt5::Core Qt5::Widgets Qt5::Network Qt5::Xml Qt5::Svg Qt5::PrintSupport)
PGetMusrFTOptionsDialog.cpp
PGetTitleBlockDialog.cpp set(musredit_src
PGetParameterBlockDialog.cpp PTextEdit.cpp
PGetTheoryBlockDialog.cpp PSubTextEdit.cpp
PGetFunctionsBlockDialog.cpp PAdmin.cpp
PGetAsymmetryRunBlockDialog.cpp PFindDialog.cpp
PGetSingleHistoRunBlockDialog.cpp PReplaceDialog.cpp
PGetNonMusrRunBlockDialog.cpp PReplaceConfirmationDialog.cpp
PGetFourierBlockDialog.cpp PFitOutputHandler.cpp
PGetPlotBlockDialog.cpp PDumpOutputHandler.cpp
PMsr2DataDialog.cpp PPrefsDialog.cpp
PChangeDefaultPathsDialog.cpp PGetMusrFTOptionsDialog.cpp
PMusrEditAbout.cpp PGetTitleBlockDialog.cpp
main.cpp PGetParameterBlockDialog.cpp
) PGetTheoryBlockDialog.cpp
PGetFunctionsBlockDialog.cpp
set(musredit_ui PGetAsymmetryRunBlockDialog.cpp
forms/PFindDialog.ui PGetSingleHistoRunBlockDialog.cpp
forms/PReplaceDialog.ui PGetNonMusrRunBlockDialog.cpp
forms/PReplaceConfirmationDialog.ui PGetFourierBlockDialog.cpp
forms/PMusrEditAbout.ui PGetPlotBlockDialog.cpp
forms/PPrefsDialog.ui PMsr2DataDialog.cpp
forms/PGetMusrFTOptionsDialog.ui PChangeDefaultPathsDialog.cpp
forms/PGetTitleBlockDialog.ui PMusrEditAbout.cpp
forms/PGetParameterBlockDialog.ui main.cpp
forms/PGetTheoryBlockDialog.ui )
forms/PGetFunctionsBlockDialog.ui
forms/PGetAsymmetryRunBlockDialog.ui set(musredit_ui
forms/PGetSingleHistoRunBlockDialog.ui forms/PFindDialog.ui
forms/PGetNonMusrRunBlockDialog.ui forms/PReplaceDialog.ui
forms/PGetFourierBlockDialog.ui forms/PReplaceConfirmationDialog.ui
forms/PGetPlotBlockDialog.ui forms/PMusrEditAbout.ui
forms/PMsr2DataDialog.ui forms/PPrefsDialog.ui
forms/PChangeDefaultPathsDialog.ui forms/PGetMusrFTOptionsDialog.ui
) forms/PGetTitleBlockDialog.ui
forms/PGetParameterBlockDialog.ui
# Instruct CMake to run moc automatically when needed forms/PGetTheoryBlockDialog.ui
set(CMAKE_AUTOMOC ON) forms/PGetFunctionsBlockDialog.ui
forms/PGetAsymmetryRunBlockDialog.ui
#[==[ forms/PGetSingleHistoRunBlockDialog.ui
# as35 currently CMAKE_AUTOUIC -> ON doesn't work since it requires the ui-files forms/PGetNonMusrRunBlockDialog.ui
# in the same directory as the cpp-files. forms/PGetFourierBlockDialog.ui
# Create code from a list of Qt designer ui files forms/PGetPlotBlockDialog.ui
set(CMAKE_AUTOUIC ON) forms/PMsr2DataDialog.ui
#]==] forms/PChangeDefaultPathsDialog.ui
set(CMAKE_AUTOUIC OFF) )
# call qt/uic if (APPLE)
qt5_wrap_ui(out_ui ${musredit_ui}) if (${CMAKE_HOST_SYSTEM_VERSION} GREATER_EQUAL "20.3.0")
# add qt/rcc set(macosx_icon_name musredit-bigsur.icns)
qt5_add_resources(musredit_rcc musredit.qrc) else()
set(macosx_icon_name musredit.icns)
# remove generated files from automoc and autouic endif()
set_property(SOURCE ui_PFindDialog.h PROPERTY SKIP_AUTOMOC ON) set(macosx_icon "icons/${macosx_icon_name}")
set_property(SOURCE ui_PReplaceDialog.h PROPERTY SKIP_AUTOMOC ON) message(STATUS "macosx_icon: ${macosx_icon}")
set_property(SOURCE ui_PReplaceConfirmationDialog.h PROPERTY SKIP_AUTOMOC ON) add_executable(musredit MACOSX_BUNDLE
set_property(SOURCE ui_PMusrEditAbout.h PROPERTY SKIP_AUTOMOC ON) ${musredit_src}
set_property(SOURCE ui_PPrefsDialog.h PROPERTY SKIP_AUTOMOC ON) ${musredit_ui}
set_property(SOURCE ui_PGetMusrFTOptionsDialog.h PROPERTY SKIP_AUTOMOC ON) musredit.qrc
set_property(SOURCE ui_PGetTitleBlockDialog.h PROPERTY SKIP_AUTOMOC ON) ${macosx_icon}
set_property(SOURCE ui_PGetParameterBlockDialog.h PROPERTY SKIP_AUTOMOC ON) )
set_property(SOURCE ui_PGetTheoryBlockDialog.h PROPERTY SKIP_AUTOMOC ON) else (APPLE)
set_property(SOURCE ui_PGetFunctionsBlockDialog.h PROPERTY SKIP_AUTOMOC ON) add_executable(musredit
set_property(SOURCE ui_PGetAsymmetryRunBlockDialog.h PROPERTY SKIP_AUTOMOC ON) ${musredit_src}
set_property(SOURCE ui_PGetSingleHistoRunBlockDialog.h PROPERTY SKIP_AUTOMOC ON) ${musredit_ui}
set_property(SOURCE ui_PGetNonMusrRunBlockDialog.h PROPERTY SKIP_AUTOMOC ON) musredit.qrc
set_property(SOURCE ui_PGetFourierBlockDialog.h PROPERTY SKIP_AUTOMOC ON) )
set_property(SOURCE ui_PGetPlotBlockDialog.h PROPERTY SKIP_AUTOMOC ON) endif (APPLE)
set_property(SOURCE ui_PMsr2DataDialog.h PROPERTY SKIP_AUTOMOC ON)
set_property(SOURCE ui_PChangeDefaultPathsDialog.h PROPERTY SKIP_AUTOMOC ON) target_include_directories(musredit
set_property(SOURCE qrc_musredit.cpp PROPERTY SKIP_AUTOMOC ON) BEFORE PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
if (APPLE) $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
if (${CMAKE_HOST_SYSTEM_VERSION} GREATER_EQUAL "20.3.0") $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/..>
set(macosx_icon_name musredit-bigsur.icns) $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../..>
else() $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../../..>
set(macosx_icon_name musredit.icns) $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../include>
endif() )
set(macosx_icon "icons/${macosx_icon_name}")
message(STATUS "macosx_icon: ${macosx_icon}") target_compile_options(musredit
add_executable(musredit MACOSX_BUNDLE PRIVATE
${musredit_src} "${HAVE_GIT_REV_H}"
${out_ui} )
${musredit_rcc}
${macosx_icon} target_link_libraries(musredit PRIVATE ${qt_libs})
)
else (APPLE) #--- installation info --------------------------------------------------------
add_executable(musredit if (APPLE)
${musredit_src} set_target_properties(musredit PROPERTIES
${out_ui} MACOSX_BUNDLE TRUE
${musredit_rcc} MACOSX_BUNDLE_BUNDLE_NAME "musredit"
) MACOSX_BUNDLE_INFO_STRING "musrfit: musredit simplifies the handling of the msr-files for uSR fitting."
endif (APPLE) MACOSX_BUNDLE_ICON_FILE "${macosx_icon_name}"
MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_VERSION}"
target_include_directories(musredit MACOSX_BUNDLE_GUI_IDENTIFIER "ch.psi.lmu.musredit"
BEFORE PRIVATE MACOSX_BUNDLE_COPYRIGHT "Andreas Suter"
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}> RESOURCE ${macosx_icon}
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> )
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/..> endif (APPLE)
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../..>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../../..> if (APPLE)
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../include> install( TARGETS musredit
) BUNDLE DESTINATION /Applications
)
target_compile_options(musredit else (APPLE)
PRIVATE install( TARGETS musredit
"${HAVE_GIT_REV_H}" RUNTIME DESTINATION bin
) )
endif (APPLE)
target_link_libraries(musredit ${qt_libs})
#--- documentation installation info ------------------------------------------
#--- installation info -------------------------------------------------------- install(
if (APPLE) DIRECTORY
set_target_properties(musredit PROPERTIES ${CMAKE_SOURCE_DIR}/doc/examples
MACOSX_BUNDLE TRUE ${CMAKE_SOURCE_DIR}/doc/html
MACOSX_BUNDLE_BUNDLE_NAME "musredit" ${CMAKE_SOURCE_DIR}/doc/memos
MACOSX_BUNDLE_INFO_STRING "musrfit: musredit simplifies the handling of the msr-files for uSR fitting." DESTINATION
MACOSX_BUNDLE_ICON_FILE "${macosx_icon_name}" ${CMAKE_INSTALL_PREFIX}/share/doc/musrfit
MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_VERSION}" MESSAGE_NEVER
MACOSX_BUNDLE_GUI_IDENTIFIER "ch.psi.lmu.musredit" )
MACOSX_BUNDLE_COPYRIGHT "Andreas Suter"
RESOURCE ${macosx_icon}
)
endif (APPLE)
if (APPLE)
install( TARGETS musredit
BUNDLE DESTINATION /Applications
)
else (APPLE)
install( TARGETS musredit
RUNTIME DESTINATION bin
)
endif (APPLE)
#--- documentation installation info ------------------------------------------
install(
DIRECTORY
${CMAKE_SOURCE_DIR}/doc/examples
${CMAKE_SOURCE_DIR}/doc/html
${CMAKE_SOURCE_DIR}/doc/memos
DESTINATION
${CMAKE_INSTALL_PREFIX}/share/doc/musrfit
MESSAGE_NEVER
)

View File

@ -1,9 +1,11 @@
#--- mupp for Qt > 6.0 -------------------------------------------------------- #--- mupp for Qt = 6.x --------------------------------------------------------
#--- Find includes in corresponding build directories ------------------------- #--- Find includes in corresponding build directories -------------------------
set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_INCLUDE_CURRENT_DIR ON)
#--- instruct CMake to run moc automatically when needed ---------------------- #--- instruct CMake to run moc automatically when needed ----------------------
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
#--- deal with the resources --------------------------------------------------
set(CMAKE_AUTORCC ON)
#--- define mupp version ------------------------------------------------------ #--- define mupp version ------------------------------------------------------
set(mupp_VERSION 1.0.0) set(mupp_VERSION 1.0.0)
@ -34,9 +36,6 @@ add_custom_target(
add_subdirectory(plotter) add_subdirectory(plotter)
qt6_add_resources(qrc_mupp.cpp mupp.qrc)
set_property(SOURCE qrc_mupp.cpp PROPERTY SKIP_AUTOMOC ON) # needed for cmake 3.x
set(GENERATED_HEADER_FILES set(GENERATED_HEADER_FILES
mupp_version.h mupp_version.h
) )
@ -55,10 +54,10 @@ if (APPLE)
set(RESOURCE_FILES icons/mupp.icns) set(RESOURCE_FILES icons/mupp.icns)
add_executable(mupp add_executable(mupp
MACOSX_BUNDLE ${GENERATED_HEADER_FILES} ${MUPP_SOURCE_FILES} MACOSX_BUNDLE ${GENERATED_HEADER_FILES} ${MUPP_SOURCE_FILES}
qrc_mupp.cpp ${RESOURCE_FILES} mupp.qrc ${RESOURCE_FILES}
) )
else (APPLE) else (APPLE)
add_executable(mupp ${GENERATED_HEADER_FILES} ${MUPP_SOURCE_FILES} qrc_mupp.cpp) add_executable(mupp ${GENERATED_HEADER_FILES} ${MUPP_SOURCE_FILES} mupp.qrc)
endif (APPLE) endif (APPLE)
#--- check if project source is repo ------------------------------------------ #--- check if project source is repo ------------------------------------------
@ -89,7 +88,7 @@ target_include_directories(mupp
) )
#--- use the Widgets and XML modules from Qt5 --------------------------------- #--- use the Widgets and XML modules from Qt5 ---------------------------------
target_link_libraries(mupp Qt6::Widgets Qt6::Xml) target_link_libraries(mupp PRIVATE Qt6::Widgets Qt6::Xml)
#--- if macOS make an app rather than just a command line executable ---------- #--- if macOS make an app rather than just a command line executable ----------
set_target_properties(mupp PROPERTIES set_target_properties(mupp PROPERTIES

View File

@ -1,4 +1,4 @@
#--- musrStep for Qt > 6.0 ---------------------------------------------------- #--- musrStep for Qt = 6.x ----------------------------------------------------
#--- check if project source is repo ------------------------------------------ #--- check if project source is repo ------------------------------------------
if (IS_GIT_REPO) if (IS_GIT_REPO)
@ -7,6 +7,13 @@ else (IS_GIT_REPO)
set(HAVE_GIT_REV_H "") set(HAVE_GIT_REV_H "")
endif (IS_GIT_REPO) endif (IS_GIT_REPO)
#--- instruct CMake to run moc automatically when needed ----------------------
set(CMAKE_AUTOMOC ON)
#--- deal with the resources --------------------------------------------------
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(qt_libs Qt6::Core Qt6::Widgets Qt6::Svg) set(qt_libs Qt6::Core Qt6::Widgets Qt6::Svg)
set(musrStep_src set(musrStep_src
@ -14,34 +21,17 @@ set(musrStep_src
musrStep.cpp musrStep.cpp
) )
# Instruct CMake to run moc automatically when needed
set(CMAKE_AUTOMOC ON)
#[==[
# as35 currently CMAKE_AUTOUIC -> ON doesn't work since it requires the ui-files
# in the same directory as the cpp-files.
# Create code from a list of Qt designer ui files
set(CMAKE_AUTOUIC ON)
#]==]
set(CMAKE_AUTOUIC OFF)
# add qt/rcc
qt6_add_resources(musrStep_rcc musrStep.qrc)
# remove generated files from automoc and autouic
set_property(SOURCE qrc_musrStep.cpp PROPERTY SKIP_AUTOMOC ON)
set(macosx_icon icons/musrStep.icns) set(macosx_icon icons/musrStep.icns)
if (APPLE) if (APPLE)
add_executable(musrStep MACOSX_BUNDLE add_executable(musrStep MACOSX_BUNDLE
${musrStep_src} ${musrStep_src}
${musrStep_rcc} musrStep.qrc
${macosx_icon} ${macosx_icon}
) )
else (APPLE) else (APPLE)
add_executable(musrStep add_executable(musrStep
${musrStep_src} ${musrStep_src}
${musrStep_rcc} musrStep.qrc
) )
endif (APPLE) endif (APPLE)
@ -59,7 +49,7 @@ target_compile_options(musrStep
"${HAVE_GIT_REV_H}" "${HAVE_GIT_REV_H}"
) )
target_link_libraries(musrStep ${qt_libs}) target_link_libraries(musrStep PRIVATE ${qt_libs})
#--- installation info -------------------------------------------------------- #--- installation info --------------------------------------------------------
if (APPLE) if (APPLE)

View File

@ -1,4 +1,4 @@
#--- musrWiz for Qt > 6.0 ----------------------------------------------------- #--- musrWiz for Qt = 6.x -----------------------------------------------------
#--- check if project source is repo ------------------------------------------ #--- check if project source is repo ------------------------------------------
if (IS_GIT_REPO) if (IS_GIT_REPO)
@ -7,6 +7,13 @@ else (IS_GIT_REPO)
set(HAVE_GIT_REV_H "") set(HAVE_GIT_REV_H "")
endif (IS_GIT_REPO) endif (IS_GIT_REPO)
#--- instruct CMake to run moc automatically when needed ----------------------
set(CMAKE_AUTOMOC ON)
#--- deal with the resources --------------------------------------------------
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(qt_libs Qt6::Core Qt6::Widgets Qt6::Svg Qt6::Xml) set(qt_libs Qt6::Core Qt6::Widgets Qt6::Svg Qt6::Xml)
set(musrWiz_src set(musrWiz_src
@ -18,34 +25,17 @@ set(musrWiz_src
musrWiz.cpp musrWiz.cpp
) )
# Instruct CMake to run moc automatically when needed
set(CMAKE_AUTOMOC ON)
#[==[
# as35 currently CMAKE_AUTOUIC -> ON doesn't work since it requires the ui-files
# in the same directory as the cpp-files.
# Create code from a list of Qt designer ui files
set(CMAKE_AUTOUIC ON)
#]==]
set(CMAKE_AUTOUIC OFF)
# add qt/rcc
qt6_add_resources(musrWiz_rcc musrWiz.qrc)
# remove generated files from automoc and autouic
set_property(SOURCE qrc_musrWiz.cpp PROPERTY SKIP_AUTOMOC ON)
set(macosx_icon icons/musrWiz.icns) set(macosx_icon icons/musrWiz.icns)
if (APPLE) if (APPLE)
add_executable(musrWiz MACOSX_BUNDLE add_executable(musrWiz MACOSX_BUNDLE
${musrWiz_src} ${musrWiz_src}
${musrWiz_rcc} musrWiz.qrc
${macosx_icon} ${macosx_icon}
) )
else (APPLE) else (APPLE)
add_executable(musrWiz add_executable(musrWiz
${musrWiz_src} ${musrWiz_src}
${musrWiz_rcc} musrWiz.qrc
) )
endif (APPLE) endif (APPLE)
@ -63,7 +53,7 @@ target_compile_options(musrWiz
"${HAVE_GIT_REV_H}" "${HAVE_GIT_REV_H}"
) )
target_link_libraries(musrWiz ${qt_libs}) target_link_libraries(musrWiz PRIVATE ${qt_libs})
#--- installation info -------------------------------------------------------- #--- installation info --------------------------------------------------------
if (APPLE) if (APPLE)

View File

@ -1,4 +1,4 @@
#--- musredit for Qt > 6.0 ---------------------------------------------------- #--- musredit for Qt = 6.x ----------------------------------------------------
#--- check if project source is repo ------------------------------------------ #--- check if project source is repo ------------------------------------------
if (IS_GIT_REPO) if (IS_GIT_REPO)
@ -7,6 +7,17 @@ else (IS_GIT_REPO)
set(HAVE_GIT_REV_H "") set(HAVE_GIT_REV_H "")
endif (IS_GIT_REPO) endif (IS_GIT_REPO)
#--- instruct CMake to run moc automatically when needed ----------------------
set(CMAKE_AUTOMOC ON)
#--- create code from a list of Qt designer ui files --------------------------
set(CMAKE_AUTOUIC ON)
#--- add forms to the uic search path -----------------------------------------
set(CMAKE_AUTOUIC_SEARCH_PATHS ${CMAKE_CURRENT_SOURCE_DIR}/forms)
#--- deal with the resources --------------------------------------------------
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(qt_libs Qt6::Core Qt6::Widgets Qt6::Network Qt6::Xml Qt6::Svg Qt6::PrintSupport) set(qt_libs Qt6::Core Qt6::Widgets Qt6::Network Qt6::Xml Qt6::Svg Qt6::PrintSupport)
set(musredit_src set(musredit_src
@ -55,42 +66,6 @@ set(musredit_ui
forms/PChangeDefaultPathsDialog.ui forms/PChangeDefaultPathsDialog.ui
) )
# Instruct CMake to run moc automatically when needed
set(CMAKE_AUTOMOC ON)
#[==[
# as35 currently CMAKE_AUTOUIC -> ON doesn't work since it requires the ui-files
# in the same directory as the cpp-files.
# Create code from a list of Qt designer ui files
set(CMAKE_AUTOUIC ON)
#]==]
set(CMAKE_AUTOUIC OFF)
# call qt/uic
qt6_wrap_ui(out_ui ${musredit_ui})
# add qt/rcc
qt6_add_resources(musredit_rcc musredit.qrc)
# remove generated files from automoc and autouic
set_property(SOURCE ui_PFindDialog.h PROPERTY SKIP_AUTOMOC ON)
set_property(SOURCE ui_PReplaceDialog.h PROPERTY SKIP_AUTOMOC ON)
set_property(SOURCE ui_PReplaceConfirmationDialog.h PROPERTY SKIP_AUTOMOC ON)
set_property(SOURCE ui_PMusrEditAbout.h PROPERTY SKIP_AUTOMOC ON)
set_property(SOURCE ui_PPrefsDialog.h PROPERTY SKIP_AUTOMOC ON)
set_property(SOURCE ui_PGetMusrFTOptionsDialog.h PROPERTY SKIP_AUTOMOC ON)
set_property(SOURCE ui_PGetTitleBlockDialog.h PROPERTY SKIP_AUTOMOC ON)
set_property(SOURCE ui_PGetParameterBlockDialog.h PROPERTY SKIP_AUTOMOC ON)
set_property(SOURCE ui_PGetTheoryBlockDialog.h PROPERTY SKIP_AUTOMOC ON)
set_property(SOURCE ui_PGetFunctionsBlockDialog.h PROPERTY SKIP_AUTOMOC ON)
set_property(SOURCE ui_PGetAsymmetryRunBlockDialog.h PROPERTY SKIP_AUTOMOC ON)
set_property(SOURCE ui_PGetSingleHistoRunBlockDialog.h PROPERTY SKIP_AUTOMOC ON)
set_property(SOURCE ui_PGetNonMusrRunBlockDialog.h PROPERTY SKIP_AUTOMOC ON)
set_property(SOURCE ui_PGetFourierBlockDialog.h PROPERTY SKIP_AUTOMOC ON)
set_property(SOURCE ui_PGetPlotBlockDialog.h PROPERTY SKIP_AUTOMOC ON)
set_property(SOURCE ui_PMsr2DataDialog.h PROPERTY SKIP_AUTOMOC ON)
set_property(SOURCE ui_PChangeDefaultPathsDialog.h PROPERTY SKIP_AUTOMOC ON)
set_property(SOURCE qrc_musredit.cpp PROPERTY SKIP_AUTOMOC ON)
if (APPLE) if (APPLE)
if (${CMAKE_HOST_SYSTEM_VERSION} GREATER_EQUAL "20.3.0") if (${CMAKE_HOST_SYSTEM_VERSION} GREATER_EQUAL "20.3.0")
set(macosx_icon_name musredit-bigsur.icns) set(macosx_icon_name musredit-bigsur.icns)
@ -100,15 +75,15 @@ if (APPLE)
set(macosx_icon "icons/${macosx_icon_name}") set(macosx_icon "icons/${macosx_icon_name}")
add_executable(musredit MACOSX_BUNDLE add_executable(musredit MACOSX_BUNDLE
${musredit_src} ${musredit_src}
${out_ui} ${musredit_ui}
${musredit_rcc} musredit.qrc
${macosx_icon} ${macosx_icon}
) )
else (APPLE) else (APPLE)
add_executable(musredit add_executable(musredit
${musredit_src} ${musredit_src}
${out_ui} ${musredit_ui}
${musredit_rcc} musredit.qrc
) )
endif (APPLE) endif (APPLE)
@ -127,7 +102,7 @@ target_compile_options(musredit
"${HAVE_GIT_REV_H}" "${HAVE_GIT_REV_H}"
) )
target_link_libraries(musredit ${qt_libs}) target_link_libraries(musredit PRIVATE ${qt_libs})
#--- installation info -------------------------------------------------------- #--- installation info --------------------------------------------------------
if (APPLE) if (APPLE)