diff options
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 2470 |
1 files changed, 784 insertions, 1686 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index eb36b5b..bec81a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,1719 +1,817 @@ -# -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12 FATAL_ERROR) -# -PROJECT(libarchive C) -# -SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake") -if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${libarchive_BINARY_DIR}/bin) -endif() -# -# Set the Build type for make based generators. -# You can choose following types: -# Debug : Debug build -# Release : Release build -# RelWithDebInfo : Release build with Debug Info -# MinSizeRel : Release Min Size build -IF(NOT CMAKE_BUILD_TYPE) - SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build Type" FORCE) -ENDIF(NOT CMAKE_BUILD_TYPE) -# Set a value type to properly display CMAKE_BUILD_TYPE on GUI if the -# value type is "UNINITIALIZED". -GET_PROPERTY(cached_type CACHE CMAKE_BUILD_TYPE PROPERTY TYPE) -IF("${cached_type}" STREQUAL "UNINITIALIZED") - SET(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING "Build Type" FORCE) -ENDIF("${cached_type}" STREQUAL "UNINITIALIZED") -# Check the Build Type. -IF(NOT "${CMAKE_BUILD_TYPE}" - MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)\$") - MESSAGE(FATAL_ERROR - "Unknown keyword for CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}\n" - "Acceptable keywords: Debug,Release,RelWithDebInfo,MinSizeRel") -ENDIF(NOT "${CMAKE_BUILD_TYPE}" - MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)\$") - -# On MacOS, prefer MacPorts libraries to system libraries. -# I haven't come up with a compelling argument for this to be conditional. -list(APPEND CMAKE_PREFIX_PATH /opt/local) -# Enable @rpath in the install name. -# detail in "cmake --help-policy CMP0042" -SET(CMAKE_MACOSX_RPATH ON) +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. -# -# Version - read from 'version' file. -# -FILE(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/build/version _version) -STRING(REGEX REPLACE - "^([0-9])[0-9][0-9][0-9][0-9][0-9][0-9][a-z]?$" "\\1" _major ${_version}) -STRING(REGEX REPLACE - "^[0-9]([0-9][0-9][0-9])[0-9][0-9][0-9][a-z]?$" "\\1" _minor ${_version}) -STRING(REGEX REPLACE - "^[0-9][0-9][0-9][0-9]([0-9][0-9][0-9])[a-z]?$" "\\1" _revision ${_version}) -STRING(REGEX REPLACE - "^[0-9][0-9][0-9][0-9][0-9][0-9][0-9]([a-z]?)$" "\\1" _quality ${_version}) -SET(_version_number ${_major}${_minor}${_revision}) -STRING(REGEX REPLACE "[0]*([^0]*[0-9])$" "\\1" _trimmed_minor ${_minor}) -STRING(REGEX REPLACE "[0]*([^0]*[0-9])$" "\\1" _trimmed_revision ${_revision}) -# -SET(VERSION "${_major}.${_trimmed_minor}.${_trimmed_revision}${_quality}") -SET(BSDCPIO_VERSION_STRING "${VERSION}") -SET(BSDTAR_VERSION_STRING "${VERSION}") -SET(BSDCAT_VERSION_STRING "${VERSION}") -SET(LIBARCHIVE_VERSION_NUMBER "${_version_number}") -SET(LIBARCHIVE_VERSION_STRING "${VERSION}") - -# INTERFACE_VERSION increments with every release -# libarchive 2.7 == interface version 9 = 2 + 7 -# libarchive 2.8 == interface version 10 = 2 + 8 -# libarchive 2.9 == interface version 11 = 2 + 9 -# libarchive 3.0 == interface version 12 -# libarchive 3.1 == interface version 13 -math(EXPR INTERFACE_VERSION "13 + ${_minor}") - -# Set SOVERSION == Interface version -# ?? Should there be more here ?? -SET(SOVERSION "${INTERFACE_VERSION}") - -# Enalbe CMAKE_PUSH_CHECK_STATE() and CMAKE_POP_CHECK_STATE() macros -# saving and restoring the state of the variables. -INCLUDE(CMakePushCheckState) - -# Initialize the state of the variables. This initialization is not -# necessary but this shows you what value the variables initially have. -SET(CMAKE_REQUIRED_DEFINITIONS) -SET(CMAKE_REQUIRED_INCLUDES) -SET(CMAKE_REQUIRED_LIBRARIES) -SET(CMAKE_REQUIRED_FLAGS) - -# Especially for early development, we want to be a little -# aggressive about diagnosing build problems; this can get -# relaxed somewhat in final shipping versions. -IF (CMAKE_C_COMPILER_ID MATCHES "^GNU$") - SET(CMAKE_REQUIRED_FLAGS "-Wall -Wformat -Wformat-security") - ################################################################# - # Set compile flags for all build types. - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wformat -Wformat-security") - ################################################################# - # Set compile flags for debug build. - # This is added into CMAKE_C_FLAGS when CMAKE_BUILD_TYPE is "Debug" - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Werror") - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wextra") - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wunused") - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wshadow") - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wmissing-prototypes") - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wcast-qual") -ENDIF (CMAKE_C_COMPILER_ID MATCHES "^GNU$") -IF (CMAKE_C_COMPILER_ID MATCHES "^Clang$") - SET(CMAKE_REQUIRED_FLAGS "-Wall -Wformat -Wformat-security") - ################################################################# - # Set compile flags for all build types. - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wformat -Wformat-security") - ################################################################# - # Set compile flags for debug build. - # This is added into CMAKE_C_FLAGS when CMAKE_BUILD_TYPE is "Debug" - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g") - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Werror") - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wextra") - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wunused") - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wshadow") - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wmissing-prototypes") - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wcast-qual") -ENDIF (CMAKE_C_COMPILER_ID MATCHES "^Clang$") -IF (CMAKE_C_COMPILER_ID MATCHES "^XL$") - SET(CMAKE_C_COMPILER "xlc_r") - SET(CMAKE_REQUIRED_FLAGS "-qflag=e:e -qformat=sec") - ################################################################# - # Set compile flags for all build types. - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -qflag=e:e -qformat=sec") - ################################################################# - # Set compile flags for debug build. - # This is added into CMAKE_C_FLAGS when CMAKE_BUILD_TYPE is "Debug" - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g") - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -qhalt=w") - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -qflag=w:w") - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -qinfo=pro:use") -ENDIF(CMAKE_C_COMPILER_ID MATCHES "^XL$") -IF (MSVC) - ################################################################# - # Set compile flags for debug build. - # This is added into CMAKE_C_FLAGS when CMAKE_BUILD_TYPE is "Debug" - # Enable level 4 C4061: The enumerate has no associated handler in a switch - # statement. - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /we4061") - # Enable level 4 C4254: A larger bit field was assigned to a smaller bit - # field. - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /we4254") - # Enable level 4 C4295: An array was initialized but the last character in - # the array is not a null; accessing the array may - # produce unexpected results. - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /we4295") - # Enable level 4 C4296: An unsigned variable was used in a comparison - # operation with zero. - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /we4296") - # Enable level 4 C4389: An operation involved signed and unsigned variables. - # This could result in a loss of data. - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /we4389") - # Enable level 4 C4505: The given function is local and not referenced in - # the body of the module; therefore, the function is - # dead code. - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /we4505") - # Enable level 4 C4514: The optimizer removed an inline function that is not - # called. - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /we4514") - # Enable level 4 C4702: Unreachable code. - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /we4702") - # Enable level 4 C4706: The test value in a conditional expression was the - # result of an assignment. - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /we4706") - # /WX option is the same as gcc's -Werror option. - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /WX") - # /Oi option enables built-in functions. - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Oi") - ################################################################# - # Set compile flags for release build. - SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Oi") -ENDIF (MSVC) - -# Enable CTest/CDash support -include(CTest) - -OPTION(ENABLE_NETTLE "Enable use of Nettle" ON) -OPTION(ENABLE_OPENSSL "Enable use of OpenSSL" ON) -OPTION(ENABLE_LZO "Enable the use of the system LZO library if found" OFF) -OPTION(ENABLE_LZMA "Enable the use of the system LZMA library if found" ON) - -OPTION(ENABLE_ZLIB "Enable the use of the system ZLIB library if found" ON) -OPTION(ENABLE_BZip2 "Enable the use of the system BZip2 library if found" ON) -OPTION(ENABLE_LIBXML2 "Enable the use of the system libxml2 library if found" ON) -OPTION(ENABLE_EXPAT "Enable the use of the system EXPAT library if found" ON) -OPTION(ENABLE_PCREPOSIX "Enable the use of the system PCREPOSIX library if found" ON) -OPTION(ENABLE_LibGCC "Enable the use of the system LibGCC library if found" ON) -# CNG is used for encrypt/decrypt Zip archives on Windows. -OPTION(ENABLE_CNG "Enable the use of CNG(Crypto Next Generation)" ON) - -OPTION(ENABLE_TAR "Enable tar building" ON) -OPTION(ENABLE_TAR_SHARED "Enable dynamic build of tar" FALSE) -OPTION(ENABLE_CPIO "Enable cpio building" ON) -OPTION(ENABLE_CPIO_SHARED "Enable dynamic build of cpio" FALSE) -OPTION(ENABLE_CAT "Enable cat building" ON) -OPTION(ENABLE_CAT_SHARED "Enable dynamic build of cat" FALSE) -OPTION(ENABLE_XATTR "Enable extended attribute support" ON) -OPTION(ENABLE_ACL "Enable ACL support" ON) -OPTION(ENABLE_ICONV "Enable iconv support" ON) -OPTION(ENABLE_TEST "Enable unit and regression tests" ON) -OPTION(ENABLE_COVERAGE "Enable code coverage (GCC only, automatically sets ENABLE_TEST to ON)" FALSE) -OPTION(ENABLE_INSTALL "Enable installing of libraries" ON) - -SET(POSIX_REGEX_LIB "AUTO" CACHE STRING "Choose what library should provide POSIX regular expression support") -SET(ENABLE_SAFESEH "AUTO" CACHE STRING "Enable use of /SAFESEH linker flag (MSVC only)") -SET(WINDOWS_VERSION "WIN7" CACHE STRING "Set Windows version to use (Windows only)") - -IF(ENABLE_COVERAGE) - include(LibarchiveCodeCoverage) -ENDIF(ENABLE_COVERAGE) - -IF(ENABLE_TEST) - ENABLE_TESTING() -ENDIF(ENABLE_TEST) - -IF(WIN32) - IF(WINDOWS_VERSION STREQUAL "WIN8") - SET(NTDDI_VERSION 0x06020000) - SET(_WIN32_WINNT 0x0602) - SET(WINVER 0x0602) - ELSEIF(WINDOWS_VERSION STREQUAL "WIN7") - SET(NTDDI_VERSION 0x06010000) - SET(_WIN32_WINNT 0x0601) - SET(WINVER 0x0601) - ELSEIF(WINDOWS_VERSION STREQUAL "WS08") - SET(NTDDI_VERSION 0x06000100) - SET(_WIN32_WINNT 0x0600) - SET(WINVER 0x0600) - ELSEIF(WINDOWS_VERSION STREQUAL "VISTA") - SET(NTDDI_VERSION 0x06000000) - SET(_WIN32_WINNT 0x0600) - SET(WINVER 0x0600) - ELSEIF(WINDOWS_VERSION STREQUAL "WS03") - SET(NTDDI_VERSION 0x05020000) - SET(_WIN32_WINNT 0x0502) - SET(WINVER 0x0502) - ELSEIF(WINDOWS_VERSION STREQUAL "WINXP") - SET(NTDDI_VERSION 0x05010000) - SET(_WIN32_WINNT 0x0501) - SET(WINVER 0x0501) - ELSE(WINDOWS_VERSION STREQUAL "WIN8") - # Default to Windows Server 2003 API if we don't recognize the specifier - SET(NTDDI_VERSION 0x05020000) - SET(_WIN32_WINNT 0x0502) - SET(WINVER 0x0502) - ENDIF(WINDOWS_VERSION STREQUAL "WIN8") -ENDIF(WIN32) - -IF(MSVC) - IF(ENABLE_SAFESEH STREQUAL "YES") - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH") - SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH") - SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH") - SET(ENV{LDFLAGS} "$ENV{LDFLAGS} /SAFESEH") - ELSEIF(ENABLE_SAFESEH STREQUAL "NO") - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO") - SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO") - SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO") - SET(ENV{LDFLAGS} "$ENV{LDFLAGS} /SAFESEH:NO") - ENDIF(ENABLE_SAFESEH STREQUAL "YES") -ENDIF(MSVC) - -IF("${CMAKE_C_PLATFORM_ID}" MATCHES "^(HP-UX)$") - ADD_DEFINITIONS(-D_XOPEN_SOURCE=500) # Ask wchar.h for mbstate_t -ENDIF() +cmake_minimum_required(VERSION 2.8.12.2 FATAL_ERROR) +if(POLICY CMP0025) + cmake_policy(SET CMP0025 NEW) +endif() +if(POLICY CMP0053) + cmake_policy(SET CMP0053 NEW) +endif() +project(CMake) -# -INCLUDE(CheckCSourceCompiles) -INCLUDE(CheckCSourceRuns) -INCLUDE(CheckFileOffsetBits) -INCLUDE(CheckFuncs) -INCLUDE(CheckHeaderDirent) -INCLUDE(CheckIncludeFile) -INCLUDE(CheckIncludeFiles) -INCLUDE(CheckLibraryExists) -INCLUDE(CheckStructHasMember) -INCLUDE(CheckSymbolExists) -INCLUDE(CheckTypeExists) -INCLUDE(CheckTypeSize) - -# -# Generate list.h -# -MACRO (GENERATE_LIST_H _listfile _cmlist __list_sources) - SET(_argv ${ARGV}) - # Remove _listfile and _cmlist from _argv - LIST(REMOVE_AT _argv 0 1) - IF (NOT EXISTS "${_listfile}" OR - ${_cmlist} IS_NEWER_THAN "${_listfile}") - - MESSAGE(STATUS "Generating ${_listfile}") - FILE(WRITE ${_listfile} "") - FOREACH (testfile ${_argv}) - IF (testfile MATCHES "^test_[^/]+[.]c$") - FILE(STRINGS ${testfile} testvar REGEX "^DEFINE_TEST") - FOREACH (deftest ${testvar}) - FILE(APPEND ${_listfile} "${deftest}\n") - ENDFOREACH (deftest) - ENDIF (testfile MATCHES "^test_[^/]+[.]c$") - ENDFOREACH (testfile) - - ENDIF (NOT EXISTS "${_listfile}" OR - ${_cmlist} IS_NEWER_THAN "${_listfile}") -ENDMACRO (GENERATE_LIST_H) -# -# Generate installation rules for man pages. -# -MACRO (INSTALL_MAN __mans) - FOREACH (_man ${ARGV}) - STRING(REGEX REPLACE "^.+[.]([1-9])" "\\1" _mansect ${_man}) - INSTALL(FILES ${_man} DESTINATION "share/man/man${_mansect}") - ENDFOREACH (_man) -ENDMACRO (INSTALL_MAN __mans) -# -# Find out what macro is needed to use libraries on Windows. -# -MACRO (TRY_MACRO_FOR_LIBRARY INCLUDES LIBRARIES - TRY_TYPE SAMPLE_SOURCE MACRO_LIST) - IF(WIN32 AND NOT CYGWIN) - CMAKE_PUSH_CHECK_STATE() # Save the state of the variables - SET(CMAKE_REQUIRED_INCLUDES ${INCLUDES}) - SET(CMAKE_REQUIRED_LIBRARIES ${LIBRARIES}) - FOREACH(VAR ${MACRO_LIST}) - # Clear ${VAR} from CACHE If the libraries which ${VAR} was - # checked with are changed. - SET(VAR_WITH_LIB "${VAR}_WITH_LIB") - GET_PROPERTY(PREV_VAR_WITH_LIB VARIABLE PROPERTY ${VAR_WITH_LIB}) - IF(NOT "${PREV_VAR_WITH_LIB}" STREQUAL "${LIBRARIES}") - UNSET(${VAR} CACHE) - ENDIF(NOT "${PREV_VAR_WITH_LIB}" STREQUAL "${LIBRARIES}") - # Check if the library can be used with the macro. - IF("${TRY_TYPE}" MATCHES "COMPILES") - CHECK_C_SOURCE_COMPILES("${SAMPLE_SOURCE}" ${VAR}) - ELSEIF("${TRY_TYPE}" MATCHES "RUNS") - CHECK_C_SOURCE_RUNS("${SAMPLE_SOURCE}" ${VAR}) - ELSE("${TRY_TYPE}" MATCHES "COMPILES") - MESSAGE(FATAL_ERROR "UNKNOWN KEYWORD \"${TRY_TYPE}\" FOR TRY_TYPE") - ENDIF("${TRY_TYPE}" MATCHES "COMPILES") - # Save the libraries which ${VAR} is checked with. - SET(${VAR_WITH_LIB} "${LIBRARIES}" CACHE INTERNAL - "Macro ${VAR} is checked with") - ENDFOREACH(VAR) - CMAKE_POP_CHECK_STATE() # Restore the state of the variables - ENDIF(WIN32 AND NOT CYGWIN) -ENDMACRO (TRY_MACRO_FOR_LIBRARY) -# -# Check compress/decompress libraries -# -IF(WIN32 AND NOT CMAKE_CL_64 AND NOT CYGWIN) - # GnuWin32 is only for Win32, not Win64. - SET(__GNUWIN32PATH "C:/Program Files/GnuWin32") -ENDIF(WIN32 AND NOT CMAKE_CL_64 AND NOT CYGWIN) -IF(DEFINED __GNUWIN32PATH AND EXISTS "${__GNUWIN32PATH}") - # You have to add a path availabel DLL file into PATH environment variable. - # Maybe DLL path is "C:/Program Files/GnuWin32/bin". - # The zlib and the bzip2 Setup program have installed programs and DLLs into - # "C:/Program Files/GnuWin32" by default. - # This is convenience setting for Windows. - SET(CMAKE_PREFIX_PATH ${__GNUWIN32PATH} $(CMAKE_PREFIX_PATH)) - # - # If you didn't use Setup program or installed into nonstandard path, - # cmake cannot find out your zlib or bzip2 libraries and include files, - # you should execute cmake with -DCMAKE_PREFIX_PATH option. - # e.g. - # cmake -DCMAKE_PREFIX_PATH=<your-GnuWin32-path> <path-to-source> - # - # If compiling error occurred in zconf.h, You may need patch to zconf.h. - #--- zconf.h.orig 2005-07-21 00:40:26.000000000 - #+++ zconf.h 2009-01-19 11:39:10.093750000 - #@@ -286,7 +286,7 @@ - # - # #if 1 /* HAVE_UNISTD_H -- this line is updated by ./configure */ - # # include <sys/types.h> /* for off_t */ - #-# include <unistd.h> /* for SEEK_* and off_t */ - #+# include <stdio.h> /* for SEEK_* and off_t */ - # # ifdef VMS - # # include <unixio.h> /* for off_t */ - # # endif -ENDIF(DEFINED __GNUWIN32PATH AND EXISTS "${__GNUWIN32PATH}") - -SET(ADDITIONAL_LIBS "") -# -# Find ZLIB -# -IF(ENABLE_ZLIB) - FIND_PACKAGE(ZLIB) -ELSE() - SET(ZLIB_FOUND FALSE) # Override cached value -ENDIF() -IF(ZLIB_FOUND) - SET(HAVE_LIBZ 1) - SET(HAVE_ZLIB_H 1) - INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) - LIST(APPEND ADDITIONAL_LIBS ${ZLIB_LIBRARIES}) - IF(WIN32 AND NOT CYGWIN) - # - # Test if ZLIB_WINAPI macro is needed to use. - # - TRY_MACRO_FOR_LIBRARY( - "${ZLIB_INCLUDE_DIR}" "${ZLIB_LIBRARIES}" - RUNS - "#include <zlib.h>\nint main() {uLong f = zlibCompileFlags(); return (f&(1U<<10))?0:-1; }" - ZLIB_WINAPI) - IF(ZLIB_WINAPI) - ADD_DEFINITIONS(-DZLIB_WINAPI) - ELSE(ZLIB_WINAPI) - # Test if a macro is needed for the library. - TRY_MACRO_FOR_LIBRARY( - "${ZLIB_INCLUDE_DIR}" "${ZLIB_LIBRARIES}" - COMPILES - "#include <zlib.h>\nint main() {return zlibVersion()?1:0; }" - "ZLIB_DLL;WITHOUT_ZLIB_DLL") - IF(ZLIB_DLL) - ADD_DEFINITIONS(-DZLIB_DLL) - ENDIF(ZLIB_DLL) - ENDIF(ZLIB_WINAPI) - ENDIF(WIN32 AND NOT CYGWIN) -ENDIF(ZLIB_FOUND) -MARK_AS_ADVANCED(CLEAR ZLIB_INCLUDE_DIR) -MARK_AS_ADVANCED(CLEAR ZLIB_LIBRARY) -# -# Find BZip2 -# -IF(ENABLE_BZip2) - FIND_PACKAGE(BZip2) -ELSE() - SET(BZIP2_FOUND FALSE) # Override cached value -ENDIF() -IF(BZIP2_FOUND) - SET(HAVE_LIBBZ2 1) - SET(HAVE_BZLIB_H 1) - INCLUDE_DIRECTORIES(${BZIP2_INCLUDE_DIR}) - LIST(APPEND ADDITIONAL_LIBS ${BZIP2_LIBRARIES}) - # Test if a macro is needed for the library. - TRY_MACRO_FOR_LIBRARY( - "${BZIP2_INCLUDE_DIR}" "${BZIP2_LIBRARIES}" - COMPILES - "#include <bzlib.h>\nint main() {return BZ2_bzlibVersion()?1:0; }" - "USE_BZIP2_DLL;USE_BZIP2_STATIC") - IF(USE_BZIP2_DLL) - ADD_DEFINITIONS(-DUSE_BZIP2_DLL) - ELSEIF(USE_BZIP2_STATIC) - ADD_DEFINITIONS(-DUSE_BZIP2_STATIC) - ENDIF(USE_BZIP2_DLL) -ENDIF(BZIP2_FOUND) -MARK_AS_ADVANCED(CLEAR BZIP2_INCLUDE_DIR) -MARK_AS_ADVANCED(CLEAR BZIP2_LIBRARIES) +# Make sure we can find internal find_package modules only used for +# building CMake and not for shipping externally +list(INSERT CMAKE_MODULE_PATH 0 ${CMake_SOURCE_DIR}/Source/Modules) +if(CMAKE_BOOTSTRAP) + # Running from bootstrap script. Set local variable and remove from cache. + set(CMAKE_BOOTSTRAP 1) + unset(CMAKE_BOOTSTRAP CACHE) +endif() -# -# Find LZMA -# -IF(ENABLE_LZMA) - FIND_PACKAGE(LibLZMA) -ELSE() - SET(LIBZMA_FOUND FALSE) # Override cached value -ENDIF() - -IF(LIBLZMA_FOUND) - SET(HAVE_LIBLZMA 1) - SET(HAVE_LZMA_H 1) - INCLUDE_DIRECTORIES(${LIBLZMA_INCLUDE_DIRS}) - LIST(APPEND ADDITIONAL_LIBS ${LIBLZMA_LIBRARIES}) - # Test if a macro is needed for the library. - TRY_MACRO_FOR_LIBRARY( - "${LIBLZMA_INCLUDE_DIRS}" "${LIBLZMA_LIBRARIES}" - COMPILES - "#include <lzma.h>\nint main() {return (int)lzma_version_number(); }" - "WITHOUT_LZMA_API_STATIC;LZMA_API_STATIC") - IF(NOT WITHOUT_LZMA_API_STATIC AND LZMA_API_STATIC) - ADD_DEFINITIONS(-DLZMA_API_STATIC) - ENDIF(NOT WITHOUT_LZMA_API_STATIC AND LZMA_API_STATIC) -ELSE(LIBLZMA_FOUND) -# LZMA not found and will not be used. -ENDIF(LIBLZMA_FOUND) -# -# Find LZO2 -# -IF(ENABLE_LZO) - IF (LZO2_INCLUDE_DIR) - # Already in cache, be silent - SET(LZO2_FIND_QUIETLY TRUE) - ENDIF (LZO2_INCLUDE_DIR) - - FIND_PATH(LZO2_INCLUDE_DIR lzo/lzoconf.h) - FIND_LIBRARY(LZO2_LIBRARY NAMES lzo2 liblzo2) - INCLUDE(FindPackageHandleStandardArgs) - FIND_PACKAGE_HANDLE_STANDARD_ARGS(LZO2 DEFAULT_MSG LZO2_LIBRARY LZO2_INCLUDE_DIR) -ELSE(ENABLE_LZO) - SET(LIBZMA_FOUND FALSE) # Override cached value -ENDIF(ENABLE_LZO) -IF(LZO2_FOUND) - SET(HAVE_LIBLZO2 1) - SET(HAVE_LZO_LZOCONF_H 1) - SET(HAVE_LZO_LZO1X_H 1) - INCLUDE_DIRECTORIES(${LZO2_INCLUDE_DIR}) - LIST(APPEND ADDITIONAL_LIBS ${LZO2_LIBRARY}) - # - # TODO: test for static library. - # -ENDIF(LZO2_FOUND) -MARK_AS_ADVANCED(CLEAR LZO2_INCLUDE_DIR) -MARK_AS_ADVANCED(CLEAR LZO2_LIBRARY) -# -# Find LZ4 -# -IF (LZ4_INCLUDE_DIR) - # Already in cache, be silent - SET(LZ4_FIND_QUIETLY TRUE) -ENDIF (LZ4_INCLUDE_DIR) - -FIND_PATH(LZ4_INCLUDE_DIR lz4.h) -FIND_LIBRARY(LZ4_LIBRARY NAMES lz4 liblz4) -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(LZ4 DEFAULT_MSG LZ4_LIBRARY LZ4_INCLUDE_DIR) -IF(LZ4_FOUND) - SET(HAVE_LIBLZ4 1) - SET(HAVE_LZ4_H 1) - CMAKE_PUSH_CHECK_STATE() # Save the state of the variables - SET(CMAKE_REQUIRED_INCLUDES ${LZ4_INCLUDE_DIR}) - CHECK_INCLUDE_FILES("lz4hc.h" HAVE_LZ4HC_H) - CMAKE_POP_CHECK_STATE() # Restore the state of the variables - INCLUDE_DIRECTORIES(${LZ4_INCLUDE_DIR}) - LIST(APPEND ADDITIONAL_LIBS ${LZ4_LIBRARY}) - # - # TODO: test for static library. - # -ENDIF(LZ4_FOUND) -MARK_AS_ADVANCED(CLEAR LZ4_INCLUDE_DIR) -MARK_AS_ADVANCED(CLEAR LZ4_LIBRARY) +if(NOT CMake_TEST_EXTERNAL_CMAKE) + set(CMake_BIN_DIR ${CMake_BINARY_DIR}/bin) +endif() -# -# Check headers -# -CHECK_HEADER_DIRENT() - -SET(INCLUDES "") -MACRO (LA_CHECK_INCLUDE_FILE header var) - CHECK_INCLUDE_FILES("${INCLUDES};${header}" ${var}) - IF (${var}) - SET(INCLUDES ${INCLUDES} ${header}) - ENDIF (${var}) -ENDMACRO (LA_CHECK_INCLUDE_FILE) - -# Some FreeBSD headers assume sys/types.h was already included. -LA_CHECK_INCLUDE_FILE("sys/types.h" HAVE_SYS_TYPES_H) - -# Alphabetize the rest unless there's a compelling reason -LA_CHECK_INCLUDE_FILE("acl/libacl.h" HAVE_ACL_LIBACL_H) -LA_CHECK_INCLUDE_FILE("ctype.h" HAVE_CTYPE_H) -LA_CHECK_INCLUDE_FILE("copyfile.h" HAVE_COPYFILE_H) -LA_CHECK_INCLUDE_FILE("direct.h" HAVE_DIRECT_H) -LA_CHECK_INCLUDE_FILE("dlfcn.h" HAVE_DLFCN_H) -LA_CHECK_INCLUDE_FILE("errno.h" HAVE_ERRNO_H) -LA_CHECK_INCLUDE_FILE("ext2fs/ext2_fs.h" HAVE_EXT2FS_EXT2_FS_H) - -CHECK_C_SOURCE_COMPILES("#include <sys/ioctl.h> -#include <ext2fs/ext2_fs.h> -int main(void) { return EXT2_IOC_GETFLAGS; }" HAVE_WORKING_EXT2_IOC_GETFLAGS) - -LA_CHECK_INCLUDE_FILE("fcntl.h" HAVE_FCNTL_H) -LA_CHECK_INCLUDE_FILE("grp.h" HAVE_GRP_H) -LA_CHECK_INCLUDE_FILE("inttypes.h" HAVE_INTTYPES_H) -LA_CHECK_INCLUDE_FILE("io.h" HAVE_IO_H) -LA_CHECK_INCLUDE_FILE("langinfo.h" HAVE_LANGINFO_H) -LA_CHECK_INCLUDE_FILE("limits.h" HAVE_LIMITS_H) -LA_CHECK_INCLUDE_FILE("linux/types.h" HAVE_LINUX_TYPES_H) -LA_CHECK_INCLUDE_FILE("linux/fiemap.h" HAVE_LINUX_FIEMAP_H) -LA_CHECK_INCLUDE_FILE("linux/fs.h" HAVE_LINUX_FS_H) -LA_CHECK_INCLUDE_FILE("linux/magic.h" HAVE_LINUX_MAGIC_H) -LA_CHECK_INCLUDE_FILE("locale.h" HAVE_LOCALE_H) -LA_CHECK_INCLUDE_FILE("memory.h" HAVE_MEMORY_H) -LA_CHECK_INCLUDE_FILE("paths.h" HAVE_PATHS_H) -LA_CHECK_INCLUDE_FILE("poll.h" HAVE_POLL_H) -LA_CHECK_INCLUDE_FILE("process.h" HAVE_PROCESS_H) -LA_CHECK_INCLUDE_FILE("pthread.h" HAVE_PTHREAD_H) -LA_CHECK_INCLUDE_FILE("pwd.h" HAVE_PWD_H) -LA_CHECK_INCLUDE_FILE("readpassphrase.h" HAVE_READPASSPHRASE_H) -LA_CHECK_INCLUDE_FILE("regex.h" HAVE_REGEX_H) -LA_CHECK_INCLUDE_FILE("signal.h" HAVE_SIGNAL_H) -LA_CHECK_INCLUDE_FILE("spawn.h" HAVE_SPAWN_H) -LA_CHECK_INCLUDE_FILE("stdarg.h" HAVE_STDARG_H) -LA_CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H) -LA_CHECK_INCLUDE_FILE("stdlib.h" HAVE_STDLIB_H) -LA_CHECK_INCLUDE_FILE("string.h" HAVE_STRING_H) -LA_CHECK_INCLUDE_FILE("strings.h" HAVE_STRINGS_H) -LA_CHECK_INCLUDE_FILE("sys/acl.h" HAVE_SYS_ACL_H) -LA_CHECK_INCLUDE_FILE("sys/cdefs.h" HAVE_SYS_CDEFS_H) -LA_CHECK_INCLUDE_FILE("sys/ioctl.h" HAVE_SYS_IOCTL_H) -LA_CHECK_INCLUDE_FILE("sys/mkdev.h" HAVE_SYS_MKDEV_H) -LA_CHECK_INCLUDE_FILE("sys/mount.h" HAVE_SYS_MOUNT_H) -LA_CHECK_INCLUDE_FILE("sys/param.h" HAVE_SYS_PARAM_H) -LA_CHECK_INCLUDE_FILE("sys/poll.h" HAVE_SYS_POLL_H) -LA_CHECK_INCLUDE_FILE("sys/select.h" HAVE_SYS_SELECT_H) -LA_CHECK_INCLUDE_FILE("sys/stat.h" HAVE_SYS_STAT_H) -LA_CHECK_INCLUDE_FILE("sys/statfs.h" HAVE_SYS_STATFS_H) -LA_CHECK_INCLUDE_FILE("sys/statvfs.h" HAVE_SYS_STATVFS_H) -LA_CHECK_INCLUDE_FILE("sys/time.h" HAVE_SYS_TIME_H) -LA_CHECK_INCLUDE_FILE("sys/utime.h" HAVE_SYS_UTIME_H) -LA_CHECK_INCLUDE_FILE("sys/utsname.h" HAVE_SYS_UTSNAME_H) -LA_CHECK_INCLUDE_FILE("sys/vfs.h" HAVE_SYS_VFS_H) -LA_CHECK_INCLUDE_FILE("sys/wait.h" HAVE_SYS_WAIT_H) -LA_CHECK_INCLUDE_FILE("time.h" HAVE_TIME_H) -LA_CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H) -LA_CHECK_INCLUDE_FILE("utime.h" HAVE_UTIME_H) -LA_CHECK_INCLUDE_FILE("wchar.h" HAVE_WCHAR_H) -LA_CHECK_INCLUDE_FILE("wctype.h" HAVE_WCTYPE_H) -LA_CHECK_INCLUDE_FILE("windows.h" HAVE_WINDOWS_H) -IF(ENABLE_CNG) - LA_CHECK_INCLUDE_FILE("Bcrypt.h" HAVE_BCRYPT_H) -ELSE(ENABLE_CNG) - UNSET(HAVE_BCRYPT_H CACHE) -ENDIF(ENABLE_CNG) -# Following files need windows.h, so we should test it after windows.h test. -LA_CHECK_INCLUDE_FILE("wincrypt.h" HAVE_WINCRYPT_H) -LA_CHECK_INCLUDE_FILE("winioctl.h" HAVE_WINIOCTL_H) +if(CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL) + if(CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL MATCHES "^3|2\\.1$") + set(USE_LGPL "${CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL}") + else() + set(USE_LGPL "2.1") + endif() +else() + set(USE_LGPL "") +endif() -# -# Check whether use of __EXTENSIONS__ is safe. -# We need some macro such as _GNU_SOURCE to use extension functions. -# -SET(_INCLUDE_FILES) -FOREACH (it ${_HEADER}) - SET(_INCLUDE_FILES "${_INCLUDE_FILES}#include <${it}>\n") -ENDFOREACH (it) +if("${CMake_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}") + # Disallow architecture-specific try_run. It may not run on the host. + macro(TRY_RUN) + if(CMAKE_TRY_COMPILE_OSX_ARCHITECTURES) + message(FATAL_ERROR "TRY_RUN not allowed with CMAKE_TRY_COMPILE_OSX_ARCHITECTURES=[${CMAKE_TRY_COMPILE_OSX_ARCHITECTURES}]") + else() + _TRY_RUN(${ARGV}) + endif() + endmacro() +endif() -CHECK_C_SOURCE_COMPILES( - "#define __EXTENSIONS__ 1 - ${_INCLUDE_FILES} - int main() { return 0;}" - SAFE_TO_DEFINE_EXTENSIONS) +# Use most-recent available language dialects with GNU and Clang +if(NOT DEFINED CMAKE_C_STANDARD AND NOT CMake_NO_C_STANDARD) + include(${CMake_SOURCE_DIR}/Source/Checks/cm_c11_thread_local.cmake) + if(NOT CMake_C11_THREAD_LOCAL_BROKEN) + set(CMAKE_C_STANDARD 11) + else() + set(CMAKE_C_STANDARD 99) + endif() +endif() +if(NOT DEFINED CMAKE_CXX_STANDARD AND NOT CMake_NO_CXX_STANDARD) + include(${CMake_SOURCE_DIR}/Source/Checks/cm_cxx14_cstdio.cmake) + if(NOT CMake_CXX14_CSTDIO_BROKEN) + set(CMAKE_CXX_STANDARD 14) + else() + set(CMAKE_CXX_STANDARD 11) + endif() +endif() +if(NOT CMake_TEST_EXTERNAL_CMAKE) + include(${CMake_SOURCE_DIR}/Source/Checks/cm_cxx_features.cmake) +endif() -# -# Find Nettle -# -IF(ENABLE_NETTLE) - FIND_PACKAGE(Nettle) - IF(NETTLE_FOUND) - SET(HAVE_LIBNETTLE 1) - LIST(APPEND ADDITIONAL_LIBS ${NETTLE_LIBRARIES}) - INCLUDE_DIRECTORIES(${NETTLE_INCLUDE_DIR}) - - LIST(APPEND CMAKE_REQUIRED_INCLUDES ${NETTLE_INCLUDE_DIR}) - LA_CHECK_INCLUDE_FILE("nettle/aes.h" HAVE_NETTLE_AES_H) - LA_CHECK_INCLUDE_FILE("nettle/hmac.h" HAVE_NETTLE_HMAC_H) - LA_CHECK_INCLUDE_FILE("nettle/md5.h" HAVE_NETTLE_MD5_H) - LA_CHECK_INCLUDE_FILE("nettle/pbkdf2.h" HAVE_NETTLE_PBKDF2_H) - LA_CHECK_INCLUDE_FILE("nettle/ripemd160.h" HAVE_NETTLE_RIPEMD160_H) - LA_CHECK_INCLUDE_FILE("nettle/sha.h" HAVE_NETTLE_SHA_H) - - ENDIF(NETTLE_FOUND) - MARK_AS_ADVANCED(CLEAR NETTLE_INCLUDE_DIR) - MARK_AS_ADVANCED(CLEAR NETTLE_LIBRARIES) -ENDIF(ENABLE_NETTLE) +# set the internal encoding of CMake to UTF-8 +set(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_UTF8) + +# option to use COMPONENT with install command +option(CMake_INSTALL_COMPONENTS "Using components when installing" OFF) +mark_as_advanced(CMake_INSTALL_COMPONENTS) +macro(CMake_OPTIONAL_COMPONENT NAME) + if(CMake_INSTALL_COMPONENTS) + set(COMPONENT COMPONENT ${NAME}) + else() + set(COMPONENT) + endif() +endmacro() + +# option to disable installing 3rd-party dependencies +option(CMake_INSTALL_DEPENDENCIES + "Whether to install 3rd-party runtime dependencies" OFF) +mark_as_advanced(CMake_INSTALL_DEPENDENCIES) + +# option to build reference for CMake developers +option(CMake_BUILD_DEVELOPER_REFERENCE + "Build CMake Developer Reference" OFF) +mark_as_advanced(CMake_BUILD_DEVELOPER_REFERENCE) + +#----------------------------------------------------------------------- +# a macro to deal with system libraries, implemented as a macro +# simply to improve readability of the main script +#----------------------------------------------------------------------- +macro(CMAKE_HANDLE_SYSTEM_LIBRARIES) + # Options have dependencies. + include(CMakeDependentOption) + + # Optionally use system xmlrpc. We no longer build or use it by default. + option(CTEST_USE_XMLRPC "Enable xmlrpc submission method in CTest." OFF) + mark_as_advanced(CTEST_USE_XMLRPC) + + # Allow the user to enable/disable all system utility library options by + # defining CMAKE_USE_SYSTEM_LIBRARIES or CMAKE_USE_SYSTEM_LIBRARY_${util}. + set(UTILITIES BZIP2 CURL EXPAT FORM JSONCPP LIBARCHIVE LIBLZMA LIBRHASH LIBUV ZLIB) + foreach(util ${UTILITIES}) + if(NOT DEFINED CMAKE_USE_SYSTEM_LIBRARY_${util} + AND DEFINED CMAKE_USE_SYSTEM_LIBRARIES) + set(CMAKE_USE_SYSTEM_LIBRARY_${util} "${CMAKE_USE_SYSTEM_LIBRARIES}") + endif() + if(DEFINED CMAKE_USE_SYSTEM_LIBRARY_${util}) + if(CMAKE_USE_SYSTEM_LIBRARY_${util}) + set(CMAKE_USE_SYSTEM_LIBRARY_${util} ON) + else() + set(CMAKE_USE_SYSTEM_LIBRARY_${util} OFF) + endif() + if(CMAKE_BOOTSTRAP) + unset(CMAKE_USE_SYSTEM_LIBRARY_${util} CACHE) + endif() + string(TOLOWER "${util}" lutil) + set(CMAKE_USE_SYSTEM_${util} "${CMAKE_USE_SYSTEM_LIBRARY_${util}}" + CACHE BOOL "Use system-installed ${lutil}" FORCE) + else() + set(CMAKE_USE_SYSTEM_LIBRARY_${util} OFF) + endif() + endforeach() + if(CMAKE_BOOTSTRAP) + unset(CMAKE_USE_SYSTEM_LIBRARIES CACHE) + endif() + + # Optionally use system utility libraries. + option(CMAKE_USE_SYSTEM_LIBARCHIVE "Use system-installed libarchive" "${CMAKE_USE_SYSTEM_LIBRARY_LIBARCHIVE}") + CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_CURL "Use system-installed curl" + "${CMAKE_USE_SYSTEM_LIBRARY_CURL}" "NOT CTEST_USE_XMLRPC" ON) + CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_EXPAT "Use system-installed expat" + "${CMAKE_USE_SYSTEM_LIBRARY_EXPAT}" "NOT CTEST_USE_XMLRPC" ON) + CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_ZLIB "Use system-installed zlib" + "${CMAKE_USE_SYSTEM_LIBRARY_ZLIB}" "NOT CMAKE_USE_SYSTEM_LIBARCHIVE;NOT CMAKE_USE_SYSTEM_CURL" ON) + CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_BZIP2 "Use system-installed bzip2" + "${CMAKE_USE_SYSTEM_LIBRARY_BZIP2}" "NOT CMAKE_USE_SYSTEM_LIBARCHIVE" ON) + CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_LIBLZMA "Use system-installed liblzma" + "${CMAKE_USE_SYSTEM_LIBRARY_LIBLZMA}" "NOT CMAKE_USE_SYSTEM_LIBARCHIVE" ON) + option(CMAKE_USE_SYSTEM_FORM "Use system-installed libform" "${CMAKE_USE_SYSTEM_LIBRARY_FORM}") + option(CMAKE_USE_SYSTEM_JSONCPP "Use system-installed jsoncpp" "${CMAKE_USE_SYSTEM_LIBRARY_JSONCPP}") + option(CMAKE_USE_SYSTEM_LIBRHASH "Use system-installed librhash" "${CMAKE_USE_SYSTEM_LIBRARY_LIBRHASH}") + option(CMAKE_USE_SYSTEM_LIBUV "Use system-installed libuv" "${CMAKE_USE_SYSTEM_LIBRARY_LIBUV}") + + # For now use system KWIML only if explicitly requested rather + # than activating via the general system libs options. + option(CMAKE_USE_SYSTEM_KWIML "Use system-installed KWIML" OFF) + mark_as_advanced(CMAKE_USE_SYSTEM_KWIML) + + # Mention to the user what system libraries are being used. + foreach(util ${UTILITIES} KWIML) + if(CMAKE_USE_SYSTEM_${util}) + message(STATUS "Using system-installed ${util}") + endif() + endforeach() + + # Inform utility library header wrappers whether to use system versions. + configure_file(${CMake_SOURCE_DIR}/Utilities/cmThirdParty.h.in + ${CMake_BINARY_DIR}/Utilities/cmThirdParty.h + @ONLY) + +endmacro() + +#----------------------------------------------------------------------- +# a macro to determine the generator and ctest executable to use +# for testing. Simply to improve readability of the main script. +#----------------------------------------------------------------------- +macro(CMAKE_SETUP_TESTING) + if(BUILD_TESTING) + set(CMAKE_TEST_SYSTEM_LIBRARIES 0) + foreach(util CURL EXPAT XMLRPC ZLIB) + if(CMAKE_USE_SYSTEM_${util}) + set(CMAKE_TEST_SYSTEM_LIBRARIES 1) + endif() + endforeach() + + # This variable is set by cmake, however to + # test cmake we want to make sure that + # the ctest from this cmake is used for testing + # and not the ctest from the cmake building and testing + # cmake. + if(CMake_TEST_EXTERNAL_CMAKE) + set(CMAKE_CTEST_COMMAND "${CMake_TEST_EXTERNAL_CMAKE}/ctest") + set(CMAKE_CMAKE_COMMAND "${CMake_TEST_EXTERNAL_CMAKE}/cmake") + set(CMAKE_CPACK_COMMAND "${CMake_TEST_EXTERNAL_CMAKE}/cpack") + foreach(exe cmake ctest cpack) + add_executable(${exe} IMPORTED) + set_property(TARGET ${exe} PROPERTY IMPORTED_LOCATION ${CMake_TEST_EXTERNAL_CMAKE}/${exe}) + endforeach() + else() + set(CMAKE_CTEST_COMMAND "${CMake_BIN_DIR}/ctest") + set(CMAKE_CMAKE_COMMAND "${CMake_BIN_DIR}/cmake") + set(CMAKE_CPACK_COMMAND "${CMake_BIN_DIR}/cpack") + endif() + endif() + + # configure some files for testing + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Templates/CTestScript.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/CTestScript.cmake" + @ONLY) + configure_file(${CMake_SOURCE_DIR}/Tests/.NoDartCoverage + ${CMake_BINARY_DIR}/Tests/.NoDartCoverage) + configure_file(${CMake_SOURCE_DIR}/Tests/.NoDartCoverage + ${CMake_BINARY_DIR}/Modules/.NoDartCoverage) + configure_file(${CMake_SOURCE_DIR}/CTestCustom.cmake.in + ${CMake_BINARY_DIR}/CTestCustom.cmake @ONLY) + if(BUILD_TESTING AND DART_ROOT) + configure_file(${CMake_SOURCE_DIR}/CMakeLogo.gif + ${CMake_BINARY_DIR}/Testing/HTML/TestingResults/Icons/Logo.gif COPYONLY) + endif() + mark_as_advanced(DART_ROOT) + mark_as_advanced(CURL_TESTING) +endmacro() + + +# Provide a way for Visual Studio Express users to turn OFF the new FOLDER +# organization feature. Default to ON for non-Express users. Express users must +# explicitly turn off this option to build CMake in the Express IDE... +# +option(CMAKE_USE_FOLDERS "Enable folder grouping of projects in IDEs." ON) +mark_as_advanced(CMAKE_USE_FOLDERS) + + +#----------------------------------------------------------------------- +# a macro that only sets the FOLDER target property if it's +# "appropriate" +#----------------------------------------------------------------------- +macro(CMAKE_SET_TARGET_FOLDER tgt folder) + if(CMAKE_USE_FOLDERS) + set_property(GLOBAL PROPERTY USE_FOLDERS ON) + if(MSVC AND TARGET ${tgt}) + set_property(TARGET "${tgt}" PROPERTY FOLDER "${folder}") + endif() + else() + set_property(GLOBAL PROPERTY USE_FOLDERS OFF) + endif() +endmacro() + + +#----------------------------------------------------------------------- +# a macro to build the utilities used by CMake +# Simply to improve readability of the main script. +#----------------------------------------------------------------------- +macro (CMAKE_BUILD_UTILITIES) + #--------------------------------------------------------------------- + # Create the kwsys library for CMake. + set(KWSYS_NAMESPACE cmsys) + set(KWSYS_USE_SystemTools 1) + set(KWSYS_USE_Directory 1) + set(KWSYS_USE_RegularExpression 1) + set(KWSYS_USE_Base64 1) + set(KWSYS_USE_MD5 1) + set(KWSYS_USE_Process 1) + set(KWSYS_USE_CommandLineArguments 1) + set(KWSYS_USE_ConsoleBuf 1) + set(KWSYS_HEADER_ROOT ${CMake_BINARY_DIR}/Source) + set(KWSYS_INSTALL_DOC_DIR "${CMAKE_DOC_DIR}") + add_subdirectory(Source/kwsys) + set(kwsys_folder "Utilities/KWSys") + CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE} "${kwsys_folder}") + CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}_c "${kwsys_folder}") + if(BUILD_TESTING) + CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestDynload "${kwsys_folder}") + CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestProcess "${kwsys_folder}") + CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestsC "${kwsys_folder}") + CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestsCxx "${kwsys_folder}") + CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestSharedForward "${kwsys_folder}") + endif() + + #--------------------------------------------------------------------- + # Setup third-party libraries. + # Everything in the tree should be able to include files from the + # Utilities directory. + include_directories( + ${CMake_BINARY_DIR}/Utilities + ${CMake_SOURCE_DIR}/Utilities + ) -# -# Find OpenSSL -# (Except on Mac, where OpenSSL is deprecated.) -# -IF(ENABLE_OPENSSL AND NOT CMAKE_SYSTEM_NAME MATCHES "Darwin") - FIND_PACKAGE(OpenSSL) - IF(OPENSSL_FOUND) - SET(HAVE_LIBCRYPTO 1) - INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR}) - LIST(APPEND ADDITIONAL_LIBS ${OPENSSL_CRYPTO_LIBRARY}) - ENDIF(OPENSSL_FOUND) -ELSE() - SET(OPENSSL_FOUND FALSE) # Override cached value -ENDIF() - -# FreeBSD libmd -IF(NOT OPENSSL_FOUND) - CHECK_LIBRARY_EXISTS(md "MD5Init" "" LIBMD_FOUND) - IF(LIBMD_FOUND) - CMAKE_PUSH_CHECK_STATE() # Save the state of the variables - SET(CMAKE_REQUIRED_LIBRARIES "md") - FIND_LIBRARY(LIBMD_LIBRARY NAMES md) - LIST(APPEND ADDITIONAL_LIBS ${LIBMD_LIBRARY}) - CMAKE_POP_CHECK_STATE() # Restore the state of the variables - ENDIF(LIBMD_FOUND) -ENDIF(NOT OPENSSL_FOUND) + # check for the use of system libraries versus builtin ones + # (a macro defined in this file) + CMAKE_HANDLE_SYSTEM_LIBRARIES() + + if(CMAKE_USE_SYSTEM_KWIML) + find_package(KWIML 1.0) + if(NOT KWIML_FOUND) + message(FATAL_ERROR "CMAKE_USE_SYSTEM_KWIML is ON but KWIML is not found!") + endif() + set(CMake_KWIML_LIBRARIES kwiml::kwiml) + else() + set(CMake_KWIML_LIBRARIES "") + if(BUILD_TESTING) + set(KWIML_TEST_ENABLE 1) + endif() + add_subdirectory(Utilities/KWIML) + endif() + + if(CMAKE_USE_SYSTEM_LIBRHASH) + if(NOT CMAKE_VERSION VERSION_LESS 3.0) + find_package(LibRHash) + else() + message(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBRHASH requires CMake >= 3.0") + endif() + if(NOT LibRHash_FOUND) + message(FATAL_ERROR + "CMAKE_USE_SYSTEM_LIBRHASH is ON but LibRHash is not found!") + endif() + set(CMAKE_LIBRHASH_LIBRARIES LibRHash::LibRHash) + else() + set(CMAKE_LIBRHASH_LIBRARIES cmlibrhash) + add_subdirectory(Utilities/cmlibrhash) + CMAKE_SET_TARGET_FOLDER(cmlibrhash "Utilities/3rdParty") + endif() + + #--------------------------------------------------------------------- + # Build zlib library for Curl, CMake, and CTest. + set(CMAKE_ZLIB_HEADER "cm_zlib.h") + if(CMAKE_USE_SYSTEM_ZLIB) + find_package(ZLIB) + if(NOT ZLIB_FOUND) + message(FATAL_ERROR + "CMAKE_USE_SYSTEM_ZLIB is ON but a zlib is not found!") + endif() + set(CMAKE_ZLIB_INCLUDES ${ZLIB_INCLUDE_DIR}) + set(CMAKE_ZLIB_LIBRARIES ${ZLIB_LIBRARIES}) + else() + set(CMAKE_ZLIB_INCLUDES ${CMake_SOURCE_DIR}/Utilities) + set(CMAKE_ZLIB_LIBRARIES cmzlib) + add_subdirectory(Utilities/cmzlib) + CMAKE_SET_TARGET_FOLDER(cmzlib "Utilities/3rdParty") + endif() + + #--------------------------------------------------------------------- + # Build Curl library for CTest. + if(CMAKE_USE_SYSTEM_CURL) + find_package(CURL) + if(NOT CURL_FOUND) + message(FATAL_ERROR + "CMAKE_USE_SYSTEM_CURL is ON but a curl is not found!") + endif() + set(CMAKE_CURL_INCLUDES ${CURL_INCLUDE_DIRS}) + set(CMAKE_CURL_LIBRARIES ${CURL_LIBRARIES}) + else() + set(CURL_SPECIAL_ZLIB_H ${CMAKE_ZLIB_HEADER}) + set(CURL_SPECIAL_LIBZ_INCLUDES ${CMAKE_ZLIB_INCLUDES}) + set(CURL_SPECIAL_LIBZ ${CMAKE_ZLIB_LIBRARIES}) + add_definitions(-DCURL_STATICLIB) + set(CMAKE_CURL_INCLUDES) + set(CMAKE_CURL_LIBRARIES cmcurl) + if(CMAKE_TESTS_CDASH_SERVER) + set(CMAKE_CURL_TEST_URL "${CMAKE_TESTS_CDASH_SERVER}/user.php") + endif() + set(_CMAKE_USE_OPENSSL_DEFAULT OFF) + if(NOT DEFINED CMAKE_USE_OPENSSL AND NOT WIN32 AND NOT APPLE + AND CMAKE_SYSTEM_NAME MATCHES "(Linux|FreeBSD)") + find_package(OpenSSL QUIET) + if(OPENSSL_FOUND) + set(_CMAKE_USE_OPENSSL_DEFAULT ON) + endif() + endif() + option(CMAKE_USE_OPENSSL "Use OpenSSL." ${_CMAKE_USE_OPENSSL_DEFAULT}) + mark_as_advanced(CMAKE_USE_OPENSSL) + if(CMAKE_USE_OPENSSL) + set(CURL_CA_BUNDLE "" CACHE FILEPATH "Path to SSL CA Certificate Bundle") + set(CURL_CA_PATH "" CACHE PATH "Path to SSL CA Certificate Directory") + mark_as_advanced(CURL_CA_BUNDLE CURL_CA_PATH) + endif() + add_subdirectory(Utilities/cmcurl) + CMAKE_SET_TARGET_FOLDER(cmcurl "Utilities/3rdParty") + CMAKE_SET_TARGET_FOLDER(LIBCURL "Utilities/3rdParty") + endif() + + #--------------------------------------------------------------------- + # Build Compress library for CTest. + set(CMAKE_COMPRESS_INCLUDES + "${CMAKE_CURRENT_BINARY_DIR}/Utilities/cmcompress") + set(CMAKE_COMPRESS_LIBRARIES "cmcompress") + add_subdirectory(Utilities/cmcompress) + CMAKE_SET_TARGET_FOLDER(cmcompress "Utilities/3rdParty") + + #--------------------------------------------------------------------- + # Build expat library for CMake, CTest, and libarchive. + if(CMAKE_USE_SYSTEM_EXPAT) + find_package(EXPAT) + if(NOT EXPAT_FOUND) + message(FATAL_ERROR + "CMAKE_USE_SYSTEM_EXPAT is ON but a expat is not found!") + endif() + set(CMAKE_EXPAT_INCLUDES ${EXPAT_INCLUDE_DIRS}) + set(CMAKE_EXPAT_LIBRARIES ${EXPAT_LIBRARIES}) + else() + set(CMAKE_EXPAT_INCLUDES) + set(CMAKE_EXPAT_LIBRARIES cmexpat) + add_subdirectory(Utilities/cmexpat) + CMAKE_SET_TARGET_FOLDER(cmexpat "Utilities/3rdParty") + endif() + + #--------------------------------------------------------------------- + # Build or use system libbz2 for libarchive. + if(NOT CMAKE_USE_SYSTEM_LIBARCHIVE) + if(CMAKE_USE_SYSTEM_BZIP2) + find_package(BZip2) + else() + set(BZIP2_INCLUDE_DIR + "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/cmbzip2") + set(BZIP2_LIBRARIES cmbzip2) + add_subdirectory(Utilities/cmbzip2) + CMAKE_SET_TARGET_FOLDER(cmbzip2 "Utilities/3rdParty") + endif() + endif() + + #--------------------------------------------------------------------- + # Build or use system liblzma for libarchive. + if(NOT CMAKE_USE_SYSTEM_LIBARCHIVE) + if(CMAKE_USE_SYSTEM_LIBLZMA) + find_package(LibLZMA) + if(NOT LIBLZMA_FOUND) + message(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBLZMA is ON but LibLZMA is not found!") + endif() + set(LZMA_INCLUDE_DIR ${LIBLZMA_INCLUDE_DIRS}) + set(LZMA_LIBRARY ${LIBLZMA_LIBRARIES}) + else() + add_subdirectory(Utilities/cmliblzma) + CMAKE_SET_TARGET_FOLDER(cmliblzma "Utilities/3rdParty") + set(LZMA_INCLUDE_DIR + "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/cmliblzma/liblzma/api") + set(LZMA_LIBRARY cmliblzma) + endif() + endif() + + #--------------------------------------------------------------------- + # Build or use system libarchive for CMake and CTest. + if(CMAKE_USE_SYSTEM_LIBARCHIVE) + find_package(LibArchive 3.0.0) + if(NOT LibArchive_FOUND) + message(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBARCHIVE is ON but LibArchive is not found!") + endif() + set(CMAKE_TAR_INCLUDES ${LibArchive_INCLUDE_DIRS}) + set(CMAKE_TAR_LIBRARIES ${LibArchive_LIBRARIES}) + else() + set(EXPAT_INCLUDE_DIR ${CMAKE_EXPAT_INCLUDES}) + set(EXPAT_LIBRARY ${CMAKE_EXPAT_LIBRARIES}) + set(ZLIB_INCLUDE_DIR ${CMAKE_ZLIB_INCLUDES}) + set(ZLIB_LIBRARY ${CMAKE_ZLIB_LIBRARIES}) + add_definitions(-DLIBARCHIVE_STATIC) + set(ENABLE_NETTLE OFF CACHE INTERNAL "Enable use of Nettle") + set(ENABLE_OPENSSL ${CMAKE_USE_OPENSSL} CACHE INTERNAL "Enable use of OpenSSL") + set(ENABLE_LZMA ON CACHE INTERNAL "Enable the use of the system found LZMA library if found") + set(ENABLE_ZLIB ON CACHE INTERNAL "Enable the use of the system found ZLIB library if found") + set(ENABLE_BZip2 ON CACHE INTERNAL "Enable the use of the system found BZip2 library if found") + set(ENABLE_LIBXML2 OFF CACHE INTERNAL "Enable the use of the system found libxml2 library if found") + set(ENABLE_EXPAT ON CACHE INTERNAL "Enable the use of the system found EXPAT library if found") + set(ENABLE_PCREPOSIX OFF CACHE INTERNAL "Enable the use of the system found PCREPOSIX library if found") + set(ENABLE_LibGCC OFF CACHE INTERNAL "Enable the use of the system found LibGCC library if found") + set(ENABLE_XATTR OFF CACHE INTERNAL "Enable extended attribute support") + set(ENABLE_ACL OFF CACHE INTERNAL "Enable ACL support") + set(ENABLE_ICONV OFF CACHE INTERNAL "Enable iconv support") + set(ENABLE_CNG OFF CACHE INTERNAL "Enable the use of CNG(Crypto Next Generation)") + add_subdirectory(Utilities/cmlibarchive) + CMAKE_SET_TARGET_FOLDER(cmlibarchive "Utilities/3rdParty") + set(CMAKE_TAR_LIBRARIES cmlibarchive ${BZIP2_LIBRARIES}) + endif() + + #--------------------------------------------------------------------- + # Build jsoncpp library. + if(CMAKE_USE_SYSTEM_JSONCPP) + if(NOT CMAKE_VERSION VERSION_LESS 3.0) + find_package(JsonCpp) + else() + message(FATAL_ERROR "CMAKE_USE_SYSTEM_JSONCPP requires CMake >= 3.0") + endif() + if(NOT JsonCpp_FOUND) + message(FATAL_ERROR + "CMAKE_USE_SYSTEM_JSONCPP is ON but a JsonCpp is not found!") + endif() + set(CMAKE_JSONCPP_LIBRARIES JsonCpp::JsonCpp) + else() + set(CMAKE_JSONCPP_LIBRARIES cmjsoncpp) + add_subdirectory(Utilities/cmjsoncpp) + CMAKE_SET_TARGET_FOLDER(cmjsoncpp "Utilities/3rdParty") + endif() + + #--------------------------------------------------------------------- + # Build libuv library. + if(NOT DEFINED CMAKE_USE_LIBUV) + set(CMAKE_USE_LIBUV 1) + if(APPLE) + include(CheckCSourceCompiles) + check_c_source_compiles(" +#include <CoreServices/CoreServices.h> +#include <AvailabilityMacros.h> +#ifndef MAC_OS_X_VERSION_10_5 +#error \"MAC_OS_X_VERSION_10_5 is not defined\" +#endif +int main(void) { return 0; } +" HAVE_CoreServices_OS_X_10_5) + if(NOT HAVE_CoreServices_OS_X_10_5) + set(CMAKE_USE_LIBUV 0) + endif() + elseif(CYGWIN) + # libuv does not support Cygwin + set(CMAKE_USE_LIBUV 0) + elseif(CMAKE_SYSTEM_NAME STREQUAL "HP-UX") + # Disable until it can be ported. + set(CMAKE_USE_LIBUV 0) + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "sparc") + # Disable until it can be ported. + set(CMAKE_USE_LIBUV 0) + elseif(CMAKE_SYSTEM STREQUAL "SunOS-5.10") + # Disable until it can be ported. + set(CMAKE_USE_LIBUV 0) + endif() + endif() + if(CMAKE_USE_LIBUV) + if(CMAKE_USE_SYSTEM_LIBUV) + if(NOT CMAKE_VERSION VERSION_LESS 3.0) + find_package(LibUV 1.0.0) + else() + message(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBUV requires CMake >= 3.0") + endif() + if(NOT LIBUV_FOUND) + message(FATAL_ERROR + "CMAKE_USE_SYSTEM_LIBUV is ON but a libuv is not found!") + endif() + set(CMAKE_LIBUV_LIBRARIES LibUV::LibUV) + else() + set(CMAKE_LIBUV_LIBRARIES cmlibuv) + add_subdirectory(Utilities/cmlibuv) + CMAKE_SET_TARGET_FOLDER(cmlibuv "Utilities/3rdParty") + endif() + else() + set(CMAKE_LIBUV_LIBRARIES) + endif() + + #--------------------------------------------------------------------- + # Build XMLRPC library for CMake and CTest. + if(CTEST_USE_XMLRPC) + find_package(XMLRPC QUIET REQUIRED libwww-client) + if(NOT XMLRPC_FOUND) + message(FATAL_ERROR + "CTEST_USE_XMLRPC is ON but xmlrpc is not found!") + endif() + set(CMAKE_XMLRPC_INCLUDES ${XMLRPC_INCLUDE_DIRS}) + set(CMAKE_XMLRPC_LIBRARIES ${XMLRPC_LIBRARIES}) + endif() + + #--------------------------------------------------------------------- + # Use curses? + if (UNIX) + # there is a bug in the Syllable libraries which makes linking ccmake fail, Alex + if(NOT CMAKE_SYSTEM_NAME MATCHES syllable) + set(CURSES_NEED_NCURSES TRUE) + find_package(Curses QUIET) + if (CURSES_LIBRARY) + option(BUILD_CursesDialog "Build the CMake Curses Dialog ccmake" ON) + else () + message("Curses libraries were not found. Curses GUI for CMake will not be built.") + set(BUILD_CursesDialog 0) + endif () + else() + set(BUILD_CursesDialog 0) + endif() + else () + set(BUILD_CursesDialog 0) + endif () + if(BUILD_CursesDialog) + if(NOT CMAKE_USE_SYSTEM_FORM) + add_subdirectory(Source/CursesDialog/form) + elseif(NOT CURSES_FORM_LIBRARY) + message( FATAL_ERROR "CMAKE_USE_SYSTEM_FORM in ON but CURSES_FORM_LIBRARY is not set!" ) + endif() + endif() +endmacro () + +#----------------------------------------------------------------------- +if(NOT CMake_TEST_EXTERNAL_CMAKE) + if(CMAKE_CXX_PLATFORM_ID MATCHES "OpenBSD") + execute_process(COMMAND ${CMAKE_CXX_COMPILER} + ${CMAKE_CXX_COMPILER_ARG1} -dumpversion + OUTPUT_VARIABLE _GXX_VERSION + ) + string(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2" + _GXX_VERSION_SHORT ${_GXX_VERSION}) + if(_GXX_VERSION_SHORT EQUAL 33) + message(FATAL_ERROR + "GXX 3.3 on OpenBSD is known to cause CPack to Crash.\n" + "Please use GXX 4.2 or greater to build CMake on OpenBSD\n" + "${CMAKE_CXX_COMPILER} version is: ${_GXX_VERSION}") + endif() + endif() +endif() +#----------------------------------------------------------------------- +# The main section of the CMakeLists file # -# How to prove that CRYPTO functions, which have several names on various -# platforms, just see if archive_digest.c can compile and link against -# required libraries. -# -MACRO(CHECK_CRYPTO ALGORITHMS IMPLEMENTATION) - FOREACH(ALGORITHM ${ALGORITHMS}) - IF(NOT ARCHIVE_CRYPTO_${ALGORITHM}) - STRING(TOLOWER "${ALGORITHM}" lower_algorithm) - STRING(TOUPPER "${ALGORITHM}" algorithm) - IF ("${IMPLEMENTATION}" MATCHES "^OPENSSL$" AND NOT OPENSSL_FOUND) - SET(ARCHIVE_CRYPTO_${ALGORITHM}_${IMPLEMENTATION} FALSE) - ELSEIF("${IMPLEMENTATION}" MATCHES "^NETTLE$" AND NOT NETTLE_FOUND) - SET(ARCHIVE_CRYPTO_${ALGORITHM}_${IMPLEMENTATION} FALSE) - ENDIF("${IMPLEMENTATION}" MATCHES "^OPENSSL$" AND NOT OPENSSL_FOUND) - - IF(NOT DEFINED ARCHIVE_CRYPTO_${ALGORITHM}_${IMPLEMENTATION}) - # Probe the local implementation for whether this - # crypto implementation is available on this platform. - SET(TRY_CRYPTO_REQUIRED_INCLUDES - "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR}/libarchive;${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp") - SET(TRY_CRYPTO_REQUIRED_LIBS) - IF ("${IMPLEMENTATION}" MATCHES "^OPENSSL$" AND OPENSSL_FOUND) - SET(TRY_CRYPTO_REQUIRED_INCLUDES - "${TRY_CRYPTO_REQUIRED_INCLUDES};${OPENSSL_INCLUDE_DIR}") - SET(TRY_CRYPTO_REQUIRED_LIBS - "-DLINK_LIBRARIES:STRING=${OPENSSL_LIBRARIES}") - ELSEIF("${IMPLEMENTATION}" MATCHES "^NETTLE$" AND NETTLE_FOUND) - SET(TRY_CRYPTO_REQUIRED_INCLUDES - "${TRY_CRYPTO_REQUIRED_INCLUDES};${NETTLE_INCLUDE_DIR}") - SET(TRY_CRYPTO_REQUIRED_LIBS - "-DLINK_LIBRARIES:STRING=${NETTLE_LIBRARY}") - ELSEIF("${IMPLEMENTATION}" MATCHES "^LIBMD$" AND LIBMD_FOUND) - SET(TRY_CRYPTO_REQUIRED_LIBS - "-DLINK_LIBRARIES:STRING=${LIBMD_LIBRARY}") - ENDIF("${IMPLEMENTATION}" MATCHES "^OPENSSL$" AND OPENSSL_FOUND) - - CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/build/cmake/config.h.in - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/confdefs.h) - FILE(READ "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/confdefs.h" - CONFDEFS_H) - FILE(READ "${CMAKE_CURRENT_SOURCE_DIR}/libarchive/archive_digest.c" - ARCHIVE_CRYPTO_C) - - SET(SOURCE "${CONFDEFS_H} - -#define ARCHIVE_${algorithm}_COMPILE_TEST -#define ARCHIVE_CRYPTO_${algorithm}_${IMPLEMENTATION} -#define PLATFORM_CONFIG_H \"check_crypto_md.h\" - -${ARCHIVE_CRYPTO_C} - -int -main(int argc, char **argv) -{ - archive_${lower_algorithm}_ctx ctx; - archive_${lower_algorithm}_init(&ctx); - archive_${lower_algorithm}_update(&ctx, *argv, argc); - archive_${lower_algorithm}_final(&ctx, NULL); - return 0; -} -") - - FILE(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/check_crypto_md.h" "") - FILE(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/check_crypto_md.c" "${SOURCE}") - MESSAGE(STATUS "Checking support for ARCHIVE_CRYPTO_${ALGORITHM}_${IMPLEMENTATION}") - - TRY_COMPILE(ARCHIVE_CRYPTO_${ALGORITHM}_${IMPLEMENTATION} - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/check_crypto_md.c - CMAKE_FLAGS - "${TRY_CRYPTO_REQUIRED_LIBS}" - "${TRY_CRYPTO_REQUIRED_INCLUDES}" - OUTPUT_VARIABLE OUTPUT) - - # Inform user whether or not we found it; if not, log why we didn't. - IF (ARCHIVE_CRYPTO_${ALGORITHM}_${IMPLEMENTATION}) - MESSAGE(STATUS "Checking support for ARCHIVE_CRYPTO_${ALGORITHM}_${IMPLEMENTATION} -- found") - SET(ARCHIVE_CRYPTO_${ALGORITHM} 1) - ELSE (ARCHIVE_CRYPTO_${ALGORITHM}_${IMPLEMENTATION}) - MESSAGE(STATUS "Checking support for ARCHIVE_CRYPTO_${ALGORITHM}_${IMPLEMENTATION} -- not found") - FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Checking support for ARCHIVE_CRYPTO_${ALGORITHM}_${IMPLEMENTATION} failed with the following output:\n" - "${OUTPUT}\n" - "Source file was:\n${SOURCE}\n") - ENDIF (ARCHIVE_CRYPTO_${ALGORITHM}_${IMPLEMENTATION}) - ENDIF(NOT DEFINED ARCHIVE_CRYPTO_${ALGORITHM}_${IMPLEMENTATION}) - - # Add appropriate libs/includes depending on whether the implementation - # was found on this platform. - IF (ARCHIVE_CRYPTO_${ALGORITHM}_${IMPLEMENTATION}) - IF ("${IMPLEMENTATION}" MATCHES "^OPENSSL$" AND OPENSSL_FOUND) - INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR}) - LIST(APPEND ADDITIONAL_LIBS ${OPENSSL_LIBRARIES}) - LIST(REMOVE_DUPLICATES ADDITIONAL_LIBS) - ENDIF ("${IMPLEMENTATION}" MATCHES "^OPENSSL$" AND OPENSSL_FOUND) - ENDIF (ARCHIVE_CRYPTO_${ALGORITHM}_${IMPLEMENTATION}) - ENDIF(NOT ARCHIVE_CRYPTO_${ALGORITHM}) - ENDFOREACH(ALGORITHM ${ALGORITHMS}) -ENDMACRO(CHECK_CRYPTO ALGORITHMS IMPLEMENTATION) +#----------------------------------------------------------------------- +# Compute CMake_VERSION, etc. +include(Source/CMakeVersionCompute.cmake) -# -# CRYPTO functions on Windows is defined at archive_windows.c, thus we do not -# need the test what the functions can be mapped to archive_{crypto name}_init, -# archive_{crypto name}_update and archive_{crypto name}_final. -# The functions on Windows use CALG_{crypto name} macro to create a crypt object -# and then we need to know what CALG_{crypto name} macros is available to show -# ARCHIVE_CRYPTO_{crypto name}_WIN macros because Windows 2000 and earlier version -# of Windows XP do not support SHA256, SHA384 and SHA512. -# -MACRO(CHECK_CRYPTO_WIN CRYPTO_LIST) - IF(WIN32 AND NOT CYGWIN) - FOREACH(CRYPTO ${CRYPTO_LIST}) - IF(NOT ARCHIVE_CRYPTO_${CRYPTO}) - IF(NOT DEFINED ARCHIVE_CRYPTO_${CRYPTO}_WIN) - STRING(TOUPPER "${CRYPTO}" crypto) - SET(ALGID "") - IF ("${CRYPTO}" MATCHES "^MD5$") - SET(ALGID "CALG_MD5") - ENDIF ("${CRYPTO}" MATCHES "^MD5$") - IF ("${CRYPTO}" MATCHES "^SHA1$") - SET(ALGID "CALG_SHA1") - ENDIF ("${CRYPTO}" MATCHES "^SHA1$") - IF ("${CRYPTO}" MATCHES "^SHA256$") - SET(ALGID "CALG_SHA_256") - ENDIF ("${CRYPTO}" MATCHES "^SHA256$") - IF ("${CRYPTO}" MATCHES "^SHA384$") - SET(ALGID "CALG_SHA_384") - ENDIF ("${CRYPTO}" MATCHES "^SHA384$") - IF ("${CRYPTO}" MATCHES "^SHA512$") - SET(ALGID "CALG_SHA_512") - ENDIF ("${CRYPTO}" MATCHES "^SHA512$") - - CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/build/cmake/config.h.in - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/confdefs.h) - FILE(READ "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/confdefs.h" - CONFDEFS_H) - - SET(SOURCE "${CONFDEFS_H} - -#define ${crypto}_COMPILE_TEST -#include <windows.h> -#include <wincrypt.h> - -int -main(int argc, char **argv) -{ - return ${ALGID}; -} -") - SET(SOURCE_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/check_crypto_win.c") - - FILE(WRITE "${SOURCE_FILE}" "${SOURCE}") - MESSAGE(STATUS "Checking support for ARCHIVE_CRYPTO_${CRYPTO}_WIN") - - TRY_COMPILE(ARCHIVE_CRYPTO_${CRYPTO}_WIN - ${CMAKE_BINARY_DIR} - ${SOURCE_FILE} - CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR}/libarchive" - OUTPUT_VARIABLE OUTPUT) - - IF (ARCHIVE_CRYPTO_${CRYPTO}_WIN) - MESSAGE(STATUS - "Checking support for ARCHIVE_CRYPTO_${CRYPTO}_WIN -- found") - SET(ARCHIVE_CRYPTO_${CRYPTO} 1) - ELSE (ARCHIVE_CRYPTO_${CRYPTO}_WIN) - MESSAGE(STATUS - "Checking support for ARCHIVE_CRYPTO_${CRYPTO}_WIN -- not found") - FILE(APPEND - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Checking support for ARCHIVE_CRYPTO_${CRYPTO}_WIN failed with the following output:\n" - "${OUTPUT}\n" - "Source file was:\n${SOURCE}\n") - ENDIF (ARCHIVE_CRYPTO_${CRYPTO}_WIN) - - ENDIF(NOT DEFINED ARCHIVE_CRYPTO_${CRYPTO}_WIN) - ENDIF(NOT ARCHIVE_CRYPTO_${CRYPTO}) - ENDFOREACH(CRYPTO) - ENDIF(WIN32 AND NOT CYGWIN) -ENDMACRO(CHECK_CRYPTO_WIN CRYPTO_LIST) +# Include the standard Dart testing module +enable_testing() +include (${CMAKE_ROOT}/Modules/Dart.cmake) -# -# Find iconv -# POSIX defines the second arg as const char ** -# and requires it to be in libc. But we can accept -# a non-const argument here and can support iconv() -# being in libiconv. -# -MACRO(CHECK_ICONV LIB TRY_ICONV_CONST) - IF(NOT HAVE_ICONV) - CMAKE_PUSH_CHECK_STATE() # Save the state of the variables - IF (CMAKE_C_COMPILER_ID MATCHES "^GNU$" OR - CMAKE_C_COMPILER_ID MATCHES "^Clang$") - # - # During checking iconv proto type, we should use -Werror to avoid the - # success of iconv detection with a warnig which success is a miss - # detection. So this needs for all build mode(even it's a release mode). - # - SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror") - ENDIF (CMAKE_C_COMPILER_ID MATCHES "^GNU$" OR - CMAKE_C_COMPILER_ID MATCHES "^Clang$") - IF (CMAKE_C_COMPILER_ID MATCHES "^XL$") - SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -qhalt=w -qflag=w:w") - ENDIF (CMAKE_C_COMPILER_ID MATCHES "^XL$") - IF (MSVC) - # NOTE: /WX option is the same as gcc's -Werror option. - SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} /WX") - ENDIF (MSVC) - # - CHECK_C_SOURCE_COMPILES( - "#include <stdlib.h> - #include <iconv.h> - int main() { - ${TRY_ICONV_CONST} char *ccp; - iconv_t cd = iconv_open(\"\", \"\"); - iconv(cd, &ccp, (size_t *)0, (char **)0, (size_t *)0); - iconv_close(cd); - return 0; - }" - HAVE_ICONV_${LIB}_${TRY_ICONV_CONST}) - IF(HAVE_ICONV_${LIB}_${TRY_ICONV_CONST}) - SET(HAVE_ICONV true) - SET(ICONV_CONST ${TRY_ICONV_CONST}) - ENDIF(HAVE_ICONV_${LIB}_${TRY_ICONV_CONST}) - CMAKE_POP_CHECK_STATE() # Restore the state of the variables - ENDIF(NOT HAVE_ICONV) -ENDMACRO(CHECK_ICONV TRY_ICONV_CONST) - -IF(ENABLE_ICONV) - CMAKE_PUSH_CHECK_STATE() # Save the state of the variables - FIND_PATH(ICONV_INCLUDE_DIR iconv.h) - IF(ICONV_INCLUDE_DIR) - #SET(INCLUDES ${INCLUDES} "iconv.h") - SET(HAVE_ICONV_H 1) - INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR}) - SET(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR}) - CHECK_ICONV("libc" "const") - CHECK_ICONV("libc" "") - - # If iconv isn't in libc and we have a libiconv, try that. - FIND_LIBRARY(LIBICONV_PATH NAMES iconv libiconv) - IF(NOT HAVE_ICONV AND LIBICONV_PATH) - LIST(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBICONV_PATH}) - # Test if a macro is needed for the library. - TRY_MACRO_FOR_LIBRARY( - "${ICONV_INCLUDE_DIR}" "${LIBICONV_PATH}" - COMPILES - "#include <iconv.h>\nint main() {return iconv_close((iconv_t)0);}" - "WITHOUT_LIBICONV_STATIC;LIBICONV_STATIC") - IF(NOT WITHOUT_LIBICONV_STATIC AND LIBICONV_STATIC) - ADD_DEFINITIONS(-DLIBICONV_STATIC) - ENDIF(NOT WITHOUT_LIBICONV_STATIC AND LIBICONV_STATIC) - # - # Set up CMAKE_REQUIRED_* for CHECK_ICONV - # - SET(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR}) - SET(CMAKE_REQUIRED_LIBRARIES ${LIBICONV_PATH}) - IF(LIBICONV_STATIC) - # LIBICONV_STATIC is necessary for the success of CHECK_ICONV - # on Windows. - SET(CMAKE_REQUIRED_DEFINITIONS "-DLIBICONV_STATIC") - ELSE(LIBICONV_STATIC) - SET(CMAKE_REQUIRED_DEFINITIONS) - ENDIF(LIBICONV_STATIC) - CHECK_ICONV("libiconv" "const") - CHECK_ICONV("libiconv" "") - IF (HAVE_ICONV) - LIST(APPEND ADDITIONAL_LIBS ${LIBICONV_PATH}) - ENDIF(HAVE_ICONV) - ENDIF(NOT HAVE_ICONV AND LIBICONV_PATH) - ENDIF(ICONV_INCLUDE_DIR) - # - # Find locale_charset() for libiconv. - # - IF(LIBICONV_PATH) - SET(CMAKE_REQUIRED_DEFINITIONS) - SET(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR}) - SET(CMAKE_REQUIRED_LIBRARIES) - CHECK_INCLUDE_FILES("localcharset.h" HAVE_LOCALCHARSET_H) - FIND_LIBRARY(LIBCHARSET_PATH NAMES charset libcharset) - IF(LIBCHARSET_PATH) - SET(CMAKE_REQUIRED_LIBRARIES ${LIBCHARSET_PATH}) - IF(WIN32 AND NOT CYGWIN) - # Test if a macro is needed for the library. - TRY_MACRO_FOR_LIBRARY( - "${ICONV_INCLUDE_DIR}" "${LIBCHARSET_PATH}" - COMPILES - "#include <localcharset.h>\nint main() {return locale_charset()?1:0;}" - "WITHOUT_LIBCHARSET_STATIC;LIBCHARSET_STATIC") - IF(NOT WITHOUT_LIBCHARSET_STATIC AND LIBCHARSET_STATIC) - ADD_DEFINITIONS(-DLIBCHARSET_STATIC) - ENDIF(NOT WITHOUT_LIBCHARSET_STATIC AND LIBCHARSET_STATIC) - IF(WITHOUT_LIBCHARSET_STATIC OR LIBCHARSET_STATIC) - SET(HAVE_LOCALE_CHARSET ON CACHE INTERNAL - "Have function locale_charset") - ENDIF(WITHOUT_LIBCHARSET_STATIC OR LIBCHARSET_STATIC) - ELSE(WIN32 AND NOT CYGWIN) - CHECK_FUNCTION_EXISTS_GLIBC(locale_charset HAVE_LOCALE_CHARSET) - ENDIF(WIN32 AND NOT CYGWIN) - IF(HAVE_LOCALE_CHARSET) - LIST(APPEND ADDITIONAL_LIBS ${LIBCHARSET_PATH}) - ENDIF(HAVE_LOCALE_CHARSET) - ENDIF(LIBCHARSET_PATH) - ENDIF(LIBICONV_PATH) - CMAKE_POP_CHECK_STATE() # Restore the state of the variables -ELSE(ENABLE_ICONV) - # Make sure ICONV variables are not in CACHE after ENABLE_ICONV disabled - # (once enabled). - UNSET(HAVE_LOCALE_CHARSET CACHE) - UNSET(HAVE_ICONV CACHE) - UNSET(HAVE_ICONV_libc_ CACHE) - UNSET(HAVE_ICONV_libc_const CACHE) - UNSET(HAVE_ICONV_libiconv_ CACHE) - UNSET(HAVE_ICONV_libiconv_const CACHE) - UNSET(ICONV_INCLUDE_DIR CACHE) - UNSET(LIBICONV_PATH CACHE) - UNSET(LIBICONV_DLL CACHE) - UNSET(LIBICONV_STATIC CACHE) - UNSET(LIBCHARSET_DLL CACHE) - UNSET(LIBCHARSET_STATIC CACHE) -ENDIF(ENABLE_ICONV) +# Set up test-time configuration. +set_directory_properties(PROPERTIES + TEST_INCLUDE_FILE "${CMake_BINARY_DIR}/Tests/EnforceConfig.cmake") -# -# Find Libxml2 -# -IF(ENABLE_LIBXML2) - FIND_PACKAGE(LibXml2) -ELSE() - SET(LIBXML2_FOUND FALSE) -ENDIF() -IF(LIBXML2_FOUND) - CMAKE_PUSH_CHECK_STATE() # Save the state of the variables - INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR}) - LIST(APPEND ADDITIONAL_LIBS ${LIBXML2_LIBRARIES}) - SET(HAVE_LIBXML2 1) - # libxml2's include files use iconv.h - SET(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR}) - CHECK_INCLUDE_FILES("libxml/xmlreader.h" HAVE_LIBXML_XMLREADER_H) - CHECK_INCLUDE_FILES("libxml/xmlwriter.h" HAVE_LIBXML_XMLWRITER_H) - # Test if a macro is needed for the library. - TRY_MACRO_FOR_LIBRARY( - "${ICONV_INCLUDE_DIR};${LIBXML2_INCLUDE_DIR}" - "ws2_32.lib;${ZLIB_LIBRARIES};${LIBICONV_PATH};${LIBXML2_LIBRARIES}" - COMPILES - "#include <stddef.h>\n#include <libxml/xmlreader.h>\nint main() {return xmlTextReaderRead((xmlTextReaderPtr)(void *)0);}" - "WITHOUT_LIBXML_STATIC;LIBXML_STATIC") - IF(NOT WITHOUT_LIBXML_STATIC AND LIBXML_STATIC) - ADD_DEFINITIONS(-DLIBXML_STATIC) - ENDIF(NOT WITHOUT_LIBXML_STATIC AND LIBXML_STATIC) - CMAKE_POP_CHECK_STATE() # Restore the state of the variables -ELSE(LIBXML2_FOUND) - # - # Find Expat - # - IF(ENABLE_EXPAT) - FIND_PACKAGE(EXPAT) - ELSE() - SET(EXPAT_FOUND FALSE) - ENDIF() - IF(EXPAT_FOUND) - CMAKE_PUSH_CHECK_STATE() # Save the state of the variables - INCLUDE_DIRECTORIES(${EXPAT_INCLUDE_DIR}) - LIST(APPEND ADDITIONAL_LIBS ${EXPAT_LIBRARIES}) - SET(HAVE_LIBEXPAT 1) - LA_CHECK_INCLUDE_FILE("expat.h" HAVE_EXPAT_H) - CMAKE_POP_CHECK_STATE() # Restore the state of the variables - ENDIF(EXPAT_FOUND) -ENDIF(LIBXML2_FOUND) -MARK_AS_ADVANCED(CLEAR LIBXML2_INCLUDE_DIR) -MARK_AS_ADVANCED(CLEAR LIBXML2_LIBRARIES) +if(NOT CMake_TEST_EXTERNAL_CMAKE) + # where to write the resulting executables and libraries + set(BUILD_SHARED_LIBS OFF) + set(EXECUTABLE_OUTPUT_PATH "" CACHE INTERNAL "No configurable exe dir.") + set(LIBRARY_OUTPUT_PATH "" CACHE INTERNAL + "Where to put the libraries for CMake") -# -# POSIX Regular Expression support -# -IF(POSIX_REGEX_LIB MATCHES "^(AUTO|LIBC|LIBREGEX)$") - # - # If PCREPOSIX is not found or not requested, try using regex - # from libc or libregex - # - FIND_PATH(REGEX_INCLUDE_DIR regex.h) - IF(REGEX_INCLUDE_DIR) - CHECK_FUNCTION_EXISTS_GLIBC(regcomp HAVE_REGCOMP_LIBC) - # - # If libc does not provide regex, find libregex. - # - IF(NOT HAVE_REGCOMP_LIBC) - CMAKE_PUSH_CHECK_STATE() # Save the state of the variables - FIND_LIBRARY(REGEX_LIBRARY regex) - IF(REGEX_LIBRARY) - SET(CMAKE_REQUIRED_LIBRARIES ${REGEX_LIBRARY}) - CHECK_FUNCTION_EXISTS_GLIBC(regcomp HAVE_REGCOMP_LIBREGEX) - IF(HAVE_REGCOMP_LIBREGEX) - LIST(APPEND ADDITIONAL_LIBS ${REGEX_LIBRARY}) - # - # If regex.h is not found, retry looking for regex.h at - # REGEX_INCLUDE_DIR - # - IF(NOT HAVE_REGEX_H) - UNSET(HAVE_REGEX_H CACHE) - INCLUDE_DIRECTORIES(${REGEX_INCLUDE_DIR}) - SET(CMAKE_REQUIRED_INCLUDES ${REGEX_INCLUDE_DIR}) - LA_CHECK_INCLUDE_FILE("regex.h" HAVE_REGEX_H) - ENDIF(NOT HAVE_REGEX_H) - # Test if a macro is needed for the library. - TRY_MACRO_FOR_LIBRARY( - "${REGEX_INCLUDE_DIR}" "${REGEX_LIBRARY}" - COMPILES - "#include <stddef.h>\n#include <regex.h>\nint main() {regex_t r;return regcomp(&r, \"\", 0);}" - "USE_REGEX_DLL;USE_REGEX_STATIC") - IF(USE_REGEX_DLL) - ADD_DEFINITIONS(-DUSE_REGEX_DLL) - ELSEIF(USE_REGEX_STATIC) - ADD_DEFINITIONS(-DUSE_REGEX_STATIC) - ENDIF(USE_REGEX_DLL) - ENDIF(HAVE_REGCOMP_LIBREGEX) - ENDIF(REGEX_LIBRARY) - CMAKE_POP_CHECK_STATE() # Restore the state of the variables - ENDIF(NOT HAVE_REGCOMP_LIBC) - ENDIF(REGEX_INCLUDE_DIR) - IF(HAVE_REGCOMP_LIBC OR HAVE_REGCOMP_LIBREGEX) - SET(FOUND_POSIX_REGEX_LIB 1) - ENDIF(HAVE_REGCOMP_LIBC OR HAVE_REGCOMP_LIBREGEX) -ENDIF(POSIX_REGEX_LIB MATCHES "^(AUTO|LIBC|LIBREGEX)$") - -IF(NOT FOUND_POSIX_REGEX_LIB AND POSIX_REGEX_LIB MATCHES "^(AUTO|LIBPCREPOSIX)$") - # - # If requested, try finding library for PCREPOSIX - # - IF(ENABLE_LibGCC) - FIND_PACKAGE(LibGCC) - ELSE() - SET(LIBGCC_FOUND FALSE) # Override cached value - ENDIF() - IF(ENABLE_PCREPOSIX) - FIND_PACKAGE(PCREPOSIX) - ELSE() - SET(PCREPOSIX_FOUND FALSE) # Override cached value - ENDIF() - IF(PCREPOSIX_FOUND) - INCLUDE_DIRECTORIES(${PCRE_INCLUDE_DIR}) - LIST(APPEND ADDITIONAL_LIBS ${PCREPOSIX_LIBRARIES}) - # Test if a macro is needed for the library. - TRY_MACRO_FOR_LIBRARY( - "${PCRE_INCLUDE_DIR}" "${PCREPOSIX_LIBRARIES}" - COMPILES - "#include <pcreposix.h>\nint main() {regex_t r;return regcomp(&r, \"\", 0);}" - "WITHOUT_PCRE_STATIC;PCRE_STATIC") - IF(NOT WITHOUT_PCRE_STATIC AND PCRE_STATIC) - ADD_DEFINITIONS(-DPCRE_STATIC) - ELSEIF(NOT WITHOUT_PCRE_STATIC AND NOT PCRE_STATIC AND PCRE_FOUND) - # Determine if pcre static libraries are to be used. - LIST(APPEND ADDITIONAL_LIBS ${PCRE_LIBRARIES}) - SET(TMP_LIBRARIES ${PCREPOSIX_LIBRARIES} ${PCRE_LIBRARIES}) - MESSAGE(STATUS "trying again with -lpcre included") - TRY_MACRO_FOR_LIBRARY( - "${PCRE_INCLUDE_DIR}" "${TMP_LIBRARIES}" - COMPILES - "#include <pcreposix.h>\nint main() {regex_t r;return regcomp(&r, \"\", 0);}" - "WITHOUT_PCRE_STATIC;PCRE_STATIC") - IF(NOT WITHOUT_PCRE_STATIC AND PCRE_STATIC) - ADD_DEFINITIONS(-DPCRE_STATIC) - ELSEIF(NOT WITHOUT_PCRE_STATIC AND NOT PCRE_STATIC AND MSVC AND LIBGCC_FOUND) - # When doing a Visual Studio build using pcre static libraries - # built using the mingw toolchain, -lgcc is needed to resolve - # ___chkstk_ms. - MESSAGE(STATUS "Visual Studio build detected, trying again with -lgcc included") - LIST(APPEND ADDITIONAL_LIBS ${LIBGCC_LIBRARIES}) - SET(TMP_LIBRARIES ${PCREPOSIX_LIBRARIES} ${PCRE_LIBRARIES} ${LIBGCC_LIBRARIES}) - TRY_MACRO_FOR_LIBRARY( - "${PCRE_INCLUDE_DIR}" "${TMP_LIBRARIES}" - COMPILES - "#include <pcreposix.h>\nint main() {regex_t r;return regcomp(&r, \"\", 0);}" - "WITHOUT_PCRE_STATIC;PCRE_STATIC") - IF(NOT WITHOUT_PCRE_STATIC AND PCRE_STATIC) - ADD_DEFINITIONS(-DPCRE_STATIC) - ENDIF(NOT WITHOUT_PCRE_STATIC AND PCRE_STATIC) - ENDIF(NOT WITHOUT_PCRE_STATIC AND PCRE_STATIC) - ENDIF(NOT WITHOUT_PCRE_STATIC AND PCRE_STATIC) - ENDIF(PCREPOSIX_FOUND) - MARK_AS_ADVANCED(CLEAR PCRE_INCLUDE_DIR) - MARK_AS_ADVANCED(CLEAR PCREPOSIX_LIBRARIES) - MARK_AS_ADVANCED(CLEAR PCRE_LIBRARIES) - MARK_AS_ADVANCED(CLEAR LIBGCC_LIBRARIES) -ENDIF(NOT FOUND_POSIX_REGEX_LIB AND POSIX_REGEX_LIB MATCHES "^(AUTO|LIBPCREPOSIX)$") + # The CMake executables usually do not need any rpath to run in the build or + # install tree. + set(CMAKE_SKIP_RPATH ON CACHE INTERNAL "CMake does not need RPATHs.") -# -# Check functions -# -CMAKE_PUSH_CHECK_STATE() # Save the state of the variables -IF (CMAKE_C_COMPILER_ID MATCHES "^GNU$" OR - CMAKE_C_COMPILER_ID MATCHES "^Clang$") - # - # During checking functions, we should use -fno-builtin to avoid the - # failure of function detection which failure is an error "conflicting - # types for built-in function" caused by using -Werror option. - # - SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-builtin") -ENDIF (CMAKE_C_COMPILER_ID MATCHES "^GNU$" OR - CMAKE_C_COMPILER_ID MATCHES "^Clang$") -CHECK_SYMBOL_EXISTS(_CrtSetReportMode "crtdbg.h" HAVE__CrtSetReportMode) -CHECK_FUNCTION_EXISTS_GLIBC(arc4random_buf HAVE_ARC4RANDOM_BUF) -CHECK_FUNCTION_EXISTS_GLIBC(chflags HAVE_CHFLAGS) -CHECK_FUNCTION_EXISTS_GLIBC(chown HAVE_CHOWN) -CHECK_FUNCTION_EXISTS_GLIBC(chroot HAVE_CHROOT) -CHECK_FUNCTION_EXISTS_GLIBC(ctime_r HAVE_CTIME_R) -CHECK_FUNCTION_EXISTS_GLIBC(dirfd HAVE_DIRFD) -CHECK_FUNCTION_EXISTS_GLIBC(fchdir HAVE_FCHDIR) -CHECK_FUNCTION_EXISTS_GLIBC(fchflags HAVE_FCHFLAGS) -CHECK_FUNCTION_EXISTS_GLIBC(fchmod HAVE_FCHMOD) -CHECK_FUNCTION_EXISTS_GLIBC(fchown HAVE_FCHOWN) -CHECK_FUNCTION_EXISTS_GLIBC(fcntl HAVE_FCNTL) -CHECK_FUNCTION_EXISTS_GLIBC(fdopendir HAVE_FDOPENDIR) -CHECK_FUNCTION_EXISTS_GLIBC(fork HAVE_FORK) -CHECK_FUNCTION_EXISTS_GLIBC(fstat HAVE_FSTAT) -CHECK_FUNCTION_EXISTS_GLIBC(fstatat HAVE_FSTATAT) -CHECK_FUNCTION_EXISTS_GLIBC(fstatfs HAVE_FSTATFS) -CHECK_FUNCTION_EXISTS_GLIBC(fstatvfs HAVE_FSTATVFS) -CHECK_FUNCTION_EXISTS_GLIBC(ftruncate HAVE_FTRUNCATE) -CHECK_FUNCTION_EXISTS_GLIBC(futimens HAVE_FUTIMENS) -CHECK_FUNCTION_EXISTS_GLIBC(futimes HAVE_FUTIMES) -CHECK_FUNCTION_EXISTS_GLIBC(futimesat HAVE_FUTIMESAT) -CHECK_FUNCTION_EXISTS_GLIBC(geteuid HAVE_GETEUID) -CHECK_FUNCTION_EXISTS_GLIBC(getgrgid_r HAVE_GETGRGID_R) -CHECK_FUNCTION_EXISTS_GLIBC(getgrnam_r HAVE_GETGRNAM_R) -CHECK_FUNCTION_EXISTS_GLIBC(getpwnam_r HAVE_GETPWNAM_R) -CHECK_FUNCTION_EXISTS_GLIBC(getpwuid_r HAVE_GETPWUID_R) -CHECK_FUNCTION_EXISTS_GLIBC(getpid HAVE_GETPID) -CHECK_FUNCTION_EXISTS_GLIBC(getvfsbyname HAVE_GETVFSBYNAME) -CHECK_FUNCTION_EXISTS_GLIBC(gmtime_r HAVE_GMTIME_R) -CHECK_FUNCTION_EXISTS_GLIBC(lchflags HAVE_LCHFLAGS) -CHECK_FUNCTION_EXISTS_GLIBC(lchmod HAVE_LCHMOD) -CHECK_FUNCTION_EXISTS_GLIBC(lchown HAVE_LCHOWN) -CHECK_FUNCTION_EXISTS_GLIBC(link HAVE_LINK) -CHECK_FUNCTION_EXISTS_GLIBC(localtime_r HAVE_LOCALTIME_R) -CHECK_FUNCTION_EXISTS_GLIBC(lstat HAVE_LSTAT) -CHECK_FUNCTION_EXISTS_GLIBC(lutimes HAVE_LUTIMES) -CHECK_FUNCTION_EXISTS_GLIBC(mbrtowc HAVE_MBRTOWC) -CHECK_FUNCTION_EXISTS_GLIBC(memmove HAVE_MEMMOVE) -CHECK_FUNCTION_EXISTS_GLIBC(mkdir HAVE_MKDIR) -CHECK_FUNCTION_EXISTS_GLIBC(mkfifo HAVE_MKFIFO) -CHECK_FUNCTION_EXISTS_GLIBC(mknod HAVE_MKNOD) -CHECK_FUNCTION_EXISTS_GLIBC(mkstemp HAVE_MKSTEMP) -CHECK_FUNCTION_EXISTS_GLIBC(nl_langinfo HAVE_NL_LANGINFO) -CHECK_FUNCTION_EXISTS_GLIBC(openat HAVE_OPENAT) -CHECK_FUNCTION_EXISTS_GLIBC(pipe HAVE_PIPE) -CHECK_FUNCTION_EXISTS_GLIBC(poll HAVE_POLL) -CHECK_FUNCTION_EXISTS_GLIBC(posix_spawnp HAVE_POSIX_SPAWNP) -CHECK_FUNCTION_EXISTS_GLIBC(readlink HAVE_READLINK) -CHECK_FUNCTION_EXISTS_GLIBC(readpassphrase HAVE_READPASSPHRASE) -CHECK_FUNCTION_EXISTS_GLIBC(select HAVE_SELECT) -CHECK_FUNCTION_EXISTS_GLIBC(setenv HAVE_SETENV) -CHECK_FUNCTION_EXISTS_GLIBC(setlocale HAVE_SETLOCALE) -CHECK_FUNCTION_EXISTS_GLIBC(sigaction HAVE_SIGACTION) -CHECK_FUNCTION_EXISTS_GLIBC(statfs HAVE_STATFS) -CHECK_FUNCTION_EXISTS_GLIBC(statvfs HAVE_STATVFS) -CHECK_FUNCTION_EXISTS_GLIBC(strchr HAVE_STRCHR) -CHECK_FUNCTION_EXISTS_GLIBC(strdup HAVE_STRDUP) -CHECK_FUNCTION_EXISTS_GLIBC(strerror HAVE_STRERROR) -CHECK_FUNCTION_EXISTS_GLIBC(strncpy_s HAVE_STRNCPY_S) -CHECK_FUNCTION_EXISTS_GLIBC(strrchr HAVE_STRRCHR) -CHECK_FUNCTION_EXISTS_GLIBC(symlink HAVE_SYMLINK) -CHECK_FUNCTION_EXISTS_GLIBC(timegm HAVE_TIMEGM) -CHECK_FUNCTION_EXISTS_GLIBC(tzset HAVE_TZSET) -CHECK_FUNCTION_EXISTS_GLIBC(unsetenv HAVE_UNSETENV) -CHECK_FUNCTION_EXISTS_GLIBC(utime HAVE_UTIME) -CHECK_FUNCTION_EXISTS_GLIBC(utimes HAVE_UTIMES) -CHECK_FUNCTION_EXISTS_GLIBC(utimensat HAVE_UTIMENSAT) -CHECK_FUNCTION_EXISTS_GLIBC(vfork HAVE_VFORK) -CHECK_FUNCTION_EXISTS_GLIBC(wcrtomb HAVE_WCRTOMB) -CHECK_FUNCTION_EXISTS_GLIBC(wcscmp HAVE_WCSCMP) -CHECK_FUNCTION_EXISTS_GLIBC(wcscpy HAVE_WCSCPY) -CHECK_FUNCTION_EXISTS_GLIBC(wcslen HAVE_WCSLEN) -CHECK_FUNCTION_EXISTS_GLIBC(wctomb HAVE_WCTOMB) -CHECK_FUNCTION_EXISTS_GLIBC(_ctime64_s HAVE__CTIME64_S) -CHECK_FUNCTION_EXISTS_GLIBC(_fseeki64 HAVE__FSEEKI64) -CHECK_FUNCTION_EXISTS_GLIBC(_get_timezone HAVE__GET_TIMEZONE) -CHECK_FUNCTION_EXISTS_GLIBC(_localtime64_s HAVE__LOCALTIME64_S) -CHECK_FUNCTION_EXISTS_GLIBC(_mkgmtime64 HAVE__MKGMTIME64) - -SET(CMAKE_REQUIRED_LIBRARIES "") -CHECK_FUNCTION_EXISTS(cygwin_conv_path HAVE_CYGWIN_CONV_PATH) -CHECK_FUNCTION_EXISTS(fseeko HAVE_FSEEKO) -CHECK_FUNCTION_EXISTS(strerror_r HAVE_STRERROR_R) -CHECK_FUNCTION_EXISTS(strftime HAVE_STRFTIME) -CHECK_FUNCTION_EXISTS(vprintf HAVE_VPRINTF) -CHECK_FUNCTION_EXISTS(wmemcmp HAVE_WMEMCMP) -CHECK_FUNCTION_EXISTS(wmemcpy HAVE_WMEMCPY) -CHECK_FUNCTION_EXISTS(wmemmove HAVE_WMEMMOVE) - -CMAKE_POP_CHECK_STATE() # Restore the state of the variables - -CHECK_C_SOURCE_COMPILES( - "#include <sys/types.h>\n#include <sys/mount.h>\nint main(void) { struct vfsconf v; return sizeof(v);}" - HAVE_STRUCT_VFSCONF) - -CHECK_C_SOURCE_COMPILES( - "#include <sys/types.h>\n#include <sys/mount.h>\nint main(void) { struct xvfsconf v; return sizeof(v);}" - HAVE_STRUCT_XVFSCONF) - -# Make sure we have the POSIX version of readdir_r, not the -# older 2-argument version. -CHECK_C_SOURCE_COMPILES( - "#include <dirent.h>\nint main() {DIR *d = opendir(\".\"); struct dirent e,*r; return readdir_r(d,&e,&r);}" - HAVE_READDIR_R) - - -# Only detect readlinkat() if we also have AT_FDCWD in unistd.h. -# NOTE: linux requires fcntl.h for AT_FDCWD. -CHECK_C_SOURCE_COMPILES( - "#include <fcntl.h>\n#include <unistd.h>\nint main() {char buf[10]; return readlinkat(AT_FDCWD, \"\", buf, 0);}" - HAVE_READLINKAT) - - -# To verify major(), we need to both include the header -# of interest and verify that the result can be linked. -# CHECK_FUNCTION_EXISTS doesn't accept a header argument, -# CHECK_SYMBOL_EXISTS doesn't test linkage. -CHECK_C_SOURCE_COMPILES( - "#include <sys/mkdev.h>\nint main() { return major(256); }" - MAJOR_IN_MKDEV) -CHECK_C_SOURCE_COMPILES( - "#include <sys/sysmacros.h>\nint main() { return major(256); }" - MAJOR_IN_SYSMACROS) - -CHECK_C_SOURCE_COMPILES( - "#include <lzma.h>\n#if LZMA_VERSION < 50020000\n#error unsupported\n#endif\nint main(void){lzma_stream_encoder_mt(0, 0); return 0;}" - HAVE_LZMA_STREAM_ENCODER_MT) - -IF(HAVE_STRERROR_R) - SET(HAVE_DECL_STRERROR_R 1) -ENDIF(HAVE_STRERROR_R) + # Load install destinations. + include(Source/CMakeInstallDestinations.cmake) -# -# Check defines -# -SET(headers "limits.h") -IF(HAVE_STDINT_H) - LIST(APPEND headers "stdint.h") -ENDIF(HAVE_STDINT_H) -IF(HAVE_INTTYPES_H) - LIST(APPEND headers "inttypes.h") -ENDIF(HAVE_INTTYPES_H) -CHECK_SYMBOL_EXISTS(EFTYPE "errno.h" HAVE_EFTYPE) -CHECK_SYMBOL_EXISTS(EILSEQ "errno.h" HAVE_EILSEQ) -CHECK_SYMBOL_EXISTS(D_MD_ORDER "langinfo.h" HAVE_D_MD_ORDER) -CHECK_SYMBOL_EXISTS(INT32_MAX "${headers}" HAVE_DECL_INT32_MAX) -CHECK_SYMBOL_EXISTS(INT32_MIN "${headers}" HAVE_DECL_INT32_MIN) -CHECK_SYMBOL_EXISTS(INT64_MAX "${headers}" HAVE_DECL_INT64_MAX) -CHECK_SYMBOL_EXISTS(INT64_MIN "${headers}" HAVE_DECL_INT64_MIN) -CHECK_SYMBOL_EXISTS(INTMAX_MAX "${headers}" HAVE_DECL_INTMAX_MAX) -CHECK_SYMBOL_EXISTS(INTMAX_MIN "${headers}" HAVE_DECL_INTMAX_MIN) -CHECK_SYMBOL_EXISTS(UINT32_MAX "${headers}" HAVE_DECL_UINT32_MAX) -CHECK_SYMBOL_EXISTS(UINT64_MAX "${headers}" HAVE_DECL_UINT64_MAX) -CHECK_SYMBOL_EXISTS(UINTMAX_MAX "${headers}" HAVE_DECL_UINTMAX_MAX) -CHECK_SYMBOL_EXISTS(SIZE_MAX "${headers}" HAVE_DECL_SIZE_MAX) -CHECK_SYMBOL_EXISTS(SSIZE_MAX "limits.h" HAVE_DECL_SSIZE_MAX) + if(BUILD_TESTING) + include(${CMake_SOURCE_DIR}/Tests/CMakeInstall.cmake) + endif() -# -# Check struct members -# -# Check for tm_gmtoff in struct tm -CHECK_STRUCT_HAS_MEMBER("struct tm" tm_gmtoff - "time.h" HAVE_STRUCT_TM_TM_GMTOFF) -CHECK_STRUCT_HAS_MEMBER("struct tm" __tm_gmtoff - "time.h" HAVE_STRUCT_TM___TM_GMTOFF) - -# Check for f_namemax in struct statfs -CHECK_STRUCT_HAS_MEMBER("struct statfs" f_namemax - "sys/param.h;sys/mount.h" HAVE_STRUCT_STATFS_F_NAMEMAX) - -# Check for birthtime in struct stat -CHECK_STRUCT_HAS_MEMBER("struct stat" st_birthtime - "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_BIRTHTIME) - -# Check for high-resolution timestamps in struct stat -CHECK_STRUCT_HAS_MEMBER("struct stat" st_birthtimespec.tv_nsec - "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC) -CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtimespec.tv_nsec - "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC) -CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtim.tv_nsec - "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC) -CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtime_n - "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_MTIME_N) -CHECK_STRUCT_HAS_MEMBER("struct stat" st_umtime - "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_UMTIME) -CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtime_usec - "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_MTIME_USEC) -# Check for block size support in struct stat -CHECK_STRUCT_HAS_MEMBER("struct stat" st_blksize - "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_BLKSIZE) -# Check for st_flags in struct stat (BSD fflags) -CHECK_STRUCT_HAS_MEMBER("struct stat" st_flags - "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_FLAGS) - -IF(HAVE_SYS_STATVFS_H) - CHECK_STRUCT_HAS_MEMBER("struct statvfs" f_iosize - "sys/types.h;sys/statvfs.h" HAVE_STRUCT_STATVFS_F_IOSIZE) -ENDIF() + # include special compile flags for some compilers + include(CompileFlags.cmake) -# -# -CHECK_STRUCT_HAS_MEMBER("struct tm" tm_sec - "sys/types.h;sys/time.h;time.h" TIME_WITH_SYS_TIME) + # no clue why we are testing for this here + include(CheckSymbolExists) + CHECK_SYMBOL_EXISTS(unsetenv "stdlib.h" HAVE_UNSETENV) + CHECK_SYMBOL_EXISTS(environ "stdlib.h" HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE) +endif() +# CMAKE_TESTS_CDASH_SERVER: CDash server used by CMake/Tests. # -# Check for integer types -# -# -CHECK_TYPE_SIZE("short" SIZE_OF_SHORT) -CHECK_TYPE_SIZE("int" SIZE_OF_INT) -CHECK_TYPE_SIZE("long" SIZE_OF_LONG) -CHECK_TYPE_SIZE("long long" SIZE_OF_LONG_LONG) - -CHECK_TYPE_SIZE("unsigned short" SIZE_OF_UNSIGNED_SHORT) -CHECK_TYPE_SIZE("unsigned" SIZE_OF_UNSIGNED) -CHECK_TYPE_SIZE("unsigned long" SIZE_OF_UNSIGNED_LONG) -CHECK_TYPE_SIZE("unsigned long long" SIZE_OF_UNSIGNED_LONG_LONG) - -CHECK_TYPE_SIZE("__int64" __INT64) -CHECK_TYPE_SIZE("unsigned __int64" UNSIGNED___INT64) - -CHECK_TYPE_SIZE(int16_t INT16_T) -CHECK_TYPE_SIZE(int32_t INT32_T) -CHECK_TYPE_SIZE(int64_t INT64_T) -CHECK_TYPE_SIZE(intmax_t INTMAX_T) -CHECK_TYPE_SIZE(uint8_t UINT8_T) -CHECK_TYPE_SIZE(uint16_t UINT16_T) -CHECK_TYPE_SIZE(uint32_t UINT32_T) -CHECK_TYPE_SIZE(uint64_t UINT64_T) -CHECK_TYPE_SIZE(uintmax_t UINTMAX_T) - -CHECK_TYPE_SIZE(dev_t DEV_T) -IF(NOT HAVE_DEV_T) - IF(MSVC) - SET(dev_t "unsigned int") - ENDIF(MSVC) -ENDIF(NOT HAVE_DEV_T) -# -CHECK_TYPE_SIZE(gid_t GID_T) -IF(NOT HAVE_GID_T) - IF(WIN32) - SET(gid_t "short") - ELSE(WIN32) - SET(gid_t "unsigned int") - ENDIF(WIN32) -ENDIF(NOT HAVE_GID_T) -# -CHECK_TYPE_SIZE(id_t ID_T) -IF(NOT HAVE_ID_T) - IF(WIN32) - SET(id_t "short") - ELSE(WIN32) - SET(id_t "unsigned int") - ENDIF(WIN32) -ENDIF(NOT HAVE_ID_T) -# -CHECK_TYPE_SIZE(mode_t MODE_T) -IF(NOT HAVE_MODE_T) - IF(WIN32) - SET(mode_t "unsigned short") - ELSE(WIN32) - SET(mode_t "int") - ENDIF(WIN32) -ENDIF(NOT HAVE_MODE_T) -# -CHECK_TYPE_SIZE(off_t OFF_T) -IF(NOT HAVE_OFF_T) - SET(off_t "__int64") -ENDIF(NOT HAVE_OFF_T) -# -CHECK_TYPE_SIZE(size_t SIZE_T) -IF(NOT HAVE_SIZE_T) - IF("${CMAKE_SIZEOF_VOID_P}" EQUAL 8) - SET(size_t "uint64_t") - ELSE("${CMAKE_SIZEOF_VOID_P}" EQUAL 8) - SET(size_t "uint32_t") - ENDIF("${CMAKE_SIZEOF_VOID_P}" EQUAL 8) -ENDIF(NOT HAVE_SIZE_T) -# -CHECK_TYPE_SIZE(ssize_t SSIZE_T) -IF(NOT HAVE_SSIZE_T) - IF("${CMAKE_SIZEOF_VOID_P}" EQUAL 8) - SET(ssize_t "int64_t") - ELSE("${CMAKE_SIZEOF_VOID_P}" EQUAL 8) - SET(ssize_t "long") - ENDIF("${CMAKE_SIZEOF_VOID_P}" EQUAL 8) -ENDIF(NOT HAVE_SSIZE_T) -# -CHECK_TYPE_SIZE(uid_t UID_T) -IF(NOT HAVE_UID_T) - IF(WIN32) - SET(uid_t "short") - ELSE(WIN32) - SET(uid_t "unsigned int") - ENDIF(WIN32) -ENDIF(NOT HAVE_UID_T) +# If not defined or "", this variable defaults to the server at +# "http://open.cdash.org". # -CHECK_TYPE_SIZE(pid_t PID_T) -IF(NOT HAVE_PID_T) - IF(WIN32) - SET(pid_t "int") - ELSE(WIN32) - MESSAGE(FATAL_ERROR "pid_t doesn't exist on this platform?") - ENDIF(WIN32) -ENDIF(NOT HAVE_PID_T) +# If set explicitly to "NOTFOUND", curl tests and ctest tests that use +# the network are skipped. # -CHECK_TYPE_SIZE(intptr_t INTPTR_T) -IF(NOT HAVE_INTPTR_T) - IF("${CMAKE_SIZEOF_VOID_P}" EQUAL 8) - SET(intptr_t "int64_t") - ELSE() - SET(intptr_t "int32_t") - ENDIF() -ENDIF(NOT HAVE_INTPTR_T) +# If set to something starting with "http://localhost/", the CDash is +# expected to be an instance of CDash used for CDash testing, pointing +# to a cdash4simpletest database. In these cases, the CDash dashboards +# should be run first. # -CHECK_TYPE_SIZE(uintptr_t UINTPTR_T) -IF(NOT HAVE_UINTPTR_T) - IF("${CMAKE_SIZEOF_VOID_P}" EQUAL 8) - SET(uintptr_t "uint64_t") - ELSE() - SET(uintptr_t "uint32_t") - ENDIF() -ENDIF(NOT HAVE_UINTPTR_T) -# -CHECK_TYPE_SIZE(wchar_t SIZEOF_WCHAR_T) -IF(HAVE_SIZEOF_WCHAR_T) - SET(HAVE_WCHAR_T 1) -ENDIF(HAVE_SIZEOF_WCHAR_T) -# -# Check if _FILE_OFFSET_BITS macro needed for large files -# -CHECK_FILE_OFFSET_BITS() +if("x${CMAKE_TESTS_CDASH_SERVER}" STREQUAL "x") + set(CMAKE_TESTS_CDASH_SERVER "http://open.cdash.org") +endif() -# -# Check for Extended Attribute libraries, headers, and functions -# -IF(ENABLE_XATTR) - LA_CHECK_INCLUDE_FILE(attr/xattr.h HAVE_ATTR_XATTR_H) - LA_CHECK_INCLUDE_FILE(sys/xattr.h HAVE_SYS_XATTR_H) - LA_CHECK_INCLUDE_FILE(sys/extattr.h HAVE_SYS_EXTATTR_H) - CHECK_LIBRARY_EXISTS(attr "setxattr" "" HAVE_LIBATTR) - IF(HAVE_LIBATTR) - SET(CMAKE_REQUIRED_LIBRARIES "attr") - ENDIF(HAVE_LIBATTR) - CHECK_SYMBOL_EXISTS(EXTATTR_NAMESPACE_USER "sys/types.h;sys/extattr.h" HAVE_DECL_EXTATTR_NAMESPACE_USER) - CHECK_FUNCTION_EXISTS_GLIBC(extattr_get_file HAVE_EXTATTR_GET_FILE) - CHECK_FUNCTION_EXISTS_GLIBC(extattr_list_file HAVE_EXTATTR_LIST_FILE) - CHECK_FUNCTION_EXISTS_GLIBC(extattr_set_fd HAVE_EXTATTR_SET_FD) - CHECK_FUNCTION_EXISTS_GLIBC(extattr_set_file HAVE_EXTATTR_SET_FILE) - CHECK_FUNCTION_EXISTS_GLIBC(fgetxattr HAVE_FGETXATTR) - CHECK_FUNCTION_EXISTS_GLIBC(flistxattr HAVE_FLISTXATTR) - CHECK_FUNCTION_EXISTS_GLIBC(fsetxattr HAVE_FSETXATTR) - CHECK_FUNCTION_EXISTS_GLIBC(getxattr HAVE_GETXATTR) - CHECK_FUNCTION_EXISTS_GLIBC(lgetxattr HAVE_LGETXATTR) - CHECK_FUNCTION_EXISTS_GLIBC(listxattr HAVE_LISTXATTR) - CHECK_FUNCTION_EXISTS_GLIBC(llistxattr HAVE_LLISTXATTR) - CHECK_FUNCTION_EXISTS_GLIBC(lsetxattr HAVE_LSETXATTR) - CHECK_FUNCTION_EXISTS_GLIBC(fgetea HAVE_FGETEA) - CHECK_FUNCTION_EXISTS_GLIBC(flistea HAVE_FLISTEA) - CHECK_FUNCTION_EXISTS_GLIBC(fsetea HAVE_FSETEA) - CHECK_FUNCTION_EXISTS_GLIBC(getea HAVE_GETEA) - CHECK_FUNCTION_EXISTS_GLIBC(lgetea HAVE_LGETEA) - CHECK_FUNCTION_EXISTS_GLIBC(listea HAVE_LISTEA) - CHECK_FUNCTION_EXISTS_GLIBC(llistea HAVE_LLISTEA) - CHECK_FUNCTION_EXISTS_GLIBC(lsetea HAVE_LSETEA) -ELSE(ENABLE_XATTR) - SET(HAVE_ATTR_LIB FALSE) - SET(HAVE_ATTR_XATTR_H FALSE) - SET(HAVE_DECL_EXTATTR_NAMESPACE_USER FALSE) - SET(HAVE_EXTATTR_GET_FILE FALSE) - SET(HAVE_EXTATTR_LIST_FILE FALSE) - SET(HAVE_EXTATTR_SET_FD FALSE) - SET(HAVE_EXTATTR_SET_FILE FALSE) - SET(HAVE_FGETEA FALSE) - SET(HAVE_FGETXATTR FALSE) - SET(HAVE_FLISTEA FALSE) - SET(HAVE_FLISTXATTR FALSE) - SET(HAVE_FSETEA FALSE) - SET(HAVE_FSETXATTR FALSE) - SET(HAVE_GETEA FALSE) - SET(HAVE_GETXATTR FALSE) - SET(HAVE_LGETEA FALSE) - SET(HAVE_LGETXATTR FALSE) - SET(HAVE_LISTEA FALSE) - SET(HAVE_LISTXATTR FALSE) - SET(HAVE_LLISTEA FALSE) - SET(HAVE_LLISTXATTR FALSE) - SET(HAVE_LSETEA FALSE) - SET(HAVE_LSETXATTR FALSE) - SET(HAVE_SYS_EXTATTR_H FALSE) - SET(HAVE_SYS_XATTR_H FALSE) -ENDIF(ENABLE_XATTR) +if(CMake_TEST_EXTERNAL_CMAKE) + set(KWIML_TEST_ENABLE 1) + add_subdirectory(Utilities/KWIML) +endif() -# -# Check for ACL libraries, headers, and functions -# -# The ACL support in libarchive is written against the POSIX1e draft, -# which was never officially approved and varies quite a bit across -# platforms. Worse, some systems have completely non-POSIX acl functions, -# which makes the following checks rather more complex than I would like. -# -IF(ENABLE_ACL) - CHECK_LIBRARY_EXISTS(acl "acl_get_file" "" HAVE_LIBACL) - IF(HAVE_LIBACL) - SET(CMAKE_REQUIRED_LIBRARIES "acl") - FIND_LIBRARY(ACL_LIBRARY NAMES acl) - LIST(APPEND ADDITIONAL_LIBS ${ACL_LIBRARY}) - ENDIF(HAVE_LIBACL) - # - CHECK_FUNCTION_EXISTS_GLIBC(acl_create_entry HAVE_ACL_CREATE_ENTRY) - CHECK_FUNCTION_EXISTS_GLIBC(acl_init HAVE_ACL_INIT) - CHECK_FUNCTION_EXISTS_GLIBC(acl_set_fd HAVE_ACL_SET_FD) - CHECK_FUNCTION_EXISTS_GLIBC(acl_set_fd_np HAVE_ACL_SET_FD_NP) - CHECK_FUNCTION_EXISTS_GLIBC(acl_set_file HAVE_ACL_SET_FILE) - CHECK_TYPE_EXISTS(acl_permset_t "${INCLUDES}" HAVE_ACL_PERMSET_T) - - # The "acl_get_perm()" function was omitted from the POSIX draft. - # (It's a pretty obvious oversight; otherwise, there's no way to - # test for specific permissions in a permset.) Linux uses the obvious - # name, FreeBSD adds _np to mark it as "non-Posix extension." - # Test for both as a double-check that we really have POSIX-style ACL support. - CHECK_FUNCTION_EXISTS(acl_get_fd_np HAVE_ACL_GET_FD_NP) - CHECK_FUNCTION_EXISTS(acl_get_perm HAVE_ACL_GET_PERM) - CHECK_FUNCTION_EXISTS(acl_get_perm_np HAVE_ACL_GET_PERM_NP) - CHECK_FUNCTION_EXISTS(acl_get_link HAVE_ACL_GET_LINK) - CHECK_FUNCTION_EXISTS(acl_get_link_np HAVE_ACL_GET_LINK_NP) - CHECK_FUNCTION_EXISTS(acl_is_trivial_np HAVE_ACL_IS_TRIVIAL_NP) - CHECK_FUNCTION_EXISTS(acl_set_link_np HAVE_ACL_SET_LINK_NP) - CHECK_SYMBOL_EXISTS(ACL_TYPE_NFS4 "${INCLUDES}" HAVE_ACL_TYPE_NFS4) - - # MacOS has an acl.h that isn't POSIX. It can be detected by - # checking for ACL_USER - CHECK_SYMBOL_EXISTS(ACL_USER "${INCLUDES}" HAVE_ACL_USER) - CHECK_C_SOURCE_COMPILES("#include <sys/types.h> -#include <sys/acl.h> -int main(void) { return ACL_TYPE_EXTENDED; }" HAVE_ACL_TYPE_EXTENDED) - - # Solaris and derivates ACLs - CHECK_LIBRARY_EXISTS(sec "acl_get" "" HAVE_LIBSEC) - IF(HAVE_LIBSEC) - SET(CMAKE_REQUIRED_LIBRARIES "sec") - FIND_LIBRARY(SEC_LIBRARY NAMES sec) - LIST(APPEND ADDITIONAL_LIBS ${SEC_LIBRARY}) - ENDIF(HAVE_LIBSEC) - # - CHECK_TYPE_EXISTS(aclent_t "${INCLUDES}" HAVE_ACLENT_T) - CHECK_TYPE_EXISTS(ace_t "${INCLUDES}" HAVE_ACE_T) - CHECK_FUNCTION_EXISTS(acl_get HAVE_FACL_GET) - CHECK_FUNCTION_EXISTS(facl_get HAVE_FACL_GET) - CHECK_FUNCTION_EXISTS(acl_set HAVE_FACL_SET) - CHECK_FUNCTION_EXISTS(facl_set HAVE_FACL_SET) -ELSE(ENABLE_ACL) - # If someone runs cmake, then disables ACL support, we need - # to forcibly override the cached values for these. - SET(HAVE_ACL_CREATE_ENTRY FALSE) - SET(HAVE_ACL_GET_LINK FALSE) - SET(HAVE_ACL_GET_LINK_NP FALSE) - SET(HAVE_ACL_GET_PERM FALSE) - SET(HAVE_ACL_GET_PERM_NP FALSE) - SET(HAVE_ACL_INIT FALSE) - SET(HAVE_ACL_LIB FALSE) - SET(HAVE_ACL_PERMSET_T FALSE) - SET(HAVE_ACL_SET_FD FALSE) - SET(HAVE_ACL_SET_FD_NP FALSE) - SET(HAVE_ACL_SET_FILE FALSE) - SET(HAVE_ACL_TYPE_NFS4 FALSE) - SET(HAVE_ACL_USER FALSE) - SET(HAVE_ACL_TYPE_EXTENDED FALSE) - SET(HAVE_ACL_GET FALSE) - SET(HAVE_ACLENT_T FALSE) - SET(HAVE_ACE_T FALSE) - SET(HAVE_FACL_GET FALSE) - SET(HAVE_ACL_SET FALSE) - SET(HAVE_FACL_SET FALSE) -ENDIF(ENABLE_ACL) +if(NOT CMake_TEST_EXTERNAL_CMAKE) + # build the utilities (a macro defined in this file) + CMAKE_BUILD_UTILITIES() + + # On NetBSD ncurses is required, since curses doesn't have the wsyncup() + # function. ncurses is installed via pkgsrc, so the library is in /usr/pkg/lib, + # which isn't in the default linker search path. So without RPATH ccmake + # doesn't run and the build doesn't succeed since ccmake is executed for + # generating the documentation. + if(BUILD_CursesDialog) + get_filename_component(_CURSES_DIR "${CURSES_LIBRARY}" PATH) + set(CURSES_NEED_RPATH FALSE) + if(NOT "${_CURSES_DIR}" STREQUAL "/lib" AND NOT "${_CURSES_DIR}" STREQUAL "/usr/lib" AND NOT "${_CURSES_DIR}" STREQUAL "/lib64" AND NOT "${_CURSES_DIR}" STREQUAL "/usr/lib64") + set(CURSES_NEED_RPATH TRUE) + endif() + endif() + + if(BUILD_QtDialog) + if(APPLE) + set(CMAKE_BUNDLE_VERSION + "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}") + set(CMAKE_BUNDLE_LOCATION "${CMAKE_INSTALL_PREFIX}") + # make sure CMAKE_INSTALL_PREFIX ends in / + if(NOT CMAKE_INSTALL_PREFIX MATCHES "/$") + set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/") + endif() + set(CMAKE_INSTALL_PREFIX + "${CMAKE_INSTALL_PREFIX}CMake.app/Contents") + endif() + + set(QT_NEED_RPATH FALSE) + if(NOT "${QT_LIBRARY_DIR}" STREQUAL "/lib" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/usr/lib" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/lib64" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/usr/lib64") + set(QT_NEED_RPATH TRUE) + endif() + endif() + + + # The same might be true on other systems for other libraries. + # Then only enable RPATH if we have are building at least with cmake 2.4, + # since this one has much better RPATH features than cmake 2.2. + # The executables are then built with the RPATH for the libraries outside + # the build tree, which is both the build and the install RPATH. + if (UNIX) + if( CMAKE_USE_SYSTEM_CURL OR CMAKE_USE_SYSTEM_ZLIB + OR CMAKE_USE_SYSTEM_EXPAT OR CTEST_USE_XMLRPC OR CURSES_NEED_RPATH OR QT_NEED_RPATH) + set(CMAKE_SKIP_RPATH OFF CACHE INTERNAL "CMake built with RPATH.") + set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) + endif() + endif () + + + # add the uninstall support + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + @ONLY) + add_custom_target(uninstall + "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") + + include (CMakeCPack.cmake) -# -# Check MD5/RMD160/SHA support -# NOTE: Crypto checks must be run last before generating config.h -# -CHECK_CRYPTO("MD5;RMD160;SHA1;SHA256;SHA384;SHA512" LIBC) -CHECK_CRYPTO("SHA256;SHA384;SHA512" LIBC2) -CHECK_CRYPTO("SHA256;SHA384;SHA512" LIBC3) -CHECK_CRYPTO("MD5;SHA1;SHA256;SHA384;SHA512" LIBSYSTEM) -CHECK_CRYPTO("MD5;RMD160;SHA1;SHA256;SHA384;SHA512" NETTLE) -CHECK_CRYPTO("MD5;RMD160;SHA1;SHA256;SHA384;SHA512" OPENSSL) +endif() -# Libmd has to be probed after OpenSSL. -CHECK_CRYPTO("MD5;RMD160;SHA1;SHA256;SHA512" LIBMD) +# setup some Testing support (a macro defined in this file) +CMAKE_SETUP_TESTING() + +# Check whether to build server mode or not: +if(NOT CMake_TEST_EXTERNAL_CMAKE) + if(NOT DEFINED CMake_ENABLE_SERVER_MODE) + list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_auto_type CMake_HAVE_CXX_AUTO_TYPE) + list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_range_for CMake_HAVE_CXX_RANGE_FOR) + if(CMAKE_USE_LIBUV + AND CMake_HAVE_CXX_AUTO_TYPE + AND CMake_HAVE_CXX_MAKE_UNIQUE + AND CMake_HAVE_CXX_RANGE_FOR + ) + set(CMake_ENABLE_SERVER_MODE 1) + else() + set(CMake_ENABLE_SERVER_MODE 0) + endif() + endif() + if(CMake_ENABLE_SERVER_MODE AND NOT CMAKE_USE_LIBUV) + message(FATAL_ERROR "The server mode requires libuv!") + endif() +else() + set(CMake_ENABLE_SERVER_MODE 0) +endif() +if(NOT DEFINED CMake_TEST_SERVER_MODE) + set(CMake_TEST_SERVER_MODE ${CMake_ENABLE_SERVER_MODE}) +endif() -CHECK_CRYPTO_WIN("MD5;SHA1;SHA256;SHA384;SHA512") +if(NOT CMake_TEST_EXTERNAL_CMAKE) + if(NOT CMake_VERSION_IS_RELEASE) + if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND + NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS 4.2) + set(C_FLAGS_LIST -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts + -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security + -Wmissing-format-attribute -fno-common -Wundef + ) + set(CXX_FLAGS_LIST -Wnon-virtual-dtor -Wcast-align -Wchar-subscripts -Wall -W + -Wshadow -Wpointer-arith -Wformat-security -Wundef + ) + + foreach(FLAG_LANG C CXX) + foreach(FLAG ${${FLAG_LANG}_FLAGS_LIST}) + if(NOT " ${CMAKE_${FLAG_LANG}_FLAGS} " MATCHES " ${FLAG} ") + set(CMAKE_${FLAG_LANG}_FLAGS "${CMAKE_${FLAG_LANG}_FLAGS} ${FLAG}") + endif() + endforeach() + endforeach() + + unset(C_FLAGS_LIST) + unset(CXX_FLAGS_LIST) + endif() + endif() + + # build the remaining subdirectories + add_subdirectory(Source) + add_subdirectory(Utilities) +endif() -# Generate "config.h" from "build/cmake/config.h.in" -CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/build/cmake/config.h.in - ${CMAKE_CURRENT_BINARY_DIR}/config.h) -INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) -ADD_DEFINITIONS(-DHAVE_CONFIG_H) +add_subdirectory(Tests) -# Handle generation of the libarchive.pc file for pkg-config -INCLUDE(CreatePkgConfigFile) +if(NOT CMake_TEST_EXTERNAL_CMAKE) + if(BUILD_TESTING) + CMAKE_SET_TARGET_FOLDER(CMakeLibTests "Tests") + endif() + if(TARGET documentation) + CMAKE_SET_TARGET_FOLDER(documentation "Documentation") + endif() +endif() -# -# Register installation of PDF documents. -# -IF(WIN32 AND NOT CYGWIN) - # - # On Windows platform, It's better that we install PDF documents - # on one's computer. - # These PDF documents are available in the release package. - # - IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/doc/pdf) - INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doc/pdf - DESTINATION share/man - FILES_MATCHING PATTERN "*.pdf" +# add a test +add_test(SystemInformationNew "${CMAKE_CMAKE_COMMAND}" + --system-information -G "${CMAKE_GENERATOR}" ) + +if(NOT CMake_TEST_EXTERNAL_CMAKE) + # Install license file as it requires. + install(FILES Copyright.txt DESTINATION ${CMAKE_DOC_DIR}) + + # Install script directories. + install( + DIRECTORY Help Modules Templates + DESTINATION ${CMAKE_DATA_DIR} + FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ + DIRECTORY_PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE + PATTERN "*.sh*" PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE ) - ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/doc/pdf) -ENDIF(WIN32 AND NOT CYGWIN) -# -# -# -INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/libarchive) -# -IF(MSVC) - ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE) -ENDIF(MSVC) - -IF(ENABLE_TEST) - ADD_CUSTOM_TARGET(run_all_tests) -ENDIF(ENABLE_TEST) - -add_subdirectory(libarchive) -add_subdirectory(cat) -add_subdirectory(tar) -add_subdirectory(cpio) + + # Install auxiliary files integrating with other tools. + add_subdirectory(Auxiliary) +endif() |