Skip to content

Commit 7af5990

Browse files
committed
Fix portable packaging
1 parent 4ee2893 commit 7af5990

File tree

9 files changed

+44
-32
lines changed

9 files changed

+44
-32
lines changed

CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ endif()
1111

1212
project(daggy_dev)
1313

14-
option(CONAN_BUILD "build with conan" ON)
15-
add_definitions(-DCONAN_BUILD)
16-
option(PACKAGE_DEPS "include daggy deps into package" ON)
14+
set(PORTABLE_BUILD ON)
1715

1816
include(CTest)
1917
add_subdirectory(src)

conanfile.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,9 @@ def config_options(self):
6363
if self.settings.os == "Windows":
6464
del self.options.fPIC
6565

66-
self.options["qt"].shared = True
67-
68-
if self.settings.os == "Windows":
69-
self.options["libssh2"].shared = True
66+
self.options["qt"].shared = self.options.shared
67+
self.options["libssh2"].shared = self.options.shared
68+
self.options["yaml-cpp"].shared = self.options.shared
7069

7170
def build_requirements(self):
7271
self.tool_requires("cmake/3.30.1")
@@ -109,10 +108,11 @@ def generate(self):
109108
tc.cache_variables["YAML_SUPPORT"] = True
110109
tc.cache_variables["CONSOLE"] = True
111110
tc.cache_variables["PCAPNG_SUPPORT"] = False
112-
tc.cache_variables["PACKAGE_DEPS"] = True
111+
tc.cache_variables["PORTABLE_BUILD"] = True
113112
tc.cache_variables["BUILD_TESTING"] = True
114113
tc.cache_variables["CONAN_BUILD"] = True
115114
tc.cache_variables["VERSION"] = GitVersion().version
115+
tc.cache_variables["VERSION_EXTENDED"] = GitVersion().extended
116116

117117
if self.options.shared:
118118
tc.cache_variables["CMAKE_C_VISIBILITY_PRESET"] = "hidden"

git_version.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,23 @@ def branch(self):
5858
stream = os.popen("git branch --show-current")
5959
return stream.read().strip()
6060

61+
@property
62+
def short(self):
63+
stream = os.popen("git rev-parse --short=6 HEAD")
64+
return stream.read().strip()
65+
6166
@property
6267
def full(self):
63-
return f"{self.version}-{self.branch}"
68+
return f"{self.version}-{self.short}"
69+
6470

6571
@property
66-
def standard(self):
67-
standard = f"{self.version}-{self.branch}"
68-
if self.branch == self.default_branch or re.match("release/.*", self.branch):
69-
standard = f"{self.version}"
70-
return standard
72+
def extended(self):
73+
if self.build == 0:
74+
extended = f"{self.version}"
75+
else:
76+
extended = f"{self.version}-{self.short}"
77+
return extended
7178

