File tree Expand file tree Collapse file tree 6 files changed +27
-13
lines changed Expand file tree Collapse file tree 6 files changed +27
-13
lines changed Original file line number Diff line number Diff line change @@ -126,6 +126,10 @@ if ( ${HAVE_CHMOD} )
126
126
add_compile_definitions ( HAVE_CHMOD=1 )
127
127
endif ()
128
128
129
+ check_symbol_exists ( getopt "unistd.h" HAVE_GETOPT )
130
+ if ( ${HAVE_GETOPT} )
131
+ add_compile_definitions ( HAVE_GETOPT=1 )
132
+ endif ()
129
133
130
134
# Check backtrace
131
135
Original file line number Diff line number Diff line change @@ -130,6 +130,7 @@ AC_TYPE_UINT8_T
130
130
131
131
# Check functions
132
132
AC_CHECK_FUNCS ( chmod , AC_DEFINE ( [ HAVE_CHMOD] , [ 1] ) )
133
+ AC_CHECK_FUNCS ( getopt , AC_DEFINE ( [ HAVE_GETOPT] , [ 1] ) )
133
134
AC_CHECK_FUNCS ( strnlen , AC_DEFINE ( [ HAVE_STRNLEN] , [ 1] ) )
134
135
AC_CHECK_FUNCS ( strndup , AC_DEFINE ( [ HAVE_STRNDUP] , [ 1] ) )
135
136
AC_CHECK_FUNCS ( mempcpy , AC_DEFINE ( [ HAVE_MEMPCPY] , [ 1] ) )
Original file line number Diff line number Diff line change @@ -4,16 +4,20 @@ include_directories (
4
4
${PROJECT_BINARY_DIR} /src
5
5
)
6
6
7
+ #check_symbol_exists ( chmod "unistd.h" HAVE_GETOPT )
7
8
8
- if ( "${CMAKE_C_COMPILER_ID} " STREQUAL "MSVC" )
9
+ #if ( "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC" )
10
+ if ( ${HAVE_GETOPT} )
11
+ set ( ADFLIB_CUSTOM_GETOPT_SRC "" )
12
+ message ( STATUS "Using system's getopt implementation." )
13
+ else ()
9
14
set ( ADFLIB_CUSTOM_GETOPT_SRC
10
15
getopt.c
11
16
getopt.h )
12
- else ( )
13
- set ( ADFLIB_CUSTOM_GETOPT_SRC "" )
17
+ message ( STATUS "Using custom getopt implementation." )
18
+ # message ( STATUS " ADFLIB_CUSTOM_GETOPT_SRC: ${ADFLIB_CUSTOM_GETOPT_SRC}" )
14
19
endif ()
15
20
16
-
17
21
add_executable ( adfbitmap adfbitmap.c )
18
22
target_link_libraries ( adfbitmap adf )
19
23
set_target_properties ( adfbitmap PROPERTIES
Original file line number Diff line number Diff line change 26
26
#include <stdlib.h>
27
27
#include <string.h>
28
28
29
+ #ifndef HAVE_GETOPT
30
+ #include "getopt.h" // use custom getopt
31
+ #endif
29
32
30
- #ifdef WIN32
31
- #include "getopt.h"
32
- #else
33
+ #ifndef WIN32
33
34
#include <libgen.h>
34
35
#include <unistd.h>
35
36
#endif
Original file line number Diff line number Diff line change 25
25
#include <stdlib.h>
26
26
#include <string.h>
27
27
28
- #ifdef WIN32
29
- #include "getopt.h"
30
- #else
28
+ #ifndef HAVE_GETOPT
29
+ #include "getopt.h" // use custom getopt
30
+ #endif
31
+
32
+ #ifndef WIN32
31
33
//#include <libgen.h>
32
34
#include <unistd.h>
33
35
#endif
Original file line number Diff line number Diff line change 26
26
#include <stdio.h>
27
27
#include <stdlib.h>
28
28
29
- #ifdef WIN32
30
- #include "getopt.h"
31
- #else
29
+ #ifndef HAVE_GETOPT
30
+ #include "getopt.h" // use custom getopt
31
+ #endif
32
+
33
+ #ifndef WIN32
32
34
#include <libgen.h>
33
35
#include <unistd.h>
34
36
#endif
You can’t perform that action at this time.
0 commit comments