XaoS icon indicating copy to clipboard operation
XaoS copied to clipboard

cmake - QT 6 / QT 5 / gcc-10.1 quadmath macOS Big Sur 11.1

Open camots opened this issue 3 years ago • 13 comments

Hi,

I'm running XaoS on macOS Big Sur 11.1 I do not know if this already exists, but I have created a CMakeLists.txt for XaoS to be able to use the cmake build engine.

Works great for clang for QT 5.x and QT 6.0 with some minor adjustments in the code like this:

#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
filename->setMinimumWidth(metric.width(filename->text()) * 1.1);
#else
filename->setMinimumWidth(metric.horizontalAdvance(filename->text()) * 1.1);
#endif

However, by using clang on macOS, you have no quadmath support, i.e. you cannot use the USE_FLOAT128 flag. In order to enjoy much deeper zooming, you have to switch to gcc-10.1. Compiles fine with QT5.12 or QT5.15, but for QT 6.0 I had to made some more adjustments to the code because the QT 6.0 distribution for macOS is not fully compatible with gcc.

The QT 6 header file qopenglcontext_platform.h located in QtGui caused gcc-10.1 to fail. However, this file is not really needed by XaoS. It is included by "QtWidgets". The solution was to not replace QtWidgets by a series of QtXXXX includes which are required for the XaoS code. To my understanding, QtWidgets is just for convenience, but it includes far too much than actually is needed.

So for me, I have everything together and it is working great.

What I would like to see in the official distribution of XaoS: Support for cmake. Quad precision support for macOS?

I've attached my CMakeLists.txt below. It has to be placed in the src directory. For clang compilation, just comment out the two lines set(CMAKE_C_COMPILER gcc-10.1) set(CMAKE_CXX_COMPILER g++-10.1) and remove -DUSE_FLOAT128

Best regards and thank you very much for this great program

# because of CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS
cmake_minimum_required(VERSION 3.14.0)

project(XaoS)

# use gcc because Apple clang lacks quadmath support
set(CMAKE_C_COMPILER gcc-10.1)
set(CMAKE_CXX_COMPILER g++-10.1)

# add definitions
add_definitions(-DUSE_FLOAT128 -DUSE_SFFE -DSFFE_CMPLX_GSL)

# resolve symbolic links
set(CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS TRUE)

if(NOT CMAKE_BUILD_TYPE)
   set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE Release)
endif(NOT CMAKE_BUILD_TYPE)

# set the project directory
get_filename_component(PROJECT_DIR ${CMAKE_SOURCE_DIR} PATH)

# set the install prefix
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
   set(CMAKE_INSTALL_PREFIX ${PROJECT_DIR} CACHE PATH "Install prefix" FORCE )
endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)

# set-up some QT stuff
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

# turn on additional options
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# look for QT5 or QT6
find_package(QT NAMES Qt5 Qt6 COMPONENTS Widgets PrintSupport REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED)

# OS specific stuff
# on macOS the QT libraries are usually not installed into the system library folders 
IF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
   list(APPEND CMAKE_INSTALL_RPATH ${Qt${QT_VERSION_MAJOR}_DIR}/../..)
ENDIF()

# set c++ flags
set(CMAKE_CXX_STANDARD 17)

# the include and link paths
include_directories(
   engine
   include
   ui
   ui-hlp
   ${CMAKE_PREFIX_PATH}/include
)

link_directories(${CMAKE_PREFIX_PATH}/lib)

