Warning, /education/kstars/CMakeLists.txt is written in an unsupported language. File is not indexed.
0001 cmake_minimum_required (VERSION 3.16.0 FATAL_ERROR) 0002 0003 PROJECT(kstars CXX C) 0004 set (KStars_VERSION_MAJOR 3) 0005 set (KStars_VERSION_MINOR 7) 0006 set (KStars_VERSION_REVISION 0) 0007 set (KSTARS_BUILD_RELEASE "Beta") 0008 set (CMAKE_CXX_STANDARD 17) 0009 0010 set(QT_MIN_VERSION 5.12.7) 0011 set(KF5_MIN_VERSION 5.68.0) 0012 0013 # Build KStars Lite with -DBUILD_KSTARS_LITE=ON 0014 option(BUILD_KSTARS_LITE "Build KStars Lite" OFF) 0015 0016 # Build KStars documentation 0017 option(BUILD_DOC "Build Documentation" ON) 0018 0019 # Build the Python bindings for the SkyMesh indexation 0020 option(BUILD_PYKSTARS "Build SkyMesh Python Bindings" OFF) 0021 0022 # KStars Timestap build 0023 string(TIMESTAMP KSTARS_BUILD_TS UTC) 0024 0025 # add EVERYTHING to the compile commands 0026 if(CMAKE_EXPORT_COMPILE_COMMANDS) 0027 set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES 0028 ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}) 0029 endif() 0030 0031 # Find includes in corresponding build directories 0032 set(CMAKE_INCLUDE_CURRENT_DIR ON) 0033 # Instruct CMake to run moc automatically when needed. 0034 set(CMAKE_AUTOMOC ON) 0035 0036 # Ccache support 0037 IF (ANDROID OR UNIX OR APPLE) 0038 FIND_PROGRAM(CCACHE_FOUND ccache) 0039 SET(CCACHE_SUPPORT OFF CACHE BOOL "Enable ccache support") 0040 IF ((CCACHE_FOUND OR ANDROID) AND CCACHE_SUPPORT MATCHES ON) 0041 SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) 0042 SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) 0043 ENDIF () 0044 ENDIF () 0045 0046 if(CMAKE_SYSTEM_NAME STREQUAL Android) 0047 add_definitions(-DANDROID -D__STDC_LIMIT_MACROS) 0048 set(ANDROID TRUE) 0049 endif() 0050 0051 if("${CMAKE_TOOLCHAIN_FILE}" MATCHES "android.toolchain.cmake$") 0052 include(${CMAKE_BINARY_DIR}/kf5/kde/install/share/ECM/cmake/ECMConfig.cmake) 0053 endif() 0054 0055 find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE) 0056 set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) 0057 set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ${CMAKE_MODULE_PATH}) 0058 0059 if(BUILD_KSTARS_LITE) 0060 if("${CMAKE_TOOLCHAIN_FILE}" MATCHES "android.toolchain.cmake$") 0061 set(QT_ANDROID $ENV{QT_ANDROID}) 0062 set(Qt5Core_DIR "${QT_ANDROID}/lib/cmake/Qt5Core") 0063 set(Qt5Gui_DIR "${QT_ANDROID}/lib/cmake/Qt5Gui") 0064 set(Qt5Network_DIR "${QT_ANDROID}/lib/cmake/Qt5Network") 0065 set(Qt5Positioning_DIR "${QT_ANDROID}/lib/cmake/Qt5Positioning") 0066 set(Qt5Qml_DIR "${QT_ANDROID}/lib/cmake/Qt5Qml") 0067 set(Qt5Quick_DIR "${QT_ANDROID}/lib/cmake/Qt5Quick") 0068 set(Qt5Widgets_DIR "${QT_ANDROID}/lib/cmake/Qt5Widgets") 0069 include(${QT_ANDROID}/lib/cmake/Qt5/Qt5Config.cmake) 0070 include(${QT_ANDROID}/lib/cmake/Qt5Core/Qt5CoreConfig.cmake) 0071 include(${QT_ANDROID}/lib/cmake/Qt5Gui/Qt5GuiConfig.cmake) 0072 include(${QT_ANDROID}/lib/cmake/Qt5Qml/Qt5QmlConfig.cmake) 0073 include(${QT_ANDROID}/lib/cmake/Qt5Quick/Qt5QuickConfig.cmake) 0074 include(${QT_ANDROID}/lib/cmake/Qt5QuickControls2/Qt5QuickControls2Config.cmake) 0075 include(${QT_ANDROID}/lib/cmake/Qt5Xml/Qt5XmlConfig.cmake) 0076 include(${QT_ANDROID}/lib/cmake/Qt5Svg/Qt5SvgConfig.cmake) 0077 include(${QT_ANDROID}/lib/cmake/Qt5Sql/Qt5SqlConfig.cmake) 0078 include(${QT_ANDROID}/lib/cmake/Qt5Network/Qt5NetworkConfig.cmake) 0079 include(${QT_ANDROID}/lib/cmake/Qt5Positioning/Qt5PositioningConfig.cmake) 0080 include(${QT_ANDROID}/lib/cmake/Qt5PositioningQuick/Qt5PositioningQuickConfig.cmake) 0081 include(${QT_ANDROID}/lib/cmake/Qt5Concurrent/Qt5ConcurrentConfig.cmake) 0082 include(${QT_ANDROID}/lib/cmake/Qt5AndroidExtras/Qt5AndroidExtrasConfig.cmake) 0083 else() 0084 if(ANDROID) 0085 list(APPEND QT_EXTRA_COMPONENTS AndroidExtras) 0086 else() 0087 list(APPEND QT_EXTRA_COMPONENTS PrintSupport) 0088 endif() 0089 find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Gui Qml Quick QuickControls2 Xml Svg Sql Network Positioning PositioningQuick Concurrent WebSockets ${QT_EXTRA_COMPONENTS}) 0090 endif() 0091 else() 0092 #find_package(Qt5 5.4 REQUIRED COMPONENTS Gui Qml Quick Xml Sql Svg Network PrintSupport Positioning Concurrent) 0093 find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Gui Qml Quick Xml Sql Svg Network PrintSupport Concurrent WebSockets) 0094 endif() 0095 include(ExternalProject) 0096 include(ECMInstallIcons) 0097 include(ECMAddAppIcon) 0098 include(KDEInstallDirs) 0099 include(MacroBoolTo01) 0100 include(ECMQtDeclareLoggingCategory) 0101 include(KDECompilerSettings NO_POLICY_SCOPE) 0102 include(KDECMakeSettings) 0103 include(FeatureSummary) 0104 0105 # Load the frameworks we need 0106 if(BUILD_KSTARS_LITE) 0107 if("${CMAKE_TOOLCHAIN_FILE}" MATCHES "android.toolchain.cmake$") 0108 set(KF5_VERSION 5.28.0) 0109 set(KF5_HOST_TOOLING /usr/lib/x86_64-linux-gnu/cmake/) 0110 include(${CMAKE_BINARY_DIR}/kf5/kde/install/lib/cmake/KF5Config/KF5ConfigConfig.cmake) 0111 include(${CMAKE_BINARY_DIR}/kf5/kde/install/lib/cmake/KF5I18n/KF5I18nConfig.cmake) 0112 include(${CMAKE_BINARY_DIR}/kf5/kde/install/lib/cmake/KF5Plotting/KF5PlottingConfig.cmake) 0113 else() 0114 # Find Optional package NotifyConfig for desktop notifications 0115 find_package(KF5 ${KF5_MIN_VERSION} COMPONENTS NotifyConfig) 0116 MACRO_BOOL_TO_01(KF5NotifyConfig_FOUND HAVE_NOTIFYCONFIG) 0117 0118 find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Auth Config Crash WidgetsAddons NewStuff I18n KIO XmlGui Plotting Notifications) 0119 endif() 0120 else(BUILD_KSTARS_LITE) 0121 # Find Optional package NotifyConfig for desktop notifications 0122 find_package(KF5 ${KF5_MIN_VERSION} COMPONENTS NotifyConfig) 0123 MACRO_BOOL_TO_01(KF5NotifyConfig_FOUND HAVE_NOTIFYCONFIG) 0124 0125 find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS 0126 Config 0127 Crash 0128 DocTools 0129 WidgetsAddons 0130 NewStuff 0131 I18n 0132 KIO 0133 XmlGui 0134 Plotting 0135 Notifications 0136 ) 0137 endif(BUILD_KSTARS_LITE) 0138 0139 ## Eigen3 Library 0140 find_package(Eigen3 REQUIRED CONFIG) 0141 0142 ## CFITSIO Library 0143 if(ANDROID) 0144 if("${CMAKE_TOOLCHAIN_FILE}" MATCHES "android.toolchain.cmake$") 0145 set(extra_cmake "-DM_LIB=-lm") 0146 endif() 0147 0148 find_program(DOS2UNIX dos2unix) 0149 if (NOT DOS2UNIX) 0150 message(FATAL_ERROR "Could not find dos2unix") 0151 endif() 0152 0153 externalproject_add(cfitsio SOURCE_DIR "${CMAKE_BINARY_DIR}/packaging/android/3rdparty/cfitsio" 0154 URL https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio3370.tar.gz 0155 PATCH_COMMAND bash -c "cd ${CMAKE_BINARY_DIR}/packaging/android/3rdparty/cfitsio && ${DOS2UNIX} ${CMAKE_BINARY_DIR}/packaging/android/3rdparty/cfitsio/CMakeLists.txt && patch -p1 < ${CMAKE_SOURCE_DIR}/packaging/android/3rdparty/cfitsio.patch" 0156 CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${extra_cmake} 0157 BUILD_COMMAND make cfitsio 0158 BUILD_IN_SOURCE 1 0159 INSTALL_COMMAND "") 0160 0161 set(CFITSIO_FOUND TRUE) 0162 set(CFITSIO_INCLUDE_DIR PUBLIC ${CMAKE_BINARY_DIR}/packaging/android/3rdparty/cfitsio) 0163 set(CFITSIO_LIBRARIES ${CMAKE_BINARY_DIR}/packaging/android/3rdparty/cfitsio/libcfitsio.a) 0164 else() 0165 if(BUILD_KSTARS_LITE) 0166 find_package(CFitsio REQUIRED) 0167 else() 0168 find_package(CFitsio) 0169 endif() 0170 endif() 0171 MACRO_BOOL_TO_01(CFITSIO_FOUND HAVE_CFITSIO) 0172 set_package_properties(CFitsio PROPERTIES DESCRIPTION "FITS IO Library" URL "https://heasarc.gsfc.nasa.gov/fitsio/fitsio.html" TYPE OPTIONAL PURPOSE "Support for the FITS (Flexible Image Transport System) data format in KStars.") 0173 0174 ## INDI Library 0175 if (ANDROID) 0176 set(QT_ANDROID $ENV{QT_ANDROID}) 0177 if("${CMAKE_TOOLCHAIN_FILE}" MATCHES "android.toolchain.cmake$") 0178 set(extra_cmake -DCMAKE_AR=${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar) 0179 endif() 0180 externalproject_add(indi SOURCE_DIR "${CMAKE_BINARY_DIR}/packaging/android/indi" 0181 URL https://github.com/indilib/indi/archive/master.zip 0182 CONFIGURE_COMMAND cmake . -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \\ 0183 -DINDI_BUILD_POSIX_CLIENT=OFF -DINDI_BUILD_SERVER=OFF -DINDI_BUILD_DRIVERS=OFF -DINDI_BUILD_UNITTESTS=OFF \\ 0184 -DINDI_BUILD_DRIVERS=OFF -DINDI_BUILD_QT5_CLIENT=ON -DINDI_CALCULATE_MINMAX=ON \\ 0185 -DCFITSIO_DIR=${CMAKE_BINARY_DIR}/packaging/android/3rdparty/cfitsio -DQT_ANDROID=${QT_ANDROID} -DCMAKE_PREFIX_PATH=${QT_ANDROID} ${extra_cmake} 0186 BUILD_COMMAND make 0187 BUILD_IN_SOURCE 1 0188 INSTALL_COMMAND "") 0189 0190 set(INDI_FOUND TRUE) 0191 set(INDI_INCLUDE_DIR ${CMAKE_BINARY_DIR}/packaging/android/indi/libs/indibase ${CMAKE_BINARY_DIR}/packaging/android/indi ${CMAKE_BINARY_DIR}/packaging/android/indi/libs) 0192 set(INDI_CLIENT_ANDROID_LIBRARIES ${CMAKE_BINARY_DIR}/packaging/android/indi/libindiclientqt.a) 0193 else () 0194 find_package(INDI 2.0.0) 0195 endif () 0196 MACRO_BOOL_TO_01(INDI_FOUND HAVE_INDI) 0197 set_package_properties(INDI PROPERTIES DESCRIPTION "Astronomical instrumentation control" URL "https://www.indilib.org" TYPE OPTIONAL PURPOSE "Support for controlling astronomical devices on Linux with KStars.") 0198 0199 if (INDI_FOUND AND NOT ANDROID) 0200 find_package(StellarSolver REQUIRED 2.2) 0201 endif(INDI_FOUND AND NOT ANDROID) 0202 MACRO_BOOL_TO_01(StellarSolver_FOUND HAVE_STELLARSOLVER) 0203 0204 find_package(Nova) 0205 MACRO_BOOL_TO_01(NOVA_FOUND HAVE_LIBNOVA) 0206 if (NOVA_FOUND) 0207 include_directories(${NOVA_INCLUDE_DIR}) 0208 endif() 0209 0210 if(BUILD_TESTING) 0211 # Find liberfa, which we check our computation against 0212 find_package(ERFA) 0213 MACRO_BOOL_TO_01(ERFA_FOUND HAVE_LIBERFA) 0214 set_package_properties(ERFA PROPERTIES TYPE OPTIONAL PURPOSE "BSD-compatible version of SOFA, used to test core computations of KStars (only needed by tests)") 0215 endif () 0216 0217 ## Libraw 0218 if(BUILD_KSTARS_LITE AND ANDROID) 0219 # OpenMP needed for LibRaw 0220 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp -DLIBRAW_USE_OPENMP") 0221 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp -DLIBRAW_USE_OPENMP") 0222 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgomp") 0223 0224 externalproject_add(raw SOURCE_DIR "${CMAKE_BINARY_DIR}/packaging/android/3rdparty/libraw" 0225 URL https://www.libraw.org/data/LibRaw-0.17.2.tar.gz 0226 PATCH_COMMAND bash -c "cd ${CMAKE_BINARY_DIR}/packaging/android/3rdparty/libraw && wget -qO- https://github.com/LibRaw/LibRaw-cmake/archive/master.zip | jar xvf /dev/stdin && rm -rf cmake && mv -f LibRaw-cmake-master/CMakeLists.txt LibRaw-cmake-master/cmake . && patch -p1 < ${CMAKE_SOURCE_DIR}/packaging/android/3rdparty/libraw.patch" 0227 CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DENABLE_OPENMP=OFF -DENABLE_LCMS=OFF 0228 BUILD_COMMAND make raw 0229 BUILD_IN_SOURCE 1 0230 INSTALL_COMMAND "") 0231 include_directories(${CMAKE_BINARY_DIR}/packaging/android/3rdparty/libraw) 0232 set(LIBRAW_LIBRARIES ${CMAKE_BINARY_DIR}/packaging/android/3rdparty/libraw/libraw.a) 0233 set(LibRaw_FOUND true) 0234 else() 0235 find_package(LibRaw) 0236 endif() 0237 MACRO_BOOL_TO_01(LibRaw_FOUND HAVE_LIBRAW) 0238 set_package_properties(LibRaw PROPERTIES DESCRIPTION "Library for reading RAW files" URL "https://www.libraw.org/" TYPE OPTIONAL PURPOSE "Support for reading and displaying RAW files in KStars.") 0239 0240 ## WCS Library 0241 find_package(WCSLIB) 0242 MACRO_BOOL_TO_01(WCSLIB_FOUND HAVE_WCSLIB) 0243 set_package_properties(WCSLIB PROPERTIES DESCRIPTION "World Coordinate System library" URL "https://www.atnf.csiro.au/people/mcalabre/WCS" TYPE OPTIONAL PURPOSE "WCS enables KStars to read and process world coordinate systems in FITS header.") 0244 0245 ## XPlanet 0246 find_package(Xplanet) 0247 set_package_properties(Xplanet PROPERTIES DESCRIPTION "Renders an image of all the major planets and most satellites" URL "http://xplanet.sourceforge.net" TYPE RUNTIME PURPOSE "Gives KStars support for xplanet.") 0248 0249 # Qt5 Data Visualization 0250 find_package(Qt5DataVisualization) 0251 MACRO_BOOL_TO_01(Qt5DataVisualization_FOUND HAVE_DATAVISUALIZATION) 0252 0253 # LibXISF 0254 find_package(LibXISF) 0255 set_package_properties(LibXISF PROPERTIES DESCRIPTION "Library for loading and saving XISF images" URL "https://nouspiro.space" TYPE OPTIONAL) 0256 MACRO_BOOL_TO_01(LibXISF_FOUND HAVE_XISF) 0257 0258 ## Astrometry.net 0259 #find_package(AstrometryNet) 0260 #set_package_properties(AstrometryNet PROPERTIES DESCRIPTION "Astrometrics Library" URL "http://www.astrometry.net" TYPE RUNTIME PURPOSE "Support for plate solving in KStars.") 0261 0262 ## Key Chain 0263 find_package(Qt5Keychain) 0264 MACRO_BOOL_TO_01(Qt5Keychain_FOUND HAVE_KEYCHAIN) 0265 0266 ## OpenGL 0267 find_package(OpenGL) 0268 set_package_properties(OpenGL PROPERTIES DESCRIPTION "Open Graphics Library" URL "https://www.opengl.org/" TYPE OPTIONAL PURPOSE "Support for hardware rendering in KStars.") 0269 0270 add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS) 0271 add_definitions(-DQT_NO_URL_CAST_FROM_STRING) 0272 if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT WIN32) 0273 add_definitions(-DQT_STRICT_ITERATORS) 0274 endif() 0275 add_definitions(-DQT_NO_CAST_TO_ASCII) 0276 0277 # Needed for htmesh, and libraw 0278 kde_enable_exceptions() 0279 0280 if (UNIX) 0281 0282 # TEMPORARY: To disable QCustomPlot warning until 2.0.0 is released which fixes these warnings 0283 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-non-virtual-dtor") 0284 0285 # Optimize binary size by dropping unneeded symbols at linking stage 0286 if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") 0287 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdata-sections -ffunction-sections") 0288 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections") 0289 endif() 0290 endif(UNIX) 0291 0292 # Optimize binary size by dropping unneeded symbols at linking stage 0293 if (ANDROID) 0294 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdata-sections -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden") 0295 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections") 0296 endif () 0297 0298 # Add security (hardening flags) 0299 IF (UNIX OR APPLE OR ANDROID) 0300 SET(SEC_COMP_FLAGS "-D_FORTIFY_SOURCE=2 -fstack-protector-all -Wcast-align -fPIE") 0301 IF (NOT ANDROID AND NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT APPLE) 0302 SET(SEC_COMP_FLAGS "${SEC_COMP_FLAGS} -Wa,--noexecstack") 0303 ENDIF () 0304 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SEC_COMP_FLAGS}") 0305 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SEC_COMP_FLAGS}") 0306 SET(SEC_LINK_FLAGS "") 0307 0308 include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/CheckNodump.cmake") 0309 check_nodump(NODUMP_FLAGS) 0310 0311 IF (NOT APPLE) 0312 SET(SEC_LINK_FLAGS "${SEC_LINK_FLAGS} ${NODUMP_FLAGS} -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now") 0313 ENDIF () 0314 IF (NOT ANDROID AND NOT APPLE) 0315 SET(SEC_LINK_FLAGS "${SEC_LINK_FLAGS} -pie") 0316 ENDIF () 0317 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SEC_LINK_FLAGS}") 0318 SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${SEC_LINK_FLAGS}") 0319 ENDIF () 0320 0321 # Clang Format support 0322 IF (UNIX OR APPLE) 0323 SET(FORMAT_CODE OFF CACHE BOOL "Enable Clang Format") 0324 IF (FORMAT_CODE MATCHES ON) 0325 FILE(GLOB_RECURSE ALL_SOURCE_FILES *.c *.cpp *.h) 0326 0327 FOREACH(SOURCE_FILE ${ALL_SOURCE_FILES}) 0328 STRING(FIND ${SOURCE_FILE} ${CMAKE_SOURCE_DIR} DIR_FOUND) 0329 IF (NOT ${DIR_FOUND} EQUAL 0) 0330 LIST(REMOVE_ITEM ALL_SOURCE_FILES ${SOURCE_FILE}) 0331 ENDIF () 0332 ENDFOREACH () 0333 0334 FIND_PROGRAM(CLANGFORMAT_EXE NAMES clang-format-5.0) 0335 IF (CLANGFORMAT_EXE) 0336 ADD_CUSTOM_TARGET(clang-format COMMAND ${CLANGFORMAT_EXE} -style=file -i ${ALL_SOURCE_FILES}) 0337 ENDIF () 0338 ENDIF () 0339 ENDIF () 0340 0341 SET(FIX_WARNINGS OFF CACHE BOOL "Enable strict compilation mode to turn compiler warnings to errors") 0342 # Warning, debug and linker flags 0343 IF (UNIX OR APPLE) 0344 SET(COMP_FLAGS "") 0345 SET(LINKER_FLAGS "") 0346 # Verbose warnings and turns all to errors 0347 SET(COMP_FLAGS "${COMP_FLAGS} -Wall -Wextra") 0348 IF (FIX_WARNINGS) 0349 SET(COMP_FLAGS "${COMP_FLAGS} -Werror") 0350 ENDIF () 0351 # Omit problematic warnings 0352 IF (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 0353 SET(COMP_FLAGS "${COMP_FLAGS} -Wno-unused-but-set-variable") 0354 SET(COMP_FLAGS "${COMP_FLAGS} -Wno-stringop-truncation") 0355 ENDIF () 0356 IF (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 6.9.9) 0357 SET(COMP_FLAGS "${COMP_FLAGS} -Wno-format-truncation") 0358 ENDIF () 0359 IF (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") 0360 SET(COMP_FLAGS "${COMP_FLAGS} -Wno-nonnull -Wno-deprecated-declarations") 0361 ENDIF () 0362 IF (BUILD_KSTARS_LITE AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") 0363 SET(COMP_FLAGS "${COMP_FLAGS} -Wno-overloaded-virtual") 0364 ENDIF () 0365 0366 SET(COMP_FLAGS "${COMP_FLAGS} -g") 0367 0368 # Note: The following flags are problematic on older systems with gcc 4.8 0369 IF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9.9)) 0370 IF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") 0371 SET(COMP_FLAGS "${COMP_FLAGS} -Wno-unused-command-line-argument") 0372 ENDIF () 0373 FIND_PROGRAM(LDGOLD_FOUND ld.gold) 0374 SET(LDGOLD_SUPPORT OFF CACHE BOOL "Enable ld.gold support") 0375 # Optional ld.gold is 2x faster than normal ld 0376 IF (LDGOLD_FOUND AND LDGOLD_SUPPORT MATCHES ON AND NOT APPLE AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES arm) 0377 SET(LINKER_FLAGS "${LINKER_FLAGS} -fuse-ld=gold") 0378 # We have Gsl library what is a special case for linking: 0379 # The gsl library must be linked with cblas. There are two alternatives for this: libcblas or libgslcblas. 0380 # For example, CMake gets the GSL_LIBRARIES linking flags from the pkgconfig (gsl.pc) file on Ubuntu. 0381 # This file defines -lgsl -lglscblas for linking flags and if KStars is compiled with Clang, the linker 0382 # finds out magically that KStars must be linked against glscblas library, but gslcblas is omitted in linking 0383 # stage if KStars is built with gcc. The linker must be instructed explicitly to link against all libraries 0384 # passed on command line by -Wl,--no-as-needed. 0385 SET(LINKER_FLAGS "${LINKER_FLAGS} -Wl,--no-as-needed") 0386 # Use Identical Code Folding 0387 SET(COMP_FLAGS "${COMP_FLAGS} -ffunction-sections") 0388 SET(LINKER_FLAGS "${LINKER_FLAGS} -Wl,--icf=safe") 0389 # Compress the debug sections 0390 # Note: Before valgrind 3.12.0, patch should be applied for valgrind (https://bugs.kde.org/show_bug.cgi?id=303877) 0391 IF (NOT APPLE AND NOT ANDROID AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES arm AND NOT CMAKE_CXX_CLANG_TIDY) 0392 SET(COMP_FLAGS "${COMP_FLAGS} -Wa,--compress-debug-sections") 0393 SET(LINKER_FLAGS "${LINKER_FLAGS} -Wl,--compress-debug-sections=zlib") 0394 ENDIF () 0395 ENDIF () 0396 ENDIF () 0397 0398 # Apply the flags 0399 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMP_FLAGS}") 0400 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMP_FLAGS}") 0401 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LINKER_FLAGS}") 0402 SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${LINKER_FLAGS}") 0403 ENDIF () 0404 0405 # Sanitizer support 0406 SET(SANITIZERS OFF CACHE BOOL "Sanitizer support for gcc and Clang") 0407 IF (SANITIZERS AND 0408 ((UNIX AND (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR CMAKE_COMPILER_IS_GNUCXX) OR 0409 (APPLE AND (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR CMAKE_COMPILER_IS_GNUCXX)))) 0410 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address,undefined -fno-omit-frame-pointer") 0411 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address,undefined -fno-omit-frame-pointer") 0412 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address,undefined -fno-omit-frame-pointer") 0413 SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address,undefined -fno-omit-frame-pointer") 0414 ENDIF () 0415 0416 # Unity build support 0417 SET(UNITY_BUILD OFF CACHE BOOL "Enable Unity Build") 0418 INCLUDE(UnityBuild) 0419 0420 configure_file( 0421 ${CMAKE_CURRENT_SOURCE_DIR}/config-kstars.h.cmake 0422 ${CMAKE_CURRENT_BINARY_DIR}/config-kstars.h 0423 ) 0424 0425 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/kstars/version.h.cmake 0426 ${CMAKE_CURRENT_BINARY_DIR}/kstars/version.h ) 0427 0428 # let our config.h be found first in any case 0429 include_directories (BEFORE ${CMAKE_CURRENT_BINARY_DIR}) 0430 0431 if (BUILD_DOC) 0432 add_subdirectory(doc) 0433 endif() 0434 0435 # add some utility headers 0436 include_directories(utils) 0437 0438 add_subdirectory(kstars) 0439 add_subdirectory(datahandlers) 0440 0441 IF (NOT ANDROID) 0442 IF (BUILD_TESTING) 0443 enable_testing(true) 0444 add_subdirectory(Tests) 0445 ENDIF() 0446 # Make it possible to use the po files fetched by the fetch-translations step 0447 ki18n_install(po) 0448 find_package(KF5DocTools CONFIG) 0449 if(KF5DocTools_FOUND) 0450 kdoctools_install(po) 0451 endif() 0452 0453 ENDIF () 0454 0455 if(NOT APPLE) #This is not used on MacOS 0456 install(FILES org.kde.kstars.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR}) 0457 endif(NOT APPLE) 0458 0459 feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) 0460 0461 # Only build k5auth for Linux 0462 # JM 2018-09-26: KAuth is disabled due to reliability issues. 0463 #if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") 0464 # # This helper file is generated to download astrometry.net index files. 0465 # add_executable(kauth_kstars_helper kstars/auxiliary/downloadhelper.cpp ${helper_mocs}) 0466 # target_link_libraries(kauth_kstars_helper Qt5::Core) 0467 # target_link_libraries(kauth_kstars_helper Qt5::Widgets) 0468 # target_link_libraries(kauth_kstars_helper KF5::Auth) 0469 # install(TARGETS kauth_kstars_helper DESTINATION ${KAUTH_HELPER_INSTALL_DIR}) 0470 # kauth_install_helper_files(kauth_kstars_helper org.kde.kf5auth.kstars root) 0471 # kauth_install_actions(org.kde.kf5auth.kstars org.kde.kf5auth.kstars.actions) 0472 #ENDIF () 0473 0474 # Final package generation 0475 if ("${CMAKE_TOOLCHAIN_FILE}" MATCHES "android.toolchain.cmake$") 0476 set(EXPORT_DIR "${CMAKE_BINARY_DIR}/packaging/android/kstars_build_apk/") 0477 set(ANDROID_APK_DIR "${CMAKE_SOURCE_DIR}/packaging/android/apk/") 0478 set(EXECUTABLE_DESTINATION_PATH "${EXPORT_DIR}/libs/armeabi-v7a/libkstars.so") 0479 set(ANDROID_NDK $ENV{CMAKE_ANDROID_NDK}) 0480 set(ANDROID_SDK_ROOT $ENV{ANDROID_SDK_ROOT}) 0481 set(ANDROID_API_LEVEL $ENV{ANDROID_API_LEVEL}) 0482 set(ANDROID_TOOLCHAIN arm-linux-androideabi) 0483 set(ANDROID_GCC_VERSION 4.9) 0484 set(ANDROID_ABI armeabi-v7a) 0485 set(_HOST "${CMAKE_HOST_SYSTEM_NAME}-${CMAKE_HOST_SYSTEM_PROCESSOR}") 0486 string(TOLOWER "${_HOST}" _HOST) 0487 set(ANDROID_SDK_BUILD_TOOLS_REVISION 21.1.1) 0488 set(ANDROID_KEYSTORE $ENV{ANDROID_KEYSTORE}) 0489 set(ANDROID_KEYSTORE_ALIAS $ENV{ANDROID_KEYSTORE_ALIAS}) 0490 configure_file("${CMAKE_SOURCE_DIR}/packaging/android/deployment-file.json.in" "${CMAKE_BINARY_DIR}/packaging/android/kstars-deployment.json.in") 0491 0492 0493 add_custom_target(create-apk-debug-kstars 0494 COMMAND cmake -E echo "Generating $<TARGET_NAME:kstars> with $<TARGET_FILE_DIR:Qt5::qmake>/androiddeployqt" 0495 COMMAND cmake -E remove_directory "${EXPORT_DIR}" 0496 COMMAND cmake -E copy_directory "${CMAKE_SOURCE_DIR}/packaging/android/apk" "${EXPORT_DIR}" 0497 COMMAND cmake -E copy "$<TARGET_FILE:kstars>" "${EXECUTABLE_DESTINATION_PATH}" 0498 COMMAND cmake -DINPUT_FILE="${CMAKE_BINARY_DIR}/packaging/android/kstars-deployment.json.in" -DOUTPUT_FILE="${CMAKE_BINARY_DIR}/packaging/android/kstars-deployment.json" "-DTARGET_DIR=${CMAKE_BINARY_DIR}/kstars" "-DTARGET_NAME=kstars" "-DEXPORT_DIR=${CMAKE_INSTALL_PREFIX}" -P ${CMAKE_SOURCE_DIR}/packaging/android/specifydependencies.cmake 0499 COMMAND $<TARGET_FILE_DIR:Qt5::qmake>/androiddeployqt --input "${CMAKE_BINARY_DIR}/packaging/android/kstars-deployment.json" --output "${EXPORT_DIR}" --android-platform android-${ANDROID_API_LEVEL} --debug --deployment bundled "\\$(ARGS)" 0500 ) 0501 add_custom_target(create-apk-release-kstars 0502 COMMAND cmake -E echo "Generating $<TARGET_NAME:kstars> with $<TARGET_FILE_DIR:Qt5::qmake>/androiddeployqt" 0503 COMMAND cmake -E remove_directory "${EXPORT_DIR}" 0504 COMMAND cmake -E copy_directory "${CMAKE_SOURCE_DIR}/packaging/android/apk" "${EXPORT_DIR}" 0505 COMMAND cmake -E copy "$<TARGET_FILE:kstars>" "${EXECUTABLE_DESTINATION_PATH}" 0506 COMMAND cmake -DINPUT_FILE="${CMAKE_BINARY_DIR}/packaging/android/kstars-deployment.json.in" -DOUTPUT_FILE="${CMAKE_BINARY_DIR}/packaging/android/kstars-deployment.json" "-DTARGET_DIR=${CMAKE_BINARY_DIR}/kstars" "-DTARGET_NAME=kstars" "-DEXPORT_DIR=${CMAKE_INSTALL_PREFIX}" -P ${CMAKE_SOURCE_DIR}/packaging/android/specifydependencies.cmake 0507 COMMAND $<TARGET_FILE_DIR:Qt5::qmake>/androiddeployqt --input "${CMAKE_BINARY_DIR}/packaging/android/kstars-deployment.json" --output "${EXPORT_DIR}" --android-platform android-${ANDROID_API_LEVEL} --release --deployment bundled "\\$(ARGS)" 0508 ) 0509 add_custom_target(install-apk-debug-kstars 0510 COMMAND adb install -r ${CMAKE_BINARY_DIR}/packaging/android/kstars_build_apk//bin/QtApp-debug.apk 0511 ) 0512 0513 if (ANDROID_KEYSTORE AND ANDROID_KEYSTORE_ALIAS) 0514 add_custom_target(sign-apk-kstars 0515 COMMAND jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ${ANDROID_KEYSTORE} ${CMAKE_BINARY_DIR}/packaging/android/kstars_build_apk/bin/QtApp-release-unsigned.apk ${ANDROID_KEYSTORE_ALIAS} 0516 COMMAND rm -rf ${CMAKE_BINARY_DIR}/packaging/android/kstars_build_apk/bin/kstars-signed.apk 0517 COMMAND zipalign -v 4 ${CMAKE_BINARY_DIR}/packaging/android/kstars_build_apk/bin/QtApp-release-unsigned.apk ${CMAKE_BINARY_DIR}/packaging/android/kstars_build_apk/bin/kstars-signed.apk 0518 ) 0519 endif () 0520 endif ()