BASIS  version 1.2.3 (revision 2104)
BasisSettings.cmake
Go to the documentation of this file.
00001 ##############################################################################
00002 # @file  BasisSettings.cmake
00003 # @brief Default project-independent settings.
00004 #
00005 # This module defines global CMake constants and variables which are used
00006 # by the BASIS CMake functions and macros. Hence, these values can be used
00007 # to configure the behavior of these functions to some extent without the
00008 # need to modify the functions themselves.
00009 #
00010 # @note As this file also sets the CMake policies to be used, it has to
00011 #       be included using the @c NO_POLICY_SCOPE in order for these policies
00012 #       to take effect also in the including file and its subdirectories.
00013 #
00014 # @attention Be careful when caching any of the variables. Usually, this
00015 #            file is included in the root CMake configuration file of the
00016 #            project which may also be a module of another project and hence
00017 #            may overwrite this project's settings.
00018 #
00019 # @attention Keep in mind that this file is included before any other
00020 #            BASIS module. Further, project-specific information such as
00021 #            the project name are not defined yet.
00022 #
00023 # Copyright (c) 2011, 2012 University of Pennsylvania. All rights reserved.<br />
00024 # See https://www.cbica.upenn.edu/sbia/software/license.html or COPYING file.
00025 #
00026 # Contact: SBIA Group <sbia-software at uphs.upenn.edu>
00027 #
00028 # @ingroup BasisSettings
00029 ##############################################################################
00030 
00031 ## @addtogroup BasisSettings
00032 # @{
00033 
00034 
00035 # ============================================================================
00036 # required modules
00037 # ============================================================================
00038 
00039 include ("${CMAKE_CURRENT_LIST_DIR}/CommonTools.cmake")
00040 
00041 # ============================================================================
00042 # CMake version and policies
00043 # ============================================================================
00044 
00045 cmake_minimum_required (VERSION 2.8.4)
00046 
00047 # Add policies introduced with CMake versions newer than the one specified
00048 # above. These policies would otherwise trigger a policy not set warning by
00049 # newer CMake versions.
00050 
00051 if (POLICY CMP0016)
00052   cmake_policy (SET CMP0016 NEW)
00053 endif ()
00054 
00055 if (POLICY CMP0017)
00056   cmake_policy (SET CMP0017 NEW)
00057 endif ()
00058 
00059 # ============================================================================
00060 # system checks
00061 # ============================================================================
00062 
00063 # used by tests to disable these checks
00064 if (NOT BASIS_NO_SYSTEM_CHECKS)
00065   include (CheckTypeSize)
00066   include (CheckIncludeFileCXX)
00067 
00068   # check if type long long is supported
00069   CHECK_TYPE_SIZE ("long long" LONG_LONG)
00070 
00071   if (HAVE_LONG_LONG)
00072     set (HAVE_LONG_LONG 1)
00073   else ()
00074     set (HAVE_LONG_LONG 0)
00075   endif ()
00076 
00077   # check for presence of sstream header
00078   include (TestForSSTREAM)
00079 
00080   if (CMAKE_NO_ANSI_STRING_STREAM)
00081     set (HAVE_SSTREAM 0)
00082   else ()
00083     set (HAVE_SSTREAM 1)
00084   endif ()
00085 
00086   # check if tr/tuple header file is available
00087   if (CMAKE_GENERATOR MATCHES "Visual Studio [1-9][0-9]+")
00088     set (HAVE_TR1_TUPLE 1)
00089   else ()
00090     CHECK_INCLUDE_FILE_CXX ("tr1/tuple" HAVE_TR1_TUPLE)
00091     if (HAVE_TR1_TUPLE)
00092       set (HAVE_TR1_TUPLE 1)
00093     else ()
00094       set (HAVE_TR1_TUPLE 0)
00095     endif ()
00096   endif ()
00097 
00098   # check for availibility of pthreads library
00099   # defines CMAKE_USE_PTHREADS_INIT and CMAKE_THREAD_LIBS_INIT
00100   find_package (Threads)
00101 
00102   if (Threads_FOUND)
00103     if (CMAKE_USE_PTHREADS_INIT)
00104       set (HAVE_PTHREAD 1)
00105     else  ()
00106       set (HAVE_PTHREAD 0)
00107     endif ()
00108   endif ()
00109 endif ()
00110 
00111 # ============================================================================
00112 # constants and global settings
00113 # ============================================================================
00114 
00115 ## @brief List of names used for special purpose targets.
00116 #
00117 # Contains a list of target names that are used by the BASIS functions for
00118 # special purposes and are hence not to be used for project targets.
00119 set (
00120   BASIS_RESERVED_TARGET_NAMES
00121     "all"
00122     "bundle"
00123     "bundle_source"
00124     "changelog"
00125     "clean"
00126     "depend"
00127     "doc"
00128     "headers"
00129     "headers_check"
00130     "package"
00131     "package_source"
00132     "scripts"
00133     "test"
00134     "uninstall"
00135 )
00136 
00137 ## @brief Names of recognized properties on targets.
00138 #
00139 # Unfortunately, the @c ARGV and @c ARGN arguments of a CMake function()
00140 # or macro() does not preserve values which themselves are lists. Therefore,
00141 # it is not possible to distinguish between property names and their values
00142 # in the arguments passed to set_target_properties() or
00143 # basis_set_target_properties(). To overcome this problem, this list specifies
00144 # all the possible property names. Everything else is considered to be a
00145 # property value except the first argument follwing right after the
00146 # @c PROPERTIES keyword. Alternatively, basis_set_property() can be used
00147 # as here no disambiguity exists.
00148 #
00149 # @note Placeholders such as &lt;CONFIG&gt; are allowed. These are treated
00150 #       as the regular expression "[^ ]+". See basis_list_to_regex().
00151 #
00152 # @sa http://www.cmake.org/cmake/help/cmake-2-8-docs.html#section_PropertiesonTargets
00153 set (BASIS_PROPERTIES_ON_TARGETS
00154   # CMake
00155   <CONFIG>_OUTPUT_NAME
00156   <CONFIG>_POSTFIX
00157   ARCHIVE_OUTPUT_DIRECTORY
00158   ARCHIVE_OUTPUT_DIRECTORY_<CONFIG>
00159   ARCHIVE_OUTPUT_NAME
00160   ARCHIVE_OUTPUT_NAME_<CONFIG>
00161   AUTOMOC
00162   BUILD_WITH_INSTALL_RPATH
00163   BUNDLE
00164   BUNDLE_EXTENSION
00165   COMPILE_DEFINITIONS
00166   COMPILE_DEFINITIONS_<CONFIG>
00167   COMPILE_FLAGS
00168   DEBUG_POSTFIX
00169   DEFINE_SYMBOL
00170   ENABLE_EXPORTS
00171   EXCLUDE_FROM_ALL
00172   EchoString
00173   FOLDER
00174   FRAMEWORK
00175   Fortran_FORMAT
00176   Fortran_MODULE_DIRECTORY
00177   GENERATOR_FILE_NAME
00178   HAS_CXX
00179   IMPLICIT_DEPENDS_INCLUDE_TRANSFORM
00180   IMPORTED
00181   IMPORTED_CONFIGURATIONS
00182   IMPORTED_IMPLIB
00183   IMPORTED_IMPLIB_<CONFIG>
00184   IMPORTED_LINK_DEPENDENT_LIBRARIES
00185   IMPORTED_LINK_DEPENDENT_LIBRARIES_<CONFIG>
00186   IMPORTED_LINK_INTERFACE_LANGUAGES
00187   IMPORTED_LINK_INTERFACE_LANGUAGES_<CONFIG>
00188   IMPORTED_LINK_INTERFACE_LIBRARIES
00189   IMPORTED_LINK_INTERFACE_LIBRARIES_<CONFIG>
00190   IMPORTED_LINK_INTERFACE_MULTIPLICITY
00191   IMPORTED_LINK_INTERFACE_MULTIPLICITY_<CONFIG>
00192   IMPORTED_LOCATION
00193   IMPORTED_LOCATION_<CONFIG>
00194   IMPORTED_NO_SONAME
00195   IMPORTED_NO_SONAME_<CONFIG>
00196   IMPORTED_SONAME
00197   IMPORTED_SONAME_<CONFIG>
00198   IMPORT_PREFIX
00199   IMPORT_SUFFIX
00200   INSTALL_NAME_DIR
00201   INSTALL_RPATH
00202   INSTALL_RPATH_USE_LINK_PATH
00203   INTERPROCEDURAL_OPTIMIZATION
00204   INTERPROCEDURAL_OPTIMIZATION_<CONFIG>
00205   LABELS
00206   LIBRARY_OUTPUT_DIRECTORY
00207   LIBRARY_OUTPUT_DIRECTORY_<CONFIG>
00208   LIBRARY_OUTPUT_NAME
00209   LIBRARY_OUTPUT_NAME_<CONFIG>
00210   LINKER_LANGUAGE
00211   LINK_DEPENDS
00212   LINK_FLAGS
00213   LINK_FLAGS_<CONFIG>
00214   LINK_INTERFACE_LIBRARIES
00215   LINK_INTERFACE_LIBRARIES_<CONFIG>
00216   LINK_INTERFACE_MULTIPLICITY
00217   LINK_INTERFACE_MULTIPLICITY_<CONFIG>
00218   LINK_SEARCH_END_STATIC
00219   LINK_SEARCH_START_STATIC
00220   LOCATION
00221   LOCATION_<CONFIG>
00222   MACOSX_BUNDLE
00223   MACOSX_BUNDLE_INFO_PLIST
00224   MACOSX_FRAMEWORK_INFO_PLIST
00225   MAP_IMPORTED_CONFIG_<CONFIG>
00226   OSX_ARCHITECTURES
00227   OSX_ARCHITECTURES_<CONFIG>
00228   OUTPUT_NAME
00229   OUTPUT_NAME_<CONFIG>
00230   POST_INSTALL_SCRIPT
00231   PREFIX
00232   PRE_INSTALL_SCRIPT
00233   PRIVATE_HEADER
00234   PROJECT_LABEL
00235   PUBLIC_HEADER
00236   RESOURCE
00237   RULE_LAUNCH_COMPILE
00238   RULE_LAUNCH_CUSTOM
00239   RULE_LAUNCH_LINK
00240   RUNTIME_OUTPUT_DIRECTORY
00241   RUNTIME_OUTPUT_DIRECTORY_<CONFIG>
00242   RUNTIME_OUTPUT_NAME
00243   RUNTIME_OUTPUT_NAME_<CONFIG>
00244   SKIP_BUILD_RPATH
00245   SOURCES
00246   SOVERSION
00247   STATIC_LIBRARY_FLAGS
00248   STATIC_LIBRARY_FLAGS_<CONFIG>
00249   SUFFIX
00250   TYPE
00251   VERSION
00252   VS_GLOBAL_<variable>
00253   VS_KEYWORD
00254   VS_SCC_LOCALPATH
00255   VS_SCC_PROJECTNAME
00256   VS_SCC_PROVIDER
00257   WIN32_EXECUTABLE
00258   XCODE_ATTRIBUTE_<an-attribute>
00259   # BASIS
00260   BASIS_INCLUDE_DIRECTORIES # include directories
00261   BASIS_LANGUAGE            # language of source files
00262   BASIS_LINK_DIRECTORIES    # link directories
00263   BASIS_TYPE                # BASIS type of target
00264   COMPILE                   # enable/disable compilation of script
00265   LIBEXEC                   # whether the target is an auxiliary executable
00266   ARCHIVE_INSTALL_DIRECTORY # installation directory of library
00267   LIBRARY_INSTALL_DIRECTORY # installation directory of library
00268   RUNTIME_INSTALL_DIRECTORY # installation directory of runtime
00269   LIBRARY_COMPONENT         # package component of the library component
00270   MFILE                     # documentation file of MEX-file
00271   NO_EXPORT                 # enable/disable export of target
00272   RUNTIME_COMPONENT         # package component of the runtime component
00273   TEST                      # whether the target is a test
00274 )
00275 
00276 # convert list of property names into regular expression
00277 basis_list_to_regex (BASIS_PROPERTIES_ON_TARGETS_REGEX ${BASIS_PROPERTIES_ON_TARGETS})
00278 
00279 ## @brief Default component used for library targets when no component is specified.
00280 #
00281 # The default component a library target and its auxiliary files
00282 # are associated with if no component was specified, explicitly.
00283 set (BASIS_LIBRARY_COMPONENT "Development")
00284 
00285 ## @brief Default component used for executables when no component is specified.
00286 #
00287 # The default component an executable target and its auxiliary files
00288 # are associated with if no component was specified, explicitly.
00289 set (BASIS_RUNTIME_COMPONENT "Runtime")
00290 
00291 ## @brief Specifies that the BASIS C++ utilities shall by default not be added
00292 #         as dependency of an executable.
00293 set (BASIS_NO_BASIS_UTILITIES FALSE)
00294 
00295 ## @brief Enable compilation of scripts if supported by the language.
00296 #
00297 # In particular, Python modules are compiled if this option is enabled and
00298 # only the compiled modules are installed.
00299 #
00300 # @sa basis_add_script()
00301 option (BASIS_COMPILE_SCRIPTS FALSE)
00302 mark_as_advanced (BASIS_COMPILE_SCRIPTS)
00303 
00304 ## @brief Script used to execute a process in CMake script mode.
00305 #
00306 # In order to be able to assign a timeout to the execution of a custom command
00307 # and to add some error message parsing, this script is used by some build
00308 # rules to actually perform the build step. See for example, the build of
00309 # executables using the MATLAB Compiler.
00310 set (BASIS_SCRIPT_EXECUTE_PROCESS "${BASIS_MODULE_PATH}/ExecuteProcess.cmake")
00311 
00312 ## @brief Default script configuration template.
00313 #
00314 # This is the default template used by basis_add_script() to configure the
00315 # script during the build step. If the file
00316 # @c PROJECT_CONFIG_DIR/ScriptConfig.cmake.in exists, the value of this variable
00317 # is set to its path by basis_project_initialize().
00318 set (BASIS_SCRIPT_CONFIG_FILE "${BASIS_MODULE_PATH}/ScriptConfig.cmake.in")
00319 
00320 ## @brief File used by default as <tt>--authors</tt> file to <tt>svn2cl</tt>.
00321 #
00322 # This file lists all Subversion users at SBIA and is used by default for
00323 # the mapping of Subversion user names to real names during the generation
00324 # of changelogs.
00325 set (BASIS_SVN_USERS_FILE "${BASIS_MODULE_PATH}/SubversionUsers.txt")
00326 
00327 ## @brief Force installation of public header files of BASIS C++ utilities.
00328 #
00329 # If this variable is set to FALSE, each header file in the @c PROJECT_INCLUDE_DIR
00330 # is scanned for an include statement which includes one of the public header
00331 # files of the BASIS C++ utilities. If such include statement was found in
00332 # a public header file of the project, the public header files of the BASIS
00333 # C++ utilities are also installed as the project's public header files depend
00334 # on them. You can set this variable to TRUE in the Settings.cmake file of your
00335 # project to force the installation of the public header files of the
00336 # project-specific BASIS C++ utilities.
00337 #
00338 # @sa basis_project_finalize()
00339 basis_set_if_empty (BASIS_INSTALL_PUBLIC_HEADERS_OF_CXX_UTILITIES FALSE)
00340 
00341 ## @brief Enable/Disable copying of all public header files to the build tree.
00342 #
00343 # If enabled, BASIS copies the public header files which were found in the
00344 # @c PROJECT_INCLUDE_DIR to the corresponding include directory in the build
00345 # tree using the same relative paths as will be used for the installation.
00346 # Moreover, header files with the .in suffix are configured using CMake's
00347 # configure_file() command with the <tt>\@ONLY</tt> option.
00348 #
00349 # As the copying of header files adds some additional complexity and results
00350 # in the file path reported by the compiler in error messages and warnings which
00351 # will name the corresponding copy of the header file in the build tree, causing
00352 # potential confusion and editing of the copy by mistake, this feature was made
00353 # optional. Further, the inclusion of uncovered files works only if the file
00354 # is in the source tree, not the build tree. This is a restriction of CTest.
00355 # A bug report has been submitted (#12910). A project can enable the copying
00356 # of public header files in the Settings.cmake file by setting this
00357 # CMake variable to TRUE. The advantage is that the files in the source
00358 # tree need not to be organized in subdirectories.
00359 #
00360 # If disabled, the relative path of header files is not adjusted to match
00361 # the actual installation. Therefore, in this case, the project developer
00362 # themself must maintain the <tt>sbia/&lt:project&gt;</tt> subdirectory
00363 # structure in the @c PROJECT_INCLUDE_DIR directory tree, where
00364 # &lt;project&gt; is the project name in lower case only.
00365 set (BASIS_AUTO_PREFIX_INCLUDES FALSE)
00366 
00367 ## @brief Specify public header files which are excluded from check
00368 #         whether their path is prefixed by the @c INCLUDE_PREFIX.
00369 #
00370 # If @c BASIS_AUTO_PREFIX_INCLUDES is @c FALSE and a public header
00371 # file is encountered whose path is not prefixed by @c INCLUDE_PREFIX,
00372 # a warning is output by BASIS. This warning can be suppressed for certain
00373 # public header files using this variable. If the path of the public header
00374 # file relative to @c PROJECT_INCLUDE_DIR matches either one of the listed
00375 # regular expressions, the warning is not displayed. Note that special
00376 # characters in the regular expressions will have to be escaped twice, e.g.,
00377 # "\\\\." corresponds to the regular expression "\.", i.e., matches a dot (.).
00378 set (BASIS_INCLUDES_CHECK_EXCLUDE "")
00379 
00380 # ============================================================================
00381 # common options
00382 # ============================================================================
00383 
00384 ## @brief Request verbose messages from BASIS functions.
00385 option (BASIS_VERBOSE "Request BASIS functions to output verbose messages." OFF)
00386 mark_as_advanced (BASIS_VERBOSE)
00387 
00388 ## @brief Request debugging messages from BASIS functions.
00389 option (BASIS_DEBUG "Request BASIS functions to help debugging." OFF)
00390 mark_as_advanced (BASIS_DEBUG)
00391 
00392 ## @brief Request installation of symbolic links.
00393 #
00394 # @note This option is not available on Windows.
00395 if (UNIX)
00396   option (INSTALL_LINKS "Request installation of (symbolic) links." ON)
00397 else ()
00398   set (INSTALL_LINKS OFF)
00399 endif ()
00400 
00401 # ============================================================================
00402 # build configuration
00403 # ============================================================================
00404 
00405 if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CXX_FLAGS AND NOT CMAKE_C_FLAGS)
00406   set (
00407     CMAKE_BUILD_TYPE "Release"
00408     CACHE STRING "Choose the type of build, options are: None (CMAKE_C_FLAGS and CMAKE_CXX_FLAGS used) Debug Release RelWithDebInfo MinSizeRel."
00409     FORCE
00410   )
00411 endif ()
00412 
00413 
00414 ## @}
00415 # end of Doxygen group