Skip to content

Commit

Permalink
experimental CMAKE_HEADER_ONLY flag, refs #2114
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 629984062
  • Loading branch information
jan-wassenberg authored and copybara-github committed May 2, 2024
1 parent 3adbb62 commit 28494a4
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ set(HWY_CMAKE_RVV ON CACHE BOOL "Set copts for RISCV with RVV?")
# arise due to compiler/platform changes. Enable this in CI/tests.
set(HWY_WARNINGS_ARE_ERRORS OFF CACHE BOOL "Add -Werror flag?")

# Experimental support for header-only builds
set(HWY_CMAKE_HEADER_ONLY OFF CACHE BOOL "Change to header-only?")

set(HWY_ENABLE_CONTRIB ON CACHE BOOL "Include contrib/")
set(HWY_ENABLE_EXAMPLES ON CACHE BOOL "Build examples")
set(HWY_ENABLE_INSTALL ON CACHE BOOL "Install library")
Expand Down Expand Up @@ -137,9 +140,7 @@ list(APPEND HWY_CONTRIB_SOURCES
endif() # HWY_ENABLE_CONTRIB

set(HWY_SOURCES
hwy/abort.cc
hwy/abort.h
hwy/aligned_allocator.cc
hwy/aligned_allocator.h
hwy/base.h
hwy/cache_control.h
Expand All @@ -148,7 +149,6 @@ set(HWY_SOURCES
hwy/foreach_target.h
hwy/highway_export.h
hwy/highway.h
hwy/nanobenchmark.cc
hwy/nanobenchmark.h
hwy/ops/arm_neon-inl.h
hwy/ops/arm_sve-inl.h
Expand All @@ -164,20 +164,28 @@ set(HWY_SOURCES
hwy/ops/x86_128-inl.h
hwy/ops/x86_256-inl.h
hwy/ops/x86_512-inl.h
hwy/per_target.cc
hwy/per_target.h
hwy/print-inl.h
hwy/print.cc
hwy/print.h
hwy/profiler.h
hwy/robust_statistics.h
hwy/targets.cc
hwy/targets.h
hwy/timer-inl.h
hwy/timer.cc
hwy/timer.h
)

if (HWY_CMAKE_HEADER_ONLY)
list(APPEND HWY_SOURCES
hwy/abort.cc
hwy/aligned_allocator.cc
hwy/nanobenchmark.cc
hwy/per_target.cc
hwy/print.cc
hwy/targets.cc
hwy/timer.cc
)
endif()

set(HWY_TEST_SOURCES
hwy/tests/hwy_gtest.h
hwy/tests/test_util-inl.h
Expand Down Expand Up @@ -367,6 +375,10 @@ else()

endif() # !MSVC

if (HWY_CMAKE_HEADER_ONLY)
list(APPEND HWY_FLAGS -DHWY_HEADER_ONLY)
endif()

include(CheckIncludeFile)
check_include_file(sys/auxv.h HAVE_SYS_AUXV_H)
check_include_file(asm/hwcap.h HAVE_ASM_HWCAP_H)
Expand Down

0 comments on commit 28494a4

Please sign in to comment.