--- CMakeLists.txt.orig	2023-05-05 19:42:19 UTC
+++ CMakeLists.txt
@@ -93,15 +93,27 @@ message(STATUS "Host system arch is: ${CMAKE_SYSTEM_PR
 # Detection of available CPU optimizations
 if(NOT DISABLE_CPU_OPTIMIZATION)
     if(UNIX AND NOT APPLE)
-        message(STATUS "Looking for available CPU optimizations on Linux/BSD system...")
-        execute_process(COMMAND grep -c "avx2" /proc/cpuinfo
-            OUTPUT_VARIABLE AVX2_PRESENT)
-        execute_process(COMMAND grep -c "avx " /proc/cpuinfo
-            OUTPUT_VARIABLE AVX_PRESENT)
-        execute_process(COMMAND grep -c "sse4_1 " /proc/cpuinfo
-            OUTPUT_VARIABLE SSE_PRESENT)
-        execute_process(COMMAND grep -c "neon" /proc/cpuinfo
-            OUTPUT_VARIABLE NEON_PRESENT)
+        if ( ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
+            message(STATUS "Looking for available CPU optimizations on FreeBSD system...")
+            execute_process(COMMAND grep -c "AVX," /var/run/dmesg.boot
+                OUTPUT_VARIABLE AVX_PRESENT)
+            execute_process(COMMAND grep -c "AVX2," /var/run/dmesg.boot
+                OUTPUT_VARIABLE AVX2_PRESENT)
+            execute_process(COMMAND grep -c "SSE," /var/run/dmesg.boot
+                OUTPUT_VARIABLE SSE_PRESENT)
+            execute_process(COMMAND grep -c "NEON," /var/run/dmesg.boot
+                OUTPUT_VARIABLE NEON_PRESENT)
+        else()
+            message(STATUS "Looking for available CPU optimizations on Linux system...")
+            execute_process(COMMAND grep -c "avx2" /proc/cpuinfo
+                OUTPUT_VARIABLE AVX2_PRESENT)
+            execute_process(COMMAND grep -c "avx " /proc/cpuinfo
+                OUTPUT_VARIABLE AVX_PRESENT)
+            execute_process(COMMAND grep -c "sse4_1 " /proc/cpuinfo
+                OUTPUT_VARIABLE SSE_PRESENT)
+            execute_process(COMMAND grep -c "neon" /proc/cpuinfo
+                OUTPUT_VARIABLE NEON_PRESENT)
+        endif()
     elseif(APPLE)
         if(BUILD_OSX_UNIVERSAL)
             # Presume AVX and SSE are enabled on the x86 side. (AVX2 is not guaranteed depending
@@ -164,38 +176,8 @@ elseif(${NEON} AND (${NEON_PRESENT} OR ${NEON_PRESENT}
     set(LPCNET_C_PROC_FLAGS -mfpu=neon -march=armv8-a -mtune=cortex-a53)
 endif()
 
-# grab latest NN model (or substitute your own)
-set(LPCNET_ROOT http://rowetel.com/downloads/deep/)
-set(LPCNET_FILE lpcnet_191005_v1.0.tgz)
-set(LPCNET_URL ${LPCNET_ROOT}${LPCNET_FILE})
-
-if(EXISTS ${CMAKE_BINARY_DIR}/${LPCNET_FILE})
-    set(lpcnet_SOURCE_DIR ${CMAKE_BINARY_DIR}/src)
-    file(MAKE_DIRECTORY ${lpcnet_SOURCE_DIR})
-    execute_process(COMMAND tar -xzf ${CMAKE_BINARY_DIR}/${LPCNET_FILE} -C ${CMAKE_BINARY_DIR}/src)
-
-# Work around not having the FetchContent module.
-elseif(CMAKE_VERSION VERSION_LESS 3.11.4)
-    set(lpcnet_SOURCE_DIR ${CMAKE_BINARY_DIR}/src)
-    if(NOT EXISTS ${lpcnet_SOURCE_DIR})
-        file(DOWNLOAD ${LPCNET_URL}
-            ${CMAKE_BINARY_DIR}/${LPCNET_FILE}
-            SHOW_PROGRESS
-        )
-        file(MAKE_DIRECTORY ${lpcnet_SOURCE_DIR})
-        execute_process(COMMAND tar -xzf ${CMAKE_BINARY_DIR}/${LPCNET_FILE} -C ${CMAKE_BINARY_DIR}/src)
-    endif()
-else()
-    include(FetchContent)
-    FetchContent_Declare(
-        lpcnet
-        URL ${LPCNET_URL})
-    FetchContent_GetProperties(lpcnet)
-    if(NOT lpcnet_POPULATED)
-        FetchContent_Populate(lpcnet)
-    endif()
-endif()
-
+## grab latest NN model (or substitute your own)
+set(lpcnet_SOURCE_DIR ${WRKSRC}/src)
 add_subdirectory(src)
 
 # Ctests ----------------------------------------------------------------------
