@@ -3,6 +3,11 @@ project(amongoc VERSION 0.1.0 DESCRIPTION "An Asynchronous MongoDB Library for C
33
44list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR} /tools" )
55
6+ # Declare that we are compiling with C++23 before we proceed. This must be near
7+ # the top before we import other libraries that might depend on our toolchain
8+ # settings (e.g. Catch2)
9+ set (CMAKE_CXX_STANDARD 23)
10+
611# Pull our deps with PMM+vcpkg
712option (AMONGOC_USE_PMM "Enable PMM execution to bootstrap dependency packages automatically" ${PROJECT_IS_TOP_LEVEL} )
813if (AMONGOC_USE_PMM)
@@ -24,6 +29,12 @@ find_package(Threads REQUIRED)
2429# Note: We respect the BUILD_TESTING option from CTest.cmake
2530include (CTest)
2631
32+ # Tweak some options if we are added as a subdirectory project
33+ if (NOT PROJECT_IS_TOP_LEVEL)
34+ # We aren't the top-level project. Don't define test cases
35+ set (BUILD_TESTING FALSE )
36+ endif ()
37+
2738if (BUILD_TESTING)
2839 find_package (Catch2 CONFIG REQUIRED)
2940endif ()
@@ -56,14 +67,12 @@ if(PROJECT_IS_TOP_LEVEL)
5667 )
5768endif ()
5869
59- # Tweak some options if we are added as a subdirectory project
60- if (NOT PROJECT_IS_TOP_LEVEL)
61- # We aren't the top-level project. Don't define test cases
62- set (BUILD_TESTING FALSE )
63- endif ()
64-
65- # When compiling C++ with GCC, set a deeper diagnostics depth
66- add_compile_options ($<$<AND :$<CXX_COMPILER_ID:GNU>,$<COMPILE_LANGUAGE:CXX>>:-fconcepts-diagnostics-depth=4>)
70+ add_compile_options (
71+ # When compiling C++ with GCC, set a deeper diagnostics depth
72+ $<$<AND :$<CXX_COMPILER_ID:GNU>,$<COMPILE_LANGUAGE:CXX>>:-fconcepts-diagnostics-depth=4>
73+ # Enable large object files with MSVC
74+ $<$<CXX_COMPILER_ID:MSVC >:/bigobj>
75+ )
6776
6877# If we generate any DLLs, use a .dll.lib suffix for the importlibs, to distinguish
6978# them from actual static libraries
@@ -125,7 +134,19 @@ target_compile_definitions(amongoc PRIVATE NEO_ENABLE_CHECKS=0)
125134# Enable C++23 features on the target
126135# We currently only use C++23 for `auto(). Future revisions
127136# can remove these requirements for greater portability.
128- target_compile_features (amongoc PRIVATE cxx_std_23)
137+ target_compile_features (amongoc PRIVATE cxx_std_23 PUBLIC cxx_std_20 c_std_11)
138+
139+ # Tweaks for MSVC/Windows
140+ target_compile_options (amongoc
141+ PUBLIC
142+ # Enable the conforming preprocessor
143+ $<$<C_COMPILER_ID:MSVC >:/Zc:preprocessor>
144+ PRIVATE
145+ # Add caret diagnostics, they're prettier
146+ $<$<CXX_COMPILER_ID:MSVC >:/diagnostics:caret>
147+ )
148+ # Set the Windows SDK target to Windows 7+
149+ add_compile_definitions ($<$<PLATFORM_ID:Windows>:_WIN32_WINNT=0x601>)
129150
130151# Link deps and platform libs.
131152target_link_libraries (amongoc
@@ -155,7 +176,9 @@ if(BUILD_TESTING)
155176 )
156177 target_include_directories (amongoc-test PRIVATE src)
157178 catch_discover_tests(amongoc-test DISCOVERY_MODE PRE_TEST
158- PROPERTIES SKIP_REGULAR_EXPRESSION ":[0-9]+: SKIPPED:"
179+ PROPERTIES
180+ SKIP_REGULAR_EXPRESSION ":[0-9]+: SKIPPED:"
181+ TIMEOUT 5
159182 )
160183 target_compile_features (amongoc-test PRIVATE cxx_std_23)
161184
0 commit comments