Skip to content

Commit ee628ca

Browse files
committed
Cleaned up shared lib install
1 parent 2fe6682 commit ee628ca

File tree

5 files changed

+53
-25
lines changed

5 files changed

+53
-25
lines changed

CMakeLists.txt

+16-8
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,22 @@ endif()
9999
# We will set this to the agent_test project.
100100
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT agent)
101101

102-
install(FILES README.md LICENSE.TXT TYPE DATA)
103-
install(DIRECTORY schemas TYPE DATA)
104-
install(DIRECTORY simulator TYPE DATA)
105-
install(DIRECTORY styles TYPE DATA)
106-
install(DIRECTORY tools TYPE DATA)
107-
install(DIRECTORY demo TYPE DATA)
108-
install(FILES demo/agent/Devices.xml TYPE SYSCONF)
109-
102+
install(FILES README.md LICENSE.TXT TYPE DATA COMPONENT Required)
103+
install(DIRECTORY schemas TYPE DATA COMPONENT Data)
104+
install(DIRECTORY simulator TYPE DATA COMPONENT Tools)
105+
install(DIRECTORY styles TYPE DATA COMPONENT Data)
106+
install(DIRECTORY tools TYPE DATA COMPONENT Tools)
107+
install(DIRECTORY demo TYPE DATA COMPONENT Demo)
108+
install(FILES demo/agent/Devices.xml TYPE SYSCONF COMPONENT Demo)
109+
110+
set(CPACK_COMPONENT_Demo_DESCRIPTION "Demo files for the Mazak and Okuma digital twin")
111+
set(CPACK_COMPONENT_Data_DESCRIPTION "Data files for schemas and styles to be served by the agent")
112+
set(CPACK_COMPONENT_Tools_DESCRIPTION "Scripts for to support running and simulating adapter behavior")
113+
set(CPACK_COMPONENT_Required_DESCRIPTION "Requied distribution files")
114+
set(CPACK_COMPONENT_Development_DESCRIPTION "Supporting files for developing using the agent library")
115+
set(CPACK_COMPONENT_Runtime_DESCRIPTION "Files required for running of the agent")
116+
117+
set(CPACK_COMPONENT_Required_REQUIRED 1)
110118
set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1)
111119
set(CPACK_PACKAGE_VERSION "${AGENT_VERSION_MAJOR}.${AGENT_VERSION_MINOR}.${AGENT_VERSION_PATCH}.${AGENT_VERSION_BUILD}${AGENT_VERSION_RC}")
112120
set(CPACK_PACKAGE_VERSION_MAJOR ${AGENT_VERSION_MAJOR})

Dockerfile

+10-2
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,11 @@ COPY . .
7474

7575
ARG WITH_TESTS=false
7676
ARG WITH_TESTS_ARG=argument
77+
ARG SHARED=False
7778

7879
# Build and optionally test
79-
RUN if [ -z "$WITH_TESTS" ] || [ "$WITH_TESTS" = "false" ]; \
80+
RUN set -x \
81+
&& if [ -z "$WITH_TESTS" ] || [ "$WITH_TESTS" = "false" ]; \
8082
then WITH_TESTS_ARG="--test-folder="; \
8183
else WITH_TESTS_ARG=""; fi \
8284
&& conan profile detect \
@@ -89,6 +91,7 @@ RUN if [ -z "$WITH_TESTS" ] || [ "$WITH_TESTS" = "false" ]; \
8991
-o cpack_destination=/root/agent \
9092
-o cpack_name=dist \
9193
-o cpack_generator=TGZ \
94+
-o shared=${SHARED} \
9295
-pr "$CONAN_PROFILE" \
9396
${WITH_TESTS_ARG}
9497

@@ -102,6 +105,7 @@ FROM os AS release
102105
LABEL author='mtconnect' description='MTConnect C++ Agent'
103106

104107
ARG BIN_DIR='/usr/local/bin'
108+
ARG LIB_DIR='/usr/local/lib'
105109

106110
ARG MTCONNECT_CONF_DIR='/etc/mtconnect'
107111
ARG MTCONNECT_DATA_DIR='/usr/local/share/mtconnect'
@@ -131,7 +135,11 @@ RUN tar xf dist.tar.gz
131135

