xz: Windows: Don't (de)compress to special files like "con" or "nul".
[xz.git] / cmake / tuklib_common.cmake
blob088a3cb1cb35436712e16b71a2b1559f48083de8
2 # tuklib_common.cmake - common functions and macros for tuklib_*.cmake files
4 # Author: Lasse Collin
6 # This file has been put into the public domain.
7 # You can do whatever you want with this file.
10 function(tuklib_add_definitions TARGET_OR_ALL DEFINITIONS)
11     # DEFINITIONS may be an empty string/list but it's fine here. There is
12     # no need to quote ${DEFINITIONS} as empty arguments are fine here.
13     if(TARGET_OR_ALL STREQUAL "ALL")
14         add_compile_definitions(${DEFINITIONS})
15     else()
16         target_compile_definitions("${TARGET_OR_ALL}" PRIVATE ${DEFINITIONS})
17     endif()
18 endfunction()
20 function(tuklib_add_definition_if TARGET_OR_ALL VAR)
21     if(${VAR})
22         tuklib_add_definitions("${TARGET_OR_ALL}" "${VAR}")
23     endif()
24 endfunction()
26 # This is an over-simplified version of AC_USE_SYSTEM_EXTENSIONS in Autoconf
27 # or gl_USE_SYSTEM_EXTENSIONS in gnulib.
28 macro(tuklib_use_system_extensions TARGET_OR_ALL)
29     if(NOT WIN32)
30         # FIXME? The Solaris-specific __EXTENSIONS__ should be conditional
31         #        even on Solaris. See gnulib: git log m4/extensions.m4.
32         # FIXME? gnulib and autoconf.git has lots of new stuff.
33         tuklib_add_definitions("${TARGET_OR_ALL}"
34             _GNU_SOURCE
35             __EXTENSIONS__
36             _POSIX_PTHREAD_SEMANTICS
37             _TANDEM_SOURCE
38             _ALL_SOURCE
39         )
41         list(APPEND CMAKE_REQUIRED_DEFINITIONS
42             -D_GNU_SOURCE
43             -D__EXTENSIONS__
44             -D_POSIX_PTHREAD_SEMANTICS
45             -D_TANDEM_SOURCE
46             -D_ALL_SOURCE
47         )
48     endif()
49 endmacro()