[1.5] Create a new cmake option to choose between convienient copy of getopt and system installed one

Udapte issue 301
This commit is contained in:
Mathieu Malaterre 2014-03-18 15:59:08 +00:00
parent 78d1820881
commit 4f4de7070e
6 changed files with 36 additions and 8 deletions

View File

@ -233,6 +233,8 @@ IF(BUILD_JPIP)
ENDIF(BUILD_JPIP)
OPTION(BUILD_VIEWER "Build the OPJViewer executable (C++)" OFF)
OPTION(BUILD_JAVA "Build the openjpeg jar (Java)" OFF)
OPTION(USE_SYSTEM_GETOPT "Prefer system installed getopt()" OFF)
MARK_AS_ADVANCED(USE_SYSTEM_GETOPT)
MARK_AS_ADVANCED(BUILD_VIEWER)
MARK_AS_ADVANCED(BUILD_JAVA)

View File

@ -5,8 +5,12 @@ SET(common_SRCS
convert.c
index.c
${OPENJPEG_SOURCE_DIR}/applications/common/color.c
)
if(NOT USE_SYSTEM_GETOPT)
list(APPEND common_SRCS
${OPENJPEG_SOURCE_DIR}/applications/common/opj_getopt.c
)
endif()
# Headers file are located here:
INCLUDE_DIRECTORIES(

View File

@ -38,6 +38,10 @@ static char sccsid[] = "@(#)opj_getopt.c 8.3 (Berkeley) 4/27/95";
#include <string.h>
#include "opj_getopt.h"
#ifdef USE_SYSTEM_GETOPT
#error
#endif
int opj_opterr = 1, /* if error message should be printed */
opj_optind = 1, /* index into parent argv vector */
opj_optopt, /* character checked for validity */

View File

@ -1,5 +1,7 @@
/* last review : october 29th, 2002 */
#include "opj_config.h"
#ifndef _GETOPT_H_
#define _GETOPT_H_
@ -15,6 +17,19 @@ typedef struct opj_option
#define REQ_ARG 1
#define OPT_ARG 2
#ifdef USE_SYSTEM_GETOPT
#include <getopt.h>
#define opj_opterr opterr
#define opj_optind optind
#define opj_optopt optopt
#define opj_optreset optreset
#define opj_optarg optarg
#define opj_getopt getopt
#define opj_getopt_long getopt_long
#else
extern int opj_opterr;
extern int opj_optind;
extern int opj_optopt;
@ -26,4 +41,5 @@ extern int opj_getopt_long(int argc, char * const argv[], const char *optstring,
const opj_option_t *longopts, int totlen);
extern void reset_options_reading(void);
#endif /* USE_SYSTEM_GETOPT */
#endif /* _GETOPT_H_ */

View File

@ -19,6 +19,7 @@
#cmakedefine HAVE_LIBLCMS2
#cmakedefine HAVE_LCMS1_H
#cmakedefine HAVE_LCMS2_H
#cmakedefine USE_SYSTEM_GETOPT
/* Byte order. */
/* All compilers that support Mac OS X define either __BIG_ENDIAN__ or

View File

@ -11,14 +11,15 @@ INCLUDE_DIRECTORIES(
# First thing define the common source:
SET(comparePGXimages_SRCS comparePGXimages.c
${OPENJPEG_SOURCE_DIR}/applications/codec/convert.c
${OPENJPEG_SOURCE_DIR}/applications/common/opj_getopt.c
)
SET(compare_dump_files_SRCS compare_dump_files.c)
SET(compareRAWimages_SRCS compareRAWimages.c)
SET(compare_dump_files_SRCS compare_dump_files.c
${OPENJPEG_SOURCE_DIR}/applications/common/opj_getopt.c)
SET(compareRAWimages_SRCS compareRAWimages.c
${OPENJPEG_SOURCE_DIR}/applications/common/opj_getopt.c)
if(NOT USE_SYSTEM_GETOPT)
list(APPEND comparePGXimages_SRCS ${OPENJPEG_SOURCE_DIR}/applications/common/opj_getopt.c)
list(APPEND compare_dump_files_SRCS ${OPENJPEG_SOURCE_DIR}/applications/common/opj_getopt.c)
list(APPEND compareRAWimages_SRCS ${OPENJPEG_SOURCE_DIR}/applications/common/opj_getopt.c)
endif()
ADD_EXECUTABLE(comparePGXimages ${comparePGXimages_SRCS})
TARGET_LINK_LIBRARIES(comparePGXimages