132136
# Copy the agent binary and create folders used by the agent
133137
USER root
134-
RUN cp /home/agent/dist/bin/* "$BIN_DIR" \
138+
RUN set +x \
139+
&& ls -lR /home/agent/dist/ \
140+
&& mkdir -p "$BIN_DIR" "$LIB_DIR" \
141+
&& cp /home/agent/dist/bin/* "$BIN_DIR" \
142+
&& cp /home/agent/dist/lib/* "$LIB_DIR" \
135143
&& mkdir -p "$MTCONNECT_CONF_DIR" \
136144
"$MTCONNECT_DATA_DIR" \
137145
"$MTCONNECT_LOG_DIR" \

agent/CMakeLists.txt

+18-6
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,17 @@ target_link_libraries(
4343

4444
target_clangtidy_setup(agent)
4545

46-
install(TARGETS agent RUNTIME)
47-
install(TARGETS agent ARCHIVE)
4846

4947
if(SHARED_AGENT_LIB AND MSVC)
5048
set(CMAKE_INSTALL_DEBUG_LIBRARIES OFF)
5149
include(InstallRequiredSystemLibraries)
5250
install(FILES ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION bin COMPONENT Libraries)
53-
file(GLOB dlls CONFIGURE_DEPENDS "${cppagent_BINARY_DIR}/dlls/*.dll")
51+
52+
file(GLOB dlls CONFIGURE_DEPENDS "${cppagent_BINARY_DIR}/libs/*.dll")
53+
file(GLOB libs CONFIGURE_DEPENDS "${cppagent_BINARY_DIR}/libs/*.lib")
54+
5455
install(FILES ${dlls} DESTINATION bin COMPONENT Libraries)
56+
install(FILES ${libs} DESTINATION lib COMPONENT Development)
5557

5658
add_custom_command(TARGET agent POST_BUILD
5759
COMMAND ${CMAKE_COMMAND} -E copy ${dlls} $<TARGET_FILE_DIR:agent>
@@ -60,7 +62,17 @@ if(SHARED_AGENT_LIB AND MSVC)
6062
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:agent> $<TARGET_FILE_DIR:agent>
6163
COMMAND_EXPAND_LISTS)
6264
elseif(SHARED_AGENT_LIB)
63-
file(GLOB dlls CONFIGURE_DEPENDS "${cppagent_BINARY_DIR}/dlls/*.dylib" "${cppagent_BINARY_DIR}/dlls/*.so")
64-
message(STATUS "!!!!! Copying ${dlls} to lib directory")
65-
install(FILES ${dlls} TYPE LIB COMPONENT Libraries)
65+
file(GLOB SharedLibs CONFIGURE_DEPENDS
66+
"${cppagent_BINARY_DIR}/libs/*.dylib"
67+
"${cppagent_BINARY_DIR}/libs/*.so.*"
68+
"${cppagent_BINARY_DIR}/libs/*.so")
69+
70+
message(STATUS "Will install shared libs ${SharedLibs} in lib directory")
71+
install(FILES ${SharedLibs} TYPE LIB COMPONENT Runtime)
6672
endif()
73+
74+
# Uncomment the next two lines to distribute *NIX archives
75+
# file(GLOB Archives CONFIGURE_DEPENDS "${cppagent_BINARY_DIR}/libs/*.a")
76+
# install(FILES ${Archives} TYPE LIB COMPONENT Developement)
77+
78+
Install(TARGETS agent RUNTIME COMPONENT Runtime)

agent_lib/CMakeLists.txt

+3-4
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,7 @@ target_sources(agent_lib PUBLIC FILE_SET headers
438438
TYPE HEADERS
439439
BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../src/" "${PROJECT_BINARY_DIR}/agent_lib/"
440440
FILES "${AGENT_LIB_HEADERS}" "${PROJECT_BINARY_DIR}/agent_lib/mtconnect/version.h")
441-
442441

443-
install(TARGETS agent_lib LIBRARY)
444-
install(TARGETS agent_lib ARCHIVE)
445-
install(TARGETS agent_lib FILE_SET headers PUBLIC_HEADER)
442+
install(TARGETS agent_lib ARCHIVE COMPONENT Development)
443+
install(TARGETS agent_lib FILE_SET headers PUBLIC_HEADER COMPONENT Development)
444+
install(TARGETS agent_lib LIBRARY COMPONENT Runtime)

conanfile.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,13 @@ def generate(self):
149149
for dep in self.dependencies.values():
150150
if dep.cpp_info.bindirs:
151151
if is_msvc(self) and dep.cpp_info.bindirs:
152-
print("Copying from " + dep.cpp_info.bindirs[0] + " to " + os.path.join(self.build_folder, "dlls"))
153-
copy(self, "*.dll", dep.cpp_info.bindirs[0], os.path.join(self.build_folder, "dlls"), keep_path=False)
152+
print("Copying from " + dep.cpp_info.bindirs[0] + " to " + os.path.join(self.build_folder, "libs"))
153+
copy(self, "*.dll", dep.cpp_info.bindirs[0], os.path.join(self.build_folder, "libs"), keep_path=False)
154154
elif dep.cpp_info.libdirs:
155-
print("Copying from " + dep.cpp_info.libdirs[0] + " to " + os.path.join(self.build_folder, "dlls"))
156-
copy(self, "*.so*", dep.cpp_info.libdirs[0], os.path.join(self.build_folder, "dlls"), keep_path=False)
157-
copy(self, "*.dylib", dep.cpp_info.libdirs[0], os.path.join(self.build_folder, "dlls"), keep_path=False)
155+
print("Copying from " + dep.cpp_info.libdirs[0] + " to " + os.path.join(self.build_folder, "libs"))
156+
# copy(self, "*.a", dep.cpp_info.libdirs[0], os.path.join(self.build_folder, "libs"), keep_path=False)
157+
copy(self, "*.so*", dep.cpp_info.libdirs[0], os.path.join(self.build_folder, "libs"), keep_path=False)
158+
copy(self, "*.dylib", dep.cpp_info.libdirs[0], os.path.join(self.build_folder, "libs"), keep_path=False)
158159

159160
tc = CMakeToolchain(self)
160161

0 commit comments

Comments
 (0)