diff --git a/CMakeLists.txt b/CMakeLists.txt
index 131b437..c29e604 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -62,6 +62,9 @@ option(WITH_JAVA "Build Java wrapper for the TurboJPEG library" FALSE)
 option(WITH_12BIT "Encode/decode JPEG images with 12-bit samples (implies WITH_SIMD=0 WITH_TURBOJPEG=0 WITH_ARITH_ENC=0 WITH_ARITH_DEC=0)" FALSE)
 option(ENABLE_STATIC "Build static libraries" TRUE)
 option(ENABLE_SHARED "Build shared libraries" TRUE)
+option(ENABLE_EXECUTABLES "Build executables" TRUE)
+option(INSTALL_DOCS "Install doc files" TRUE)
+option(INSTALL_HEADERS "Install header files" TRUE)
 
 if(WITH_12BIT)
   set(WITH_SIMD FALSE)
@@ -279,14 +282,16 @@ if(WITH_TURBOJPEG)
     target_link_libraries(turbojpeg jpeg-static)
     set_target_properties(turbojpeg PROPERTIES LINK_INTERFACE_LIBRARIES "")
 
-    add_executable(tjunittest tjunittest.c tjutil.c)
-    target_link_libraries(tjunittest turbojpeg)
+    if(ENABLE_EXECUTABLES)
+      add_executable(tjunittest tjunittest.c tjutil.c)
+      target_link_libraries(tjunittest turbojpeg)
 
-    add_executable(tjbench tjbench.c bmp.c tjutil.c rdbmp.c rdppm.c wrbmp.c
-      wrppm.c)
-    target_link_libraries(tjbench turbojpeg jpeg-static)
-    set_property(TARGET tjbench PROPERTY COMPILE_FLAGS
-      "-DBMP_SUPPORTED -DPPM_SUPPORTED")
+      add_executable(tjbench tjbench.c bmp.c tjutil.c rdbmp.c rdppm.c wrbmp.c
+        wrppm.c)
+      target_link_libraries(tjbench turbojpeg jpeg-static)
+      set_property(TARGET tjbench PROPERTY COMPILE_FLAGS
+        "-DBMP_SUPPORTED -DPPM_SUPPORTED")
+    endif()
   endif()
 
   if(ENABLE_STATIC)
@@ -299,14 +304,16 @@ if(WITH_TURBOJPEG)
       add_dependencies(turbojpeg-static simd)
     endif()
 
-    add_executable(tjunittest-static tjunittest.c tjutil.c)
-    target_link_libraries(tjunittest-static turbojpeg-static)
+    if(ENABLE_EXECUTABLES)
+      add_executable(tjunittest-static tjunittest.c tjutil.c)
+      target_link_libraries(tjunittest-static turbojpeg-static)
 
-    add_executable(tjbench-static tjbench.c bmp.c tjutil.c rdbmp.c rdppm.c
-      wrbmp.c wrppm.c)
-    target_link_libraries(tjbench-static turbojpeg-static jpeg-static)
-    set_property(TARGET tjbench-static PROPERTY COMPILE_FLAGS
-      "-DBMP_SUPPORTED -DPPM_SUPPORTED")
+      add_executable(tjbench-static tjbench.c bmp.c tjutil.c rdbmp.c rdppm.c
+        wrbmp.c wrppm.c)
+      target_link_libraries(tjbench-static turbojpeg-static jpeg-static)
+      set_property(TARGET tjbench-static PROPERTY COMPILE_FLAGS
+        "-DBMP_SUPPORTED -DPPM_SUPPORTED")
+    endif()
   endif()
 endif()
 
@@ -318,7 +325,7 @@ else()
   set(DJPEG_BMP_SOURCES wrbmp.c wrtarga.c)
 endif()
 
-if(ENABLE_STATIC)
+if(ENABLE_STATIC AND ENABLE_EXECUTABLES)
   add_executable(cjpeg-static cjpeg.c cdjpeg.c rdgif.c rdppm.c rdswitch.c
     ${CJPEG_BMP_SOURCES})
   set_property(TARGET cjpeg-static PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS})
@@ -334,10 +341,11 @@ if(ENABLE_STATIC)
   set_property(TARGET jpegtran-static PROPERTY COMPILE_FLAGS "-DUSE_SETMODE")
 endif()
 
-add_executable(rdjpgcom rdjpgcom.c)
-
-add_executable(wrjpgcom wrjpgcom.c)
+if(ENABLE_EXECUTABLES)
+  add_executable(rdjpgcom rdjpgcom.c)
 
+  add_executable(wrjpgcom wrjpgcom.c)
+endif()
 
 #
 # Tests
@@ -917,24 +925,30 @@ add_custom_target(installer
 
 if(WITH_TURBOJPEG)
   if(ENABLE_SHARED)
-    install(TARGETS turbojpeg tjbench
+    install(TARGETS turbojpeg
       ARCHIVE DESTINATION lib
       LIBRARY DESTINATION lib
       RUNTIME DESTINATION bin)
+    if(ENABLE_EXECUTABLES)
+      install(TARGETS tjbench
+        RUNTIME DESTINATION bin)
+    endif()
   endif()
   if(ENABLE_STATIC)
     install(TARGETS turbojpeg-static ARCHIVE DESTINATION lib)
-    if(NOT ENABLE_SHARED)
+    if(NOT ENABLE_SHARED AND ENABLE_EXECUTABLES)
       install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/tjbench-static.exe
         DESTINATION bin RENAME tjbench.exe)
     endif()
   endif()
-  install(FILES ${CMAKE_SOURCE_DIR}/turbojpeg.h DESTINATION include)
+  if(INSTALL_HEADERS)
+    install(FILES ${CMAKE_SOURCE_DIR}/turbojpeg.h DESTINATION include)
+  endif()
 endif()
 
 if(ENABLE_STATIC)
   install(TARGETS jpeg-static ARCHIVE DESTINATION lib)
-  if(NOT ENABLE_SHARED)
+  if(NOT ENABLE_SHARED AND ENABLE_EXECUTABLES)
     install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/cjpeg-static.exe
       DESTINATION bin RENAME cjpeg.exe)
     install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/djpeg-static.exe
