Skip to content
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
33 changes: 27 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.5)
project(hmac_cpp LANGUAGES CXX)
project(hmac_cpp VERSION 0.1.0 LANGUAGES CXX)

if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
Expand All @@ -25,17 +25,38 @@ set(HMAC_HEADERS
include/hmac_cpp/sha512.hpp
)

add_library(hmac STATIC ${HMAC_SOURCES})
target_include_directories(hmac PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
add_library(hmac_cpp STATIC ${HMAC_SOURCES})
target_include_directories(hmac_cpp PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)

if(BUILD_EXAMPLE)
add_executable(example example.cpp)
target_link_libraries(example PRIVATE hmac)
target_link_libraries(example PRIVATE hmac_cpp)
target_include_directories(example PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
endif()

install(TARGETS hmac DESTINATION lib)
include(CMakePackageConfigHelpers)
install(TARGETS hmac_cpp EXPORT hmac_cppTargets DESTINATION lib)
install(FILES ${HMAC_HEADERS} DESTINATION include/hmac_cpp)
install(EXPORT hmac_cppTargets NAMESPACE hmac_cpp:: DESTINATION lib/cmake/hmac_cpp)

configure_package_config_file(
cmake/hmac_cppConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/hmac_cppConfig.cmake"
INSTALL_DESTINATION lib/cmake/hmac_cpp
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/hmac_cppConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/hmac_cppConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/hmac_cppConfigVersion.cmake"
DESTINATION lib/cmake/hmac_cpp
)

if(BUILD_TESTS)
enable_testing()
Expand All @@ -46,7 +67,7 @@ if(BUILD_TESTS)
)
FetchContent_MakeAvailable(googletest)
add_executable(test_all test_all.cpp)
target_link_libraries(test_all PRIVATE hmac gtest_main)
target_link_libraries(test_all PRIVATE hmac_cpp gtest_main)
target_include_directories(test_all PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
add_test(NAME test_all COMMAND test_all)
endif()
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,19 @@ _install/
│ ├── sha1.hpp
│ ├── sha256.hpp
│ └── sha512.hpp
└── lib/
└── libhmac.a
└── lib/
└── libhmac_cpp.a
```

Predefined `.bat` scripts for MinGW builds are also available: `build_*.bat`.

After installation, the package can be found and linked in other projects using `find_package`:

```cmake
find_package(hmac_cpp CONFIG REQUIRED)
target_link_libraries(my_app PRIVATE hmac_cpp::hmac_cpp)
```

## 📦 MQL5 Compatibility

The repository includes `sha256.mqh`, `sha512.mqh`, `hmac.mqh`, and `hmac_utils.mqh` files, fully compatible with `MetaTrader 5`.
Expand Down
5 changes: 5 additions & 0 deletions cmake/hmac_cppConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@PACKAGE_INIT@

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

check_required_components(hmac_cpp)
1 change: 1 addition & 0 deletions cmake/hmac_cppConfigVersion.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# hmac_cppConfigVersion.cmake is generated by write_basic_package_version_file
Loading