Skip to content

Add cmake install targets #21

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

Merged
merged 1 commit into from
Apr 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 7 additions & 0 deletions CMake/bncsutilConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/bncsutilTargets.cmake")

set(bncsutil_FOUND TRUE)
set(bncsutil_VERSION "@PROJECT_VERSION@")
message(STATUS "Found bncsutil: ${bncsutil_VERSION}")
47 changes: 40 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
cmake_minimum_required(VERSION 3.25)
project(bncsutil)
SET(VERSION_MAJOR "1")
SET(VERSION_MINOR "4")
SET(VERSION_PATCH "3")

project(bncsutil VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")

set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR} "${PROJECT_SOURCE_DIR}/CMake/Modules")
message(${CMAKE_BINARY_DIR})

SET(VERSION_MAJOR "1")
SET(VERSION_MINOR "4")
SET(VERSION_PATCH "2")

add_library(bncsutil SHARED)

set(HEADERS
Expand Down Expand Up @@ -97,9 +97,42 @@ if (MSVC)
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT "bncsutil")
endif()

install(TARGETS bncsutil RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
include(CMakePackageConfigHelpers)

install(TARGETS bncsutil
EXPORT bncsutilTargets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
INCLUDES DESTINATION include
)

install(FILES ${HEADERS} DESTINATION include/bncsutil)

install(EXPORT bncsutilTargets
FILE bncsutilTargets.cmake
NAMESPACE bncsutil::
DESTINATION lib/cmake/bncsutil
)

configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/CMake/bncsutilConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/bncsutilConfig.cmake"
INSTALL_DESTINATION lib/cmake/bncsutil
)

write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/bncsutilConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)

install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/bncsutilConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/bncsutilConfigVersion.cmake"
DESTINATION lib/cmake/bncsutil
)

#CPack configuration
SET(CPACK_GENERATOR "DEB" "RPM")
SET(CPACK_PACKAGE_NAME "bncsutil")
Expand All @@ -124,7 +157,7 @@ SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libgmp10")

#RPM configuration
SET(CPACK_RPM_PACKAGE_RELEASE 1)
SET(CPACK_RPM_PACKAGE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
SET(CPACK_RPM_PACKAGE_LICENSE "LGPL-2.1")
SET(CPACK_RPM_PACKAGE_GROUP "bncsutil")
SET(CPACK_RPM_PACKAGE_URL "https://github.com/BNETDocs/bncsutil")
SET(CPACK_RPM_PACKAGE_REQUIRES "gmp")
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ been maintained over the course of several years by the open source Battle.net c
# Usage
`#include <bncsutil/bncsutil.h>` and link against `bncsutil.lib` or `libbncsutil.so`.

For CMake add:
```
find_package(bncsutil REQUIRED)
target_link_libraries(mytarget PRIVATE bncsutil::bncsutil)
```

# Building

To force a specific build (32bit or 64bit) add `-DCMAKE_GENERATOR_PLATFORM=x86` or `-DCMAKE_GENERATOR_PLATFORM=x64` to CMake flags.
Expand Down