Skip to content

Commit

Permalink
Merge pull request #310 from maxmind/greg/fix-cmake-package-version
Browse files Browse the repository at this point in the history
Set PACKAGE_VERSION in header file for CMake
  • Loading branch information
shadromani authored Oct 27, 2022
2 parents 7612070 + 3f5e112 commit 876e68c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ add_library(maxminddb::maxminddb ALIAS maxminddb)

set_target_properties(maxminddb PROPERTIES VERSION ${MAXMINDDB_SOVERSION})

target_compile_definitions(maxminddb PUBLIC PACKAGE_VERSION="${PROJECT_VERSION}")
target_compile_definitions(maxminddb PRIVATE PACKAGE_VERSION="${PROJECT_VERSION}")

if(NOT IS_BIG_ENDIAN)
target_compile_definitions(maxminddb PRIVATE MMDB_LITTLE_ENDIAN=1)
Expand Down
5 changes: 5 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.7.2

* `PACKAGE_VERSION` is now a private compile definition when building
with CMake. Pull request by bsergean. GitHub #308.

## 1.7.1 - 2022-09-30

* The external symbols test now only runs on Linux. It assumes a Linux
Expand Down
2 changes: 2 additions & 0 deletions bin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ if(NOT MSVC)
target_link_options(mmdblookup PRIVATE "-municode")
endif()

target_compile_definitions(mmdblookup PRIVATE PACKAGE_VERSION="${PROJECT_VERSION}")

target_link_libraries(mmdblookup maxminddb pthread)

install(
Expand Down
3 changes: 3 additions & 0 deletions include/maxminddb.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ extern "C" {
#include <winsock2.h>
#include <ws2tcpip.h>
/* libmaxminddb package version from configure */
#ifndef PACKAGE_VERSION
/* This is used by msbuild. Once we delete those files, we can remove this. */
#define PACKAGE_VERSION "1.7.1"
#endif

typedef ADDRESS_FAMILY sa_family_t;

Expand Down
1 change: 1 addition & 0 deletions t/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ foreach(TEST_TARGET_NAME ${TEST_TARGET_NAMES})
add_executable(${TEST_TARGET_NAME} ${TEST_TARGET_NAME}.c maxminddb_test_helper.c)
target_include_directories(${TEST_TARGET_NAME} PRIVATE ../src)
target_link_libraries(${TEST_TARGET_NAME} maxminddb tap)
target_compile_definitions(${TEST_TARGET_NAME} PRIVATE PACKAGE_VERSION="${PROJECT_VERSION}")

if(UNIX)
target_link_libraries(${TEST_TARGET_NAME} m)
Expand Down

0 comments on commit 876e68c

Please sign in to comment.