@@ -944,17 +958,23 @@ if(ENABLE_STATIC)
   endif()
 endif()
 
-install(TARGETS rdjpgcom wrjpgcom RUNTIME DESTINATION bin)
+if(ENABLE_EXECUTABLES)
+  install(TARGETS rdjpgcom wrjpgcom RUNTIME DESTINATION bin)
+endif()
 
-install(FILES ${CMAKE_SOURCE_DIR}/README.ijg ${CMAKE_SOURCE_DIR}/README.md
-  ${CMAKE_SOURCE_DIR}/example.c ${CMAKE_SOURCE_DIR}/libjpeg.txt
-  ${CMAKE_SOURCE_DIR}/structure.txt ${CMAKE_SOURCE_DIR}/usage.txt
-  ${CMAKE_SOURCE_DIR}/wizard.txt
-  DESTINATION doc)
+if(INSTALL_DOCS)
+  install(FILES ${CMAKE_SOURCE_DIR}/README.ijg ${CMAKE_SOURCE_DIR}/README.md
+    ${CMAKE_SOURCE_DIR}/example.c ${CMAKE_SOURCE_DIR}/libjpeg.txt
+    ${CMAKE_SOURCE_DIR}/structure.txt ${CMAKE_SOURCE_DIR}/usage.txt
+    ${CMAKE_SOURCE_DIR}/wizard.txt
+    DESTINATION doc)
+endif()
 
-install(FILES ${CMAKE_BINARY_DIR}/jconfig.h ${CMAKE_SOURCE_DIR}/jerror.h
-  ${CMAKE_SOURCE_DIR}/jmorecfg.h ${CMAKE_SOURCE_DIR}/jpeglib.h
-  DESTINATION include)
+if(INSTALL_HEADERS)
+  install(FILES ${CMAKE_BINARY_DIR}/jconfig.h ${CMAKE_SOURCE_DIR}/jerror.h
+    ${CMAKE_SOURCE_DIR}/jmorecfg.h ${CMAKE_SOURCE_DIR}/jpeglib.h
+    DESTINATION include)
+endif()
 
 configure_file("${CMAKE_SOURCE_DIR}/cmakescripts/cmake_uninstall.cmake.in"
   "cmake_uninstall.cmake" IMMEDIATE @ONLY)

diff --git a/sharedlib/CMakeLists.txt b/sharedlib/CMakeLists.txt
index d423cce..9da7c6e 100644
--- a/sharedlib/CMakeLists.txt
+++ b/sharedlib/CMakeLists.txt
@@ -50,24 +50,31 @@ else()
 	set(DJPEG_BMP_SOURCES ../wrbmp.c ../wrtarga.c)
 endif()
 
-add_executable(cjpeg ../cjpeg.c ../cdjpeg.c ../rdgif.c ../rdppm.c
-  ../rdswitch.c ${CJPEG_BMP_SOURCES})
-set_property(TARGET cjpeg PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS})
-target_link_libraries(cjpeg jpeg)
+if(ENABLE_EXECUTABLES)
+  add_executable(cjpeg ../cjpeg.c ../cdjpeg.c ../rdgif.c ../rdppm.c
+    ../rdswitch.c ${CJPEG_BMP_SOURCES})
+  set_property(TARGET cjpeg PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS})
+  target_link_libraries(cjpeg jpeg)
 
-add_executable(djpeg ../djpeg.c ../cdjpeg.c ../rdcolmap.c ../rdswitch.c
-  ../wrgif.c ../wrppm.c ${DJPEG_BMP_SOURCES})
-set_property(TARGET djpeg PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS})
-target_link_libraries(djpeg jpeg)
+  add_executable(djpeg ../djpeg.c ../cdjpeg.c ../rdcolmap.c ../rdswitch.c
+    ../wrgif.c ../wrppm.c ${DJPEG_BMP_SOURCES})
+  set_property(TARGET djpeg PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS})
+  target_link_libraries(djpeg jpeg)
 
-add_executable(jpegtran ../jpegtran.c ../cdjpeg.c ../rdswitch.c ../transupp.c)
-target_link_libraries(jpegtran jpeg)
-set_property(TARGET jpegtran PROPERTY COMPILE_FLAGS "-DUSE_SETMODE")
+  add_executable(jpegtran ../jpegtran.c ../cdjpeg.c ../rdswitch.c ../transupp.c)
+  target_link_libraries(jpegtran jpeg)
+  set_property(TARGET jpegtran PROPERTY COMPILE_FLAGS "-DUSE_SETMODE")
 
-add_executable(jcstest ../jcstest.c)
-target_link_libraries(jcstest jpeg)
+  add_executable(jcstest ../jcstest.c)
+  target_link_libraries(jcstest jpeg)
 
-install(TARGETS jpeg cjpeg djpeg jpegtran
+  install(TARGETS cjpeg djpeg jpegtran
+    ARCHIVE DESTINATION lib
+    LIBRARY DESTINATION lib
+    RUNTIME DESTINATION bin)
+endif()
+
+install(TARGETS jpeg
   ARCHIVE DESTINATION lib
   LIBRARY DESTINATION lib
   RUNTIME DESTINATION bin)