7279
@property
7380
def commit(self):
@@ -82,7 +89,7 @@ def __str__(self):
8289
Full: {self.full}
8390
Branch: {self.branch}
8491
Build: {self.build}
85-
Standard: {self.standard}
92+
Extended: {self.extended}
8693
Commit: {self.commit}
8794
"""
8895

src/CMakeLists.txt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,23 @@ include_directories(${CMAKE_BINARY_EXPORTS_DIR})
1818
set(PROJECT_VENDOR synacker)
1919
set(PROJECT_COPYRIGTH "Copyright \\251 2025 Mikhail Milovidov. Some Rights Reserved")
2020

21+
option(PORTABLE_BUILD "portable install packages" OFF)
22+
option(APPONLY_BUILD "build only application with static deps linkage" OFF)
23+
option(CONAN_BUILD "build with conan specific changes" OFF)
24+
2125
option(SSH2_SUPPORT "ssh2 data provider support" ON)
2226
option(YAML_SUPPORT "yaml data sources support" ON)
2327
option(CONSOLE "daggy console application" ON)
24-
option(BUILD_SHARED_LIBS ON)
28+
29+
if (APPONLY_BUILD)
30+
set(BUILD_SHARED_LIBS OFF)
31+
set(CONSOLE ON)
32+
endif()
33+
34+
if (PORTABLE_BUILD)
35+
set(CONAN_BUILD ON)
36+
set(BUILD_SHARED_LIBS ON)
37+
endif()
2538

2639
if(SSH2_SUPPORT)
2740
add_definitions(-DSSH2_SUPPORT)
@@ -31,14 +44,9 @@ if(YAML_SUPPORT)
3144
add_definitions(-DYAML_SUPPORT)
3245
endif()
3346

34-
if(CONAN_BUILD)
35-
add_definitions(-DCONAN_BUILD)
36-
endif()
37-
3847
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
3948

4049
include(compiler)
41-
4250
include(CTest)
4351

4452
add_subdirectory(DaggyCore)

src/DaggyCore/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ set(TARGET DaggyCore)
33
find_package(Qt6 COMPONENTS Core Network REQUIRED)
44
add_library(${TARGET})
55
include(rpath_lib)
6-
76
set_target_properties(${TARGET} PROPERTIES AUTOMOC ON)
87

98
target_sources(${TARGET}

src/cmake/pack.cmake

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,8 @@ set(CPACK_IFW_PACKAGE_STYLE_SHEET ${CMAKE_CURRENT_LIST_DIR}/installer.qss)
6060
set(CPACK_IFW_PACKAGE_TITLE_COLOR "#007A5C")
6161
set(CPACK_IFW_PACKAGE_NAME ${CPACK_PACKAGE_NAME})
6262

63-
if(PACKAGE_DEPS)
64-
include(package_deps)
65-
endif()
63+
64+
include(package_deps)
6665

6766
IF(${CPACK_SYSTEM_NAME} MATCHES Windows)
6867
IF(CMAKE_CL_64)

src/cmake/package_deps.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
if (PACKAGE_DEPS)
1+
if (PORTABLE_BUILD AND CONAN_BUILD)
22
install(TARGETS ${TARGET}
33
RUNTIME_DEPENDENCY_SET ${TARGET}_deps
44
)
@@ -13,5 +13,6 @@ if (PACKAGE_DEPS)
1313
[=[.*system32\/.*\.dll]=]
1414
[=[^\/(lib|usr\/lib|usr\/local\/lib\/lib64)]=]
1515
DIRECTORIES ${CONAN_RUNTIME_LIB_DIRS} ${CONAN_LIB_DIRS}
16+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}
1617
)
1718
endif()

src/cmake/rpath_bin.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
if(CONAN_BUILD)
1+
if(PORTABLE_BUILD)
22
if(APPLE)
3-
set_target_properties(${TARGET} PROPERTIES INSTALL_RPATH "@executable_path/../${CMAKE_INSTALL_LIBDIR}")
3+
set_target_properties(${TARGET} PROPERTIES INSTALL_RPATH "@executable_path/../${CMAKE_INSTALL_LIBDIR};@executable_path/../${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}")
44
elseif(UNIX)
5-
set_target_properties(${TARGET} PROPERTIES INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}")
5+
set_target_properties(${TARGET} PROPERTIES INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR};$ORIGIN/../${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}")
66
endif()
77
endif()

src/cmake/rpath_lib.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
if(CONAN_BUILD)
1+
if(PORTABLE_BUILD)
22
if(APPLE)
3-
set_target_properties(${TARGET} PROPERTIES INSTALL_RPATH "@loader_path")
3+
set_target_properties(${TARGET} PROPERTIES INSTALL_RPATH "@loader_path/${PROJECT_NAME}")
44
elseif(UNIX)
5-
set_target_properties(${TARGET} PROPERTIES INSTALL_RPATH "$ORIGIN")
5+
set_target_properties(${TARGET} PROPERTIES INSTALL_RPATH "$ORIGIN/${PROJECT_NAME}")
66
endif()
77
endif()

0 commit comments

Comments
 (0)