Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Statically link our code #99

Closed
wants to merge 8 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 25 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ set(ANTIMICROX_MAJOR_VERSION 3)
set(ANTIMICROX_MINOR_VERSION 1)
set(ANTIMICROX_PATCH_VERSION 3)

# antilib soname version
set(ANTILIB_MAJOR_VERSION 1)
set(ANTILIB_VERSION "${ANTILIB_MAJOR_VERSION}")
# antimicrolib soname version
### set(ANTIMICROLIB_MAJOR_VERSION 1)
### set(ANTIMICROLIB_VERSION "${ANTIMICROLIB_MAJOR_VERSION}")
AriaMoradi marked this conversation as resolved.
Show resolved Hide resolved

option(WITH_TESTS "Allow tests for classes" OFF)

Expand All @@ -84,7 +84,7 @@ if(UNIX)
option(WITH_UINPUT "Compile with support for uinput. uinput will be usable to simulate events." ON)
option(WITH_XTEST "Compile with support for XTest. XTest will be usable to simulate events." ON)
option(APPDATA "Build project with AppData file support." ON)
option(ANTILIB_PATH "Set your own path for antilib" OFF)
option(ANTIMICROLIB_PATH "Set your own path for antimicrolib" OFF)
endif(UNIX)

option(UPDATE_TRANSLATIONS "Call lupdate to update translation files from source." OFF)
Expand Down Expand Up @@ -491,41 +491,47 @@ endif(UNIX)

if(UNIX)

if(ANTILIB_PATH)
ADD_DEFINITIONS(-DANTILIB_PATH="${ANTILIB_PATH}")
if(ANTIMICROLIB_PATH)
ADD_DEFINITIONS(-DANTIMICROLIB_PATH="${ANTIMICROLIB_PATH}")

# Generally package manager takes care of this while installing the new library, but not always
# especially with cmake
ADD_DEFINITIONS(-DLD_LIBRARY_PATH="${ANTILIB_PATH}:${LD_LIBRARY_PATH}")
ADD_DEFINITIONS(-DLD_LIBRARY_PATH="${ANTIMICROLIB_PATH}:${LD_LIBRARY_PATH}")

# those instructions have to be before add_executable() or add_library() is called, otherwise it has no effect
set(CMAKE_INSTALL_RPATH "${ANTILIB_PATH}")
set(CMAKE_INSTALL_RPATH "${ANTIMICROLIB_PATH}")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif()

add_library( antilib
add_library( antimicrolib
AriaMoradi marked this conversation as resolved.
Show resolved Hide resolved
SHARED
Copy link
Collaborator

@gombosg gombosg Nov 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a suspicion that xcb linking was not needed because this used to be compiled as a shared library, it was only linked dynamically, and xcb is a requirement for qt so it's available at runtime. @pktiuk is this a wild guess?

Copy link
Contributor Author

@AriaMoradi AriaMoradi Nov 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We directly need xcb because some functions fro xcb/xcb.h where used.
And these are not a part of qt in any ways possible..

${antimicrox_HEADERS_MOC}
${antimicrox_SOURCES}
${antimicrox_FORMS_HEADERS}
${antimicrox_RESOURCES_RCC}
)

set_target_properties(antilib PROPERTIES
SOVERSION ${ANTILIB_VERSION}
set_target_properties(antimicrolib PROPERTIES
NO_SONAME 1
AriaMoradi marked this conversation as resolved.
Show resolved Hide resolved
)

set_target_properties(antimicrolib PROPERTIES
OUTPUT_NAME "antimicro"
)
AriaMoradi marked this conversation as resolved.
Show resolved Hide resolved



AriaMoradi marked this conversation as resolved.
Show resolved Hide resolved

#target_link_libraries (antilib Qt5::Widgets Qt5::Core Qt5::Test Qt5::Gui Qt5::Network Qt5::Concurrent ${SDL_LIBRARY} ${LIBS})
target_link_libraries (antilib Qt5::Widgets Qt5::Core Qt5::Gui Qt5::Network Qt5::Concurrent ${SDL_LIBRARY} ${LIBS})
#target_link_libraries (antimicrolib Qt5::Widgets Qt5::Core Qt5::Test Qt5::Gui Qt5::Network Qt5::Concurrent ${SDL_LIBRARY} ${LIBS})
target_link_libraries (antimicrolib Qt5::Widgets Qt5::Core Qt5::Gui Qt5::Network Qt5::Concurrent ${SDL_LIBRARY} ${LIBS})

if (WITH_X11)
target_link_libraries(antilib Qt5::X11Extras)
target_link_libraries(antimicrolib Qt5::X11Extras)
endif()


add_executable(antimicrox ${antimicrox_MAIN})
target_link_libraries (antimicrox antilib Qt5::Widgets Qt5::Core Qt5::Gui Qt5::Network Qt5::Concurrent)
target_link_libraries (antimicrox antimicrolib Qt5::Widgets Qt5::Core Qt5::Gui Qt5::Network Qt5::Concurrent)

endif(UNIX)

Expand All @@ -534,10 +540,10 @@ endif(UNIX)
if(UNIX)
install(TARGETS antimicrox RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")

if(ANTILIB_PATH)
install(TARGETS antilib DESTINATION "${ANTILIB_PATH}")
if(ANTIMICROLIB_PATH)
install(TARGETS antimicrolib DESTINATION "${ANTIMICROLIB_PATH}")
else()
install(TARGETS antilib DESTINATION "${CMAKE_INSTALL_LIBDIR}")
install(TARGETS antimicrolib DESTINATION "${CMAKE_INSTALL_LIBDIR}")
endif()

install(FILES ${antimicrox_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/antimicrox")
Expand Down Expand Up @@ -647,7 +653,7 @@ It is a new fork of discontinued AntiMicro.")
COMMAND strip --strip-unneeded --remove-section=.comment --remove-section=.note "${CMAKE_CURRENT_BINARY_DIR}/bin/antimicrox" VERBATIM)

add_custom_command(TARGET antimicrox POST_BUILD
COMMAND strip --strip-unneeded --remove-section=.comment --remove-section=.note "${CMAKE_CURRENT_BINARY_DIR}/libantilib.so.1" VERBATIM)
COMMAND strip --strip-unneeded --remove-section=.comment --remove-section=.note "${CMAKE_CURRENT_BINARY_DIR}/libantimicrolib.so" VERBATIM)

endif()

Expand Down