From: <tbr...@us...> - 2012-03-18 21:56:39
|
Revision: 192 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=192&view=rev Author: tbrowder2 Date: 2012-03-18 21:56:31 +0000 (Sun, 18 Mar 2012) Log Message: ----------- add top-level starting CMake file borrowed from BRL-CAD project Added Paths: ----------- trunk/CMakeLists.txt Added: trunk/CMakeLists.txt =================================================================== --- trunk/CMakeLists.txt (rev 0) +++ trunk/CMakeLists.txt 2012-03-18 21:56:31 UTC (rev 192) @@ -0,0 +1,2120 @@ +# C M A K E L I S T S . T X T +# +# This file is based on a modified version of the one used +# by the BRL-CAD project (http://brlcad.org). +# +# This file defines the toplevel CMake build logic for xmlwrapp. +# As best as is reasonably possible, proper ordering and +# separation of tests and settings should be maintained per the +# recommended standard layout. The tests should be added to the +# labeled sections below so that they are organized as follows: +# +# 0) information on the package and toplevel CMake settings +# 1) define top level options +# 2) check programs +# 3) check compiler characteristics +# 4) check libraries +# 5) check headers +# 6) check types/structures +# 7) check functions +# 8) check system services +# 9) output a summary +# +# The output summary should report key information about the final +# configuration of the build. Comprehensive information is available +# in the CMake cache file in the build directory, so just hit the +# high points in the summary. + + +# ******************************************************************* +# *** Top Level Settings *** +# ******************************************************************* +# This file contains the top level CMakeLists.txt logic for the +# xmlwrapp software package. + +# We want to support a "distclean" build target that will clear all +# CMake-generated files from a source directory in the case of an +# in-source-dir configuration. Not recommended, but we'll try to +# recover if it happens. +define_property(GLOBAL PROPERTY CMAKE_DISTCLEAN_FILES_LIST BRIEF_DOCS "All CMake generated files" FULL_DOCS "List of all files generated by CMake") + +macro(DISTCLEAN) + foreach(item ${ARGN}) + get_property(CMAKE_DISTCLEAN_TARGET_LIST GLOBAL PROPERTY CMAKE_DISTCLEAN_TARGET_LIST) + set_property(GLOBAL APPEND PROPERTY CMAKE_DISTCLEAN_TARGET_LIST ${item}) + endforeach(item ${ARGN}) +endmacro(DISTCLEAN) + +# First step - stash the initial CMakeCache.txt file, if it exists, for subsequent +# comparison +if(EXISTS ${CMAKE_BINARY_DIR}/CMakeCache.txt) + configure_file(${CMAKE_BINARY_DIR}/CMakeCache.txt ${CMAKE_BINARY_DIR}/CMakeCache.txt.prev COPY_ONLY) + DISTCLEAN(${CMAKE_BINARY_DIR}/CMakeCache.txt.prev) +endif(EXISTS ${CMAKE_BINARY_DIR}/CMakeCache.txt) +DISTCLEAN(${CMAKE_BINARY_DIR}/CMakeCache.txt) + +# Minimum required version of CMake +cmake_minimum_required(VERSION 2.8.4) +if(COMMAND CMAKE_POLICY) + CMAKE_POLICY(SET CMP0003 NEW) + CMAKE_POLICY(SET CMP0007 OLD) + if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} VERSION_GREATER 2.8.3) + CMAKE_POLICY(SET CMP0017 OLD) + endif(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} VERSION_GREATER 2.8.3) +endif(COMMAND CMAKE_POLICY) + +# set CMake project name +project(XMLWRAPP) + +set(XMLWRAPP "XMLWRAPP") + +#--------------------------------------------------------------------- +# Write out entries to populate a tm struct to be used for time deltas +# later +if(NOT IS_SUBBUILD) + set(DELTA_START "${CMAKE_BINARY_DIR}/CMakeTmp/DELTA_START") + configure_file(${CMAKE_SOURCE_DIR}/misc/CMake/test_srcs/timedelta_start.c.in ${CMAKE_BINARY_DIR}/CMakeTmp/timedelta_start.c) + TRY_RUN(TIME_RESULT TIME_COMPILED + ${CMAKE_BINARY_DIR}/CMakeTmp + ${CMAKE_BINARY_DIR}/CMakeTmp/timedelta_start.c + OUTPUT_VARIABLE COMPILEMESSAGES) +endif(NOT IS_SUBBUILD) + + +#--------------------------------------------------------------------- +# If it exists, load an XMLWRAPP.GLOBAL file. This allows +# advanced users to specify options or preferences they want to always +# use by default even when doing clean BRL-CAD builds without a +# CMakeCache.txt file - for example, to always enable all local libs +# the following line can be added to XMLWRAPP_CONFIG.GLOBAL: +# +# set(XMLWRAPP_BUNDLED_LIBS "Bundled" CACHE STRING "Enable all local libs") + +# The user's configuration file can be defined by environment variable +# "XMLWRAPP_USER_GLOBAL_CONFIG_FILE" or, in its absence, by a file named +# "XMLWRAPP_CONFIG.GLOBAL" located either above or in the XMLWRAPP +# source directory. +set(XMLWRAPP_USER_GLOBAL_CONFIG_FILE "$ENV{XMLWRAPP_USER_GLOBAL_CONFIG_FILE}") +if(XMLWRAPP_USER_GLOBAL_CONFIG_FILE AND EXISTS ${XMLWRAPP_USER_GLOBAL_CONFIG_FILE}) + message("Reading user preference file '${XMLWRAPP_USER_GLOBAL_CONFIG_FILE}'") + include(${XMLWRAPP_USER_GLOBAL_CONFIG_FILE}) +elseif(EXISTS ${XMLWRAPP_SOURCE_DIR}/../XMLWRAPP_CONFIG.GLOBAL) + message("Reading user preference file '${XMLWRAPP_SOURCE_DIR}/../XMLWRAPP_CONFIG.GLOBAL'") + include(${XMLWRAPP_SOURCE_DIR}/../XMLWRAPP_CONFIG.GLOBAL) +elseif(EXISTS ${XMLWRAPP_SOURCE_DIR}/XMLWRAPP_CONFIG.GLOBAL) + message("Reading user preference file '${XMLWRAPP_SOURCE_DIR}/XMLWRAPP_CONFIG.GLOBAL'") + include(${XMLWRAPP_SOURCE_DIR}/XMLWRAPP_CONFIG.GLOBAL) +else(XMLWRAPP_USER_GLOBAL_CONFIG_FILE AND EXISTS ${XMLWRAPP_USER_GLOBAL_CONFIG_FILE}) + if(XMLWRAPP_USER_GLOBAL_CONFIG_FILE) + message(WARNING "User preference file ${XMLWRAPP_USER_GLOBAL_CONFIG_FILE} specified but not found...") + endif(XMLWRAPP_USER_GLOBAL_CONFIG_FILE) +endif(XMLWRAPP_USER_GLOBAL_CONFIG_FILE AND EXISTS ${XMLWRAPP_USER_GLOBAL_CONFIG_FILE}) + +# Allow the XMLWRAPP_ROOT environment variable to set CMAKE_INSTALL_PREFIX +# but be noisy about it. This is generally not a good idea. +find_program(SLEEP_EXEC sleep) +mark_as_advanced(SLEEP_EXEC) +set(XMLWRAPP_ROOT "$ENV{XMLWRAPP_ROOT}") +if(XMLWRAPP_ROOT) + if(NOT XMLWRAPP_ROOT_OVERRIDE) + message(WARNING "}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}\nXMLWRAPP_ROOT should only be used to override an install directory at runtime. XMLWRAPP_ROOT is presently set to \"${XMLWRAPP_ROOT}\" It is *highly* recommended that XMLWRAPP_ROOT be unset and not used.\n}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}") + if(CMAKE_INSTALL_PREFIX AND NOT CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT ) + if(${XMLWRAPP_ROOT} STREQUAL "${CMAKE_INSTALL_PREFIX}") + message("XMLWRAPP_ROOT is not necessary and may cause unexpected behavior") + else(${XMLWRAPP_ROOT} STREQUAL "${CMAKE_INSTALL_PREFIX}") + message(FATAL_ERROR "XMLWRAPP_ROOT environment variable conflicts with CMAKE_INSTALL_PREFIX") + endif(${XMLWRAPP_ROOT} STREQUAL "${CMAKE_INSTALL_PREFIX}") + endif(CMAKE_INSTALL_PREFIX AND NOT CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT ) + if(SLEEP_EXEC) + execute_process(COMMAND ${SLEEP_EXEC} 2) + endif(SLEEP_EXEC) + endif(NOT XMLWRAPP_ROOT_OVERRIDE) +endif(XMLWRAPP_ROOT) +if(NOT XMLWRAPP_ROOT_OVERRIDE) + if(XMLWRAPP_ROOT STREQUAL "/usr" OR ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr") + message(WARNING "}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}\nIt is STRONGLY recommended that you DO NOT install XMLWRAPP into /usr as XMLWRAPP provides several libraries that may conflict with other libraries (e.g. librt, libbu, libbn) on certain system configurations.\nSince our libraries predate all those that we're known to conflict with and are at the very core of our geometry services and project heritage, we have no plans to change the names of our libraries at this time.\nINSTALLING INTO /usr CAN MAKE A SYSTEM COMPLETELY UNUSABLE. If you choose to continue installing into /usr, you do so entirely at your own risk. You have been warned.\n}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}") + if(SLEEP_EXEC) + message("Pausing 15 seconds...") + execute_process(COMMAND ${SLEEP_EXEC} 15) + endif(SLEEP_EXEC) + if(${CMAKE_INSTALL_PREFIX} STREQUAL "/usr") + message(FATAL_ERROR "If you wish to proceed using /usr as your prefix, define XMLWRAPP_ROOT_OVERRIDE=1 for CMake") + endif(${CMAKE_INSTALL_PREFIX} STREQUAL "/usr") + endif(XMLWRAPP_ROOT STREQUAL "/usr" OR ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr") +endif(NOT XMLWRAPP_ROOT_OVERRIDE) + +# While we're at it, complain if XMLWRAPP_DATA is set +set(XMLWRAPP_DATA_ENV "$ENV{XMLWRAPP_DATA}") +if(XMLWRAPP_DATA_ENV) + message(WARNING "}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}\nXMLWRAPP_DATA should only be used to override an install directory at runtime. XMLWRAPP_DATA is presently set to \"${XMLWRAPP_DATA_ENV}\" It is *highly* recommended that XMLWRAPP_DATA be unset and not used.\n}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}") + if(SLEEP_EXEC) + execute_process(COMMAND ${SLEEP_EXEC} 2) + endif(SLEEP_EXEC) +endif(XMLWRAPP_DATA_ENV) + +# Searching the system for packages presents something of a dilemma - +# in most situations it is Very Bad for a XMLWRAPP build to be using +# older versions of libraries in install directories as search results. +# Generally, the desired behavior is to ignore whatever libraries are +# in the install directories, and only use external library results if +# they are something already found on the system due to non-XMLWRAPP +# installation (source compile, package managers, etc.). Unfortunately, +# CMake's standard behavior is to add a CMAKE_INSTALL_PREFIX to the +# search path once defined, resulting in (for us) an unexpected behavior +# of returning old installed libraries when CMake is re-run in a +# directory. +# +# To work around this, there are two possible approaches. One, +# identified by Maik Beckmann, operates on CMAKE_SYSTEM_PREFIX_PATH: +# +# http://www.cmake.org/pipermail/cmake/2010-October/040292.html +# +# The other, pointed out by Michael Hertling, uses the +# CMake_[SYSTEM_]IGNORE_PATH variables. +# +# http://www.cmake.org/pipermail/cmake/2011-May/044503.html +# +# XMLWRAPP initially operated on CMAKE_SYSTEM_PREFIX_PATH, but has +# switched to using the *_IGNORE_PATH variables. This requires +# CMake 2.8.3 or later. +# +# The complication with ignoring install paths is if we are +# installing to a "legitimate" system search path - i.e. our +# CMAKE_INSTALL_PREFIX value is standard enough that it is a legitimate +# search target for find_package. In this case, we can't exclude +# accidental hits on our libraries without also excluding legitimate +# find_package results. So the net results are: +# +# 1. If you are planning to install to a system directory (typically +# a bad idea but the settings are legal) clean out the old system +# first or accept that the old libraries will be found and used. +# +# 2. For more custom paths, the logic below will avoid the value +# of CMAKE_INSTALL_PREFIX in find_package searches +# +# (Note: CMAKE_INSTALL_PREFIX must be checked in the case where someone +# sets it on the command line prior to CMake being run. XMLWRAPP_PREFIX +# preserves the CMAKE_INSTALL_PREFIX setting from the previous CMake run. +# CMAKE_INSTALL_PREFIX does not seem to be immediately set in this context +# when CMake is re-run unless specified explicitly on the command line. +# To ensure the previous (and internally set) CMAKE_INSTALL_PREFIX value +# is available, XMLWRAPP_PREFIX is used to store the value in the cache.) + +if(CMAKE_INSTALL_PREFIX) + if(NOT ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr" AND NOT ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr/local") + get_filename_component(PATH_NORMALIZED ${CMAKE_INSTALL_PREFIX}/lib ABSOLUTE) + set(CMAKE_SYSTEM_IGNORE_PATH ${PATH_NORMALIZED}) + endif(NOT ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr" AND NOT ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr/local") +endif(CMAKE_INSTALL_PREFIX) +if(XMLWRAPP_PREFIX) + if(NOT ${XMLWRAPP_PREFIX} STREQUAL "/usr" AND NOT ${XMLWRAPP_PREFIX} STREQUAL "/usr/local") + get_filename_component(PATH_NORMALIZED ${XMLWRAPP_PREFIX}/lib ABSOLUTE) + set(CMAKE_SYSTEM_IGNORE_PATH ${PATH_NORMALIZED}) + endif(NOT ${XMLWRAPP_PREFIX} STREQUAL "/usr" AND NOT ${XMLWRAPP_PREFIX} STREQUAL "/usr/local") +endif(XMLWRAPP_PREFIX) +mark_as_advanced(CMAKE_SYSTEM_IGNORE_PATH) + +# Define CMake routines for bookkeeping of build files +include(${CMAKE_SOURCE_DIR}/misc/CMake/CMakeFiles.cmake) + +#--------------------------------------------------------------------- +# Define the current XMLWRAPP version. +# See HACKING for details on how to properly update the version + +file(READ ${XMLWRAPP_SOURCE_DIR}/include/conf/MAJOR XMLWRAPP_MAJOR_VERSION) +string(STRIP ${XMLWRAPP_MAJOR_VERSION} XMLWRAPP_MAJOR_VERSION) +file(READ ${XMLWRAPP_SOURCE_DIR}/include/conf/MINOR XMLWRAPP_MINOR_VERSION) +string(STRIP ${XMLWRAPP_MINOR_VERSION} XMLWRAPP_MINOR_VERSION) +file(READ ${XMLWRAPP_SOURCE_DIR}/include/conf/PATCH XMLWRAPP_PATCH_VERSION) +string(STRIP ${XMLWRAPP_PATCH_VERSION} XMLWRAPP_PATCH_VERSION) + +set(XMLWRAPP_VERSION "${XMLWRAPP_MAJOR_VERSION}.${XMLWRAPP_MINOR_VERSION}.${XMLWRAPP_PATCH_VERSION}") + +#--------------------------------------------------------------------- +# Define relative install locations. Don't set these if they have already +# been set by some other means (like a higher level CMakeLists.txt file +# including this one.) + +# The location in which to install XMLWRAPP executables. +if(NOT BIN_DIR) + set(BIN_DIR bin) +endif(NOT BIN_DIR) + +# The location in which to install XMLWRAPP header files. +if(NOT INCLUDE_DIR) + set(INCLUDE_DIR include) +endif(NOT INCLUDE_DIR) + +# The location in which to install XMLWRAPP libraries. +if(NOT LIB_DIR) + set(LIB_DIR lib) +endif(NOT LIB_DIR) + +# The location in which to install XMLWRAPP configuration files. +if(NOT CONF_DIR) + set(CONF_DIR etc) +endif(NOT CONF_DIR) + +# The location in which to install CMake scripts for packaging XMLWRAPP. +if(NOT PACKAGE_DIR) + set(PACKAGE_DIR lib) +endif(NOT PACKAGE_DIR) + +# The location in which to install XMLWRAPP data files +if(NOT DATA_DIR) + set(DATA_DIR share/xmlwrapp/${XMLWRAPP_VERSION}) +endif(NOT DATA_DIR) + +# The location in which to install XMLWRAPP Manual pages +if(NOT MAN_DIR) + set(MAN_DIR ${DATA_DIR}/man) +endif(NOT MAN_DIR) + +# The location in which to install XMLWRAPP documentation files +if(NOT DOC_DIR) + set(DOC_DIR ${DATA_DIR}/doc) +endif(NOT DOC_DIR) + + + +#--------------------------------------------------------------------- +# By default (as of version 2.8.2) CMake does not provide access to +# global lists of executable and library targets. This is useful +# in a number of situations related to formulating custom rules and +# target dependency management. To avoid the necessity of replacing +# add_library and add_executable calls with custom macros, override +# the function names and call the _add_* functions to access the CMake +# functionality previously available under the add_* functions. See +# http://www.cmake.org/pipermail/cmake/2010-September/039388.html + +# To allow a hypothetical parent build to disable this mechanism and +# replace it, we wrap the whole show in an IF conditional. To avoid +# the distcheck setup, the parent file should define the variable +# IS_SUBBUILD to ON. Note that this also disables the +# liblib prefix check in add_library, making that the responsibility +# of the parent build as well, and disables the mechanism for ensuring +# that the timing code runs at the correct points during the build. + +# We also need to provide bookkeeping logic here for the distribution +# verification or "distcheck" routines that will validate the state +# of the source tree against that expected and accounted for in the +# build files. The global coverage needed for the purpose results in +# the add_library/add_executable command override mechanism having +# to serve two purposes at once; since we only override these functions +# once the logic for both jobs is intertwined below. + +if(NOT IS_SUBBUILD) + # Functions in CMake have local variable scope, + # hence the use of properties to allow access to directory-specific + # and global information scopes. + define_property(GLOBAL PROPERTY CMAKE_LIBRARY_TARGET_LIST BRIEF_DOCS "libtarget list" FULL_DOCS "Library target list") + define_property(GLOBAL PROPERTY CMAKE_EXEC_TARGET_LIST BRIEF_DOCS "exec target list" FULL_DOCS "Executable target list") + define_property(GLOBAL PROPERTY CMAKE_CUSTOM_TARGET_LIST BRIEF_DOCS "custom target list" FULL_DOCS "Custom target list") + define_property(GLOBAL PROPERTY CMAKE_EXTERNAL_TARGET_LIST BRIEF_DOCS "external target list" FULL_DOCS "External target list") + mark_as_advanced(CMAKE_LIBRARY_TARGET_LIST) + mark_as_advanced(CMAKE_EXEC_TARGET_LIST) + mark_as_advanced(CMAKE_CUSTOM_TARGET_LIST) + mark_as_advanced(CMAKE_EXTERNAL_TARGET_LIST) + + # Need build_files_list to be clear each CMake run + file(WRITE ${CMAKE_BINARY_DIR}/build_files_list.txt "") + + # Override and wrap add_library. While we're at it, avoid doubling up + # on the lib prefix for libraries if the target name is lib<target> + function(add_library name) + get_property(CMAKE_LIBRARY_TARGET_LIST GLOBAL PROPERTY CMAKE_LIBRARY_TARGET_LIST) + _add_library(${name} ${ARGN}) + CMAKEFILES(${ARGN}) + if(${name} MATCHES "^lib*") + set_target_properties(${name} PROPERTIES PREFIX "") + endif(${name} MATCHES "^lib*") + set_property(GLOBAL APPEND PROPERTY CMAKE_LIBRARY_TARGET_LIST ${name}) + endfunction(add_library) + + # Override and wrap add_executable + function(add_executable name) + get_property(CMAKE_EXEC_TARGET_LIST GLOBAL PROPERTY CMAKE_EXEC_TARGET_LIST) + _add_executable(${name} ${ARGN}) + CMAKEFILES(${ARGN}) + set_property(GLOBAL APPEND PROPERTY CMAKE_EXEC_TARGET_LIST ${name}) + endfunction(add_executable) + + # Override and wrap add_custom_target + function(add_custom_target name) + get_property(CMAKE_CUSTOM_TARGET_LIST GLOBAL PROPERTY CMAKE_CUSTOM_TARGET_LIST) + _add_custom_target(${name} ${ARGN}) + set_property(GLOBAL APPEND PROPERTY CMAKE_CUSTOM_TARGET_LIST ${name}) + endfunction(add_custom_target) + + # Note that at the moment we do not need to override CMake's external + # project mechanisms because CMake does not use them, but if that changes + # in the future an override will need to be added here - probably of the + # ExternalProject_Add functionality. + + # Override and wrap configure_file. In the case of a configure_file, we'll + # check that the file is part of the source tree and not itself a + # generated file, but not reject full-path entries since there are quite a + # few of them. + function(configure_file file targetfile) + _configure_file(${file} ${targetfile} ${ARGN}) + GET_FILENAME_COMPONENT(ITEM_ABS ${file} ABSOLUTE) + set(TEST_BUILD_PATH "${CMAKE_BINARY_DIR}/") + set(TEST_SOURCE_PATH "${CMAKE_SOURCE_DIR}/") + string(REGEX REPLACE "^${TEST_BUILD_PATH}" "" BUILD_DIR_TRIMMED "${ITEM_ABS}") + if(${ITEM_ABS} STREQUAL ${BUILD_DIR_TRIMMED}) + string(REGEX REPLACE "^${TEST_SOURCE_PATH}" "" SOURCE_DIR_TRIMMED "${ITEM_ABS}") + if(NOT ${ITEM_ABS} STREQUAL ${SOURCE_DIR_TRIMMED}) + file(APPEND ${CMAKE_BINARY_DIR}/cmakefiles.cmake "${ITEM_ABS}\n") + endif(NOT ${ITEM_ABS} STREQUAL ${SOURCE_DIR_TRIMMED}) + endif(${ITEM_ABS} STREQUAL ${BUILD_DIR_TRIMMED}) + if(NOT ${targetfile} MATCHES "distclean") + DISTCLEAN(${targetfile}) + endif(NOT ${targetfile} MATCHES "distclean") + endfunction(configure_file) + + # Override and wrap add_subdirctory. + function(add_subdirectory name) + _add_subdirectory(${name} ${ARGN}) + file(APPEND ${CMAKE_BINARY_DIR}/cmakefiles.cmake "${CMAKE_CURRENT_SOURCE_DIR}/${name}\n") + file(APPEND ${CMAKE_BINARY_DIR}/cmakefiles.cmake "${CMAKE_CURRENT_SOURCE_DIR}/${name}/CMakeLists.txt\n") + DISTCLEAN(${CMAKE_CURRENT_BINARY_DIR}/${name}/CMakeFiles) + DISTCLEAN(${CMAKE_CURRENT_BINARY_DIR}/${name}/cmake_install.cmake) + DISTCLEAN(${CMAKE_CURRENT_BINARY_DIR}/${name}/Makefile) + endfunction(add_subdirectory) + +endif(NOT IS_SUBBUILD) + +file(REMOVE ${CMAKE_BINARY_DIR}/cmakefiles.cmake) +file(REMOVE ${CMAKE_BINARY_DIR}/cmakedirs.cmake) + +# We wrap the message function to also append ALL messages to CMakeOutput.log, +# as well as printing them on the console output. +if(NOT IS_SUBBUILD) + function(message) + _message(${ARGN}) + string(REGEX REPLACE ";" ": " msg "${ARGV}") + file(APPEND ${XMLWRAPP_BINARY_DIR}/CMakeFiles/CMakeOutput.log "${msg}\n") + endfunction(message) +endif(NOT IS_SUBBUILD) + +#--------------------------------------------------------------------- +# CMake derives much of its functionality from modules, typically +# stored in one directory - let CMake know where to find them. If we +# are a subbuild, let the parent's CMAKE_MODULE_PATH supply files before +# our own, otherwise misc/CMake takes first priority. +set(XMLWRAPP_CMAKE_DIR "${XMLWRAPP_SOURCE_DIR}/misc/CMake") +if(IS_SUBBUILD) + set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${XMLWRAPP_CMAKE_DIR}") +else(IS_SUBBUILD) + set(CMAKE_MODULE_PATH "${XMLWRAPP_CMAKE_DIR};${CMAKE_MODULE_PATH}") +endif(IS_SUBBUILD) + +# There are collections of macro definitions in misc/CMake that +# don't make sense to load with find_package - define a convenience +# macro to do what we want in such cases. +include(${XMLWRAPP_CMAKE_DIR}/LoadMacros.cmake) + +# Load utility macros that will be used throughout the XMLWRAPP +# build logic +include(${XMLWRAPP_CMAKE_DIR}/XMLWRAPP_Options.cmake) +include(${XMLWRAPP_CMAKE_DIR}/XMLWRAPP_Util.cmake) +include(CheckTypeSize) + +#--------------------------------------------------------------------- +# Save the current LC_ALL, LC_MESSAGES, and LANG environment variables +# and set them to "C" so things like date output are as expected. +set(_orig_lc_all $ENV{LC_ALL}) +set(_orig_lc_messages $ENV{LC_MESSAGES}) +set(_orig_lang $ENV{LANG}) +if(_orig_lc_all) + set(ENV{LC_ALL} C) +endif(_orig_lc_all) +if(_orig_lc_messages) + set(ENV{LC_MESSAGES} C) +endif(_orig_lc_messages) +if(_orig_lang) + set(ENV{LANG} C) +endif(_orig_lang) + +#--------------------------------------------------------------------- +# Unfortunately, CMake doesn't give you variables with current day, +# month, etc. There are several possible approaches to this, but most +# (e.g. the date command) are not cross platform. We build a small C +# file which writes out the needed values to files in the build +# directory. Those files are then read and stripped by CMake. +set(CONFIG_TIME_DAY_FILE "${XMLWRAPP_BINARY_DIR}/include/conf/CONFIG_TIME_DAY") +set(CONFIG_TIME_MONTH_FILE "${XMLWRAPP_BINARY_DIR}/include/conf/CONFIG_TIME_MONTH") +set(CONFIG_TIME_YEAR_FILE "${XMLWRAPP_BINARY_DIR}/include/conf/CONFIG_TIME_YEAR") +set(CONFIG_TIMESTAMP_FILE "${XMLWRAPP_BINARY_DIR}/include/conf/CONFIG_TIMESTAMP") +DISTCLEAN(${CONFIG_TIME_DAY_FILE} ${CONFIG_TIME_MONTH_FILE} + ${CONFIG_TIME_YEAR_FILE} ${CONFIG_TIMESTAMP_FILE}) +file(MAKE_DIRECTORY "${XMLWRAPP_BINARY_DIR}/include") +file(MAKE_DIRECTORY "${XMLWRAPP_BINARY_DIR}/include/conf") +configure_file(${XMLWRAPP_CMAKE_DIR}/test_srcs/time.c.in ${CMAKE_BINARY_DIR}/CMakeTmp/time.c) +TRY_RUN(TIME_RESULT TIME_COMPILED + ${CMAKE_BINARY_DIR}/CMakeTmp + ${CMAKE_BINARY_DIR}/CMakeTmp/time.c + OUTPUT_VARIABLE COMPILEMESSAGES) +if(TIME_RESULT MATCHES "^0$") + file(READ ${CONFIG_TIME_DAY_FILE} CONFIG_DAY) + string(STRIP ${CONFIG_DAY} CONFIG_DAY) + file(READ ${CONFIG_TIME_MONTH_FILE} CONFIG_MONTH) + string(STRIP ${CONFIG_MONTH} CONFIG_MONTH) + file(READ ${CONFIG_TIME_YEAR_FILE} CONFIG_YEAR) + string(STRIP ${CONFIG_YEAR} CONFIG_YEAR) + set(CONFIG_DATE "${CONFIG_YEAR}${CONFIG_MONTH}${CONFIG_DAY}") +else(TIME_RESULT MATCHES "^0$") + message(FATAL_ERROR "Code to determine current date and time failed!\n") +endif(TIME_RESULT MATCHES "^0$") + +#--------------------------------------------------------------------- +# print out the title with a pretty box computed to wrap around +BOX_PRINT("*** Configuring XMLWRAPP Release ${XMLWRAPP_VERSION}, Build ${CONFIG_DATE} ***" "*") + +#--------------------------------------------------------------------- +# We want to check /usr/local by default, so add it +set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} /usr/local) +set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} /usr/local/include) + +#--------------------------------------------------------------------- +# In the case of CMake, we're usually doing one of several Build +# Types. It's very rare to want to NOT specify a build type, so +# make it a little more work to do so. +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE_MSG) + message("CMake build type not set - performing Debug build.") + message("* To use optimized settings intended for a package or system install,") + message(" specify a Release build (on the command line, -DCMAKE_BUILD_TYPE=Release).") + message("* To force CMake to not set build type, specify -DCMAKE_BUILD_TYPE=NONE") + set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build Type" FORCE) + set(CMAKE_BUILD_TYPE_MSG TRUE CACHE INTERNAL "Printed build type info message") +endif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE_MSG) +set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release) + +if(CMAKE_BUILD_TYPE MATCHES "NONE") + set(CMAKE_BUILD_TYPE "") +endif(CMAKE_BUILD_TYPE MATCHES "NONE") + +#--------------------------------------------------------------------- +# The location in which to install XMLWRAPP. Only do this if +# CMAKE_INSTALL_PREFIX hasn't been set already, to try and allow +# parent builds (if any) some control. +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR NOT CMAKE_INSTALL_PREFIX) + if(NOT WIN32) + if("${CMAKE_BUILD_TYPE}" MATCHES "Release") + set(CMAKE_INSTALL_PREFIX "/usr/xmlwrapp/rel-${XMLWRAPP_VERSION}") + elseif("${CMAKE_BUILD_TYPE}" MATCHES "Debug") + set(CMAKE_INSTALL_PREFIX "/usr/xmlwrapp/dev-${XMLWRAPP_VERSION}") + else("${CMAKE_BUILD_TYPE}" MATCHES "Release") + set(CMAKE_INSTALL_PREFIX "/usr/xmlwrapp") + endif("${CMAKE_BUILD_TYPE}" MATCHES "Release") + endif(NOT WIN32) + set(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE STRING "XMLWRAPP install prefix" FORCE) + set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT 0) +endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR NOT CMAKE_INSTALL_PREFIX) +set(XMLWRAPP_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE STRING "XMLWRAPP install prefix") +mark_as_advanced(XMLWRAPP_PREFIX) + +# If we've got a Release build with a Debug path or vice versa, change it - that +# is probably the most "expected" behavior. +if("${CMAKE_BUILD_TYPE}" MATCHES "Release" AND ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr/xmlwrapp/dev-${XMLWRAPP_VERSION}") + set(CMAKE_INSTALL_PREFIX "/usr/xmlwrapp/rel-${XMLWRAPP_VERSION}" CACHE STRING "XMLWRAPP install prefix" FORCE) +endif("${CMAKE_BUILD_TYPE}" MATCHES "Release" AND ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr/xmlwrapp/dev-${XMLWRAPP_VERSION}") +if("${CMAKE_BUILD_TYPE}" MATCHES "Debug" AND ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr/xmlwrapp/rel-${XMLWRAPP_VERSION}") + set(CMAKE_INSTALL_PREFIX "/usr/xmlwrapp/dev-${XMLWRAPP_VERSION}" CACHE STRING "XMLWRAPP install prefix" FORCE) +endif("${CMAKE_BUILD_TYPE}" MATCHES "Debug" AND ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr/xmlwrapp/rel-${XMLWRAPP_VERSION}") + + +#--------------------------------------------------------------------- +# The following logic is what allows binaries to run successfully in +# the build directory AND install directory. Thanks to plplot for +# identifying the necessity of setting CMAKE_INSTALL_NAME_DIR on OSX. +# Documentation of these options is available at +# http://www.cmake.org/Wiki/CMake_RPATH_handling + +# use, i.e. don't skip the full RPATH for the build tree +set(CMAKE_SKIP_BUILD_RPATH FALSE) + +# when building, don't use the install RPATH already +# (but later on when installing) +set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) + +# the RPATH/INSTALL_NAME_DIR to be used when installing +if (NOT APPLE) + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_DIR}:\$ORIGIN/../${LIB_DIR}") +endif(NOT APPLE) +# On OSX, we need to set INSTALL_NAME_DIR instead of RPATH +# http://www.cmake.org/cmake/help/cmake-2-8-docs.html#variable:CMAKE_INSTALL_NAME_DIR +set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${LIB_DIR}") + +# add the automatically determined parts of the RPATH which point to +# directories outside the build tree to the install RPATH +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + +#--------------------------------------------------------------------- +# Output directories - this is where built library and executable +# files will be placed after building but prior to install. The +# necessary variables change between single and multi configuration +# build systems, so it is necessary to handle both cases on a +# conditional basis. + +if(NOT CMAKE_CONFIGURATION_TYPES) + # If we're not doing multi-configuration, just set the three main + # variables to the correct values. + if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${XMLWRAPP_BINARY_DIR}/${LIB_DIR} CACHE INTERNAL "Single output directory for building all libraries.") + endif(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY) + if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${XMLWRAPP_BINARY_DIR}/${LIB_DIR} CACHE INTERNAL "Single output directory for building all archives.") + endif(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY) + if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${XMLWRAPP_BINARY_DIR}/${BIN_DIR} CACHE INTERNAL "Single output directory for building all executables.") + endif(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) +else(NOT CMAKE_CONFIGURATION_TYPES) + # Multi-configuration is more difficult. Not only do we need to + # properly set the output directories, but we also need to + # identify the "toplevel" directory for each configuration so + # we can place files, documentation, etc. in the correct + # relative positions. + foreach(CFG_TYPE ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER "${CFG_TYPE}" CFG_TYPE_UPPER) + if(NOT "CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}") + set("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${XMLWRAPP_BINARY_DIR}/${CFG_TYPE}/${LIB_DIR} CACHE INTERNAL "Single output directory for building ${CFG_TYPE} libraries.") + endif(NOT "CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}") + if(NOT "CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}") + set("CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${XMLWRAPP_BINARY_DIR}/${CFG_TYPE}/${LIB_DIR} CACHE INTERNAL "Single output directory for building ${CFG_TYPE} archives.") + endif(NOT "CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}") + if(NOT "CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}") + set("CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${XMLWRAPP_BINARY_DIR}/${CFG_TYPE}/${BIN_DIR} CACHE INTERNAL "Single output directory for building ${CFG_TYPE} executables.") + endif(NOT "CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}") + if(NOT "CMAKE_BINARY_DIR_${CFG_TYPE_UPPER}") + set("CMAKE_BINARY_DIR_${CFG_TYPE_UPPER}" ${XMLWRAPP_BINARY_DIR}/${CFG_TYPE} CACHE INTERNAL "Toplevel binary dir for ${CFG_TYPE} building.") + endif(NOT "CMAKE_BINARY_DIR_${CFG_TYPE_UPPER}") + if(NOT "XMLWRAPP_BINARY_DIR_${CFG_TYPE_UPPER}") + set("XMLWRAPP_BINARY_DIR_${CFG_TYPE_UPPER}" ${XMLWRAPP_BINARY_DIR}/${CFG_TYPE} CACHE INTERNAL "Toplevel binary dir for ${CFG_TYPE} building.") + endif(NOT "XMLWRAPP_BINARY_DIR_${CFG_TYPE_UPPER}") + endforeach() +endif(NOT CMAKE_CONFIGURATION_TYPES) + +#--------------------------------------------------------------------- +# We will need a xmlwrapp_config.h.in file to hold all the #cmakedefine +# statements, which will in turn be used to generate a xmlwrapp_conf.h +# file. In autotools this process is handled by autoheader - in the +# case of CMake we wrap the CHECK_* functions and the creation of the +# entry in the xmlwrapp_config.h.in file into one step via a macro. To +# run this macro, the config.h.in file must first be present, which +# we take care of here: + +set(CONFIG_H_FILE "${XMLWRAPP_BINARY_DIR}/include/xmlwrapp_config.h.in") +file(WRITE ${CONFIG_H_FILE} "/**** Define statements for CMake ****/\n") +file(APPEND ${CONFIG_H_FILE} "#ifndef __CONFIG_H__\n") +file(APPEND ${CONFIG_H_FILE} "#define __CONFIG_H__\n") + +# If we're building on Windows, start off with the config_win.h file +if(WIN32) + file(APPEND ${CONFIG_H_FILE} "#include \"config_win_cmake.h\"\n") +endif(WIN32) + +# Set up some of the define statements for path information and other basics +file(APPEND ${CONFIG_H_FILE} "#define PACKAGE \"xmlwrapp\"\n") +file(APPEND ${CONFIG_H_FILE} "#define PACKAGE_BUGREPORT \"http://xmlwrapp.org\"\n") +file(APPEND ${CONFIG_H_FILE} "#define PACKAGE_NAME \"XMLWRAPP\"\n") +file(APPEND ${CONFIG_H_FILE} "#define PACKAGE_STRING \"XMLWRAPP ${XMLWRAPP_VERSION}\"\n") +file(APPEND ${CONFIG_H_FILE} "#define PACKAGE_TARNAME \"xmlwrapp\"\n") +file(APPEND ${CONFIG_H_FILE} "#define XMLWRAPP_DATA \"${CMAKE_INSTALL_PREFIX}/${DATA_DIR}\"\n") +file(APPEND ${CONFIG_H_FILE} "#define XMLWRAPP_ROOT \"${CMAKE_INSTALL_PREFIX}\"\n") +file(APPEND ${CONFIG_H_FILE} "#define PACKAGE_VERSION \"${XMLWRAPP_VERSION}\"\n") +file(APPEND ${CONFIG_H_FILE} "#define VERSION \"${XMLWRAPP_VERSION}\"\n") + +# A variety of debugging messages in the code key off of the DEBUG +# definition - unlike the build flags, this is turned on and off based +# on the build type. A "Release" build with debugging compiler flags +# will still not print debugging messages conditionalized on DEBUG. +if("${CMAKE_BUILD_TYPE}" MATCHES "Debug") + file(APPEND ${CONFIG_H_FILE} "#define DEBUG 1\n") +endif("${CMAKE_BUILD_TYPE}" MATCHES "Debug") + +#---------------------------------------------------------------------- +# Decide whether to do a 32 or a 64 bit build. + +set(WORD_SIZE_LABEL "Compile as 32BIT or 64BIT?") +if(NOT XMLWRAPP_WORD_SIZE) + set(XMLWRAPP_WORD_SIZE "AUTO" CACHE STRING WORD_SIZE_LABEL) +endif(NOT XMLWRAPP_WORD_SIZE) +set_property(CACHE XMLWRAPP_WORD_SIZE PROPERTY STRINGS AUTO 32BIT 64BIT) +string(TOUPPER "${XMLWRAPP_WORD_SIZE}" XMLWRAPP_WORD_SIZE_UPPER) +set(XMLWRAPP_WORD_SIZE "${XMLWRAPP_WORD_SIZE_UPPER}" CACHE STRING WORD_SIZE_LABEL FORCE) +if(NOT XMLWRAPP_WORD_SIZE MATCHES "AUTO" AND NOT XMLWRAPP_WORD_SIZE MATCHES "64BIT" AND NOT XMLWRAPP_WORD_SIZE MATCHES "32BIT") + message(WARNING "Unknown value ${XMLWRAPP_WORD_SIZE} supplied for XMLWRAPP_WORD_SIZE - defaulting to AUTO") + message(WARNING "Valid options are AUTO, 32BIT and 64BIT") + set(XMLWRAPP_WORD_SIZE "AUTO" CACHE STRING WORD_SIZE_LABEL FORCE) +endif(NOT XMLWRAPP_WORD_SIZE MATCHES "AUTO" AND NOT XMLWRAPP_WORD_SIZE MATCHES "64BIT" AND NOT XMLWRAPP_WORD_SIZE MATCHES "32BIT") + +# calculate the size of a pointer if we haven't already +CHECK_TYPE_SIZE("void *" CMAKE_SIZEOF_VOID_P) + +# still not defined? +if(NOT CMAKE_SIZEOF_VOID_P) + message(WARNING "CMAKE_SIZEOF_VOID_P is not defined - assuming 32 bit platform") + set(CMAKE_SIZEOF_VOID_P 4) +endif(NOT CMAKE_SIZEOF_VOID_P) + +if(${XMLWRAPP_WORD_SIZE} MATCHES "AUTO") + if(${CMAKE_SIZEOF_VOID_P} MATCHES "^8$") + set(CMAKE_WORD_SIZE "64BIT") + set(XMLWRAPP_WORD_SIZE "64BIT (AUTO)" CACHE STRING WORD_SIZE_LABEL FORCE) + else(${CMAKE_SIZEOF_VOID_P} MATCHES "^8$") + if(${CMAKE_SIZEOF_VOID_P} MATCHES "^4$") + set(CMAKE_WORD_SIZE "32BIT") + set(XMLWRAPP_WORD_SIZE "32BIT (AUTO)" CACHE STRING WORD_SIZE_LABEL FORCE) + else(${CMAKE_SIZEOF_VOID_P} MATCHES "^4$") + if(${CMAKE_SIZEOF_VOID_P} MATCHES "^2$") + set(CMAKE_WORD_SIZE "16BIT") + set(XMLWRAPP_WORD_SIZE "16BIT (AUTO)" CACHE STRING WORD_SIZE_LABEL FORCE) + else(${CMAKE_SIZEOF_VOID_P} MATCHES "^2$") + set(CMAKE_WORD_SIZE "8BIT") + set(XMLWRAPP_WORD_SIZE "8BIT (AUTO)" CACHE STRING WORD_SIZE_LABEL FORCE) + endif(${CMAKE_SIZEOF_VOID_P} MATCHES "^2$") + endif(${CMAKE_SIZEOF_VOID_P} MATCHES "^4$") + endif(${CMAKE_SIZEOF_VOID_P} MATCHES "^8$") +else(${XMLWRAPP_WORD_SIZE} MATCHES "AUTO") + set(CMAKE_WORD_SIZE "${XMLWRAPP_WORD_SIZE}") +endif(${XMLWRAPP_WORD_SIZE} MATCHES "AUTO") +file(APPEND ${CONFIG_H_FILE} "#define SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P}\n") + +# Enable/disable 64-bit build settings for MSVC, which is apparently +# determined at the CMake generator level - need to override other +# settings if the compiler disagrees with them. +if(MSVC) + if(CMAKE_CL_64) + if(NOT ${CMAKE_WORD_SIZE} MATCHES "64BIT") + set(CMAKE_WORD_SIZE "64BIT") + if(NOT "${XMLWRAPP_WORD_SIZE}" MATCHES "AUTO") + message(WARNING "Selected MSVC compiler is 64BIT - setting word size to 64BIT. To perform a 32BIT MSVC build, select the 32BIT MSVC CMake generator.") + set(XMLWRAPP_WORD_SIZE "64BIT" CACHE STRING WORD_SIZE_LABEL FORCE) + endif(NOT "${XMLWRAPP_WORD_SIZE}" MATCHES "AUTO") + endif(NOT ${CMAKE_WORD_SIZE} MATCHES "64BIT") + else(CMAKE_CL_64) + if(NOT ${CMAKE_WORD_SIZE} MATCHES "32BIT") + set(CMAKE_WORD_SIZE "32BIT") + if(NOT "${XMLWRAPP_WORD_SIZE}" MATCHES "AUTO") + message(WARNING "Selected MSVC compiler is 32BIT - setting word size to 32BIT. To perform a 64BIT MSVC build, select the 64BIT MSVC CMake generator.") + set(XMLWRAPP_WORD_SIZE "32BIT" CACHE STRING WORD_SIZE_LABEL FORCE) + endif(NOT "${XMLWRAPP_WORD_SIZE}" MATCHES "AUTO") + endif(NOT ${CMAKE_WORD_SIZE} MATCHES "32BIT") + endif(CMAKE_CL_64) +endif(MSVC) + +# Based on what we are doing, we may need to constrain our search paths +if(${CMAKE_WORD_SIZE} MATCHES "32BIT") + set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS OFF) +else(${CMAKE_WORD_SIZE} MATCHES "32BIT") + set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON) +endif(${CMAKE_WORD_SIZE} MATCHES "32BIT") + +# One of the problems with 32/64 building is we need to search anew +# for 64 bit libs after a 32 bit configure, or vice versa. +if(PREVIOUS_CONFIGURE_TYPE) + if(NOT ${PREVIOUS_CONFIGURE_TYPE} MATCHES ${CMAKE_WORD_SIZE}) + include(${CMAKE_SOURCE_DIR}/misc/CMake/ResetCache.cmake) + RESET_CACHE_file() + endif(NOT ${PREVIOUS_CONFIGURE_TYPE} MATCHES ${CMAKE_WORD_SIZE}) +endif(PREVIOUS_CONFIGURE_TYPE) + +set(PREVIOUS_CONFIGURE_TYPE ${CMAKE_WORD_SIZE} CACHE STRING "Previous configuration word size" FORCE) +mark_as_advanced(PREVIOUS_CONFIGURE_TYPE) + + +# ******************************************************************* +# *** Top Level Configure Options - Stage 1 of 9 *** +# ******************************************************************* +# +# Now we define the various options for XMLWRAPP - ways to enable and +# disable features, select which parts of the system to build, etc. +# As much as possible, sane default options are either selected or +# detected. Because documentation is autogenerated for XMLWRAPP +# options, be sure to initialize the file. +set(CONFIG_OPT_STRING "CONFIGURATION OPTIONS\n---------------------\n") +file(WRITE ${CMAKE_BINARY_DIR}/OPTIONS "${CONFIG_OPT_STRING}") + +# The XMLWRAPP CMake build will also generate a configure script +# that emulates the command option style of GNU Autotool's +# configure. Write the pre-defined header into the build-dir template +# to initialize the file. +file(REMOVE ${CMAKE_BINARY_DIR}/configure.new) +file(READ ${XMLWRAPP_SOURCE_DIR}/misc/CMake/configure_prefix.sh CONFIG_PREFIX) +file(WRITE ${CMAKE_BINARY_DIR}/configure.new.tmp "${CONFIG_PREFIX}") +file(COPY ${CMAKE_BINARY_DIR}/configure.new.tmp DESTINATION + ${CMAKE_BINARY_DIR}/CMakeFiles FILE_PERMISSIONS OWNER_READ OWNER_WRITE + OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) +file(REMOVE ${CMAKE_BINARY_DIR}/configure.new.tmp) +file(RENAME ${CMAKE_BINARY_DIR}/CMakeFiles/configure.new.tmp + ${CMAKE_BINARY_DIR}/configure.new) + +# Build shared libs by default. Mark this as advanced - turning off +# ALL shared library building is unlikely to result in a working build +# and is not a typical configuration. Note that turning this option off +# will not disable libraries specifically added as SHARED. +option(BUILD_SHARED_LIBS "Build shared libraries" ON) +mark_as_advanced(BUILD_SHARED_LIBS) + +# Build static libs by default unless we're debugging. Note: this +# option will not disable libraries specifically added as STATIC even +# when OFF. +AUTO_OPTION(XMLWRAPP_BUILD_STATIC_LIBS BUILD_STATIC_LIBS "OFF" "ON") + + +# On Mac OS X, it is common to have third party package managers +# present for easy software installation (currently we're aware of +# Fink and MacPorts). This can seriously complicate find_* results, +# so provide an option to specify whether or which of the third +# party setup to use. +include(${CMAKE_SOURCE_DIR}/misc/CMake/Fink_MacPorts.cmake) + +# Option for librtserver, used to help Java programs interface with librt. +option(XMLWRAPP_ENABLE_RTSERVER "Enable the librtserver target." OFF) + +# Turn off the xmlwrapp.dll build. +# It's an expert's setting at the moment. +option(XMLWRAPP_ENABLE_XMLWRAPP_LIBRARY "Build the xmlwrapp.dll" OFF) +mark_as_advanced(XMLWRAPP_ENABLE_XMLWRAPP_LIBRARY) + +# Global third party controls - these options enable and disable ALL +# local copies of libraries in src/other. Forcing all local +# libraries off is not usually recommended unless attempting to +# build packages for a distribution. If both of these options are +# on the enabling of local packages is the "senior" option and will +# force the system libs option to off. +set(XMLWRAPP_BUNDLED_LIBS_ALIASES "ENABLE_ALL") +set(XMLWRAPP_BUNDLED_LIBS_DESCRIPTION " +Enables compilation of all 3rd party sources that are provided within a XMLWRAPP +source distribution. If used this option sets all other 3rd party library +build flags to ON by default. However, that setting can be overridden by +manually setting individual variables. Default is \"AUTO\" - 3rd party sources +are compiled only if they are not detected as being available and functioning +as expected. +") +XMLWRAPP_OPTION(AUTO XMLWRAPP_BUNDLED_LIBS XMLWRAPP_BUNDLED_LIBS_ALIASES XMLWRAPP_BUNDLED_LIBS_DESCRIPTION) +set_property(CACHE XMLWRAPP_BUNDLED_LIBS PROPERTY STRINGS AUTO BUNDLED SYSTEM) +string(TOUPPER "${XMLWRAPP_BUNDLED_LIBS}" XMLWRAPP_BUNDLED_LIBS_UPPER) +set(XMLWRAPP_BUNDLED_LIBS "${XMLWRAPP_BUNDLED_LIBS_UPPER}" CACHE STRING "Build bundled libraries." FORCE) +if(${XMLWRAPP_BUNDLED_LIBS} MATCHES "ON") + set(XMLWRAPP_BUNDLED_LIBS "BUNDLED" CACHE STRING "Build bundled libraries." FORCE) +endif(${XMLWRAPP_BUNDLED_LIBS} MATCHES "ON") +if(${XMLWRAPP_BUNDLED_LIBS} MATCHES "OFF") + set(XMLWRAPP_BUNDLED_LIBS "SYSTEM" CACHE STRING "Build bundled libraries." FORCE) +endif(${XMLWRAPP_BUNDLED_LIBS} MATCHES "OFF") +if(NOT XMLWRAPP_BUNDLED_LIBS MATCHES "AUTO" AND NOT XMLWRAPP_BUNDLED_LIBS MATCHES "BUNDLED" AND NOT XMLWRAPP_BUNDLED_LIBS MATCHES "SYSTEM") + message(WARNING "Unknown value XMLWRAPP_BUNDLED_LIBS supplied for XMLWRAPP_BUNDLED_LIBS - defaulting to AUTO") + message(WARNING "Valid options are AUTO, BUNDLED and SYSTEM") + set(XMLWRAPP_BUNDLED_LIBS "AUTO" CACHE STRING "Build bundled libraries." FORCE) +endif(NOT XMLWRAPP_BUNDLED_LIBS MATCHES "AUTO" AND NOT XMLWRAPP_BUNDLED_LIBS MATCHES "BUNDLED" AND NOT XMLWRAPP_BUNDLED_LIBS MATCHES "SYSTEM") + +# Enable Aqua widgets on Mac OSX. This impacts Tcl/Tk building and OpenGL +# building. Not currently working - needs work in at least Tk and togl +# CMake logic (probably more), and the display manager/framebuffer codes are known to depend +# on either GLX or WGL specifically in their current forms. +option(XMLWRAPP_ENABLE_AQUA "Use Aqua instead of X11 whenever possible on OSX." OFF) +mark_as_advanced(XMLWRAPP_ENABLE_AQUA) + +# Install example XMLWRAPP Geometry Files +option(XMLWRAPP_INSTALL_EXAMPLE_GEOMETRY "Install the example XMLWRAPP geometry files." ON) + +# Enable features requiring X11 +if(WIN32) + option(XMLWRAPP_ENABLE_X11 "Use X11." OFF) + mark_as_advanced(XMLWRAPP_ENABLE_X11) +elseif(XMLWRAPP_ENABLE_AQUA) + option(XMLWRAPP_ENABLE_X11 "Use X11." OFF) +else(WIN32) + option(XMLWRAPP_ENABLE_X11 "Use X11." ON) +endif(WIN32) +if(XMLWRAPP_ENABLE_X11) + set(XMLWRAPP_ENABLE_AQUA OFF CACHE STRING "Don't use Aqua if we're doing X11" FORCE) + set(OPENGL_USE_AQUA OFF CACHE STRING "Don't use Aqua if we're doing X11" FORCE) +endif(XMLWRAPP_ENABLE_X11) +mark_as_advanced(OPENGL_USE_AQUA) + +# Enable/disable features requiring the Tk toolkit - usually this should +# be on, as a lot of functionality in XMLWRAPP depends on Tk +option(XMLWRAPP_ENABLE_TK "Enable features requiring the Tk toolkit" ON) +mark_as_advanced(XMLWRAPP_ENABLE_TK) +if(NOT WIN32) + if(APPLE) + if(NOT XMLWRAPP_ENABLE_X11 AND NOT XMLWRAPP_ENABLE_AQUA) + set(XMLWRAPP_ENABLE_TK OFF) + endif(NOT XMLWRAPP_ENABLE_X11 AND NOT XMLWRAPP_ENABLE_AQUA) + if(XMLWRAPP_ENABLE_X11) + set(TK_X11_GRAPHICS ON CACHE STRING "Need X11 Tk" FORCE) + endif(XMLWRAPP_ENABLE_X11) + else(APPLE) + if(NOT XMLWRAPP_ENABLE_X11) + set(XMLWRAPP_ENABLE_TK OFF) + else(NOT XMLWRAPP_ENABLE_X11) + set(TK_X11_GRAPHICS ON CACHE STRING "Need X11 Tk" FORCE) + endif(NOT XMLWRAPP_ENABLE_X11) + endif(APPLE) +endif(NOT WIN32) + +# Enable features requring OPENGL +# Be smart about this - if we don't have X11 or Aqua and we're +# not on Windows, we're non-graphical and that means OpenGL is +# a no-go. The Windows version would have to be some sort of +# option for the WIN32 graphics layer? Should probably think +# about that... for now, on Win32 don't try OpenGL if Tk is +# off. That'll hold until we get a non-Tk based GUI - then +# setting non-graphical on Windows will take more thought. +if(NOT WIN32) + if(APPLE) + if(NOT XMLWRAPP_ENABLE_X11 AND NOT XMLWRAPP_ENABLE_AQUA) + set(OPENGL_FOUND OFF) + set(XMLWRAPP_ENABLE_OPENGL OFF CACHE BOOL "Disabled - NOT XMLWRAPP_ENABLE_X11 AND NOT XMLWRAPP_ENABLE_AQUA" FORCE) + else(NOT XMLWRAPP_ENABLE_X11 AND NOT XMLWRAPP_ENABLE_AQUA) + include(${XMLWRAPP_CMAKE_DIR}/FindGL.cmake) + endif(NOT XMLWRAPP_ENABLE_X11 AND NOT XMLWRAPP_ENABLE_AQUA) + else(APPLE) + if(NOT XMLWRAPP_ENABLE_X11) + set(OPENGL_FOUND OFF) + set(XMLWRAPP_ENABLE_OPENGL OFF CACHE BOOL "Disabled - NOT XMLWRAPP_ENABLE_X11" FORCE) + else(NOT XMLWRAPP_ENABLE_X11) + include(${XMLWRAPP_CMAKE_DIR}/FindGL.cmake) + endif(NOT XMLWRAPP_ENABLE_X11) + endif(APPLE) +else(NOT WIN32) + if(XMLWRAPP_ENABLE_TK) + include(${XMLWRAPP_CMAKE_DIR}/FindGL.cmake) + else(XMLWRAPP_ENABLE_TK) + set(XMLWRAPP_ENABLE_OPENGL OFF CACHE BOOL "Disabled - WIN32 AND NOT XMLWRAPP_ENABLE_TK" FORCE) + endif(XMLWRAPP_ENABLE_TK) +endif(NOT WIN32) + +set(XMLWRAPP_ENABLE_OPENGL_ALIASES + ENABLE_OPENGL + ) +set(XMLWRAPP_ENABLE_OPENGL_DESCRIPTION " +Enable support for OpenGL based Display Managers in XMLWRAPP. +Default depends on whether OpenGL is successfully detected - +if it is, default is to enable. +") +XMLWRAPP_OPTION(${OPENGL_FOUND} XMLWRAPP_ENABLE_OPENGL XMLWRAPP_ENABLE_OPENGL_ALIASES XMLWRAPP_ENABLE_OPENGL_DESCRIPTION) + +# Enable RTGL. Requires an enabled OpenGL. +option(XMLWRAPP_ENABLE_RTGL "Enable experimental RTGL code." OFF) +mark_as_advanced(XMLWRAPP_ENABLE_RTGL) +if(NOT XMLWRAPP_ENABLE_OPENGL AND XMLWRAPP_ENABLE_RTGL) + message("RTGL requested, but OpenGL is not enabled - disabling") + set(XMLWRAPP_ENABLE_RTGL OFF CACHE BOOL "Enable experimental RTGL code." FORCE) +endif(NOT XMLWRAPP_ENABLE_OPENGL AND XMLWRAPP_ENABLE_RTGL) +if(NOT XMLWRAPP_ENABLE_X11 AND XMLWRAPP_ENABLE_RTGL) + message("RTGL currently works only with GLX, and X11 is not enabled - disabling") + set(XMLWRAPP_ENABLE_RTGL OFF CACHE BOOL "Enable experimental RTGL code." FORCE) +endif(NOT XMLWRAPP_ENABLE_X11 AND XMLWRAPP_ENABLE_RTGL) +if(XMLWRAPP_ENABLE_AQUA) + set(OPENGL_USE_AQUA ON CACHE STRING "Aqua enabled - use Aqua OpenGL" FORCE) +endif(XMLWRAPP_ENABLE_AQUA) + + +# Enable JOVE. +option(XMLWRAPP_ENABLE_JOVE "Enable jove editor build." OFF) +mark_as_advanced(XMLWRAPP_ENABLE_JOVE) + + +#---------------------------------------------------------------------- +# There are extra documentation files available requiring DocBook +# They are quite useful in graphical interfaces, but also add considerably +# to the overall build time. If necesssary XMLWRAPP provides its own +# xsltproc (see src/other/xmltools), so the html and man page +# outputs are always potentially available. PDF output, on the other hand, +# needs Apache FOP. FOP is not a candidate to bundle with XMLWRAPP for +# a number of reasons, so we simply check to see if it is present and set +# the options accordingly. + +# Do we have the environment variable set locally? +if(NOT "$ENV{APACHE_FOP}" STREQUAL "") + set(APACHE_FOP "$ENV{APACHE_FOP}") +endif(NOT "$ENV{APACHE_FOP}" STREQUAL "") +if(NOT APACHE_FOP) + find_program(APACHE_FOP fop DOC "path to the exec script for Apache FOP") +endif(NOT APACHE_FOP) +mark_as_advanced(APACHE_FOP) +# We care about the FOP version, unfortunately - find out what we have. +if(APACHE_FOP) + execute_process(COMMAND ${APACHE_FOP} -v OUTPUT_VARIABLE APACHE_FOP_INFO ERROR_QUIET) + string(REGEX REPLACE "FOP Version ([0-9\\.]*)" "\\1" APACHE_FOP_VERSION_REGEX "${APACHE_FOP_INFO}") + if(APACHE_FOP_VERSION_REGEX) + string(STRIP ${APACHE_FOP_VERSION_REGEX} APACHE_FOP_VERSION_REGEX) + endif(APACHE_FOP_VERSION_REGEX) + if(NOT "${APACHE_FOP_VERSION}" STREQUAL "${APACHE_FOP_VERSION_REGEX}") + message("-- Found Apache FOP: version ${APACHE_FOP_VERSION_REGEX}") + set(APACHE_FOP_VERSION ${APACHE_FOP_VERSION_REGEX} CACHE STRING "Apache FOP version" FORCE) + mark_as_advanced(APACHE_FOP_VERSION) + endif(NOT "${APACHE_FOP_VERSION}" STREQUAL "${APACHE_FOP_VERSION_REGEX}") +endif(APACHE_FOP) + +# The HTML output is used in the graphical help browsers in MGED and Archer, +# as well as being the most likely candidate for external viewers. Turn this +# on unless explicitly instructed otherwise by the user. +set(XMLWRAPP_EXTRADOCS_ALIASES + ENABLE_DOCS + ENABLE_EXTRA_DOCS + ENABLE_DOCBOOK + ) +set(XMLWRAPP_EXTRADOCS_DESCRIPTION " +The core option that enables and disables building of XMLWRAPP's DocBook +based documentation (includes manuals and man pages for commands, among +other things.) Defaults to ON, but only HTML and MAN formats are enabled +by default - PDF must be enabled separately by use of this option or one +of its aliases. Note that you may set environment variable APACHE_FOP +to point to your locally installed fop executable file (which on Linux is +usually a shell script with 0755 permissions). +") +XMLWRAPP_OPTION(ON XMLWRAPP_EXTRADOCS XMLWRAPP_EXTRADOCS_ALIASES XMLWRAPP_EXTRADOCS_DESCRIPTION) + +include(CMakeDependentOption) + +# By default, always do HTML output if we're doing extradocs output +CMAKE_DEPENDENT_OPTION(XMLWRAPP_EXTRADOCS_HTML "Build MAN page output from DocBook documentation" ON "XMLWRAPP_EXTRADOCS" OFF) +mark_as_advanced(XMLWRAPP_EXTRADOCS_HTML) + +# Normally, we'll turn on man page output by default, but there is +# no point in doing man page output for a Visual Studio build - the +# files aren't useful and it *seriously* increases the target build +# count/build time. Conditionalize on the CMake MSVC variable NOT +# being set. +CMAKE_DEPENDENT_OPTION(XMLWRAPP_EXTRADOCS_MAN "Build MAN page output from DocBook documentation" ON "XMLWRAPP_EXTRADOCS;NOT MSVC" OFF) +mark_as_advanced(XMLWRAPP_EXTRADOCS_MAN) + +# Don't do PDF by default, and hide the option unless the tools to do it are +# present. Provide an option to disable the PDF output for man pages without +# disabling the rest of the PDF output - PDF generation for hundreds of man +# pages can be expensive in time. +set(XMLWRAPP_EXTRADOCS_PDF_DESCRIPTION " +Option that enables building of XMLWRAPP's DocBook PDF-based documentation +(includes manuals and man pages for commands, among +other things.) Defaults to OFF. +Note that you may set environment variable APACHE_FOP +to point to your locally installed fop executable file (which on Linux is +usually a shell script with 0755 permissions). +") +set(XMLWRAPP_EXTRADOCS_PDF_MAN_DESCRIPTION " +Option that enables building of XMLWRAPP's DocBook PDF-based documentation +for man pages only. Defaults to OFF. +") +CMAKE_DEPENDENT_OPTION(XMLWRAPP_EXTRADOCS_PDF "Build PDF output from DocBook documentation" OFF "XMLWRAPP_EXTRADOCS;APACHE_FOP" OFF) +CMAKE_DEPENDENT_OPTION(XMLWRAPP_EXTRADOCS_PDF_MAN "Build PDF output from DocBook documentation for man pages" ON "XMLWRAPP_EXTRADOCS_PDF" OFF) + +# Don't do it by default, but provide an option to perform validation as part +# of the DocBook build - sort of a "strict flags" mode for DocBook +CMAKE_DEPENDENT_OPTION(XMLWRAPP_EXTRADOCS_VALIDATE "Perform validation for DocBook documentation" OFF "XMLWRAPP_EXTRADOCS" OFF) +mark_as_advanced(XMLWRAPP_EXTRADOCS_VALIDATE) + +#---------------------------------------------------------------------- +# The following are fine-grained options for enabling/disabling compiler +# and source code definition settings. Typically these are set to +# various configurations by the toplevel CMAKE_BUILD_TYPE setting, but +# can also be individually set. + +# Enable/disable runtime debugging - these are protections for +# minimizing the possibility of corrupted data files. Generally +# speaking these should be left on. +set(XMLWRAPP_ENABLE_RUNTIME_DEBUG_ALIASES + ENABLE_RUNTIME_DEBUG + ENABLE_RUN_TIME_DEBUG + ENABLE_RUNTIME_DEBUGGING + ENABLE_RUN_TIME_DEBUGGING) +set(XMLWRAPP_ENABLE_RUNTIME_DEBUG_DESCRIPTION " +Enables support for application and library debugging facilities. +Disabling the run-time debugging facilities can provide a significant +(10%-30%) performance boost at the expense of extensive error +checking (that in turn help prevent corruption of your data). +Default is "ON", and should only be disabled for read-only render +work where performance is critical. +") +XMLWRAPP_OPTION(ON XMLWRAPP_ENABLE_RUNTIME_DEBUG XMLWRAPP_ENABLE_RUNTIME_DEBUG_ALIASES XMLWRAPP_ENABLE_RUNTIME_DEBUG_DESCRIPTION) +mark_as_advanced(XMLWRAPP_ENABLE_RUNTIME_DEBUG) +if(NOT XMLWRAPP_ENABLE_RUNTIME_DEBUG) + message("}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}") + message("While disabling run-time debugging should increase") + message("performance, it will likewise remove several") + message("data-protection safeguards that are in place to") + message("minimize the possibility of corrupted data files") + message("in the inevitable event of a user encountering a bug.") + message("You have been warned. Proceed at your own risk.") + message("{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{") + file(APPEND ${CONFIG_H_FILE} "/*Define to not do anything for macros that only bomb on a fatal error. */\n") + file(APPEND ${CONFIG_H_FILE} "#define NO_BOMBING_MACROS 1\n") + file(APPEND ${CONFIG_H_FILE} "/*Define to not perform magic number checking */\n") + file(APPEND ${CONFIG_H_FILE} "#define NO_MAGIC_CHECKING 1\n") + file(APPEND ${CONFIG_H_FILE} "/*Define to not check for divide by zero during ray shots */\n") + file(APPEND ${CONFIG_H_FILE} "#define NO_BADRAY_CHECKING 1\n") + file(APPEND ${CONFIG_H_FILE} "/*Define to not provide run-time debug facilities via rt_g.debug */\n") + file(APPEND ${CONFIG_H_FILE} "#define NO_DEBUG_CHECKING 1\n") +endif(NOT XMLWRAPP_ENABLE_RUNTIME_DEBUG) + +# Enable debug flags during compilation +set(XMLWRAPP_FLAGS_DEBUG_ALIASES + ENABLE_DEBUG + ENABLE_FLAGS_DEBUG + ENABLE_DEBUG_FLAGS + ) +set(XMLWRAPP_FLAGS_DEBUG_DESCRIPTION " +Add compiler flags to aid in program debugging. Default depends on CMake +build type - defaults to ON for Debug, OFF for Release. +") +AUTO_OPTION(XMLWRAPP_FLAGS_DEBUG XMLWRAPP_DEBUG_BUILD "ON" "OFF") +OPTION_ALIASES(XMLWRAPP_FLAGS_DEBUG XMLWRAPP_FLAGS_DEBUG_ALIASES "BOOL") +OPTION_DESCRIPTION(XMLWRAPP_FLAGS_DEBUG XMLWRAPP_FLAGS_DEBUG_ALIASES XMLWRAPP_FLAGS_DEBUG_DESCRIPTION) + +# Build with compiler warning flags +set(XMLWRAPP_ENABLE_COMPILER_WARNINGS_ALIASES + ENABLE_WARNINGS + ENABLE_COMPILER_WARNINGS + ) +set(XMLWRAPP_ENABLE_COMPILER_WARNINGS_DESCRIPTION " +Use extra compiler warning flags when compiling C/C++ code. Defaults to ON. +") +XMLWRAPP_OPTION(ON XMLWRAPP_ENABLE_COMPILER_WARNINGS + XMLWRAPP_ENABLE_COMPILER_WARNINGS_ALIASES + XMLWRAPP_ENABLE_COMPILER_WARNINGS_DESCRIPTION) +mark_as_advanced(XMLWRAPP_ENABLE_COMPILER_WARNINGS) + +# Enable/disable strict compiler settings - these are limited to libraries that +# specifically inform the XMLWRAPP_ADDLIB macro they can be built with STRICT flags. + +set(XMLWRAPP_ENABLE_STRICT_ALIASES + ENABLE_STRICT + ENABLE_STRICT_COMPILE + ENABLE_STRICT_COMPILE_FLAGS) +set(XMLWRAPP_ENABLE_STRICT_DESCRIPTION " +Causes all compilation warnings for C code to be treated as errors. This is now +the default for XMLWRAPP source code, and developers should address issues +discovered by these flags whenever possible rather than disabling strict +mode. +") +XMLWRAPP_OPTION(ON XMLWRAPP_ENABLE_STRICT XMLWRAPP_ENABLE_STRICT_ALIASES XMLWRAPP_ENABLE_STRICT_DESCRIPTION) + +# The full XMLWRAPP strict flags are too much for a variety of system +# C++ headers presently (Dec. 2011) so we don't default to erroring out +# on warnings for C++ +option(XMLWRAPP_ENABLE_CXX_STRICT "Use strict compiler settings on cxx files in libraries that build with strict" OFF) +if(XMLWRAPP_ENABLE_STRICT) + mark_as_advanced(XMLWRAPP_ENABLE_STRICT) + mark_as_advanced(XMLWRAPP_ENABLE_CXX_STRICT) + file(APPEND ${CONFIG_H_FILE} "#define STRICT_FLAGS 1\n") +endif(XMLWRAPP_ENABLE_STRICT) + +# Build with compiler optimization flags. This should normally be on for release builds +AUTO_OPTION(XMLWRAPP_FLAGS_OPTIMIZATION XMLWRAPP_OPTIMIZED_BUILD "OFF" "ON") + +# By default, we don't want any error reports at all from src/other +option(XMLWRAPP_DISABLE_SRC_OTHER_WARN "Disable warnings for src/other" ON) +mark_as_advanced(XMLWRAPP_DISABLE_SRC_OTHER_WARN) + +# Build with full compiler lines visible by default (won't need make +# VERBOSE=1) on command line +option(XMLWRAPP_ENABLE_VERBOSE_PROGRESS "verbose output" OFF) +mark_as_advanced(XMLWRAPP_ENABLE_VERBOSE_PROGRESS) +if(XMLWRAPP_ENABLE_VERBOSE_PROGRESS) + set(CMAKE_VERBOSE_MAKEFILE ON) +endif(XMLWRAPP_ENABLE_VERBOSE_PROGRESS) + +# Build with profiling support +option(XMLWRAPP_ENABLE_PROFILING "Build with profiling support" OFF) +mark_as_advanced(XMLWRAPP_ENABLE_PROFILING) + +# Build with dtrace support +option(XMLWRAPP_ENABLE_DTRACE "Build with dtrace support" OFF) +mark_as_advanced(XMLWRAPP_ENABLE_DTRACE) +if(XMLWRAPP_ENABLE_DTRACE) + XMLWRAPP_INCLUDE_FILE(sys/sdt.h HAVE_SYS_SDT_H) + if(NOT HAVE_SYS_SDT_H) + set(XMLWRAPP_ENABLE_DTRACE OFF) + endif(NOT HAVE_SYS_SDT_H) +endif(XMLWRAPP_ENABLE_DTRACE) + +# Take advantage of parallel processors if available - highly recommended +option(XMLWRAPP_ENABLE_SMP "Enable SMP architecture parallel computation support" ON) +if(WIN32 AND XMLWRAPP_ENABLE_SMP) + message("SMP Support is not ready on Windows - disabling") + set(XMLWRAPP_ENABLE_SMP OFF) +endif(WIN32 AND XMLWRAPP_ENABLE_SMP) +mark_as_advanced(XMLWRAPP_ENABLE_SMP) +if(XMLWRAPP_ENABLE_SMP) + file(APPEND ${CONFIG_H_FILE} "#define PARALLEL 1\n") +endif(XMLWRAPP_ENABLE_SMP) + +# ******************************************************************* +# *** Check for Programs - Stage 2 of 9 *** +# ******************************************************************* + +# A variety of tools, such as the benchmark utilities, need +# a Bourne shell and other commands - check for them. +include(${XMLWRAPP_CMAKE_DIR}/FindShellDeps.cmake) + +# CMake can detect flex and bison, but apparently not generic lex/yacc. +# Solution is to make our own generic lex/yacc Find routines that look +# first for flex/bison, but will take whatever's available. Since the +# XMLWRAPP project isn't supposed to rely on flex/bison specific features +# anyway, there shouldn't be a problem. +include(${XMLWRAPP_CMAKE_DIR}/FindLEX.cmake) +include(${XMLWRAPP_CMAKE_DIR}/FindYACC.cmake) + + +# If using dtrace, we will need to find it +if(XMLWRAPP_ENABLE_DTRACE) + find_program(DTRACE_EXEC NAMES dtrace DOC "path to dtrace executable") +endif(XMLWRAPP_ENABLE_DTRACE) + + +# Load various wrapper macros for checking libraries, headers and +# functions +include(${XMLWRAPP_CMAKE_DIR}/XMLWRAPP_CheckFunctions.cmake) + + +# ******************************************************************* +# *** Check for Compiler Characteristics - Stage 3 of 9 *** +# ******************************************************************* + +... [truncated message content] |