project(mkisofs) cmake_minimum_required(VERSION 3.1.3) include(CheckIncludeFile) include(CheckSymbolExists) include(CheckTypeSize) include(CMakePushCheckState) check_include_file (assert.h HAVE_ASSERT_H) check_include_file (stdarg.h HAVE_STDARG_H) check_include_file (stdlib.h HAVE_STDLIB_H) check_include_file (stddef.h HAVE_STDEF_H) check_include_file (string.h HAVE_STRING_H) check_include_file (unistd.h HAVE_UNISTD_H) check_include_file (limits.h HAVE_LIMITS_H) check_include_file (fcntl.h HAVE_FCNTL_H) check_include_file (io.h HAVE_IO_H) check_include_file (inttypes.h HAVE_INTTYPES_H) check_include_file (stdint.h HAVE_STDINT_H) check_include_file (dirent.h HAVE_DIRENT_H) check_include_file (stdint.h HAVE_STDINT_H) check_include_file (sys/time.h HAVE_SYS_TIME_H) check_include_file (stdint.h HAVE_STDINT_H) check_include_file (sys/types.h HAVE_SYS_TYPES_H) check_include_file (math.h HAVE_MATH_H) check_include_file (locale.h HAVE_LOCALE_H) check_include_file (ctype.h HAVE_CTYPE_H) check_include_file (wctype.h HAVE_WCTYPE_H) check_include_file (wchar.h HAVE_WCHAR_H) check_symbol_exists (errno errno.h HAVE_ERRNO_DEF) check_symbol_exists (strerror string.h HAVE_STRERROR) check_symbol_exists (memchr string.h HAVE_MEMCHR) check_symbol_exists (memcpy string.h HAVE_MEMCPY) check_symbol_exists (memmove string.h HAVE_MEMMOVE) check_symbol_exists (memset string.h HAVE_MEMSET) check_symbol_exists (gettimeofday sys/time.h HAVE_GETTIMEOFDAY) check_symbol_exists (time time.h HAVE_TIME) check_symbol_exists (va_copy stdarg.h HAVE_VA_COPY) check_symbol_exists (ecvt stdlib.h HAVE_ECVT) check_symbol_exists (fcvt stdlib.h HAVE_FCVT) check_symbol_exists (gcvt stdlib.h HAVE_GCVT) check_symbol_exists (isinf math.h HAVE_C99_ISINF) check_symbol_exists (isnan math.h HAVE_C99_ISNAN) check_symbol_exists (snprintf stdio.h HAVE_SNPRINTF) check_symbol_exists (strcat string.h HAVE_STRCAT) check_symbol_exists (strncat string.h HAVE_STRNCAT) check_symbol_exists (strcmp string.h HAVE_STRCMP) check_symbol_exists (strncmp string.h HAVE_STRNCMP) check_symbol_exists (strcpy string.h HAVE_STRCPY) check_symbol_exists (strlcat string.h HAVE_STRLCAT) check_symbol_exists (strlcpy string.h HAVE_STRLCPY) check_symbol_exists (strncpy string.h HAVE_STRNCPY) check_symbol_exists (strlen string.h HAVE_STRLEN) check_symbol_exists (strchr string.h HAVE_STRCHR) check_symbol_exists (strrchr string.h HAVE_STRRCHR) check_symbol_exists (strstr string.h HAVE_STRSTR) check_symbol_exists (strchr string.h HAVE_STRCHR) check_symbol_exists (strcasecmp string.h HAVE_STRCASECMP) check_symbol_exists (strncascmp string.h HAVE_STRNCASECMP) check_symbol_exists (usleep unistd.h HAVE_USLEEP) check_symbol_exists (wcscat wchar.h HAVE_WCSCAT) check_symbol_exists (wcsncat wchar.h HAVE_WCSNCAT) check_symbol_exists (wcscmp wchar.h HAVE_WCSCMP) check_symbol_exists (wcsncmp wchar.h HAVE_WCSNCMP) check_symbol_exists (wcscpy wchar.h HAVE_WCSCPY) check_symbol_exists (wcslcat wchar.h HAVE_WCSLCAT) check_symbol_exists (wcslcpy wchar.h HAVE_WCSLCPY) check_symbol_exists (wcsncpy wchar.h HAVE_WCSNCPY) check_symbol_exists (wcsdup wchar.h HAVE_WCSDUP) check_symbol_exists (wcsndup wchar.h HAVE_WCSNDUP) check_symbol_exists (wcslen wchar.h HAVE_WCSLEN) check_symbol_exists (wcsnlen wchar.h HAVE_WCSNLEN) check_symbol_exists (wcschr wchar.h HAVE_WCSCHR) check_symbol_exists (wcsrchr wchar.h HAVE_WCSRCHR) check_symbol_exists (wcsstr wchar.h HAVE_WCSSTR) check_symbol_exists (wcwidth wchar.h HAVE_WCWIDTH) check_symbol_exists (setvbuf stdio.h HAVE_SETVBUF) check_symbol_exists (iswprint wctype.h HAVE_ISWPRINT) check_symbol_exists (mbsinit wchar.h HAVE_MBSINIT) check_symbol_exists (mbtowc stdlib.h HAVE_MBTOWC) check_symbol_exists (wctomb stdlib.h HAVE_WCTOMB) check_symbol_exists (mbrtowc wchar.h HAVE_MBRTOWC) check_symbol_exists (wcrtomb stdio.h HAVE_WCRTOMB) check_symbol_exists (environ stdlib.h HAVE_ENVIRON_DEF) check_symbol_exists (rename stdio.h HAVE_RENAME) check_type_size ("long long" LONGLONG) check_type_size ("intmax_t" TYPE_INTMAX_T) check_type_size ("uintmax_t" TYPE_UINTMAX_T) cmake_push_check_state () set (CMAKE_EXTRA_INCLUDE_FILES time.h) check_type_size ("struct timespec" STRUCT_TIMESPEC) cmake_pop_check_state () cmake_push_check_state () set (CMAKE_EXTRA_INCLUDE_FILES sys/time.h) check_type_size ("struct timeval" STRUCT_TIMEVAL) check_type_size ("struct timezone" STRUCT_TIMEZONE) cmake_pop_check_state () configure_file (xconfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/xconfig.h) configure_file (align.h.in ${CMAKE_CURRENT_BINARY_DIR}/align.h) include_directories( include ${CMAKE_CURRENT_BINARY_DIR} ) # libschily and libsiconv are licensed under CDDL whereas mkisofs is licensed under GPL. # As such, we cannot mix the library sources with mkisofs sources and have to build them seperately. # Later on, they may still be linked together though. # # Reference: http://opensource.stackexchange.com/questions/2094 add_library(libschily libschily/stdio/cvmod.c libschily/stdio/dat.c libschily/stdio/fcons.c libschily/stdio/ffileread.c libschily/stdio/fgetline.c libschily/stdio/fileopen.c libschily/stdio/filewrite.c libschily/stdio/flag.c libschily/stdio/niwrite.c libschily/astoll.c libschily/checkerr.c libschily/comerr.c libschily/dirent.c libschily/eaccess.c libschily/error.c libschily/fconv.c libschily/fillbytes.c libschily/fnmatch.c libschily/format.c libschily/getargs.c libschily/geterrno.c libschily/getexecpath.c libschily/gettimeofday.c libschily/gid.c libschily/jsprintf.c libschily/jssnprintf.c libschily/match.c libschily/mem.c libschily/movebytes.c libschily/raisecond.c libschily/saveargs.c libschily/searchinpath.c libschily/seterrno.c libschily/streql.c libschily/strlcat.c libschily/strlcpy.c libschily/uid.c libschily/zerobytes.c ) target_compile_definitions (libschily PUBLIC INS_BASE="\\".\\"" SCHILY_BUILD PROTOTYPES=1 STDC_HEADERS=1 ) #libschily as such does not require ANSI'90, but this cmake script pretends it #does - by specifying PROTOTYPES and STDC_HEADERS to the compiler. target_compile_features (libschily PUBLIC c_std_90) add_library(libmdigest libmdigest/sha3.c) target_link_libraries (libmdigest PUBLIC libschily) add_library(libsiconv libsiconv/sic_nls.c) target_link_libraries(libsiconv PUBLIC libschily) add_executable(mkisofs mkisofs/boot.c mkisofs/eltorito.c mkisofs/hash.c mkisofs/inode.c mkisofs/isonum.c mkisofs/joliet.c mkisofs/match.c mkisofs/mkisofs.c mkisofs/multi.c mkisofs/name.c mkisofs/rock.c mkisofs/stream.c mkisofs/tree.c mkisofs/write.c ) target_link_libraries(mkisofs PRIVATE libmdigest libschily libsiconv) target_compile_definitions (mkisofs PRIVATE DUPLICATES_ONCE SORTING ) #Install an export file so that a cmake script can import an mkisofs target via #find_package(mkisofs REQUIRED CONFIG) #The importing cmake script can then use #add_custom_command(OUTPUT file.iso COMMAND mkisofs DEPENDS ... COMMAND mkisofs -o file.iso ...) #in order to generate an iso file. install (TARGETS mkisofs EXPORT mkisofs-config DESTINATION bin) install (EXPORT mkisofs-config DESTINATION cmake) if(MSVC) # mkisofs uses K&R-style function definitions to support very old compilers. # MSVC complains about the resulting foo() vs. foo(void) mismatches. target_compile_options(mkisofs PRIVATE "/wd4113") else() # libschily implements an own printf function with support for the %r formatter. # Silence compilers checking for invalid formatting sequences. target_compile_options(libschily PRIVATE "-Wno-format") endif()