diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 32c3c17..190a405 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -62,3 +62,13 @@ jobs: - name: Test run: ctest --test-dir build --output-on-failure + + - name: Install + run: cmake --install build --strip --prefix install + + - name: Upload + uses: actions/upload-artifact@v3 + with: + name: unshield-${{github.sha}} (${{matrix.platform.name}}) + path: install + if-no-files-found: error diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f90e1a..28e1a31 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,6 +84,7 @@ add_subdirectory(src) install(FILES man/unshield.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libunshield.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +install(EXPORT unshieldConfig NAMESPACE unshield:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/unshield) if (BUILD_TESTING) add_subdirectory(test) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 26989aa..7d98cf1 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -27,10 +27,12 @@ else() add_library(libunshield SHARED ${LIBUNSHIELD_HEADERS} ${LIBUNSHIELD_SOURCES}) endif() -target_include_directories(libunshield PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries(libunshield PUBLIC ZLIB::ZLIB convert_utf) +target_include_directories(libunshield PUBLIC + $ + $) +target_link_libraries(libunshield PUBLIC ZLIB::ZLIB PRIVATE convert_utf) set_target_properties(libunshield PROPERTIES OUTPUT_NAME unshield) -set_target_properties(libunshield PROPERTIES VERSION 0.0.0 SOVERSION 0) +set_target_properties(libunshield PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}) if(USE_OUR_OWN_MD5) target_link_libraries(libunshield PUBLIC md5) @@ -38,5 +40,4 @@ else() target_link_libraries(libunshield PUBLIC OpenSSL::Crypto) endif() -install(TARGETS libunshield RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -install(FILES libunshield.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install(TARGETS libunshield EXPORT unshieldConfig RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 77d6825..5e92190 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -22,4 +22,10 @@ if(BUILD_STATIC AND MSVC) set_msvc_runtime_static() endif() -install(TARGETS unshield RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +set(TARGETS_TO_INSTALL unshield) + +if(BUILD_STATIC) + list(APPEND TARGETS_TO_INSTALL convert_utf) +endif() + +install(TARGETS ${TARGETS_TO_INSTALL} EXPORT unshieldConfig RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})