--- CMakeLists.txt.orig	2022-11-11 20:23:57 UTC
+++ CMakeLists.txt
@@ -243,9 +243,11 @@ if(DAKOTA_MODULE_DAKOTA)
   endif()
 
   # Legacy examples
-  add_subdirectory(examples)
+  if (FREEBSD_ENABLE_EXAMPLES)
+    add_subdirectory(examples)
+  endif()
   # New examples library, taking care to guard against empty directory
-  if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/dakota-examples/CMakeLists.txt")
+  if(FREEBSD_ENABLE_EXAMPLES AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/dakota-examples/CMakeLists.txt")
     add_subdirectory(dakota-examples)
   endif()
 
@@ -268,19 +270,23 @@ install(FILES INSTALL LICENSE COPYRIGHT README
   DESTINATION ${DAKOTA_TOPFILES_INSTALL}
   )
 
+if (FREEBSD_ENABLE_EXAMPLES)
 install(DIRECTORY examples DESTINATION ${DAKOTA_EXAMPLES_INSTALL}
   USE_SOURCE_PERMISSIONS
   PATTERN "CMakeLists.txt" EXCLUDE
   PATTERN "*.c" EXCLUDE 
   PATTERN "*.f" EXCLUDE 
   )
+endif()
 
+if (FREEBSD_INSTALL_TESTS)
 install(DIRECTORY test DESTINATION ${DAKOTA_TEST_INSTALL}
   PATTERN "CMakeLists.txt" EXCLUDE
   PATTERN "*.c" EXCLUDE 
   PATTERN "*.cpp" EXCLUDE 
   PATTERN "*.f" EXCLUDE 
   )
+endif()
 
 if(DAKOTA_VERSION_FOUND)
    install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/VERSION DESTINATION
