From cf383a34929f2416228e3d9740a884f3b4b7ce17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Kov=C3=A1cs?= Date: Sat, 20 Jan 2024 16:42:34 +0100 Subject: [PATCH] First attempt to compile XaoS via cmake (Linux) --- CMakeLists.txt | 129 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..4923a664 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,129 @@ +# This cmake configuration file is based on the work by Werner Volken + +# To create a native build of XaoS on Linux: +# +# * download a recent Qt SDK (at least Qt 6.2.4 is recommended), +# +# * install CMake (at least CMake 3.14 is suggested), +# +# * type: +# +# mkdir build; cd build \ +# CMAKE_PREFIX_PATH=/Qt/6.6.1/gcc_64/lib/cmake/Qt6LinguistTools \ +# cmake -DCMAKE_INSTALL_PREFIX= .. && \ +# make -j +# +# where +# - PATH_TO_QT_SDK is the path of your Qt SDK installation (typically $HOME/Qt), +# - INSTALLATION_PATH is the planned installation folder of the executable and the supplementary files +# (typically $HOME/install/xaos), +# - N_PROCS is the number of processors you want to use for the compilation (if you have 8 cores, +# you may want to use 6). +# +# * If the compilation succeeds, you can directly type: +# +# ./XaoS +# +# * To install XaoS in your INSTALLATION_PATH, type: +# +# make install +# +# * To run XaoS from your installation path, type: +# +# cd ; ./XaoS + + +# because of CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS +cmake_minimum_required(VERSION 3.14.0) + +project(XaoS) + +# use gcc also Mac because Apple clang lacks quadmath support +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_COMPILER g++) + +# add definitions (remove -DUSE_FLOAT128 if you have a slow machine) +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-up some QT stuff, they are required for the proper compilation of the GUI +# and automated embedding of the translations in the binary executable +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +# look for Qt6 +find_package(QT NAMES Qt6 COMPONENTS Widgets PrintSupport REQUIRED) +find_package(Qt6 COMPONENTS Widgets PrintSupport REQUIRED) + +# OS specific stuff +# on macOS the QT libraries are usually not installed into the system library folders +IF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + # 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( + ${CMAKE_CURRENT_SOURCE_DIR}/src/engine + ${CMAKE_CURRENT_SOURCE_DIR}/src/util + ${CMAKE_CURRENT_SOURCE_DIR}/src/sffe + ${CMAKE_CURRENT_SOURCE_DIR}/src/include + ${CMAKE_CURRENT_SOURCE_DIR}/src/ui + ${CMAKE_CURRENT_SOURCE_DIR}/src/ui-hlp +) + +# 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}/src/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 ${CMAKE_CURRENT_SOURCE_DIR}/i18n/*.ts) + +# qt_add_translation +qt_add_translation(QM_FILES ${TRANSLATION_FILES}) + +# grab all sources for executable +file(GLOB CXX_FILES src/ui/*.cpp src/ui-hlp/*.cpp src/util/*.cpp src/engine/*.cpp src/sffe/*.cpp) +file(GLOB C_FILES src/sffe/*.c) +add_executable(XaoS MACOSX_BUNDLE + ${CXX_FILES} + ${C_FILES} + ${QM_FILES} + ${XaoS_ICON} + src/ui/XaoS.qrc + XaoS.qrc +) + +# Link +target_link_libraries(XaoS + Qt${QT_VERSION_MAJOR}::Widgets + Qt${QT_VERSION_MAJOR}::PrintSupport + quadmath +) + +# install bundle +install(TARGETS XaoS DESTINATION bin) + +# install translations +install(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)