Skip to content

Commit 8fc8184

Browse files
committed
Adapt CMakelLists.txt for Windows conda build
Signed-off-by: Julien Jerphanion <[email protected]>
1 parent 476acdd commit 8fc8184

File tree

2 files changed

+79
-9
lines changed

2 files changed

+79
-9
lines changed

cpp/CMakeLists.txt

Lines changed: 65 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,82 @@ if(ARCTICDB_SANITIZER_FLAGS)
7575
message(STATUS "Building ArcticDB with sanitizers. Compiler flags: ${ARCTICDB_SANITIZER_FLAGS}")
7676
endif()
7777

78+
if(${ARCTICDB_USING_CONDA})
79+
# Required to be able to include headers from glog since glog 0.7
80+
# See: https://github.com/google/glog/pull/1030
81+
add_compile_definitions(GLOG_USE_GLOG_EXPORT)
82+
endif()
83+
7884
if(WIN32)
7985
add_compile_definitions(
8086
NOGDI WIN32_LEAN_AND_MEAN HAVE_SNPRINTF NOMINMAX
8187
"$<$<CONFIG:Debug>:DEBUG_BUILD>"
8288
)
89+
if(${ARCTICDB_USING_CONDA})
90+
add_compile_definitions(
91+
# Required to link against zstd.dll
92+
# See: https://github.com/facebook/zstd/blob/dev/lib/zstd.h#L47-L53
93+
ZSTD_DLL_IMPORT=1
94+
95+
# Required to link against lz4.dll
96+
# See: https://github.com/lz4/lz4/blob/dev/lib/lz4frame.h#L79-L85
97+
LZ4_DLL_IMPORT=1
98+
99+
# Required to link against protobuf.dll
100+
# See: https://github.com/protocolbuffers/protobuf/blob/384fabf35a9b5d1f1502edaf9a139b1f51551a01/cmake/README.md?plain=1#L296-L319
101+
PROTOBUF_USE_DLLS=1
102+
103+
# Required to link against fmt.dll
104+
FMT_SHARED=1
105+
106+
# Required to link against spdlog.dll
107+
# See: https://github.com/gabime/spdlog/blob/faa0a7a9c5a3550ed5461fab7d8e31c37fd1a2ef/include/spdlog/common.h#L28-L48
108+
SPDLOG_COMPILED_LIB=1
109+
SPDLOG_SHARED_LIB=1
110+
SPDLOG_HEADER_ONLY=0
111+
112+
# Indicate that we are building using fmt's external DLL instead of spdlog's internal fmt
113+
SPDLOG_FMT_EXTERNAL=1
114+
115+
# Required to link against azure-core.dll
116+
# See: https://github.com/Azure/azure-sdk-for-cpp/blob/c914c0933fa4835c6618a42bb276d6077423b170/sdk/storage/azure-storage-common/inc/azure/storage/common/dll_import_export.hpp#L19
117+
AZ_CORE_DLL=1
118+
119+
# Required to link against azure-identity.dll
120+
# See: https://github.com/Azure/azure-sdk-for-cpp/blob/bf36db827f5ea1ef2e38953875c6c335b4242b2e/sdk/identity/azure-identity/inc/azure/identity/dll_import_export.hpp
121+
AZ_IDENTITY_DLL=1
122+
123+
# Required to link against azure-storage-common.dll
124+
# See: https://github.com/Azure/azure-sdk-for-cpp/blob/c914c0933fa4835c6618a42bb276d6077423b170/sdk/storage/azure-storage-common/inc/azure/storage/common/dll_import_export.hpp#L19
125+
AZ_STORAGE_COMMON_DLL=1
126+
127+
# Required to link against azure-storage-blobs.dll
128+
# See: https://github.com/Azure/azure-sdk-for-cpp/blob/bf36db827f5ea1ef2e38953875c6c335b4242b2e/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/dll_import_export.hpp
129+
AZ_STORAGE_BLOBS_DLL=1
130+
)
131+
endif()
83132

84133
# We always generate the debug info on Windows since those are not in the final .dll.
85134
# sccache needs the /Z7 format, but the linker will still produce .pdb files.
86135
# Guide to MSVC compilation warnings https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warnings-c4000-through-c4199?view=msvc-170
87136
add_compile_options(
88137
/DWIN32 /D_WINDOWS /GR /EHsc /bigobj /Z7 /wd4244 /wd4267
89-
"$<$<CONFIG:Debug>:/Od;/MTd>"
90-
"$<$<CONFIG:Release>:/MT;/Ox>"
91138
)
139+
140+
if(${ARCTICDB_USING_CONDA})
141+
# Conda builds use dynamic linkage
142+
add_compile_options(
143+
"$<$<CONFIG:Debug>:/MDd>"
144+
"$<$<CONFIG:Release>:/MD;/Ox>"
145+
)
146+
else()
147+
# PyPI builds use static linkage
148+
add_compile_options(
149+
"$<$<CONFIG:Debug>:/Od;/MTd>"
150+
"$<$<CONFIG:Release>:/MT;/Ox>"
151+
)
152+
endif()
153+
92154
if(${ARCTICDB_MSVC_OMIT_RUNTIME_CHECKS})
93155
message(STATUS "Removing MSVC runtime checks")
94156
foreach(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
@@ -97,9 +159,7 @@ if(WIN32)
97159
endif()
98160
else()
99161
if(${ARCTICDB_USING_CONDA})
100-
# Required to be able to include headers from glog since glog 0.7
101-
# See: https://github.com/google/glog/pull/1030
102-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra -DGLOG_USE_GLOG_EXPORT")
162+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
103163
else()
104164
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
105165
endif()

cpp/arcticdb/CMakeLists.txt

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,19 @@ if (NOT MSVC)
168168
add_compile_options("-fno-omit-frame-pointer")
169169
else()
170170
add_compile_options(
171-
/WX
172171
/wd4250 # Suppress inherits via dominance warning
173-
/we4189 # Unused local variable is an error
174172
/we4100 # Unused function parameter is an error
175173
)
174+
if(NOT ${ARCTICDB_USING_CONDA})
175+
# Some of the warnings are due to the protobuf library,
176+
# observed for the conda-forge builds.
177+
# For now, we do not want to treat warnings as errors for those builds.
178+
# See: https://github.com/protocolbuffers/protobuf/pull/20840
179+
add_compile_options(
180+
/WX
181+
/we4189 # Unused local variable is an error
182+
)
183+
endif()
176184
endif ()
177185

178186
## Core library without python bindings ##
@@ -692,8 +700,10 @@ if (WIN32)
692700
arcticdb_core_object
693701
PRIVATE
694702
/W4
695-
/external:I${CMAKE_SOURCE_DIR}/vcpkg
696-
/external:I${CMAKE_SOURCE_DIR}/third_party
703+
# The distribution on conda-forge only uses the source code of ArcticDB itself
704+
# without submodules and dependencies from `vcpkg` or `third_party`.
705+
$<$<NOT:$<BOOL:${ARCTICDB_USING_CONDA}>>:/external:I${CMAKE_SOURCE_DIR}/vcpkg>
706+
$<$<NOT:$<BOOL:${ARCTICDB_USING_CONDA}>>:/external:I${CMAKE_SOURCE_DIR}/third_party>
697707
/Zc:__cplusplus #needed to get the correct __cplusplus macro value
698708
)
699709
endif()

0 commit comments

Comments
 (0)