Skip to content

Commit df96277

Browse files
committed
Microsoft build fixes - v0.3.0_4
1 parent c5f5eb0 commit df96277

File tree

2 files changed

+33
-20
lines changed

2 files changed

+33
-20
lines changed

CMakeLists.txt

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -111,28 +111,40 @@ else()
111111
endif()
112112

113113
# Try to find system lz4 first, fetch if not found
114-
find_package(PkgConfig QUIET)
115-
if(PkgConfig_FOUND)
116-
pkg_check_modules(LZ4 QUIET liblz4)
114+
# Prefer CMake config (gives proper targets with full paths on all platforms)
115+
find_package(lz4 CONFIG QUIET)
116+
if(lz4_FOUND)
117+
message(STATUS "Found lz4 via CMake config")
118+
if(CARQUET_BUILD_SHARED AND TARGET LZ4::lz4_shared)
119+
set(LZ4_LIBRARIES LZ4::lz4_shared)
120+
elseif(TARGET LZ4::lz4_static)
121+
set(LZ4_LIBRARIES LZ4::lz4_static)
122+
elseif(TARGET LZ4::lz4_shared)
123+
set(LZ4_LIBRARIES LZ4::lz4_shared)
124+
elseif(TARGET lz4::lz4)
125+
set(LZ4_LIBRARIES lz4::lz4)
126+
endif()
127+
# Only mark as found if we actually resolved a target
128+
if(LZ4_LIBRARIES)
129+
set(LZ4_FOUND TRUE)
130+
else()
131+
message(STATUS "lz4 CMake config found but no known target — trying pkg-config")
132+
set(LZ4_FOUND FALSE)
133+
endif()
117134
endif()
118135

119-
if(LZ4_FOUND)
120-
message(STATUS "Found system liblz4")
121-
else()
122-
# Try CMake config (vcpkg, conda, etc.)
123-
find_package(lz4 CONFIG QUIET)
124-
if(lz4_FOUND)
125-
message(STATUS "Found lz4 via CMake config")
126-
if(CARQUET_BUILD_SHARED AND TARGET LZ4::lz4_shared)
127-
set(LZ4_LIBRARIES LZ4::lz4_shared)
128-
elseif(TARGET LZ4::lz4_static)
129-
set(LZ4_LIBRARIES LZ4::lz4_static)
130-
elseif(TARGET LZ4::lz4_shared)
131-
set(LZ4_LIBRARIES LZ4::lz4_shared)
132-
elseif(TARGET lz4::lz4)
133-
set(LZ4_LIBRARIES lz4::lz4)
136+
if(NOT LZ4_FOUND)
137+
find_package(PkgConfig QUIET)
138+
if(PkgConfig_FOUND)
139+
pkg_check_modules(LZ4 QUIET liblz4)
140+
if(LZ4_FOUND)
141+
message(STATUS "Found system liblz4 via pkg-config")
142+
# Use LINK_LIBRARIES (full paths) instead of LIBRARIES (bare names)
143+
# to avoid MSVC linker failing to locate the .lib file
144+
if(LZ4_LINK_LIBRARIES)
145+
set(LZ4_LIBRARIES ${LZ4_LINK_LIBRARIES})
146+
endif()
134147
endif()
135-
set(LZ4_FOUND TRUE)
136148
endif()
137149
endif()
138150

@@ -407,7 +419,7 @@ endif()
407419
# Create library
408420
if(CARQUET_BUILD_SHARED)
409421
add_library(carquet SHARED ${CARQUET_SOURCES})
410-
target_compile_definitions(carquet PRIVATE CARQUET_BUILD_SHARED)
422+
target_compile_definitions(carquet PRIVATE CARQUET_BUILD_SHARED CARQUET_BUILDING_DLL)
411423
else()
412424
add_library(carquet STATIC ${CARQUET_SOURCES})
413425
endif()

src/simd/x86/avx2_ops.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ static inline int msvc_ctz(unsigned int x) {
2828
return (int)index;
2929
}
3030
#define __builtin_ctz(x) msvc_ctz(x)
31+
#define __builtin_popcount(x) __popcnt(x)
3132
#endif
3233
#include <immintrin.h>
3334

0 commit comments

Comments
 (0)