2012-08-30 19:14:39 +02:00
|
|
|
include_regular_expression("^.*$")
|
2012-10-01 09:49:52 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/opj_config.h
|
|
|
|
DESTINATION ${OPENJPEG_INSTALL_INCLUDE_DIR} COMPONENT Headers)
|
|
|
|
|
|
|
|
include_directories(
|
2016-09-26 12:01:31 +02:00
|
|
|
${${OPENJPEG_NAMESPACE}_BINARY_DIR}/src/lib/openjp2 # opj_config.h and opj_config_private.h
|
2012-10-01 09:49:52 +02:00
|
|
|
)
|
2006-01-25 17:32:48 +01:00
|
|
|
# Defines the source code for the library
|
2012-08-30 19:14:39 +02:00
|
|
|
set(OPENJPEG_SRCS
|
2016-05-25 16:34:52 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/thread.c
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/thread.h
|
2011-04-14 00:38:50 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/bio.c
|
2015-07-18 01:50:17 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/bio.h
|
2011-04-14 00:38:50 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cio.c
|
2015-07-18 01:50:17 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cio.h
|
2011-04-14 00:38:50 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/dwt.c
|
2015-07-18 01:50:17 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/dwt.h
|
2011-04-14 00:38:50 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/event.c
|
2015-07-18 01:50:17 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/event.h
|
2011-04-14 00:38:50 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/image.c
|
2015-07-18 01:50:17 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/image.h
|
2012-10-24 17:19:51 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/invert.c
|
2015-07-18 01:50:17 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/invert.h
|
2011-04-14 00:38:50 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/j2k.c
|
2015-07-18 01:50:17 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/j2k.h
|
2011-04-14 00:38:50 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/jp2.c
|
2015-07-18 01:50:17 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/jp2.h
|
2011-04-14 00:38:50 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/mct.c
|
2015-07-18 01:50:17 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/mct.h
|
2011-04-14 00:38:50 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/mqc.c
|
2015-07-18 01:50:17 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/mqc.h
|
2015-12-27 20:14:47 +01:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/mqc_inl.h
|
2011-04-14 00:38:50 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/openjpeg.c
|
2015-07-18 01:50:17 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/openjpeg.h
|
2012-10-15 14:58:32 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_clock.c
|
2015-07-18 01:50:17 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_clock.h
|
2011-04-14 00:38:50 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/pi.c
|
2015-07-18 01:50:17 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/pi.h
|
2011-04-14 00:38:50 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/t1.c
|
2015-07-18 01:50:17 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/t1.h
|
2011-04-14 00:38:50 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/t2.c
|
2015-07-18 01:50:17 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/t2.h
|
2011-04-14 00:38:50 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/tcd.c
|
2015-07-18 01:50:17 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/tcd.h
|
2011-04-14 00:38:50 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/tgt.c
|
2015-07-18 01:50:17 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/tgt.h
|
2012-10-15 11:44:34 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/function_list.c
|
2015-07-18 01:50:17 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/function_list.h
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_codec.h
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_includes.h
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_intmath.h
|
2015-10-09 22:03:35 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_malloc.c
|
2015-07-18 01:50:17 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_malloc.h
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_stdint.h
|
2006-01-25 10:23:17 +01:00
|
|
|
)
|
2012-10-25 09:39:59 +02:00
|
|
|
if(BUILD_JPIP)
|
|
|
|
add_definitions(-DUSE_JPIP)
|
|
|
|
set(OPENJPEG_SRCS
|
|
|
|
${OPENJPEG_SRCS}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cidx_manager.c
|
2015-07-18 01:50:17 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cidx_manager.h
|
2012-10-25 09:39:59 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/phix_manager.c
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/ppix_manager.c
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/thix_manager.c
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/tpix_manager.c
|
2015-07-18 01:50:17 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/indexbox_manager.h
|
2012-10-25 09:39:59 +02:00
|
|
|
)
|
|
|
|
endif()
|
2010-11-28 18:07:04 +01:00
|
|
|
|
2015-07-04 00:04:55 +02:00
|
|
|
option(OPJ_DISABLE_TPSOT_FIX "Disable TPsot==TNsot fix. See https://github.com/uclouvain/openjpeg/issues/254." OFF)
|
|
|
|
if(OPJ_DISABLE_TPSOT_FIX)
|
|
|
|
add_definitions(-DOPJ_DISABLE_TPSOT_FIX)
|
|
|
|
endif()
|
|
|
|
|
2016-05-25 16:34:52 +02:00
|
|
|
# Special case for old i586-mingw32msvc-gcc cross compiler
|
|
|
|
if(NOT WIN32 AND CMAKE_COMPILER_IS_GNUCC AND CMAKE_C_COMPILER MATCHES ".*mingw32msvc.*" )
|
|
|
|
set(WIN32 YES)
|
|
|
|
endif()
|
|
|
|
|
2010-12-05 16:19:57 +01:00
|
|
|
# Build the library
|
2012-08-30 19:14:39 +02:00
|
|
|
if(WIN32)
|
|
|
|
if(BUILD_SHARED_LIBS)
|
|
|
|
add_definitions(-DOPJ_EXPORTS)
|
2012-08-30 19:20:03 +02:00
|
|
|
else()
|
2012-08-30 19:14:39 +02:00
|
|
|
add_definitions(-DOPJ_STATIC)
|
2012-08-30 19:20:03 +02:00
|
|
|
endif()
|
2017-06-16 13:58:25 +02:00
|
|
|
add_library(${OPENJPEG_LIBRARY_NAME} ${OPENJPEG_SRCS})
|
2017-07-13 11:34:15 +02:00
|
|
|
set(INSTALL_LIBS ${OPENJPEG_LIBRARY_NAME})
|
2017-06-16 13:58:25 +02:00
|
|
|
else()
|
|
|
|
# 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})
|
2017-07-13 11:34:15 +02:00
|
|
|
set(INSTALL_LIBS ${OPENJPEG_LIBRARY_NAME} openjp2_static)
|
2012-08-30 19:20:03 +02:00
|
|
|
endif()
|
2017-06-16 13:58:25 +02:00
|
|
|
|
2012-08-30 19:14:39 +02:00
|
|
|
if(UNIX)
|
|
|
|
target_link_libraries(${OPENJPEG_LIBRARY_NAME} m)
|
2012-08-30 19:20:03 +02:00
|
|
|
endif()
|
2012-08-30 19:14:39 +02:00
|
|
|
set_target_properties(${OPENJPEG_LIBRARY_NAME} PROPERTIES ${OPENJPEG_LIBRARY_PROPERTIES})
|
2015-09-01 20:43:43 +02:00
|
|
|
if(${CMAKE_VERSION} VERSION_GREATER "2.8.11")
|
2017-05-23 15:12:19 +02:00
|
|
|
target_compile_options(${OPENJPEG_LIBRARY_NAME} PRIVATE ${OPENJP2_COMPILE_OPTIONS})
|
2015-09-01 20:43:43 +02:00
|
|
|
endif()
|
2010-12-05 16:19:57 +01:00
|
|
|
|
2006-01-25 19:18:09 +01:00
|
|
|
# Install library
|
2017-07-13 11:34:15 +02:00
|
|
|
install(TARGETS ${INSTALL_LIBS}
|
2010-06-29 21:08:58 +02:00
|
|
|
EXPORT OpenJPEGTargets
|
2012-03-02 14:59:12 +01:00
|
|
|
RUNTIME DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
|
|
|
|
LIBRARY DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
|
|
|
|
ARCHIVE DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
|
2010-06-29 21:08:58 +02:00
|
|
|
)
|
2006-01-31 15:20:06 +01:00
|
|
|
|
2006-07-22 05:47:02 +02:00
|
|
|
# Install includes files
|
2012-08-30 19:14:39 +02:00
|
|
|
install(FILES openjpeg.h opj_stdint.h
|
2012-03-02 14:59:12 +01:00
|
|
|
DESTINATION ${OPENJPEG_INSTALL_INCLUDE_DIR} COMPONENT Headers
|
2010-06-29 21:08:58 +02:00
|
|
|
)
|
2010-11-17 11:59:21 +01:00
|
|
|
|
2014-04-28 09:34:26 +02:00
|
|
|
if(BUILD_DOC)
|
2010-11-17 11:59:21 +01:00
|
|
|
# install man page of the library
|
2012-08-30 19:14:39 +02:00
|
|
|
install(
|
2012-10-15 13:57:47 +02:00
|
|
|
FILES ${OPENJPEG_SOURCE_DIR}/doc/man/man3/libopenjp2.3
|
2010-11-17 11:59:21 +01:00
|
|
|
DESTINATION ${OPENJPEG_INSTALL_MAN_DIR}/man3)
|
2014-04-28 09:34:26 +02:00
|
|
|
endif()
|
2011-12-06 17:03:05 +01:00
|
|
|
|
2016-09-20 18:48:06 +02:00
|
|
|
if(BUILD_LUTS_GENERATOR)
|
|
|
|
# internal utility to generate t1_luts.h (part of the jp2 lib)
|
2012-10-02 09:45:49 +02:00
|
|
|
# no need to install:
|
2016-09-20 18:48:06 +02:00
|
|
|
add_executable(t1_generate_luts t1_generate_luts.c)
|
|
|
|
if(UNIX)
|
|
|
|
target_link_libraries(t1_generate_luts m)
|
|
|
|
endif()
|
2012-10-02 09:45:49 +02:00
|
|
|
endif()
|
|
|
|
|
2011-12-06 17:03:05 +01:00
|
|
|
# Experimental option; let's how cppcheck performs
|
|
|
|
# Implementation details:
|
2016-09-16 17:54:12 +02:00
|
|
|
# I could not figure out how to easily upload a file to CDash. Instead simply
|
2011-12-06 17:03:05 +01:00
|
|
|
# pretend cppcheck is part of the Build step. Technically cppcheck can even
|
|
|
|
# output gcc formatted error/warning report
|
|
|
|
# Another implementation detail: I could not redirect error to the error
|
|
|
|
# catching mechanism something is busted in cmake 2.8.5, I had to use the
|
|
|
|
# warning regex to catch them.
|
|
|
|
if(OPENJPEG_CPPCHECK)
|
|
|
|
find_package(CPPCHECK REQUIRED)
|
|
|
|
foreach(f ${OPENJPEG_SRCS})
|
|
|
|
# cppcheck complains about too many configuration, pretend to be WIN32:
|
|
|
|
add_custom_command(TARGET ${OPENJPEG_LIBRARY_NAME}
|
|
|
|
COMMAND ${CPPCHECK_EXECUTABLE} -DWIN32 ${f})
|
|
|
|
endforeach()
|
|
|
|
endif()
|
2014-10-15 12:24:49 +02:00
|
|
|
|
|
|
|
if(OPJ_USE_DSYMUTIL)
|
|
|
|
if(BUILD_SHARED_LIBS)
|
2016-05-02 16:03:16 +02:00
|
|
|
add_custom_command(TARGET ${OPENJPEG_LIBRARY_NAME} POST_BUILD
|
2014-11-25 22:52:24 +01:00
|
|
|
COMMAND "dsymutil" "$<TARGET_SONAME_FILE:${OPENJPEG_LIBRARY_NAME}>"
|
|
|
|
COMMENT "dsymutil $<TARGET_SONAME_FILE:${OPENJPEG_LIBRARY_NAME}>"
|
2014-10-15 12:24:49 +02:00
|
|
|
DEPENDS ${OPENJPEG_LIBRARY_NAME})
|
|
|
|
endif()
|
|
|
|
endif()
|
2016-05-25 16:34:52 +02:00
|
|
|
|
|
|
|
#################################################################################
|
|
|
|
# threading configuration
|
|
|
|
#################################################################################
|
|
|
|
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
|
|
|
|
2016-09-16 17:54:12 +02:00
|
|
|
option(OPJ_USE_THREAD "Build with thread/mutex support " ON)
|
|
|
|
if(NOT OPJ_USE_THREAD)
|
2016-05-25 16:34:52 +02:00
|
|
|
add_definitions( -DMUTEX_stub)
|
2016-09-16 17:54:12 +02:00
|
|
|
endif(NOT OPJ_USE_THREAD)
|
2016-05-25 16:34:52 +02:00
|
|
|
|
|
|
|
find_package(Threads QUIET)
|
|
|
|
|
2016-09-16 17:54:12 +02:00
|
|
|
if(OPJ_USE_THREAD AND WIN32 AND NOT Threads_FOUND )
|
2016-05-25 16:34:52 +02:00
|
|
|
add_definitions( -DMUTEX_win32)
|
|
|
|
set(Threads_FOUND YES)
|
|
|
|
endif()
|
|
|
|
|
2016-09-16 17:54:12 +02:00
|
|
|
if(OPJ_USE_THREAD AND Threads_FOUND AND CMAKE_USE_WIN32_THREADS_INIT )
|
2016-05-25 16:34:52 +02:00
|
|
|
add_definitions( -DMUTEX_win32)
|
2016-09-16 17:54:12 +02:00
|
|
|
endif(OPJ_USE_THREAD AND Threads_FOUND AND CMAKE_USE_WIN32_THREADS_INIT )
|
2016-05-25 16:34:52 +02:00
|
|
|
|
2016-09-16 17:54:12 +02:00
|
|
|
if(OPJ_USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT )
|
2016-05-25 16:34:52 +02:00
|
|
|
add_definitions( -DMUTEX_pthread)
|
2016-09-16 17:54:12 +02:00
|
|
|
endif(OPJ_USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT )
|
2016-05-25 16:34:52 +02:00
|
|
|
|
2016-09-16 17:54:12 +02:00
|
|
|
if(OPJ_USE_THREAD AND NOT Threads_FOUND)
|
|
|
|
message(FATAL_ERROR "No thread library found and thread/mutex support is required by OPJ_USE_THREAD option")
|
|
|
|
endif(OPJ_USE_THREAD AND NOT Threads_FOUND)
|
2016-05-25 16:34:52 +02:00
|
|
|
|
2016-09-16 17:54:12 +02:00
|
|
|
if(OPJ_USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
|
2016-05-25 16:34:52 +02:00
|
|
|
TARGET_LINK_LIBRARIES(${OPENJPEG_LIBRARY_NAME} ${CMAKE_THREAD_LIBS_INIT})
|
2016-09-16 17:54:12 +02:00
|
|
|
endif(OPJ_USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
|
2017-06-20 17:56:19 +02:00
|
|
|
|
|
|
|
if(BUILD_BENCH_DWT)
|
|
|
|
add_executable(bench_dwt bench_dwt.c dwt.c opj_malloc.c thread.c)
|
|
|
|
if(UNIX)
|
|
|
|
target_link_libraries(bench_dwt m)
|
|
|
|
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)
|