Skip to content

Commit 3874577

Browse files
kovdan01Leon0402
authored andcommitted
Add USE_SYSTEM_DATE cmake option (rbock#372)
* Add `USE_SYSTEM_DATE` cmake option
1 parent 98402aa commit 3874577

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
3232

3333
include(CTest)
3434

35+
option(USE_SYSTEM_DATE "\
36+
Use find_package to find installed HowardHinnant's \
37+
date library instead of fetching it from github" OFF
38+
)
39+
40+
if(USE_SYSTEM_DATE)
41+
find_package(date REQUIRED)
42+
endif()
3543

3644
### Dependencies
3745
add_subdirectory(dependencies)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ To demonstrate that sqlpp11 can work with other backends as well, here is an exp
135135
* STL Container: https://github.com/rbock/sqlpp11-connector-stl
136136
137137
__Date Library:__
138-
sqlpp11 requires [Howard Hinnant's date library](https://github.com/HowardHinnant/date) for `date` and `date_time` data types. Sqlpp11 uses FetchContent to pull the library automatically in the project.
138+
sqlpp11 requires [Howard Hinnant's date library](https://github.com/HowardHinnant/date) for `date` and `date_time` data types. By default, sqlpp11 uses FetchContent to pull the library automatically in the project. If you want to use an already installed version of the library with `find_package`, set `USE_SYSTEM_DATE` option to `ON`.
139139
140140
Build and Install
141141
-----------------

dependencies/CMakeLists.txt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@
2222
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2323
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2424

25-
include(FetchContent)
2625

27-
FetchContent_Declare(date
28-
GIT_REPOSITORY https://github.com/HowardHinnant/date.git
29-
GIT_TAG v3.0.0
30-
)
26+
if(NOT USE_SYSTEM_DATE)
27+
include(FetchContent)
3128

32-
add_subdirectory(hinnant_date)
29+
FetchContent_Declare(date
30+
GIT_REPOSITORY https://github.com/HowardHinnant/date.git
31+
GIT_TAG v3.0.0
32+
)
33+
34+
add_subdirectory(hinnant_date)
35+
endif()

0 commit comments

Comments
 (0)