Encoder: grow buffer size in opj_tcd_code_block_enc_allocate_data() to avoid write...
[openjpeg.git] / src / lib / openjp2 / CMakeLists.txt
index 0e8e9a9cd3be50a741c4cf8e7915c6a1aea8ba7d..9f79b9c3181e1e6efd44c4d6367430eef39eb3d2 100644 (file)
@@ -54,6 +54,8 @@ set(OPENJPEG_SRCS
   ${CMAKE_CURRENT_SOURCE_DIR}/opj_malloc.c
   ${CMAKE_CURRENT_SOURCE_DIR}/opj_malloc.h
   ${CMAKE_CURRENT_SOURCE_DIR}/opj_stdint.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/sparse_array.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/sparse_array.h
 )
 if(BUILD_JPIP)
   add_definitions(-DUSE_JPIP)
@@ -86,18 +88,31 @@ if(WIN32)
   else()
     add_definitions(-DOPJ_STATIC)
   endif()
+  add_library(${OPENJPEG_LIBRARY_NAME} ${OPENJPEG_SRCS})
+  set(INSTALL_LIBS ${OPENJPEG_LIBRARY_NAME})
+else()
+  if(BUILD_SHARED_LIBS AND BUILD_STATIC_LIBS)
+    # Builds both static and dynamic libs
+    add_library(${OPENJPEG_LIBRARY_NAME} SHARED ${OPENJPEG_SRCS})
+    add_library(openjp2_static STATIC ${OPENJPEG_SRCS})
+    set_target_properties(openjp2_static PROPERTIES OUTPUT_NAME ${OPENJPEG_LIBRARY_NAME})
+    set(INSTALL_LIBS ${OPENJPEG_LIBRARY_NAME} openjp2_static)
+  else()
+    add_library(${OPENJPEG_LIBRARY_NAME} ${OPENJPEG_SRCS})
+    set(INSTALL_LIBS ${OPENJPEG_LIBRARY_NAME})
+  endif()
 endif()
-add_library(${OPENJPEG_LIBRARY_NAME} ${OPENJPEG_SRCS})
+
 if(UNIX)
   target_link_libraries(${OPENJPEG_LIBRARY_NAME} m)
 endif()
 set_target_properties(${OPENJPEG_LIBRARY_NAME} PROPERTIES ${OPENJPEG_LIBRARY_PROPERTIES})
-if(${CMAKE_VERSION} VERSION_GREATER "2.8.11")
+if(NOT ${CMAKE_VERSION} VERSION_LESS "2.8.12")
   target_compile_options(${OPENJPEG_LIBRARY_NAME} PRIVATE ${OPENJP2_COMPILE_OPTIONS})
 endif()
 
 # Install library
-install(TARGETS ${OPENJPEG_LIBRARY_NAME}
+install(TARGETS ${INSTALL_LIBS}
   EXPORT OpenJPEGTargets
   RUNTIME DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
   LIBRARY DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
@@ -184,12 +199,20 @@ if(OPJ_USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
    TARGET_LINK_LIBRARIES(${OPENJPEG_LIBRARY_NAME} ${CMAKE_THREAD_LIBS_INIT})
 endif(OPJ_USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
 
-if(BUILD_BENCH_DWT)
-    add_executable(bench_dwt bench_dwt.c dwt.c opj_malloc.c thread.c)
+if(BUILD_UNIT_TESTS AND UNIX)
+    add_executable(bench_dwt bench_dwt.c)
     if(UNIX)
-        target_link_libraries(bench_dwt m)
+        target_link_libraries(bench_dwt m ${OPENJPEG_LIBRARY_NAME})
     endif()
     if(OPJ_USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
         target_link_libraries(bench_dwt ${CMAKE_THREAD_LIBS_INIT})
     endif(OPJ_USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
-endif(BUILD_BENCH_DWT)
+
+    add_executable(test_sparse_array test_sparse_array.c)
+    if(UNIX)
+        target_link_libraries(test_sparse_array m ${OPENJPEG_LIBRARY_NAME})
+    endif()
+    if(OPJ_USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
+        target_link_libraries(test_sparse_array ${CMAKE_THREAD_LIBS_INIT})
+    endif(OPJ_USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
+endif(BUILD_UNIT_TESTS AND UNIX)