From 040c9a68b685facb6e36751d1ff07b21cc8ded6d Mon Sep 17 00:00:00 2001 From: Antonin Descampe Date: Wed, 25 Jan 2012 16:30:03 +0000 Subject: [PATCH] [1.5] remove pthread dependency in JPIP client and tweak thirdparty stuff --- CMakeLists.txt | 12 ++---- applications/codec/CMakeLists.txt | 18 ++++++++- applications/jpip/CMakeLists.txt | 9 ++--- applications/jpip/libopenjpip/CMakeLists.txt | 2 +- applications/jpip/libopenjpip/openjpip.c | 5 +++ applications/jpip/libopenjpip/openjpip.h | 4 +- applications/jpip/util/CMakeLists.txt | 41 +++++++++++--------- thirdparty/CMakeLists.txt | 6 ++- 8 files changed, 58 insertions(+), 39 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ce4ee15..61689ca5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -184,6 +184,7 @@ ADD_SUBDIRECTORY(libopenjpeg) # Build Applications OPTION(BUILD_CODEC "Build the CODEC executables" ON) OPTION(BUILD_MJ2 "Build the MJ2 executables." OFF) +OPTION(BUILD_JPWL "Build the JPWL library and executables" OFF) OPTION(BUILD_JPIP "Build the JPIP library and executables." OFF) IF(BUILD_JPIP) OPTION(BUILD_JPIP_SERVER "Build the JPIP server." OFF) @@ -193,16 +194,13 @@ OPTION(BUILD_JAVA "Build the openjpeg jar (Java)" OFF) MARK_AS_ADVANCED(BUILD_VIEWER) MARK_AS_ADVANCED(BUILD_JAVA) -# Try to find lib Z -FIND_PACKAGE(ZLIB) - -IF(BUILD_CODEC OR BUILD_MJ2 OR BUILD_JPIP) +IF(BUILD_CODEC OR BUILD_MJ2) # OFF: It will only build 3rd party libs if they are not found on the system # ON: 3rd party libs will ALWAYS be build, and used OPTION(BUILD_THIRDPARTY "Build the thirdparty executables if it is needed" OFF) ADD_SUBDIRECTORY(thirdparty) ADD_SUBDIRECTORY(applications) -ENDIF (BUILD_CODEC OR BUILD_MJ2 OR BUILD_JPIP) +ENDIF (BUILD_CODEC OR BUILD_MJ2) #----------------------------------------------------------------------------- # opj_config.h generation (2/2) @@ -211,10 +209,6 @@ CONFIGURE_FILE("${OPENJPEG_SOURCE_DIR}/opj_config.h.cmake.in" @ONLY ) -#----------------------------------------------------------------------------- -# Build JPWL-flavoured library and executables -OPTION(BUILD_JPWL "Build the JPWL library and executables" OFF) - #----------------------------------------------------------------------------- # Build DOCUMENTATION (not in ALL target and only if Doxygen is found) OPTION(BUILD_DOC "Build the HTML documentation (with doxygen if available)." OFF) diff --git a/applications/codec/CMakeLists.txt b/applications/codec/CMakeLists.txt index 31009c34..2a195155 100644 --- a/applications/codec/CMakeLists.txt +++ b/applications/codec/CMakeLists.txt @@ -70,7 +70,14 @@ IF(BUILD_JPWL) ) TARGET_LINK_LIBRARIES(JPWL_j2k_to_image ${OPENJPEG_LIBRARY_NAME}_JPWL - ${LCMS_LIBNAME} ${Z_LIBNAME} ${PNG_LIBNAME} ${TIFF_LIBNAME}) + ${LCMS_LIBNAME} ${PNG_LIBNAME} ${TIFF_LIBNAME}) + + # To support universal exe: + IF(ZLIB_FOUND AND APPLE) + TARGET_LINK_LIBRARIES(JPWL_j2k_to_image z) + ELSe(ZLIB_FOUND AND APPLE) + TARGET_LINK_LIBRARIES(JPWL_j2k_to_image ${Z_LIBNAME}) + ENDIF(ZLIB_FOUND AND APPLE) IF(UNIX) TARGET_LINK_LIBRARIES(JPWL_j2k_to_image m) @@ -87,7 +94,14 @@ IF(BUILD_JPWL) ) TARGET_LINK_LIBRARIES(JPWL_image_to_j2k ${OPENJPEG_LIBRARY_NAME}_JPWL - ${LCMS_LIBNAME} ${Z_LIBNAME} ${PNG_LIBNAME} ${TIFF_LIBNAME}) + ${LCMS_LIBNAME} ${PNG_LIBNAME} ${TIFF_LIBNAME}) + + # To support universal exe: + IF(ZLIB_FOUND AND APPLE) + TARGET_LINK_LIBRARIES(JPWL_image_to_j2k z) + ELSe(ZLIB_FOUND AND APPLE) + TARGET_LINK_LIBRARIES(JPWL_image_to_j2k ${Z_LIBNAME}) + ENDIF(ZLIB_FOUND AND APPLE) IF(UNIX) TARGET_LINK_LIBRARIES(JPWL_image_to_j2k m) diff --git a/applications/jpip/CMakeLists.txt b/applications/jpip/CMakeLists.txt index d4a140a5..77485a3d 100644 --- a/applications/jpip/CMakeLists.txt +++ b/applications/jpip/CMakeLists.txt @@ -4,10 +4,9 @@ IF(BUILD_JPIP_SERVER) FIND_PACKAGE(FCGI REQUIRED) ENDIF(BUILD_JPIP_SERVER) -# JPIP client & server: +# JPIP library: ADD_SUBDIRECTORY(libopenjpip) -# jpip server: -IF(BUILD_JPIP_SERVER) - ADD_SUBDIRECTORY(util) -ENDIF(BUILD_JPIP_SERVER) +# JPIP binaries: +ADD_SUBDIRECTORY(util) + diff --git a/applications/jpip/libopenjpip/CMakeLists.txt b/applications/jpip/libopenjpip/CMakeLists.txt index b177fb7e..befc6390 100644 --- a/applications/jpip/libopenjpip/CMakeLists.txt +++ b/applications/jpip/libopenjpip/CMakeLists.txt @@ -45,7 +45,7 @@ SET(LOCAL_SRCS # Build the library ADD_LIBRARY(openjpip_local STATIC ${OPENJPIP_SRCS} ${LOCAL_SRCS}) -TARGET_LINK_LIBRARIES(openjpip_local ${OPENJPEG_LIBRARY_NAME} ${CURL_LIBRARIES}) +TARGET_LINK_LIBRARIES(openjpip_local ${OPENJPEG_LIBRARY_NAME}) # Install library INSTALL(TARGETS openjpip_local diff --git a/applications/jpip/libopenjpip/openjpip.c b/applications/jpip/libopenjpip/openjpip.c index f19d7aea..fa4d8cf9 100644 --- a/applications/jpip/libopenjpip/openjpip.c +++ b/applications/jpip/libopenjpip/openjpip.c @@ -46,6 +46,8 @@ #include #include "jp2k_encoder.h" +#ifdef SERVER + server_record_t * init_JPIPserver( int tcp_auxport, int udp_auxport) { server_record_t *record = (server_record_t *)malloc( sizeof(server_record_t)); @@ -176,6 +178,7 @@ void end_QRprocess( server_record_t *rec, QR_t **qr) free( *qr); } + void local_log( bool query, bool messages, bool sessions, bool targets, QR_t *qr, server_record_t *rec) { if( query) @@ -191,6 +194,8 @@ void local_log( bool query, bool messages, bool sessions, bool targets, QR_t *qr print_alltarget( rec->targetlist); } +#endif //SERVER + #ifndef SERVER dec_server_record_t * init_dec_server( int port) diff --git a/applications/jpip/libopenjpip/openjpip.h b/applications/jpip/libopenjpip/openjpip.h index 4f7941fe..82529362 100644 --- a/applications/jpip/libopenjpip/openjpip.h +++ b/applications/jpip/libopenjpip/openjpip.h @@ -65,6 +65,8 @@ * JPIP server API *========================================================== */ + + #ifdef SERVER //! Server static records typedef struct server_record{ @@ -129,8 +131,6 @@ void send_responsedata( server_record_t *rec, QR_t *qr); */ void end_QRprocess( server_record_t *rec, QR_t **qr); -#ifndef SERVER - /** * Option for local tests; print out parameter values to logstream (stderr) * diff --git a/applications/jpip/util/CMakeLists.txt b/applications/jpip/util/CMakeLists.txt index caa3774d..1eff3346 100644 --- a/applications/jpip/util/CMakeLists.txt +++ b/applications/jpip/util/CMakeLists.txt @@ -4,30 +4,33 @@ INCLUDE_DIRECTORIES( ${FCGI_INCLUDE_DIRS} ) -SET(OPJ_SERVER_SRCS +IF(BUILD_JPIP_SERVER) + + SET(OPJ_SERVER_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/opj_server.c ) + + # Build executable + ADD_EXECUTABLE(opj_server ${OPJ_SERVER_SRCS}) + TARGET_LINK_LIBRARIES(opj_server openjpip_server) + SET_PROPERTY( + TARGET opj_server + APPEND PROPERTY + COMPILE_DEFINITIONS SERVER QUIT_SIGNAL="quitJPIP" + ) -# Build executable -ADD_EXECUTABLE(opj_server ${OPJ_SERVER_SRCS}) -TARGET_LINK_LIBRARIES(opj_server openjpip_server ${FCGI_LIBRARIES}) -SET_PROPERTY( - TARGET opj_server - APPEND PROPERTY - COMPILE_DEFINITIONS SERVER QUIT_SIGNAL="quitJPIP" - ) + # On unix you need to link to the math library: + IF(UNIX) + TARGET_LINK_LIBRARIES(opj_server m) + ENDIF(UNIX) -# On unix you need to link to the math library: -IF(UNIX) - TARGET_LINK_LIBRARIES(opj_server m) -ENDIF(UNIX) + # Install exe + INSTALL(TARGETS opj_server + EXPORT OpenJPEGTargets + DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications + ) +ENDIF(BUILD_JPIP_SERVER) -# Install exe -INSTALL(TARGETS opj_server - EXPORT OpenJPEGTargets - DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications - ) -# SET(EXES opj_dec_server jpip_to_jp2 diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 78abffbe..7ab24ba3 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -1,5 +1,7 @@ # 3rd party libs +#------------ +# Try to find lib Z IF(BUILD_THIRDPARTY) # Try to build it message(STATUS "We will build Z lib from thirdparty") @@ -8,6 +10,8 @@ IF(BUILD_THIRDPARTY) SET(Z_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/include PARENT_SCOPE) SET(ZLIB_FOUND 1) ELSE (BUILD_THIRDPARTY) + # Try to find lib Z + FIND_PACKAGE(ZLIB) IF(ZLIB_FOUND) SET(Z_LIBNAME ${ZLIB_LIBRARIES} PARENT_SCOPE) SET(Z_INCLUDE_DIRNAME ${ZLIB_INCLUDE_DIRS} PARENT_SCOPE) @@ -19,7 +23,7 @@ ENDIF(BUILD_THIRDPARTY) #------------ -# Try to find lib PNG (which depends to zlib) +# Try to find lib PNG (which depends on zlib) IF(BUILD_THIRDPARTY) # Try to build it message(STATUS "We will build PNG lib from thirdparty")