# set the Application icon, the first line is the property added to Info.plist
set(MACOSX_BUNDLE_ICON_FILE XaoS.icns)
set(XaoS_ICON ${CMAKE_CURRENT_SOURCE_DIR}/ui/XaoS.icns)
set_source_files_properties(${XaoS_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")

# Multilingual support: *.ts -> build/*.qm
FIND_PACKAGE(Qt${QT_VERSION_MAJOR}LinguistTools)
file(GLOB TRANSLATION_FILES ${PROJECT_DIR}/i18n/*.ts)

# qt_add_translation is universal for 5.15 and newer
IF (${QT_VERSION} VERSION_LESS 5.15.0)
   qt5_add_translation(QM_FILES ${TRANSLATION_FILES})
ELSE()
   qt_add_translation(QM_FILES ${TRANSLATION_FILES})
ENDIF()

# grab all sources for executable
file(GLOB CXX_FILES ui/*.cpp ui-hlp/*.cpp util/*.cpp engine/*.cpp sffe/*.cpp)
file(GLOB C_FILES sffe/*.c)
add_executable(XaoS MACOSX_BUNDLE 
   ${CXX_FILES} 
   ${C_FILES} 
   ${QM_FILES} 
   ${XaoS_ICON} 
   ui/XaoS.qrc
)

# Link
target_link_libraries(XaoS Qt${QT_VERSION_MAJOR}::Widgets quadmath)

# install bundle
install(TARGETS XaoS DESTINATION bin)

# install translations
install(FILES ${QM_FILES} DESTINATION bin/XaoS.app/Contents/Resources/translations)

# install catalogs and tutorial
install(DIRECTORY ../catalogs ../tutorial DESTINATION bin/XaoS.app/Contents/Resources)

# install example files
file(GLOB EXAMPLE_FILES ${PROJECT_DIR}/examples/*/*.xpf)
install(FILES ${EXAMPLE_FILES} DESTINATION bin/XaoS.app/Contents/Resources/examples)

camots avatar Jan 19 '21 05:01 camots

Great, thanks for this thorough contribution! I will check your ideas step by step, as soon as possible. I am a bit confused with your ideas with cmake. Is qmake planned to be obsolete in the new Qt versions? Is there any benefit if we add cmake support? Is it eventually useful to drop qmake support at the same time (for future versions)? Thanks for any clarification in advance.

kovzol avatar Jan 19 '21 16:01 kovzol

Hi,

CMake gained very much attraction in the C++ world during the last decade.

Maybe it's not wrong to say that nowadays,  CMake is the de-facto industry standard for C++ in general.

Concerning QT:

Since CMake is used as the build system for QT 6 and above, I have the impression the QT people are jumping to the CNake bandwagon as well.

See

https://www.qt.io/blog/qt-6-build-system

and

https://www.kdab.com/using-modern-cmake-with-qt/

By the way if you are Interested in the adaptions making the code ready for QT 6, I can send you my code in a tarball.

Best regards

camots avatar Jan 20 '21 07:01 camots

OK, I think it is good idea to have a cmake based build system as well. You can either fork XaoS, patch it and create a pull request, or simply create a tarball and send it to me directly. Thanks in advance!

kovzol avatar Jan 22 '21 07:01 kovzol

qmake works fine for the project and I don't really see what cmake gives us other than added complexity and another dependency that developers have to install. We finally got away from autoconf and I am not sold on changing the build system again. If there is a specific problem you can't solve in qmake, please explain. "It's an industry standard" is not a good enough reason to switch.

jblang avatar Jan 30 '21 04:01 jblang

I agree with J.B. Adding a cmake based build system increases complexity and we want to avoid that right now. ;-)

kovzol avatar Jan 30 '21 07:01 kovzol

setMinimumWidth(metric.width(filename->text()) * 1.1); Is deprecated since Qt5, I'd make a commit soon to replace it.

kanurag94 avatar Jan 30 '21 07:01 kanurag94

@jblang Maybe there is a fundamental misunderstanding here: My intention was not to replace qmake by cmake, but to offer it as an alternative. You get cmake support by just adding the CMakeLists.txt. There is no interference with qmake in any way and there is virtually ZERO effort to maintain it. It is an add-on and NOT intended to replace anything!

@kanurag94 : Actually you have to make more adjustments in order to make the code QT 6 compatible.

camots avatar Jan 31 '21 13:01 camots

Offering too many alternatives has costs too. How do new developers know which build system they should use? Will you be committed to maintaining the cmake build file indefinitely? If you lose interest, do we have to now maintain two build systems? If we don't maintain the cmake build file and test it on every platform for every release, will we have to deal with people who had problems trying to use it?

Again, if there is some specific problem with the current build system that can't be solved with qmake, I'm open to hearing about it. But if it's just because you like cmake better, that's not a good enough reason for us to take on the additional maintenance burden. I undertook a major effort last year to remove a lot of old code and the autoconf build system, both of which made XaoS harder to understand and to maintain, so I hope you can understand where I'm coming from.

jblang avatar Jan 31 '21 17:01 jblang

@jblang https://www.qt.io/blog/qt-6-build-system I guess qmake will likely to be dropped in the future. Just my two cents. Future will show. I'm fine with any build system. Thank you!

camots avatar Feb 01 '21 08:02 camots

@camots I've just read (most of) this thread: https://www.qt.io/blog/2018/10/29/deprecation-of-qbs. It is not clear for me what Qt people want to do with qmake, but I guess it will remain for a while.

kovzol avatar Feb 01 '21 09:02 kovzol

@kovzol This blog is from 2018. Let's see what happens...

camots avatar Feb 01 '21 09:02 camots

Well, I would expect it to be around at least until Qt 7. If the time between Qt 5 and Qt 6 is anything to go by, that'll be another 8 years. But the Qt company is making a lot of decisions I don't like lately, so who knows? Their commitment to open source is now in serious question and there is talk of forking Qt 5.14 because they've just closed the repository and are offering bugfixes to paying customers only. I've also read a lot of people saying that Qt 6 is really not ready for general use, although I haven't tried it myself. Part of me wonders if we made a mistake going all in on Qt. Unfortunately there aren't a lot of cross-platform alternatives with the same level of polish. GTK is great on Linux, OK on Windows, and severely lacking on Mac.

Anyway, we can put your CMakeLists.txt in a contrib folder with a README to say it's not officially supported and that qmake is the recommended build system. That way we can dust if off if we ever need it.

jblang avatar Feb 01 '21 15:02 jblang

I'm working on 2 projects using QT and it was relatively easy to get these running with QT 6.0. There was also no major problem to get XaoS running with QT 6.0 on macOS Big Sur 11.1. As far as I know, they will release QT 6.1 in April and a LTS version towards the end of the year Of course qmake will be around for a couple years more years. There is no hurry to change anything in the build system.

camots avatar Feb 01 '21 15:02 camots

@camots We are seriously thinking about changing to cmake. Could you please suggest a CMakeLists.txt for the current version? We use Qt 6, and also WebAssembly should be supported. Thanks for your effort in advance!

kovzol avatar Oct 16 '23 06:10 kovzol

Hi,

IIn order to compile Xaos with QT 6.2.2, I had to modify some source files. Please find the CMakeLists.txt and the modified sources in the attached zip-file.

If you unpack you will get the folder src. I have this folder directly under the XaoS main folder. For building:

cd XaoS mkdir build cd build ccmake ../src make -j11 install

I can compile with gcc-10.1 or gcc12.2 or gcc-13.2

However, the current sources in the Xaos git repository do no compile against QT 6.2.2 Maybe you have to adjust some sources as I did.

Best regards,

Werner

On 16 Oct 2023, at 08:53, Zoltán Kovács @.***> wrote:

@camots We are seriously thinking about changing to cmake. Could you please suggest a CMakeLists.txt for the current version? We use Qt 6, and also WebAssembly should be supported. Thanks for your effort in advance! — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

camots avatar Oct 20 '23 13:10 camots

Thanks so much! I am afraid that the zip file is missing from your message, please could you check? Thanks in advance!

kovzol avatar Oct 20 '23 15:10 kovzol

Hi,

I did not forget the attachment. However some e-mail clients reject zip files because of security concerns.

Try a UNIX tar file now! File size is 491'324 Bytes. Please let me know if you receive it.

Best regards,

Werner

On 20 Oct 2023, at 17:01, Zoltán Kovács @.***> wrote:

Thanks so much! I am afraid that the zip file is missing from your message, please could you check? Thanks in advance! — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

camots avatar Oct 20 '23 15:10 camots

Sorry, I didn't receive any attachments. :-( Please could you send me the file to @.*** or @.*** ? Thanks! :-) Zoltan

camots @.***> ezt írta (időpont: 2023. okt. 20., P, 17:41):

Hi,

I did not forget the attachment. However some e-mail clients reject zip files because of security concerns.

Try a UNIX tar file now! File size is 491'324 Bytes. Please let me know if you receive it.

Best regards,

Werner

On 20 Oct 2023, at 17:01, Zoltán Kovács @.***> wrote:

Thanks so much! I am afraid that the zip file is missing from your message, please could you check? Thanks in advance! — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/xaos-project/XaoS/issues/209#issuecomment-1772975324, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIOG6HJ5PSRR4J2NBJ6MP3YAKLRRAVCNFSM4WIHXQFKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCNZXGI4TONJTGI2A . You are receiving this because you were mentioned.Message ID: @.***>

--

Dr. Zoltán* Kovács, MSc*

Institut Ausbildung

Private Pädagogische Hochschule der Diözese Linz Private University of Education, Diocese Linz**Salesianumweg 3, 4020 Linz Mail: @.** @.**>

Web: www.ph-linz.at http://www.ph-linz.at/

kovzol avatar Oct 20 '23 15:10 kovzol

Thanks again, @camots, for your wonderful work, and sorry for the very long delay. Now I included your cmake configuration (with some minor updates) in the root folder: https://github.com/xaos-project/XaoS/blob/master/CMakeLists.txt Hopefully this new version still works on Mac.

kovzol avatar Jan 20 '24 15:01 kovzol

I close this issue and continue discussion at https://github.com/xaos-project/XaoS/issues/242.

kovzol avatar Jan 20 '24 20:01 kovzol