10110111 / CalcMySky

Simulator of light scattering by planetary atmospheres
GNU General Public License v3.0
29 stars 7 forks source link

Allow usage without installing #7

Closed DarthGandalf closed 1 year ago

DarthGandalf commented 1 year ago

As discussed in #5

The patch to Stellarium would look approximately like this:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e4ccacd..fe935a4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -685,15 +685,42 @@ SET(CMAKE_AUTOUIC ON) # ?
 SET(CMAKE_INCLUDE_CURRENT_DIR ON)

 IF(ENABLE_SHOWMYSKY)
-    FIND_PACKAGE(ShowMySky REQUIRED)
+    CPMFindPackage(NAME ShowMySky
+        URL https://github.com/DarthGandalf/CalcMySky/archive/refs/heads/alias.zip
+        URL_HASH
+        SHA256=4b485d6c53672979912cf0e5b1f9b61bf039306aadfef9d6433c50084291eafc
+        EXCLUDE_FROM_ALL yes
+        OPTIONS "QT_VERSION ${QT_VERSION_MAJOR}"
+        )
+    if(ShowMySky_ADDED)
+        GET_TARGET_PROPERTY(ShowMySky_INCLUDE_DIRECTORIES
+            ShowMySky::ShowMySky INTERFACE_INCLUDE_DIRECTORIES)
+        set(ShowMySky_LIBRARY $<TARGET_FILE:ShowMySky::ShowMySky>)
+        message(STATUS "Will build ShowMySky library")
+        include(GNUInstallDirs)
+        install(TARGETS ShowMySky
+            LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+            RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+        # We used EXCLUDE_FROM_ALL in CPMFindPackage to avoid building
+        # irrelevant binaries of CalcMySky. But we still need to build
+        # libShowMySky, so add some target which would depend on it.
+        # stelMain is not defined at this point yet, so can't use it.
+        file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/fake-show-my-sky-client.cpp "")
+        add_library(fake-show-my-sky-client SHARED
+            ${CMAKE_CURRENT_BINARY_DIR}/fake-show-my-sky-client.cpp)
+        ADD_DEPENDENCIES(fake-show-my-sky-client ShowMySky::ShowMySky)
+    else()
+        GET_TARGET_PROPERTY(ShowMySky_INCLUDE_DIRECTORIES
+            ShowMySky::ShowMySky INTERFACE_INCLUDE_DIRECTORIES)
+        GET_TARGET_PROPERTY(ShowMySky_LIBRARY
+            ShowMySky::ShowMySky LOCATION)
+        IF(EXISTS ${ShowMySky_LIBRARY})
+            MESSAGE(STATUS "Found ShowMySky library: ${ShowMySky_LIBRARY}")
+        ELSE()
+            MESSAGE(FATAL_ERROR "Could NOT found ShowMySky library")
+        ENDIF()
+    endif()
     ADD_DEFINITIONS(-DENABLE_SHOWMYSKY)
-    GET_TARGET_PROPERTY(ShowMySky_INCLUDE_DIRECTORIES ShowMySky::ShowMySky INTERFACE_INCLUDE_DIRECTORIES)
-    GET_TARGET_PROPERTY(ShowMySky_LIBRARY ShowMySky::ShowMySky LOCATION)
-    IF(EXISTS ${ShowMySky_LIBRARY})
-   MESSAGE(STATUS "Found ShowMySky library: ${ShowMySky_LIBRARY}")
-    ELSE()
-   MESSAGE(STATUS "Could NOT found ShowMySky library")
-    ENDIF()
 ENDIF(ENABLE_SHOWMYSKY)

 IF(ENABLE_SCRIPTING)

And that'll allow simplifying a lot developer setup to stop downloading ShowMySky to the correct place, and CI too

10110111 commented 1 year ago

With this patch to Stellarium applied, how will it behave if CalcMySky is already installed system-wide? Will it use the system package, or download it again?

DarthGandalf commented 1 year ago

CPMFindPackage tries the system one by default, and if not found, downloads

чт, 6 окт. 2022 г., 15:00 Ruslan Kabatsayev @.***>:

With this patch to Stellarium applied, how will it behave if CalcMySky is already installed system-wide? Will it use the system package, or download it again?

— Reply to this email directly, view it on GitHub https://github.com/10110111/CalcMySky/pull/7#issuecomment-1270105180, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACPLZH33IG4K3BF5EBMGU3WB3LO7ANCNFSM6AAAAAAQ6B5MFY . You are receiving this because you authored the thread.Message ID: @.***>

DarthGandalf commented 1 year ago

I've rebased this

DarthGandalf commented 1 year ago

Thanks, when can we expect new version with all these changes? That can simplify a bit the patch to stellarium, draft of which is shown above, because it could use the git tag; and it'd also make the packaging work slightly simpler, to avoid refering to some random non-released commit here, or to apply a number of patches on top of 0.1.0, for every distro

10110111 commented 1 year ago

Let's wait a week. I expect some other packagers might come with their patches.

DarthGandalf commented 1 year ago

Sounds good

DarthGandalf commented 1 year ago

Let's wait a week

@10110111 hi, how are you? :)

10110111 commented 1 year ago

Hi, I've found some problems that I'd like to get fixed before the release. I hope to get this done in several days.

Funnily, no packagers have come since my previous comment :)

10110111 commented 1 year ago

Version 0.2.0 is released now.

DarthGandalf commented 1 year ago

Thanks; the title of the release says 0.0.2 though instead of 0.2.0

10110111 commented 1 year ago

Fixed, thanks.