--- CMakeLists.txt.orig	2022-04-18 18:07:26 UTC
+++ CMakeLists.txt
@@ -141,6 +141,12 @@ attach a debugger which will then receive the console 
 # install locations
 #
 
+if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
+  set (FREEBSD TRUE)
+  link_directories("/usr/lib" "${LOCALBASE}/lib")
+  include_directories("/usr/include" "${LOCALBASE}/include")
+endif()
+
 if (APPLE)
   set (CMAKE_INSTALL_BINDIR ${CMAKE_PROJECT_NAME}.app/Contents/MacOS)
   set (CMAKE_INSTALL_DATAROOTDIR ${CMAKE_PROJECT_NAME}.app/Contents/Resources)
@@ -875,8 +881,20 @@ find_package (Boost 1.62 REQUIRED COMPONENTS log_setup
 #
 # OpenMP
 #
-find_package (OpenMP)
+#    OpenMP_C_FLAGS - flags to add to the C compiler for OpenMP support
+#    OpenMP_CXX_FLAGS - flags to add to the CXX compiler for OpenMP support
+#    OpenMP_Fortran_FLAGS - flags to add to the Fortran compiler for OpenMP support
+#    OPENMP_FOUND - true if openmp is detected
 
+if (FREEBSD)
+  set (OpenMP_C_FLAGS "-openmp")
+  set (OpenMP_CXX_FLAGS "-openmp")
+  set (OpenMP_Fortran_FLAGS "-openmp")
+  set (OPENMP_FOUND TRUE)
+else()
+  find_package (OpenMP)
+endif()
+
 #
 # fftw3 single precision library
 #
@@ -923,7 +941,7 @@ set (CMAKE_VISIBILITY_INLINES_HIDDEN ON)
 #
 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
 
-set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -fexceptions -frtti")
+set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wno-vla -Wextra -fexceptions -frtti")
 
 if (NOT APPLE)
   set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-pragmas")
@@ -1169,7 +1187,7 @@ add_executable (encode77 lib/77bit/encode77.f90)
 target_link_libraries (encode77 wsjt_fort wsjt_cxx)
 
 add_executable (wsprsim ${wsprsim_CSRCS})
-target_link_libraries (wsprsim ${LIBM_LIBRARIES})
+target_link_libraries (wsprsim ${LIBM_LIBRARIES} -lm)
 
 add_executable (jt4code lib/jt4code.f90)
 target_link_libraries (jt4code wsjt_fort wsjt_cxx)
@@ -1211,6 +1229,12 @@ target_link_libraries (ldpcsim240_74 wsjt_fort wsjt_cx
 
 endif(WSJT_BUILD_UTILS)
 
+if(FREEBSD)
+   set (extraLIBS "ltdl" "usb")
+ else()
+   set (extraLIBS "")
+endif()
+
 add_executable (fmtave lib/fmtave.f90)
 
 add_executable (fcal lib/fcal.f90)
@@ -1410,6 +1434,11 @@ if (${OPENMP_FOUND} OR APPLE)
 else (${OPENMP_FOUND} OR APPLE)
   target_link_libraries (jt9 wsjt_fort wsjt_cxx fort_qt)
 endif (${OPENMP_FOUND} OR APPLE)
+if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
+  set_target_properties (jt9 PROPERTIES
+    LINK_FLAGS -Wl,-zexecstack
+    )
+endif ()
 
 if (WIN32)
   # build map65
@@ -1601,12 +1630,12 @@ install (PROGRAMS
   RENAME rigctld-wsjtx${CMAKE_EXECUTABLE_SUFFIX}
   )
 
-install (PROGRAMS
-  ${RIGCTLCOM_EXE}
-  DESTINATION ${CMAKE_INSTALL_BINDIR}
-  #COMPONENT runtime
-  RENAME rigctlcom-wsjtx${CMAKE_EXECUTABLE_SUFFIX}
-  )
+#install (PROGRAMS
+#  ${RIGCTLCOM_EXE}
+#  DESTINATION ${CMAKE_INSTALL_BINDIR}
+#  #COMPONENT runtime
+#  RENAME rigctlcom-wsjtx${CMAKE_EXECUTABLE_SUFFIX}
+#  )
 
 install (FILES
   README
