From dee93e614c46005ef4cbb68810431f5073b68a49 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 1 Jul 2021 14:06:05 -0700 Subject: [PATCH 1/5] Add changelog entry for #269 --- Changes.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Changes.md b/Changes.md index e2c5c31c..080fc0b8 100644 --- a/Changes.md +++ b/Changes.md @@ -1,3 +1,9 @@ +## 1.6.1 + +* When building with Visual Studio, you may now build a static runtime with + CMake by setting `MSVC_STATIC_RUNTIME` to `ON`. Pull request by Rafael + Santiago. GitHub #269. + ## 1.6.0 - 2021-04-29 * This release includes several improvements to the CMake build. In From 2f03eef8293163fe5e5ec10276382e9127793f4d Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 1 Jul 2021 14:06:53 -0700 Subject: [PATCH 2/5] Move block to be with other WIN32 items --- CMakeLists.txt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ac4fd885..f1dc1899 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,14 +1,5 @@ cmake_minimum_required (VERSION 3.9) -if (WIN32 AND MSVC_STATIC_RUNTIME) - # On MSVC, when MSVC_STATIC_RUNTIME is ON, MT (Release) and MTd (Debug) run-time libraries will be used instead of MD/MDd. - # The default is OFF so MD/MDd are used when nothing related is passed. - set(CMAKE_USER_MAKE_RULES_OVERRIDE - ${CMAKE_CURRENT_SOURCE_DIR}/c_flag_overrides.cmake) - set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX - ${CMAKE_CURRENT_SOURCE_DIR}/cxx_flag_overrides.cmake) -endif() - project(maxminddb LANGUAGES C VERSION 1.6.0 @@ -70,6 +61,15 @@ if(WIN32) if(BUILD_SHARED_LIBS) set_target_properties(maxminddb PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) endif() + if(MSVC_STATIC_RUNTIME) + # On MSVC, when MSVC_STATIC_RUNTIME is ON, MT (Release) and MTd (Debug) + # run-time libraries will be used instead of MD/MDd. The default is OFF so + # MD/MDd are used when nothing related is passed. + set(CMAKE_USER_MAKE_RULES_OVERRIDE + ${CMAKE_CURRENT_SOURCE_DIR}/c_flag_overrides.cmake) + set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX + ${CMAKE_CURRENT_SOURCE_DIR}/cxx_flag_overrides.cmake) + endif() endif() target_include_directories(maxminddb PUBLIC From 4f5887b58c65f8ee94331b26e64fca4af292bfad Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 1 Jul 2021 14:07:56 -0700 Subject: [PATCH 3/5] Add comment on source of override rules --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f1dc1899..8cdf5a1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,6 +65,8 @@ if(WIN32) # On MSVC, when MSVC_STATIC_RUNTIME is ON, MT (Release) and MTd (Debug) # run-time libraries will be used instead of MD/MDd. The default is OFF so # MD/MDd are used when nothing related is passed. + # + # Adapted from https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#make-override-files set(CMAKE_USER_MAKE_RULES_OVERRIDE ${CMAKE_CURRENT_SOURCE_DIR}/c_flag_overrides.cmake) set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX From 37a0e1ef46b2b4a13fa6877c7bf1abfd0c709d2a Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 1 Jul 2021 14:12:43 -0700 Subject: [PATCH 4/5] Update language in README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c29877aa..184aae13 100644 --- a/README.md +++ b/README.md @@ -80,10 +80,10 @@ work. $ ctest -V . $ cmake --build . --target install -On Windows, when using ``MSVC`` if the multithreaded (MT/MTd) run-time library is desired -instead of the shared default (MD/MDd). Try the following during build scripts generation: +When building with Visual Studio, you may build a multithreaded (MT/MTd) +runtime library, using the `MSVC_STATIC_RUNTIME` setting: - $ cmake -DMSVC_STATIC_RUNTIME=ON -DBUILD_SHARED_LIBS=OFF .. + $ cmake -DMSVC_STATIC_RUNTIME=ON -DBUILD_SHARED_LIBS=OFF .. ## On Ubuntu via PPA From ee3efb50da267773a5a8f3644b0d985dd69c5189 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 1 Jul 2021 14:14:44 -0700 Subject: [PATCH 5/5] Wrap long line --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 184aae13..ad71faff 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,8 @@ You can clone this repository and build it by running: $ git clone --recursive https://github.com/maxmind/libmaxminddb After cloning, run `./bootstrap` from the `libmaxminddb` directory and then -follow the instructions for installing from a named release tarball as described above. +follow the instructions for installing from a named release tarball as +described above. ## Using CMake