diff options
45 files changed, 1249 insertions, 399 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index d77c377..fc1f4a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -330,7 +330,21 @@ MACRO (CMAKE_BUILD_UTILITIES) ENDIF(BUILD_CursesDialog) ENDMACRO (CMAKE_BUILD_UTILITIES) - +#----------------------------------------------------------------------- +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() #----------------------------------------------------------------------- # The main section of the CMakeLists file diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index 3a7be1e..f7687e4 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -81,6 +81,18 @@ # Mandatory : NO # Default : - # May be used to set RPM packages that are obsoleted by this one. +# CPACK_RPM_PACKAGE_RELOCATABLE +# Mandatory : NO +# Default : - +# If this variable is set to TRUE or ON CPackRPM will try +# to build a relocatable RPM package. A relocatable RPM may +# be installed using rpm --prefix or --relocate in order to +# install it at an alternate place see rpm(8). +# Note that currently this may fail if the package contains +# files installed with absolute path or CPACK_SET_DESTDIR is set to ON. +# If CPACK_SET_DESTDIR is set then you will get a warning message +# but if there is file installed with absolute path you'll get +# unexpected behavior. # CPACK_RPM_SPEC_INSTALL_POST # Mandatory : NO # Default : - @@ -232,6 +244,11 @@ IF(NOT CPACK_RPM_PACKAGE_VERSION) ENDIF(NOT CPACK_PACKAGE_VERSION) SET(CPACK_RPM_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}) ENDIF(NOT CPACK_RPM_PACKAGE_VERSION) +# Replace '-' in version with '_' +# '-' character is an Illegal RPM version character +# it is illegal because it is used to separate +# RPM "Version" from RPM "Release" +STRING(REPLACE "-" "_" CPACK_RPM_PACKAGE_VERSION ${CPACK_RPM_PACKAGE_VERSION}) # CPACK_RPM_PACKAGE_ARCHITECTURE (optional) IF(CPACK_RPM_PACKAGE_ARCHITECTURE) @@ -314,8 +331,19 @@ ELSE(CPACK_RPM_COMPRESSION_TYPE) SET(CPACK_RPM_COMPRESSION_TYPE_TMP "") ENDIF(CPACK_RPM_COMPRESSION_TYPE) +if(CPACK_RPM_PACKAGE_RELOCATABLE) + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: Trying to build a relocatable package") + endif(CPACK_RPM_PACKAGE_DEBUG) + if(CPACK_SET_DESTDIR) + message(SEND_ERROR "CPackRPM:Warning: CPACK_SET_DESTDIR is set while requesting a relocatable package (CPACK_RPM_PACKAGE_RELOCATABLE is set): this is not supported, the package won't be relocatable.") + else(CPACK_SET_DESTDIR) + set(CPACK_RPM_PACKAGE_PREFIX ${CPACK_PACKAGING_INSTALL_PREFIX}) + endif(CPACK_SET_DESTDIR) +endif(CPACK_RPM_PACKAGE_RELOCATABLE) + # check if additional fields for RPM spec header are given -FOREACH(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES) +FOREACH(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX) IF(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}) STRING(LENGTH ${_RPM_SPEC_HEADER} _PACKAGE_HEADER_STRLENGTH) MATH(EXPR _PACKAGE_HEADER_STRLENGTH "${_PACKAGE_HEADER_STRLENGTH} - 1") @@ -392,6 +420,8 @@ if(CPACK_RPM_CHANGELOG_FILE) else(EXISTS ${CPACK_RPM_CHANGELOG_FILE}) message(SEND_ERROR "CPackRPM:Warning: CPACK_RPM_CHANGELOG_FILE <${CPACK_RPM_CHANGELOG_FILE}> does not exists - ignoring") endif(EXISTS ${CPACK_RPM_CHANGELOG_FILE}) +else(CPACK_RPM_CHANGELOG_FILE) + set(CPACK_RPM_SPEC_CHANGELOG "* Sun Jul 4 2010 Erk <eric.noulard@gmail.com>\n Generated by CPack RPM (no Changelog file were provided)") endif(CPACK_RPM_CHANGELOG_FILE) # CPACK_RPM_SPEC_MORE_DEFINE @@ -423,12 +453,13 @@ SET(CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}") # Use files tree to construct files command (spec file) # We should not forget to include symlinks (thus -o -type l) -# We must remove the './' due to the local search (thus the sed) +# We must remove the './' due to the local search and escape the +# file name by enclosing it between double quotes (thus the sed) # Then we must authorize any man pages extension (adding * at the end) # because rpmbuild may automatically compress those files EXECUTE_PROCESS(COMMAND find -type f -o -type l - COMMAND sed {s/\\.//} - COMMAND sed {s/.*man.*\\/.*/&*/} + COMMAND sed {s:.*/man.*/.*:&*:} + COMMAND sed {s/\\.\\\(.*\\\)/\"\\1\"/} WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}" OUTPUT_VARIABLE CPACK_RPM_INSTALL_FILES) @@ -469,8 +500,8 @@ Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@ \@TMP_RPM_PROVIDES\@ \@TMP_RPM_OBSOLETES\@ \@TMP_RPM_BUILDARCH\@ +\@TMP_RPM_PREFIX\@ -#p define prefix \@CMAKE_INSTALL_PREFIX\@ %define _rpmdir \@CPACK_RPM_DIRECTORY\@ %define _rpmfilename \@CPACK_RPM_FILE_NAME\@ %define _unpackaged_files_terminate_build 0 diff --git a/Modules/CTest.cmake b/Modules/CTest.cmake index 2d0702e..bdaf911 100644 --- a/Modules/CTest.cmake +++ b/Modules/CTest.cmake @@ -163,6 +163,11 @@ IF(BUILD_TESTING) SET(DART_TESTING_TIMEOUT 1500 CACHE STRING "Maximum time allowed before CTest will kill the test.") + SET(CTEST_SUBMIT_RETRY_DELAY 5 CACHE STRING + "How long to wait between timed-out CTest submissions.") + SET(CTEST_SUBMIT_RETRY_COUNT 3 CACHE STRING + "How many times to retry timed-out CTest submissions.") + FIND_PROGRAM(MEMORYCHECK_COMMAND NAMES purify valgrind boundscheck PATHS @@ -262,7 +267,9 @@ IF(BUILD_TESTING) SCPCOMMAND SLURM_SBATCH_COMMAND SLURM_SRUN_COMMAND - SITE + SITE + CTEST_SUBMIT_RETRY_DELAY + CTEST_SUBMIT_RETRY_COUNT ) # BUILDNAME IF(NOT RUN_FROM_DART) diff --git a/Modules/DartConfiguration.tcl.in b/Modules/DartConfiguration.tcl.in index 51f514f..caf0afe 100644 --- a/Modules/DartConfiguration.tcl.in +++ b/Modules/DartConfiguration.tcl.in @@ -84,3 +84,7 @@ CurlOptions: @CTEST_CURL_OPTIONS@ # warning, if you add new options here that have to do with submit, # you have to update cmCTestSubmitCommand.cxx +# For CTest submissions that timeout, these options +# specify behavior for retrying the submission +CTestSubmitRetryDelay: @CTEST_SUBMIT_RETRY_DELAY@ +CTestSubmitRetryCount: @CTEST_SUBMIT_RETRY_COUNT@ diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 8c249dc..b74f207 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -43,6 +43,13 @@ # [TEST_BEFORE_INSTALL 1] # Add test step executed before install step # [TEST_AFTER_INSTALL 1] # Add test step executed after install step # [TEST_COMMAND cmd...] # Command to drive test +# #--Output logging------------- +# [LOG_DOWNLOAD 1] # Wrap download in script to log output +# [LOG_UPDATE 1] # Wrap update in script to log output +# [LOG_CONFIGURE 1] # Wrap configure in script to log output +# [LOG_BUILD 1] # Wrap build in script to log output +# [LOG_TEST 1] # Wrap test in script to log output +# [LOG_INSTALL 1] # Wrap install in script to log output # ) # The *_DIR options specify directories for the project, with default # directories computed as follows. @@ -86,6 +93,7 @@ # [DEPENDS files...] # Files on which this step depends # [ALWAYS 1] # No stamp file, step always runs # [WORKING_DIRECTORY dir] # Working directory for command +# [LOG 1] # Wrap step in script to log output # ) # The command line, comment, and working directory of every standard # and custom step is processed to replace tokens @@ -606,6 +614,81 @@ function(_ep_get_build_command name step cmd_var) set(${cmd_var} "${cmd}" PARENT_SCOPE) endfunction(_ep_get_build_command) +function(_ep_write_log_script name step cmd_var) + ExternalProject_Get_Property(${name} stamp_dir) + set(command "${${cmd_var}}") + + set(make "") + if("${command}" MATCHES "^\\$\\(MAKE\\)") + # GNU make recognizes the string "$(MAKE)" as recursive make, so + # ensure that it appears directly in the makefile. + string(REGEX REPLACE "^\\$\\(MAKE\\)" "\${make}" command "${command}") + set(make "-Dmake=$(MAKE)") + endif() + + set(config "") + if("${CMAKE_CFG_INTDIR}" MATCHES "^\\$") + string(REPLACE "${CMAKE_CFG_INTDIR}" "\${config}" command "${command}") + set(config "-Dconfig=${CMAKE_CFG_INTDIR}") + endif() + + # Wrap multiple 'COMMAND' lines up into a second-level wrapper + # script so all output can be sent to one log file. + if("${command}" MATCHES ";COMMAND;") + set(code_execute_process " +execute_process(COMMAND \${command} RESULT_VARIABLE result) +if(result) + set(msg \"Command failed (\${result}):\\n\") + foreach(arg IN LISTS command) + set(msg \"\${msg} '\${arg}'\") + endforeach(arg) + message(FATAL_ERROR \"\${msg}\") +endif() +") + set(code "") + set(cmd "") + set(sep "") + foreach(arg IN LISTS command) + if("x${arg}" STREQUAL "xCOMMAND") + set(code "${code}set(command \"${cmd}\")${code_execute_process}") + set(cmd "") + set(sep "") + else() + set(cmd "${cmd}${sep}${arg}") + set(sep ";") + endif() + endforeach() + set(code "${code}set(command \"${cmd}\")${code_execute_process}") + file(WRITE ${stamp_dir}/${name}-${step}-impl.cmake "${code}") + set(command ${CMAKE_COMMAND} "-Dmake=\${make}" "-Dconfig=\${config}" -P ${stamp_dir}/${name}-${step}-impl.cmake) + endif() + + # Wrap the command in a script to log output to files. + set(script ${stamp_dir}/${name}-${step}.cmake) + set(logbase ${stamp_dir}/${name}-${step}) + file(WRITE ${script} " +set(command \"${command}\") +execute_process( + COMMAND \${command} + RESULT_VARIABLE result + OUTPUT_FILE \"${logbase}-out.log\" + ERROR_FILE \"${logbase}-err.log\" + ) +if(result) + set(msg \"Command failed: \${result}\\n\") + foreach(arg IN LISTS command) + set(msg \"\${msg} '\${arg}'\") + endforeach(arg) + set(msg \"\${msg}\\nSee also\\n ${logbase}-*.log\\n\") + message(FATAL_ERROR \"\${msg}\") +else() + set(msg \"${name} ${step} command succeeded. See also ${logbase}-*.log\\n\") + message(STATUS \"\${msg}\") +endif() +") + set(command ${CMAKE_COMMAND} ${make} ${config} -P ${script}) + set(${cmd_var} "${command}" PARENT_SCOPE) +endfunction(_ep_write_log_script) # This module used to use "/${CMAKE_CFG_INTDIR}" directly and produced # makefiles with "/./" in paths for custom command dependencies. Which @@ -695,6 +778,12 @@ function(ExternalProject_Add_Step name step) set(touch ${CMAKE_COMMAND} -E touch ${stamp_dir}${cfgdir}/${name}-${step}) endif() + # Wrap with log script? + get_property(log TARGET ${name} PROPERTY _EP_${step}_LOG) + if(command AND log) + _ep_write_log_script(${name} ${step} command) + endif() + add_custom_command( OUTPUT ${stamp_dir}${cfgdir}/${name}-${step} COMMENT ${comment} @@ -905,12 +994,20 @@ function(_ep_add_download_command name) endif() endif() + get_property(log TARGET ${name} PROPERTY _EP_LOG_DOWNLOAD) + if(log) + set(log LOG 1) + else() + set(log "") + endif() + ExternalProject_Add_Step(${name} download COMMENT ${comment} COMMAND ${cmd} WORKING_DIRECTORY ${work_dir} DEPENDS ${depends} DEPENDEES mkdir + ${log} ) endfunction(_ep_add_download_command) @@ -968,12 +1065,20 @@ function(_ep_add_update_command name) set(always 1) endif() + get_property(log TARGET ${name} PROPERTY _EP_LOG_UPDATE) + if(log) + set(log LOG 1) + else() + set(log "") + endif() + ExternalProject_Add_Step(${name} update COMMENT ${comment} COMMAND ${cmd} ALWAYS ${always} WORKING_DIRECTORY ${work_dir} DEPENDEES download + ${log} ) endfunction(_ep_add_update_command) @@ -1044,11 +1149,19 @@ function(_ep_add_configure_command name) configure_file(${tmp_dir}/${name}-cfgcmd.txt.in ${tmp_dir}/${name}-cfgcmd.txt) list(APPEND file_deps ${tmp_dir}/${name}-cfgcmd.txt) + get_property(log TARGET ${name} PROPERTY _EP_LOG_CONFIGURE) + if(log) + set(log LOG 1) + else() + set(log "") + endif() + ExternalProject_Add_Step(${name} configure COMMAND ${cmd} WORKING_DIRECTORY ${binary_dir} DEPENDEES update patch DEPENDS ${file_deps} + ${log} ) endfunction(_ep_add_configure_command) @@ -1063,10 +1176,18 @@ function(_ep_add_build_command name) _ep_get_build_command(${name} BUILD cmd) endif() + get_property(log TARGET ${name} PROPERTY _EP_LOG_BUILD) + if(log) + set(log LOG 1) + else() + set(log "") + endif() + ExternalProject_Add_Step(${name} build COMMAND ${cmd} WORKING_DIRECTORY ${binary_dir} DEPENDEES configure + ${log} ) endfunction(_ep_add_build_command) @@ -1081,10 +1202,18 @@ function(_ep_add_install_command name) _ep_get_build_command(${name} INSTALL cmd) endif() + get_property(log TARGET ${name} PROPERTY _EP_LOG_INSTALL) + if(log) + set(log LOG 1) + else() + set(log "") + endif() + ExternalProject_Add_Step(${name} install COMMAND ${cmd} WORKING_DIRECTORY ${binary_dir} DEPENDEES build + ${log} ) endfunction(_ep_add_install_command) @@ -1112,10 +1241,18 @@ function(_ep_add_test_command name) set(dep_args DEPENDEES install) endif() + get_property(log TARGET ${name} PROPERTY _EP_LOG_TEST) + if(log) + set(log LOG 1) + else() + set(log "") + endif() + ExternalProject_Add_Step(${name} test COMMAND ${cmd} WORKING_DIRECTORY ${binary_dir} ${dep_args} + ${log} ) endif() endfunction(_ep_add_test_command) diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index ca9649a..21dadd9 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -188,7 +188,7 @@ if (MPI_INCLUDE_PATH AND MPI_LIBRARY) # the cache, and we don't want to override those settings. elseif (MPI_COMPILE_CMDLINE) # Extract compile flags from the compile command line. - string(REGEX MATCHALL "-D([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_FLAGS "${MPI_COMPILE_CMDLINE}") + string(REGEX MATCHALL "(^| )-D([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_FLAGS "${MPI_COMPILE_CMDLINE}") set(MPI_COMPILE_FLAGS_WORK) foreach(FLAG ${MPI_ALL_COMPILE_FLAGS}) if (MPI_COMPILE_FLAGS_WORK) @@ -199,10 +199,10 @@ elseif (MPI_COMPILE_CMDLINE) endforeach(FLAG) # Extract include paths from compile command line - string(REGEX MATCHALL "-I([^\" ]+|\"[^\"]+\")" MPI_ALL_INCLUDE_PATHS "${MPI_COMPILE_CMDLINE}") + string(REGEX MATCHALL "(^| )-I([^\" ]+|\"[^\"]+\")" MPI_ALL_INCLUDE_PATHS "${MPI_COMPILE_CMDLINE}") set(MPI_INCLUDE_PATH_WORK) foreach(IPATH ${MPI_ALL_INCLUDE_PATHS}) - string(REGEX REPLACE "^-I" "" IPATH ${IPATH}) + string(REGEX REPLACE "^ ?-I" "" IPATH ${IPATH}) string(REGEX REPLACE "//" "/" IPATH ${IPATH}) list(APPEND MPI_INCLUDE_PATH_WORK ${IPATH}) endforeach(IPATH) @@ -230,10 +230,10 @@ elseif (MPI_COMPILE_CMDLINE) endif (NOT MPI_INCLUDE_PATH_WORK) # Extract linker paths from the link command line - string(REGEX MATCHALL "-L([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_PATHS "${MPI_LINK_CMDLINE}") + string(REGEX MATCHALL "(^| |-Wl,)-L([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_PATHS "${MPI_LINK_CMDLINE}") set(MPI_LINK_PATH) foreach(LPATH ${MPI_ALL_LINK_PATHS}) - string(REGEX REPLACE "^-L" "" LPATH ${LPATH}) + string(REGEX REPLACE "^(| |-Wl,)-L" "" LPATH ${LPATH}) string(REGEX REPLACE "//" "/" LPATH ${LPATH}) list(APPEND MPI_LINK_PATH ${LPATH}) endforeach(LPATH) @@ -251,7 +251,7 @@ elseif (MPI_COMPILE_CMDLINE) endif (NOT MPI_LINK_PATH) # Extract linker flags from the link command line - string(REGEX MATCHALL "-Wl,([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_FLAGS "${MPI_LINK_CMDLINE}") + string(REGEX MATCHALL "(^| )-Wl,([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_FLAGS "${MPI_LINK_CMDLINE}") set(MPI_LINK_FLAGS_WORK) foreach(FLAG ${MPI_ALL_LINK_FLAGS}) if (MPI_LINK_FLAGS_WORK) @@ -263,20 +263,20 @@ elseif (MPI_COMPILE_CMDLINE) # Extract the set of libraries to link against from the link command # line - string(REGEX MATCHALL "-l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}") + string(REGEX MATCHALL "(^| )-l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}") # Determine full path names for all of the libraries that one needs # to link against in an MPI program set(MPI_LIBRARIES) foreach(LIB ${MPI_LIBNAMES}) - string(REGEX REPLACE "^-l" "" LIB ${LIB}) + string(REGEX REPLACE "^ ?-l" "" LIB ${LIB}) set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE) find_library(MPI_LIB ${LIB} HINTS ${MPI_LINK_PATH}) if (MPI_LIB) list(APPEND MPI_LIBRARIES ${MPI_LIB}) - else (MPI_LIB) - message(SEND_ERROR "Unable to find MPI library ${LIB}") - endif (MPI_LIB) + elseif (NOT MPI_FIND_QUIETLY) + message(WARNING "Unable to find MPI library ${LIB}") + endif () endforeach(LIB) set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE INTERNAL "Scratch variable for MPI detection" FORCE) diff --git a/Modules/FindPostgreSQL.cmake b/Modules/FindPostgreSQL.cmake new file mode 100644 index 0000000..e96e1d9 --- /dev/null +++ b/Modules/FindPostgreSQL.cmake @@ -0,0 +1,181 @@ +# Find the PostgreSQL installation. +# +# ---------------------------------------------------------------------------- +# Usage: +# In your CMakeLists.txt file do something like this: +# ... +# # PostgreSQL +# FIND_PACKAGE(PostgreSQL) +# ... +# if( PostgreSQL_FOUND ) +# include_directories(${PostgreSQL_INCLUDE_DIRS}) +# link_directories(${PostgreSQL_LIBRARY_DIRS}) +# endif( PostgreSQL_FOUND ) +# ... +# Remember to include ${PostgreSQL_LIBRARIES} in the target_link_libraries() statement. +# +# +# In Windows, we make the assumption that, if the PostgreSQL files are installed, the default directory +# will be C:\Program Files\PostgreSQL. +# + +#============================================================================= +# Copyright 2004-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distributed this file outside of CMake, substitute the full +# License text for the above reference.) + +# ---------------------------------------------------------------------------- +# History: +# This module is derived from the module originally found in the VTK source tree. +# +# ---------------------------------------------------------------------------- +# Note: +# PostgreSQL_ADDITIONAL_VERSIONS is a variable that can be used to set the +# version mumber of the implementation of PostgreSQL. +# In Windows the default installation of PostgreSQL uses that as part of the path. +# E.g C:\Program Files\PostgreSQL\8.4. +# Currently, the following version numbers are known to this module: +# "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0" +# +# To use this variable just do something like this: +# set(PostgreSQL_ADDITIONAL_VERSIONS "9.2" "8.4.4") +# before calling FIND_PACKAGE(PostgreSQL) in your CMakeLists.txt file. +# This will mean that the versions you set here will be found first in the order +# specified before the default ones are searched. +# +# ---------------------------------------------------------------------------- +# You may need to manually set: +# PostgreSQL_INCLUDE_DIR - the path to where the PostgreSQL include files are. +# PostgreSQL_LIBRARY_DIR - The path to where the PostgreSQL library files are. +# If FindPostgreSQL.cmake cannot find the include files or the library files. +# +# ---------------------------------------------------------------------------- +# The following variables are set if PostgreSQL is found: +# PostgreSQL_FOUND - Set to true when PostgreSQL is found. +# PostgreSQL_INCLUDE_DIRS - Include directories for PostgreSQL +# PostgreSQL_LIBRARY_DIRS - Link directories for PostgreSQL libraries +# PostgreSQL_LIBRARIES - The PostgreSQL libraries. +# +# ---------------------------------------------------------------------------- +# If you have installed PostgreSQL in a non-standard location. +# (Please note that in the following comments, it is assumed that <Your Path> +# points to the root directory of the include directory of PostgreSQL.) +# Then you have three options. +# 1) After CMake runs, set PostgreSQL_INCLUDE_DIR to <Your Path>/include and +# PostgreSQL_LIBRARY_DIR to wherever the library pq (or libpq in windows) is +# 2) Use CMAKE_INCLUDE_PATH to set a path to <Your Path>/PostgreSQL<-version>. This will allow find_path() +# to locate PostgreSQL_INCLUDE_DIR by utilizing the PATH_SUFFIXES option. e.g. In your CMakeLists.txt file +# SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "<Your Path>/include") +# 3) Set an environment variable called ${PostgreSQL_ROOT} that points to the root of where you have +# installed PostgreSQL, e.g. <Your Path>. +# +# ---------------------------------------------------------------------------- + +set(PostgreSQL_INCLUDE_PATH_DESCRIPTION "top-level directory containing the PostgreSQL include directories. E.g /usr/local/include/PostgreSQL/8.4 or C:/Program Files/PostgreSQL/8.4/include") +set(PostgreSQL_INCLUDE_DIR_MESSAGE "Set the PostgreSQL_INCLUDE_DIR cmake cache entry to the ${PostgreSQL_INCLUDE_PATH_DESCRIPTION}") +set(PostgreSQL_LIBRARY_PATH_DESCRIPTION "top-level directory containing the PostgreSQL libraries.") +set(PostgreSQL_LIBRARY_DIR_MESSAGE "Set the PostgreSQL_LIBRARY_DIR cmake cache entry to the ${PostgreSQL_LIBRARY_PATH_DESCRIPTION}") +set(PostgreSQL_ROOT_DIR_MESSAGE "Set the PostgreSQL_ROOT system variable to where PostgreSQL is found on the machine E.g C:/Program Files/PostgreSQL/8.4") + + +set(PostgreSQL_ROOT_DIRECTORIES $ENV{PostgreSQL_ROOT}) +if(PostgreSQL_ROOT_DIRECTORIES) + file(TO_CMAKE_PATH ${PostgreSQL_ROOT_DIRECTORIES} PostgreSQL_ROOT_DIRECTORIES) +endif(PostgreSQL_ROOT_DIRECTORIES) + +set(PostgreSQL_KNOWN_VERSIONS ${PostgreSQL_ADDITIONAL_VERSIONS} + "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0") + +# Define additional search paths for root directories. +if ( WIN32 ) + foreach (suffix ${PostgreSQL_KNOWN_VERSIONS} ) + set(PostgreSQL_ADDITIONAL_SEARCH_PATHS ${PostgreSQL_ADDITIONAL_SEARCH_PATHS} "C:/Program Files/PostgreSQL/${suffix}" ) + endforeach(suffix) +endif( WIN32 ) +set( PostgreSQL_ROOT_DIRECTORIES + ${PostgreSQL_ROOT_DIRECTORIES} + ${PostgreSQL_ROOT} + ${PostgreSQL_ADDITIONAL_SEARCH_PATHS} +) + +# +# Look for an installation. +# +find_path(PostgreSQL_INCLUDE_DIR + NAMES libpq-fe.h + PATHS + # Look in other places. + ${PostgreSQL_ROOT_DIRECTORIES} + PATH_SUFFIXES + postgresql + include + # Help the user find it if we cannot. + DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}" +) + +# The PostgreSQL library. +set (PostgreSQL_LIBRARY_TO_FIND pq) +# Setting some more prefixes for the library +set (PostgreSQL_LIB_PREFIX "") +if ( WIN32 ) + set (PostgreSQL_LIB_PREFIX ${PostgreSQL_LIB_PREFIX} "lib") + set ( PostgreSQL_LIBRARY_TO_FIND ${PostgreSQL_LIB_PREFIX}${PostgreSQL_LIBRARY_TO_FIND}) +endif() + +find_library( PostgreSQL_LIBRARY + NAMES ${PostgreSQL_LIBRARY_TO_FIND} + PATHS + ${PostgreSQL_ROOT_DIRECTORIES} + PATH_SUFFIXES + lib +) +get_filename_component(PostgreSQL_LIBRARY_DIR ${PostgreSQL_LIBRARY} PATH) + +# Did we find anything? +set( PostgreSQL_FOUND 0 ) +if ( EXISTS "${PostgreSQL_INCLUDE_DIR}" AND EXISTS "${PostgreSQL_LIBRARY_DIR}" ) + set( PostgreSQL_FOUND 1 ) +else ( EXISTS "${PostgreSQL_INCLUDE_DIR}" AND EXISTS "${PostgreSQL_LIBRARY_DIR}" ) + if ( POSTGRES_REQUIRED ) + message( FATAL_ERROR "PostgreSQL is required. ${PostgreSQL_ROOT_DIR_MESSAGE}" ) + endif ( POSTGRES_REQUIRED ) +endif (EXISTS "${PostgreSQL_INCLUDE_DIR}" AND EXISTS "${PostgreSQL_LIBRARY_DIR}" ) + +# Now try to get the include and library path. +if(PostgreSQL_FOUND) + + if(EXISTS "${PostgreSQL_INCLUDE_DIR}") + set(PostgreSQL_INCLUDE_DIRS + ${PostgreSQL_INCLUDE_DIR} + ) + endif(EXISTS "${PostgreSQL_INCLUDE_DIR}") + + if(EXISTS "${PostgreSQL_LIBRARY_DIR}") + set(PostgreSQL_LIBRARY_DIRS + ${PostgreSQL_LIBRARY_DIR} + ) + set(PostgreSQL_LIBRARIES ${PostgreSQL_LIBRARY_TO_FIND}) + endif(EXISTS "${PostgreSQL_LIBRARY_DIR}") + + #message("Final PostgreSQL include dir: ${PostgreSQL_INCLUDE_DIRS}") + #message("Final PostgreSQL library dir: ${PostgreSQL_LIBRARY_DIRS}") + #message("Final PostgreSQL libraries: ${PostgreSQL_LIBRARIES}") +endif(PostgreSQL_FOUND) + +if(NOT PostgreSQL_FOUND) + if(NOT PostgreSQL_FIND_QUIETLY) + message(STATUS "PostgreSQL was not found. ${PostgreSQL_DIR_MESSAGE}") + else(NOT PostgreSQL_FIND_QUIETLY) + if(PostgreSQL_FIND_REQUIRED) + message(FATAL_ERROR "PostgreSQL was not found. ${PostgreSQL_DIR_MESSAGE}") + endif(PostgreSQL_FIND_REQUIRED) + endif(NOT PostgreSQL_FIND_QUIETLY) +endif(NOT PostgreSQL_FOUND) diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index 654879e..5f0bfe7 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -358,6 +358,94 @@ SET(QT_USE_FILE ${CMAKE_ROOT}/Modules/UseQt4.cmake) SET( QT_DEFINITIONS "") +# convenience macro for dealing with debug/release library names +MACRO (_QT4_ADJUST_LIB_VARS _camelCaseBasename) + + STRING(TOUPPER "${_camelCaseBasename}" basename) + + # The name of the imported targets, i.e. the prefix "Qt4::" must not change, + # since it is stored in EXPORT-files as name of a required library. If the name would change + # here, this would lead to the imported Qt4-library targets not being resolved by cmake anymore. + IF (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG) + + IF(NOT TARGET Qt4::${_camelCaseBasename}) + ADD_LIBRARY(Qt4::${_camelCaseBasename} UNKNOWN IMPORTED ) + + IF (QT_${basename}_LIBRARY_RELEASE) + SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) + SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} PROPERTY IMPORTED_LOCATION_RELEASE "${QT_${basename}_LIBRARY_RELEASE}" ) + ENDIF (QT_${basename}_LIBRARY_RELEASE) + + IF (QT_${basename}_LIBRARY_DEBUG) + SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) + SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} PROPERTY IMPORTED_LOCATION_DEBUG "${QT_${basename}_LIBRARY_DEBUG}" ) + ENDIF (QT_${basename}_LIBRARY_DEBUG) + ENDIF(NOT TARGET Qt4::${_camelCaseBasename}) + + # If QT_USE_IMPORTED_TARGETS is enabled, the QT_QTFOO_LIBRARY variables are set to point at these + # imported targets. This works better in general, and is also in almost all cases fully + # backward compatible. The only issue is when a project A which had this enabled then exports its + # libraries via export or EXPORT_LIBRARY_DEPENDENCIES(). In this case the libraries from project + # A will depend on the imported Qt targets, and the names of these imported targets will be stored + # in the dependency files on disk. This means when a project B then uses project A, these imported + # targets must be created again, otherwise e.g. "Qt4__QtCore" will be interpreted as name of a + # library file on disk, and not as a target, and linking will fail: + IF(QT_USE_IMPORTED_TARGETS) + SET(QT_${basename}_LIBRARY Qt4::${_camelCaseBasename} ) + SET(QT_${basename}_LIBRARIES Qt4::${_camelCaseBasename} ) + ELSE(QT_USE_IMPORTED_TARGETS) + + # if the release- as well as the debug-version of the library have been found: + IF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE) + # if the generator supports configuration types then set + # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value + IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) + SET(QT_${basename}_LIBRARY optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG}) + ELSE(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) + # if there are no configuration types and CMAKE_BUILD_TYPE has no value + # then just use the release libraries + SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE} ) + ENDIF(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) + SET(QT_${basename}_LIBRARIES optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG}) + ENDIF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE) + + # if only the release version was found, set the debug variable also to the release version + IF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG) + SET(QT_${basename}_LIBRARY_DEBUG ${QT_${basename}_LIBRARY_RELEASE}) + SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE}) + SET(QT_${basename}_LIBRARIES ${QT_${basename}_LIBRARY_RELEASE}) + ENDIF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG) + + # if only the debug version was found, set the release variable also to the debug version + IF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE) + SET(QT_${basename}_LIBRARY_RELEASE ${QT_${basename}_LIBRARY_DEBUG}) + SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_DEBUG}) + SET(QT_${basename}_LIBRARIES ${QT_${basename}_LIBRARY_DEBUG}) + ENDIF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE) + + # put the value in the cache: + SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY} CACHE STRING "The Qt ${basename} library" FORCE) + + ENDIF(QT_USE_IMPORTED_TARGETS) + + SET(QT_${basename}_FOUND 1) + + ELSE (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG) + + SET(QT_${basename}_LIBRARY "" CACHE STRING "The Qt ${basename} library" FORCE) + + ENDIF (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG) + + IF (QT_${basename}_INCLUDE_DIR) + #add the include directory to QT_INCLUDES + SET(QT_INCLUDES "${QT_${basename}_INCLUDE_DIR}" ${QT_INCLUDES}) + ENDIF (QT_${basename}_INCLUDE_DIR) + + # Make variables changeble to the advanced user + MARK_AS_ADVANCED(QT_${basename}_LIBRARY QT_${basename}_LIBRARY_RELEASE QT_${basename}_LIBRARY_DEBUG QT_${basename}_INCLUDE_DIR) +ENDMACRO (_QT4_ADJUST_LIB_VARS) + + SET(QT4_INSTALLED_VERSION_TOO_OLD FALSE) GET_FILENAME_COMPONENT(qt_install_version "[HKEY_CURRENT_USER\\Software\\trolltech\\Versions;DefaultQtVersion]" NAME) @@ -468,53 +556,147 @@ ENDIF (QT_QMAKE_EXECUTABLE) IF (QT4_QMAKE_FOUND) - # ask qmake for the library dir - # Set QT_LIBRARY_DIR - IF (NOT QT_LIBRARY_DIR OR QT_QMAKE_CHANGED) + # ask qmake for the mkspecs directory + # we do this first because QT_LIBINFIX might be set + IF (NOT QT_MKSPECS_DIR OR QT_QMAKE_CHANGED) + EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE} + ARGS "-query QMAKE_MKSPECS" + OUTPUT_VARIABLE qt_mkspecs_dirs ) + # do not replace : on windows as it might be a drive letter + # and windows should already use ; as a separator + IF(NOT WIN32) + STRING(REPLACE ":" ";" qt_mkspecs_dirs "${qt_mkspecs_dirs}") + ENDIF(NOT WIN32) + set(qt_cross_paths) + foreach(qt_cross_path ${CMAKE_FIND_ROOT_PATH}) + set(qt_cross_paths ${qt_cross_paths} "${qt_cross_path}/mkspecs") + endforeach(qt_cross_path) + SET(QT_MKSPECS_DIR NOTFOUND) + FIND_PATH(QT_MKSPECS_DIR NAMES qconfig.pri + HINTS ${qt_cross_paths} ${qt_mkspecs_dirs} + DOC "The location of the Qt mkspecs containing qconfig.pri") + ENDIF() + + IF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri") + FILE(READ ${QT_MKSPECS_DIR}/qconfig.pri _qconfig_FILE_contents) + STRING(REGEX MATCH "QT_CONFIG[^\n]+" QT_QCONFIG "${_qconfig_FILE_contents}") + STRING(REGEX MATCH "CONFIG[^\n]+" QT_CONFIG "${_qconfig_FILE_contents}") + STRING(REGEX MATCH "EDITION[^\n]+" QT_EDITION "${_qconfig_FILE_contents}") + STRING(REGEX MATCH "QT_LIBINFIX[^\n]+" _qconfig_qt_libinfix "${_qconfig_FILE_contents}") + STRING(REGEX REPLACE "QT_LIBINFIX *= *([^\n]*)" "\\1" QT_LIBINFIX "${_qconfig_qt_libinfix}") + ENDIF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri") + IF("${QT_EDITION}" MATCHES "DesktopLight") + SET(QT_EDITION_DESKTOPLIGHT 1) + ENDIF("${QT_EDITION}" MATCHES "DesktopLight") + + # ask qmake for the library dir as a hint, then search for QtCore library and use that as a reference for finding the + # others and for setting QT_LIBRARY_DIR + IF (NOT QT_QTCORE_LIBRARY OR QT_QMAKE_CHANGED) EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_LIBS" OUTPUT_VARIABLE QT_LIBRARY_DIR_TMP ) # make sure we have / and not \ as qmake gives on windows FILE(TO_CMAKE_PATH "${QT_LIBRARY_DIR_TMP}" QT_LIBRARY_DIR_TMP) - IF(EXISTS "${QT_LIBRARY_DIR_TMP}") - SET(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE PATH "Qt library dir" FORCE) - ELSE(EXISTS "${QT_LIBRARY_DIR_TMP}") - MESSAGE("Warning: QT_QMAKE_EXECUTABLE reported QT_INSTALL_LIBS as ${QT_LIBRARY_DIR_TMP}") - MESSAGE("Warning: ${QT_LIBRARY_DIR_TMP} does NOT exist, Qt must NOT be installed correctly.") - ENDIF(EXISTS "${QT_LIBRARY_DIR_TMP}") - ENDIF(NOT QT_LIBRARY_DIR OR QT_QMAKE_CHANGED) - + SET(QT_QTCORE_LIBRARY_RELEASE NOTFOUND) + SET(QT_QTCORE_LIBRARY_DEBUG NOTFOUND) + FIND_LIBRARY(QT_QTCORE_LIBRARY_RELEASE + NAMES QtCore${QT_LIBINFIX} QtCore${QT_LIBINFIX}4 + HINTS ${QT_LIBRARY_DIR_TMP} + ) + FIND_LIBRARY(QT_QTCORE_LIBRARY_DEBUG + NAMES QtCore${QT_LIBINFIX}_debug QtCore${QT_LIBINFIX}d QtCore${QT_LIBINFIX}d4 + HINTS ${QT_LIBRARY_DIR_TMP} + ) + ENDIF (NOT QT_QTCORE_LIBRARY OR QT_QMAKE_CHANGED) + + _QT4_ADJUST_LIB_VARS(QtCore) + + # set QT_LIBRARY_DIR based on location of QtCore found. + IF(QT_QTCORE_LIBRARY_RELEASE) + GET_FILENAME_COMPONENT(QT_LIBRARY_DIR_TMP "${QT_QTCORE_LIBRARY_RELEASE}" PATH) + SET(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE INTERNAL "Qt library dir" FORCE) + SET(QT_QTCORE_FOUND 1) + ELSEIF(QT_QTCORE_LIBRARY_DEBUG) + GET_FILENAME_COMPONENT(QT_LIBRARY_DIR_TMP "${QT_QTCORE_LIBRARY_DEBUG}" PATH) + SET(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE INTERNAL "Qt library dir" FORCE) + SET(QT_QTCORE_FOUND 1) + ELSE() + MESSAGE("Warning: QT_QMAKE_EXECUTABLE reported QT_INSTALL_LIBS as ${QT_LIBRARY_DIR_TMP}") + MESSAGE("Warning: But QtCore couldn't be found. Qt must NOT be installed correctly.") + + # try dropping a hint if trying to use Visual Studio with Qt built by mingw + IF(QT_LIBRARY_DIR AND MSVC) + IF(EXISTS ${QT_LIBRARY_DIR_TMP}/libqtmain.a) + MESSAGE( FATAL_ERROR "It appears you're trying to use Visual Studio with Qt built by mingw. Those compilers do not produce code compatible with each other.") + ENDIF(EXISTS ${QT_LIBRARY_DIR_TMP}/libqtmain.a) + ENDIF(QT_LIBRARY_DIR AND MSVC) + + IF(Qt4_FIND_REQUIRED) + MESSAGE( FATAL_ERROR "Could NOT find QtCore. Check ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log for more details.") + ENDIF(Qt4_FIND_REQUIRED) + ENDIF() + IF (APPLE) IF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework) - SET(QT_USE_FRAMEWORKS ON - CACHE BOOL "Set to ON if Qt build uses frameworks." FORCE) + SET(QT_USE_FRAMEWORKS ON CACHE INTERNAL "" FORCE) ELSE (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework) - SET(QT_USE_FRAMEWORKS OFF - CACHE BOOL "Set to ON if Qt build uses frameworks." FORCE) + SET(QT_USE_FRAMEWORKS OFF CACHE INTERNAL "" FORCE) ENDIF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework) - MARK_AS_ADVANCED(QT_USE_FRAMEWORKS) ENDIF (APPLE) # ask qmake for the binary dir - IF (QT_LIBRARY_DIR AND NOT QT_BINARY_DIR OR QT_QMAKE_CHANGED) + IF (NOT QT_BINARY_DIR OR QT_QMAKE_CHANGED) EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_BINS" OUTPUT_VARIABLE qt_bins ) # make sure we have / and not \ as qmake gives on windows FILE(TO_CMAKE_PATH "${qt_bins}" qt_bins) SET(QT_BINARY_DIR ${qt_bins} CACHE INTERNAL "" FORCE) - ENDIF (QT_LIBRARY_DIR AND NOT QT_BINARY_DIR OR QT_QMAKE_CHANGED) + ENDIF (NOT QT_BINARY_DIR OR QT_QMAKE_CHANGED) # ask qmake for the include dir - IF (QT_LIBRARY_DIR AND NOT QT_HEADERS_DIR OR QT_QMAKE_CHANGED) + IF (QT_LIBRARY_DIR AND (NOT QT_QTCORE_INCLUDE_DIR OR NOT QT_HEADERS_DIR OR QT_QMAKE_CHANGED)) EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_HEADERS" OUTPUT_VARIABLE qt_headers ) # make sure we have / and not \ as qmake gives on windows FILE(TO_CMAKE_PATH "${qt_headers}" qt_headers) - SET(QT_HEADERS_DIR ${qt_headers} CACHE INTERNAL "" FORCE) - ENDIF (QT_LIBRARY_DIR AND NOT QT_HEADERS_DIR OR QT_QMAKE_CHANGED) + SET(QT_QTCORE_INCLUDE_DIR NOTFOUND) + FIND_PATH(QT_QTCORE_INCLUDE_DIR QtCore + HINTS ${qt_headers} + ${QT_LIBRARY_DIR}/QtCore.framework/Headers + PATH_SUFFIXES QtCore + ) + + # Set QT_HEADERS_DIR based on finding QtCore header + IF(QT_QTCORE_INCLUDE_DIR) + IF(QT_USE_FRAMEWORKS) + SET(QT_HEADERS_DIR "${qt_headers}" CACHE INTERNAL "" FORCE) + ELSE(QT_USE_FRAMEWORKS) + GET_FILENAME_COMPONENT(qt_headers "${QT_QTCORE_INCLUDE_DIR}/../" ABSOLUTE) + SET(QT_HEADERS_DIR "${qt_headers}" CACHE INTERNAL "" FORCE) + ENDIF(QT_USE_FRAMEWORKS) + ELSEIF() + MESSAGE("Warning: QT_QMAKE_EXECUTABLE reported QT_INSTALL_HEADERS as ${qt_headers}") + MESSAGE("Warning: But QtCore couldn't be found. Qt must NOT be installed correctly.") + ENDIF() + ENDIF() + + # Set QT_INCLUDE_DIR based on QT_HEADERS_DIR + IF(QT_HEADERS_DIR) + IF(QT_USE_FRAMEWORKS) + # Qt/Mac frameworks has two include dirs. + # One is the framework include for which CMake will add a -F flag + # and the other is an include dir for non-framework Qt modules + SET(QT_INCLUDE_DIR ${QT_HEADERS_DIR} ${QT_QTCORE_LIBRARY} ) + ELSE(QT_USE_FRAMEWORKS) + SET(QT_INCLUDE_DIR ${QT_HEADERS_DIR}) + ENDIF(QT_USE_FRAMEWORKS) + ENDIF(QT_HEADERS_DIR) + + # Set QT_INCLUDES + SET( QT_INCLUDES ${QT_MKSPECS_DIR}/default ${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR}) # ask qmake for the documentation directory @@ -527,21 +709,6 @@ IF (QT4_QMAKE_FOUND) SET(QT_DOC_DIR ${qt_doc_dir} CACHE PATH "The location of the Qt docs" FORCE) ENDIF (QT_LIBRARY_DIR AND NOT QT_DOC_DIR OR QT_QMAKE_CHANGED) - # ask qmake for the mkspecs directory - IF (QT_LIBRARY_DIR AND NOT QT_MKSPECS_DIR OR QT_QMAKE_CHANGED) - EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE} - ARGS "-query QMAKE_MKSPECS" - OUTPUT_VARIABLE qt_mkspecs_dirs ) - # do not replace : on windows as it might be a drive letter - # and windows should already use ; as a separator - IF(UNIX) - STRING(REPLACE ":" ";" qt_mkspecs_dirs "${qt_mkspecs_dirs}") - ENDIF(UNIX) - SET(QT_MKSPECS_DIR NOTFOUND) - FIND_PATH(QT_MKSPECS_DIR qconfig.pri PATHS ${qt_mkspecs_dirs} - DOC "The location of the Qt mkspecs containing qconfig.pri" - NO_DEFAULT_PATH ) - ENDIF (QT_LIBRARY_DIR AND NOT QT_MKSPECS_DIR OR QT_QMAKE_CHANGED) # ask qmake for the plugins directory IF (QT_LIBRARY_DIR AND NOT QT_PLUGINS_DIR OR QT_QMAKE_CHANGED) @@ -550,7 +717,13 @@ IF (QT4_QMAKE_FOUND) OUTPUT_VARIABLE qt_plugins_dir ) # make sure we have / and not \ as qmake gives on windows FILE(TO_CMAKE_PATH "${qt_plugins_dir}" qt_plugins_dir) - SET(QT_PLUGINS_DIR ${qt_plugins_dir} CACHE PATH "The location of the Qt plugins" FORCE) + SET(QT_PLUGINS_DIR NOTFOUND) + foreach(qt_cross_path ${CMAKE_FIND_ROOT_PATH}) + set(qt_cross_paths ${qt_cross_paths} "${qt_cross_path}/plugins") + endforeach(qt_cross_path) + FIND_PATH(QT_PLUGINS_DIR NAMES accessible imageformats sqldrivers codecs designer + HINTS ${qt_cross_paths} ${qt_plugins_dir} + DOC "The location of the Qt plugins") ENDIF (QT_LIBRARY_DIR AND NOT QT_PLUGINS_DIR OR QT_QMAKE_CHANGED) # ask qmake for the translations directory @@ -568,6 +741,8 @@ IF (QT4_QMAKE_FOUND) QT_PLUGINS_DIR QT_TRANSLATIONS_DIR) + + ############################################# # # Find out what window system we're using @@ -577,11 +752,7 @@ IF (QT4_QMAKE_FOUND) SET(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) SET(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS}) # Add QT_INCLUDE_DIR to CMAKE_REQUIRED_INCLUDES - SET(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${QT_HEADERS_DIR}") - # On Mac OS X when Qt has framework support, also add the framework path - IF( QT_USE_FRAMEWORKS ) - SET(CMAKE_REQUIRED_FLAGS "-F${QT_LIBRARY_DIR} ") - ENDIF( QT_USE_FRAMEWORKS ) + SET(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${QT_INCLUDE_DIR}") # Check for Window system symbols (note: only one should end up being set) CHECK_SYMBOL_EXISTS(Q_WS_X11 "QtCore/qglobal.h" Q_WS_X11) CHECK_SYMBOL_EXISTS(Q_WS_WIN "QtCore/qglobal.h" Q_WS_WIN) @@ -615,7 +786,7 @@ IF (QT4_QMAKE_FOUND) # ######################################## - SET(QT_MODULES QtCore QtGui Qt3Support QtSvg QtScript QtTest QtUiTools + SET(QT_MODULES QtGui Qt3Support QtSvg QtScript QtTest QtUiTools QtHelp QtWebKit QtXmlPatterns phonon QtNetwork QtMultimedia QtNsPlugin QtOpenGL QtSql QtXml QtDesigner QtDBus QtScriptTools QtDeclarative) @@ -648,10 +819,10 @@ IF (QT4_QMAKE_FOUND) SET(QT_QAXSERVER_INCLUDE_DIR NOTFOUND) SET(QT_QAXSERVER_LIBRARY_RELEASE NOTFOUND) SET(QT_QAXSERVER_LIBRARY_DEBUG NOTFOUND) - IF(WIN32) + IF(Q_WS_WIN) SET(QT_QTMAIN_LIBRARY_DEBUG NOTFOUND) SET(QT_QTMAIN_LIBRARY_RELEASE NOTFOUND) - ENDIF(WIN32) + ENDIF(Q_WS_WIN) ENDIF(QT_QMAKE_CHANGED) FOREACH(QT_MODULE ${QT_MODULES}) @@ -674,20 +845,18 @@ IF (QT4_QMAKE_FOUND) ENDIF(${QT_MODULE} STREQUAL "phonon") ENDFOREACH(QT_MODULE) - IF(WIN32) + IF(Q_WS_WIN) SET(QT_MODULES ${QT_MODULES} QAxContainer QAxServer) # Set QT_AXCONTAINER_INCLUDE_DIR and QT_AXSERVER_INCLUDE_DIR FIND_PATH(QT_QAXCONTAINER_INCLUDE_DIR ActiveQt - PATHS - ${QT_HEADERS_DIR}/ActiveQt + PATHS ${QT_HEADERS_DIR}/ActiveQt NO_DEFAULT_PATH ) FIND_PATH(QT_QAXSERVER_INCLUDE_DIR ActiveQt - PATHS - ${QT_HEADERS_DIR}/ActiveQt + PATHS ${QT_HEADERS_DIR}/ActiveQt NO_DEFAULT_PATH ) - ENDIF(WIN32) + ENDIF(Q_WS_WIN) # Set QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR FIND_PATH(QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR QDesignerComponents @@ -713,49 +882,6 @@ IF (QT4_QMAKE_FOUND) NO_DEFAULT_PATH ) - # Set QT_INCLUDE_DIR by removine "/QtCore" in the string ${QT_QTCORE_INCLUDE_DIR} - IF( QT_QTCORE_INCLUDE_DIR ) - IF (QT_USE_FRAMEWORKS) - SET(QT_INCLUDE_DIR ${QT_HEADERS_DIR}) - ELSE (QT_USE_FRAMEWORKS) - STRING( REGEX REPLACE "/QtCore$" "" qt4_include_dir ${QT_QTCORE_INCLUDE_DIR}) - SET( QT_INCLUDE_DIR ${qt4_include_dir}) - ENDIF (QT_USE_FRAMEWORKS) - ENDIF( QT_QTCORE_INCLUDE_DIR ) - - IF( NOT QT_INCLUDE_DIR) - IF(Qt4_FIND_REQUIRED) - MESSAGE( FATAL_ERROR "Could NOT find QtCore header") - ENDIF(Qt4_FIND_REQUIRED) - ENDIF( NOT QT_INCLUDE_DIR) - - # Make variables changeble to the advanced user - MARK_AS_ADVANCED( QT_INCLUDE_DIR ) - - # Set QT_INCLUDES - SET( QT_INCLUDES ${QT_MKSPECS_DIR}/default ${QT_INCLUDE_DIR} ) - - - - - - ####################################### - # - # Qt configuration - # - ####################################### - IF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri") - FILE(READ ${QT_MKSPECS_DIR}/qconfig.pri _qconfig_FILE_contents) - STRING(REGEX MATCH "QT_CONFIG[^\n]+" QT_QCONFIG "${_qconfig_FILE_contents}") - STRING(REGEX MATCH "CONFIG[^\n]+" QT_CONFIG "${_qconfig_FILE_contents}") - STRING(REGEX MATCH "EDITION[^\n]+" QT_EDITION "${_qconfig_FILE_contents}") - STRING(REGEX MATCH "QT_LIBINFIX[^\n]+" _qconfig_qt_libinfix "${_qconfig_FILE_contents}") - STRING(REGEX REPLACE "QT_LIBINFIX *= *([^\n]*)" "\\1" QT_LIBINFIX "${_qconfig_qt_libinfix}") - ENDIF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri") - IF("${QT_EDITION}" MATCHES "DesktopLight") - SET(QT_EDITION_DESKTOPLIGHT 1) - ENDIF("${QT_EDITION}" MATCHES "DesktopLight") - ######################################## # # Setting the LIBRARY-Variables @@ -780,48 +906,32 @@ IF (QT4_QMAKE_FOUND) FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_RELEASE NAMES QtUiTools${QT_LIBINFIX} PATHS ${QT_LIBRARY_DIR}) ENDIF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTUITOOLS_LIBRARY_RELEASE) - IF( NOT QT_QTCORE_LIBRARY_DEBUG AND NOT QT_QTCORE_LIBRARY_RELEASE ) - - # try dropping a hint if trying to use Visual Studio with Qt built by mingw - IF(QT_LIBRARY_DIR AND MSVC) - IF(EXISTS ${QT_LIBRARY_DIR}/libqtmain.a) - MESSAGE( FATAL_ERROR "It appears you're trying to use Visual Studio with Qt built by mingw") - ENDIF(EXISTS ${QT_LIBRARY_DIR}/libqtmain.a) - ENDIF(QT_LIBRARY_DIR AND MSVC) - - IF(Qt4_FIND_REQUIRED) - MESSAGE( FATAL_ERROR "Could NOT find QtCore. Check ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log for more details.") - ENDIF(Qt4_FIND_REQUIRED) - ENDIF( NOT QT_QTCORE_LIBRARY_DEBUG AND NOT QT_QTCORE_LIBRARY_RELEASE ) - # Set QT_QTDESIGNERCOMPONENTS_LIBRARY - FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_RELEASE NAMES QtDesignerComponents${QT_LIBINFIX} QtDesignerComponents${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_RELEASE NAMES QtDesignerComponents${QT_LIBINFIX} QtDesignerComponents${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_DEBUG NAMES QtDesignerComponents${QT_LIBINFIX}_debug QtDesignerComponents${QT_LIBINFIX}d QtDesignerComponents${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) # Set QT_QTMAIN_LIBRARY - IF(WIN32) - FIND_LIBRARY(QT_QTMAIN_LIBRARY_RELEASE NAMES qtmain${QT_LIBINFIX} PATHS ${QT_LIBRARY_DIR} - NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTMAIN_LIBRARY_DEBUG NAMES qtmain${QT_LIBINFIX}d PATHS ${QT_LIBRARY_DIR} - NO_DEFAULT_PATH) - ENDIF(WIN32) + IF(Q_WS_WIN) + FIND_LIBRARY(QT_QTMAIN_LIBRARY_RELEASE NAMES qtmain${QT_LIBINFIX} PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTMAIN_LIBRARY_DEBUG NAMES qtmain${QT_LIBINFIX}d PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + ENDIF(Q_WS_WIN) # Set QT_QTASSISTANTCLIENT_LIBRARY - FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY_RELEASE NAMES QtAssistantClient${QT_LIBINFIX} QtAssistantClient${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY_DEBUG NAMES QtAssistantClient${QT_LIBINFIX}_debug QtAssistantClient${QT_LIBINFIX}d QtAssistantClient${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY_RELEASE NAMES QtAssistantClient${QT_LIBINFIX} QtAssistantClient${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY_DEBUG NAMES QtAssistantClient${QT_LIBINFIX}_debug QtAssistantClient${QT_LIBINFIX}d QtAssistantClient${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) # Set QT_QTASSISTANT_LIBRARY - FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_RELEASE NAMES QtAssistantClient${QT_LIBINFIX} QtAssistantClient${QT_LIBINFIX}4 QtAssistant${QT_LIBINFIX} QtAssistant${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_RELEASE NAMES QtAssistantClient${QT_LIBINFIX} QtAssistantClient${QT_LIBINFIX}4 QtAssistant${QT_LIBINFIX} QtAssistant${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_DEBUG NAMES QtAssistantClient${QT_LIBINFIX}_debug QtAssistantClient${QT_LIBINFIX}d QtAssistantClient${QT_LIBINFIX}d4 QtAssistant${QT_LIBINFIX}_debug QtAssistant${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) # Set QT_QTHELP_LIBRARY - FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_RELEASE NAMES QtCLucene${QT_LIBINFIX} QtCLucene${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_RELEASE NAMES QtCLucene${QT_LIBINFIX} QtCLucene${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_DEBUG NAMES QtCLucene${QT_LIBINFIX}_debug QtCLucene${QT_LIBINFIX}d QtCLucene${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - # QtCLucene not with other frameworks with binary installation (in /usr/lib) IF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTCLUCENE_LIBRARY_RELEASE) FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_RELEASE NAMES QtCLucene${QT_LIBINFIX} PATHS ${QT_LIBRARY_DIR}) ENDIF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTCLUCENE_LIBRARY_RELEASE) + ############################################ # # Check the existence of the libraries. @@ -835,137 +945,23 @@ IF (QT4_QMAKE_FOUND) ENDIF(QT_USE_FRAMEWORKS) - MACRO (_QT4_ADJUST_LIB_VARS _camelCaseBasename) - - STRING(TOUPPER "${_camelCaseBasename}" basename) - - # The name of the imported targets, i.e. the prefix "Qt4::" must not change, - # since it is stored in EXPORT-files as name of a required library. If the name would change - # here, this would lead to the imported Qt4-library targets not being resolved by cmake anymore. - IF (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG) - - IF(NOT TARGET Qt4::${_camelCaseBasename}) - ADD_LIBRARY(Qt4::${_camelCaseBasename} UNKNOWN IMPORTED ) - - IF (QT_${basename}_LIBRARY_RELEASE) - SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) - SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} PROPERTY IMPORTED_LOCATION_RELEASE "${QT_${basename}_LIBRARY_RELEASE}" ) - ENDIF (QT_${basename}_LIBRARY_RELEASE) - - IF (QT_${basename}_LIBRARY_DEBUG) - SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) - SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} PROPERTY IMPORTED_LOCATION_DEBUG "${QT_${basename}_LIBRARY_DEBUG}" ) - ENDIF (QT_${basename}_LIBRARY_DEBUG) - ENDIF(NOT TARGET Qt4::${_camelCaseBasename}) - - # If QT_USE_IMPORTED_TARGETS is enabled, the QT_QTFOO_LIBRARY variables are set to point at these - # imported targets. This works better in general, and is also in almost all cases fully - # backward compatible. The only issue is when a project A which had this enabled then exports its - # libraries via export or EXPORT_LIBRARY_DEPENDENCIES(). In this case the libraries from project - # A will depend on the imported Qt targets, and the names of these imported targets will be stored - # in the dependency files on disk. This means when a project B then uses project A, these imported - # targets must be created again, otherwise e.g. "Qt4__QtCore" will be interpreted as name of a - # library file on disk, and not as a target, and linking will fail: - IF(QT_USE_IMPORTED_TARGETS) - SET(QT_${basename}_LIBRARY Qt4::${_camelCaseBasename} ) - SET(QT_${basename}_LIBRARIES Qt4::${_camelCaseBasename} ) - ELSE(QT_USE_IMPORTED_TARGETS) - - # if the release- as well as the debug-version of the library have been found: - IF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE) - # if the generator supports configuration types then set - # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value - IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) - SET(QT_${basename}_LIBRARY optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG}) - ELSE(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) - # if there are no configuration types and CMAKE_BUILD_TYPE has no value - # then just use the release libraries - SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE} ) - ENDIF(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) - SET(QT_${basename}_LIBRARIES optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG}) - ENDIF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE) - - # if only the release version was found, set the debug variable also to the release version - IF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG) - SET(QT_${basename}_LIBRARY_DEBUG ${QT_${basename}_LIBRARY_RELEASE}) - SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE}) - SET(QT_${basename}_LIBRARIES ${QT_${basename}_LIBRARY_RELEASE}) - ENDIF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG) - - # if only the debug version was found, set the release variable also to the debug version - IF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE) - SET(QT_${basename}_LIBRARY_RELEASE ${QT_${basename}_LIBRARY_DEBUG}) - SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_DEBUG}) - SET(QT_${basename}_LIBRARIES ${QT_${basename}_LIBRARY_DEBUG}) - ENDIF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE) - - # put the value in the cache: - SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY} CACHE STRING "The Qt ${basename} library" FORCE) - - ENDIF(QT_USE_IMPORTED_TARGETS) - -# message(STATUS "QT_${basename}_LIBRARY: ${QT_${basename}_LIBRARY}") - - SET(QT_${basename}_FOUND 1) - - ENDIF (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG) - - IF (QT_${basename}_INCLUDE_DIR) - #add the include directory to QT_INCLUDES - SET(QT_INCLUDES "${QT_${basename}_INCLUDE_DIR}" ${QT_INCLUDES}) - ENDIF (QT_${basename}_INCLUDE_DIR) - - # Make variables changeble to the advanced user - MARK_AS_ADVANCED(QT_${basename}_LIBRARY QT_${basename}_LIBRARY_RELEASE QT_${basename}_LIBRARY_DEBUG QT_${basename}_INCLUDE_DIR) - ENDMACRO (_QT4_ADJUST_LIB_VARS) - - # Set QT_xyz_LIBRARY variable and add # library include path to QT_INCLUDES - _QT4_ADJUST_LIB_VARS(QtCore) - _QT4_ADJUST_LIB_VARS(QtGui) - _QT4_ADJUST_LIB_VARS(Qt3Support) + FOREACH(QT_MODULE ${QT_MODULES}) + _QT4_ADJUST_LIB_VARS(${QT_MODULE}) + ENDFOREACH(QT_MODULE) + _QT4_ADJUST_LIB_VARS(QtAssistant) _QT4_ADJUST_LIB_VARS(QtAssistantClient) _QT4_ADJUST_LIB_VARS(QtCLucene) - _QT4_ADJUST_LIB_VARS(QtDBus) - _QT4_ADJUST_LIB_VARS(QtDeclarative) - _QT4_ADJUST_LIB_VARS(QtDesigner) _QT4_ADJUST_LIB_VARS(QtDesignerComponents) - _QT4_ADJUST_LIB_VARS(QtHelp) - _QT4_ADJUST_LIB_VARS(QtMultimedia) - _QT4_ADJUST_LIB_VARS(QtNetwork) - _QT4_ADJUST_LIB_VARS(QtNsPlugin) - _QT4_ADJUST_LIB_VARS(QtOpenGL) - _QT4_ADJUST_LIB_VARS(QtScript) - _QT4_ADJUST_LIB_VARS(QtScriptTools) - _QT4_ADJUST_LIB_VARS(QtSql) - _QT4_ADJUST_LIB_VARS(QtSvg) - _QT4_ADJUST_LIB_VARS(QtTest) - _QT4_ADJUST_LIB_VARS(QtUiTools) - _QT4_ADJUST_LIB_VARS(QtWebKit) - _QT4_ADJUST_LIB_VARS(QtXml) - _QT4_ADJUST_LIB_VARS(QtXmlPatterns) - _QT4_ADJUST_LIB_VARS(phonon) # platform dependent libraries - IF(Q_WS_X11) - _QT4_ADJUST_LIB_VARS(QtMotif) - ENDIF(Q_WS_X11) - IF(WIN32) + IF(Q_WS_WIN) _QT4_ADJUST_LIB_VARS(qtmain) _QT4_ADJUST_LIB_VARS(QAxServer) _QT4_ADJUST_LIB_VARS(QAxContainer) - ENDIF(WIN32) - - # If Qt is installed as a framework, we need to add QT_QTCORE_LIBRARY here (which - # is the framework directory in that case), since this will make the cmake include_directories() - # command recognize that we need the framework flag with the respective directory (-F) - IF(QT_USE_FRAMEWORKS) - SET(QT_INCLUDES ${QT_INCLUDES} ${QT_QTCORE_LIBRARY} ) - SET(QT_INCLUDE_DIR ${QT_INCLUDE_DIR} ${QT_QTCORE_LIBRARY} ) - ENDIF(QT_USE_FRAMEWORKS) - + ENDIF(Q_WS_WIN) ####################################### diff --git a/Modules/Qt4ConfigDependentSettings.cmake b/Modules/Qt4ConfigDependentSettings.cmake index 51d5fd9..2e03716 100644 --- a/Modules/Qt4ConfigDependentSettings.cmake +++ b/Modules/Qt4ConfigDependentSettings.cmake @@ -34,12 +34,12 @@ SET(QT_QTDBUS_LIB_DEPENDENCIES "") SET(QT_QTHELP_LIB_DEPENDENCIES ${QT_QTCLUCENE_LIBRARY}) -IF(WIN32) +IF(Q_WS_WIN) # On Windows, qconfig.pri has "static" for static library builds IF(QT_CONFIG MATCHES "static") SET(QT_IS_STATIC 1) ENDIF(QT_CONFIG MATCHES "static") -ELSE(WIN32) +ELSE(Q_WS_WIN) # On other platforms, check file extension to know if its static IF(QT_QTCORE_LIBRARY_RELEASE) GET_FILENAME_COMPONENT(qtcore_lib_ext "${QT_QTCORE_LIBRARY_RELEASE}" EXT) @@ -53,12 +53,12 @@ ELSE(WIN32) SET(QT_IS_STATIC 1) ENDIF(${qtcore_lib_ext} STREQUAL ${CMAKE_STATIC_LIBRARY_SUFFIX}) ENDIF(QT_QTCORE_LIBRARY_DEBUG) -ENDIF(WIN32) +ENDIF(Q_WS_WIN) # build using shared Qt needs -DQT_DLL on Windows -IF(WIN32 AND NOT QT_IS_STATIC) +IF(Q_WS_WIN AND NOT QT_IS_STATIC) SET(QT_DEFINITIONS ${QT_DEFINITIONS} -DQT_DLL) -ENDIF(WIN32 AND NOT QT_IS_STATIC) +ENDIF(Q_WS_WIN AND NOT QT_IS_STATIC) IF(NOT QT_IS_STATIC) RETURN() diff --git a/Modules/UseQt4.cmake b/Modules/UseQt4.cmake index 63a0919..ea0ab95 100644 --- a/Modules/UseQt4.cmake +++ b/Modules/UseQt4.cmake @@ -27,9 +27,9 @@ INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR}) SET(QT_LIBRARIES "") IF (QT_USE_QTMAIN) - IF (WIN32) + IF (Q_WS_WIN) SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY}) - ENDIF (WIN32) + ENDIF (Q_WS_WIN) ENDIF (QT_USE_QTMAIN) IF(QT_DONT_USE_QTGUI) diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index c254dbb..cee24ef 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -371,7 +371,7 @@ static const char * ar_rname(const char *path) typedef struct ar_hdr HDR; static char ar_hb[sizeof(HDR) + 1]; /* real header */ -static int ar_already_written; +static size_t ar_already_written; /* copy_ar -- * Copy size bytes from one file to another - taking care to handle the diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 3fd19a5..3c5993d 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -65,7 +65,7 @@ static const char* cmCTestErrorMatches[] = { "^Unresolved:", "Undefined symbols:", "^Undefined[ \\t]+first referenced", - "^CMake Error:", + "^CMake Error.*:", ":[ \\t]cannot find", ":[ \\t]can't find", ": \\*\\*\\* No rule to make target \\`.*\\'. Stop", @@ -129,6 +129,7 @@ static const char* cmCTestWarningMatches[] = { "\\([0-9]*\\): remark #[0-9]*", "\".*\", line [0-9]+: remark\\([0-9]*\\):", "cc-[0-9]* CC: REMARK File = .*, Line = [0-9]*", + "^CMake Warning.*:", 0 }; @@ -174,8 +175,8 @@ cmCTestWarningErrorFileLine[] = { //---------------------------------------------------------------------- cmCTestBuildHandler::cmCTestBuildHandler() { - this->MaxPreContext = 6; - this->MaxPostContext = 6; + this->MaxPreContext = 10; + this->MaxPostContext = 10; this->MaxErrors = 50; this->MaxWarnings = 50; @@ -214,8 +215,8 @@ void cmCTestBuildHandler::Initialize() this->ErrorsAndWarnings.clear(); this->LastErrorOrWarning = this->ErrorsAndWarnings.end(); this->PostContextCount = 0; - this->MaxPreContext = 6; - this->MaxPostContext = 6; + this->MaxPreContext = 10; + this->MaxPostContext = 10; this->PreContext.clear(); this->TotalErrors = 0; @@ -249,6 +250,20 @@ void cmCTestBuildHandler::PopulateCustomVectors(cmMakefile *mf) "CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS", this->MaxWarnings); + int n = -1; + this->CTest->PopulateCustomInteger(mf, "CTEST_CUSTOM_ERROR_PRE_CONTEXT", n); + if (n != -1) + { + this->MaxPreContext = static_cast<size_t>(n); + } + + n = -1; + this->CTest->PopulateCustomInteger(mf, "CTEST_CUSTOM_ERROR_POST_CONTEXT", n); + if (n != -1) + { + this->MaxPostContext = static_cast<size_t>(n); + } + // Record the user-specified custom warning rules. if(const char* customWarningMatchers = mf->GetDefinition("CTEST_CUSTOM_WARNING_MATCH")) diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 4d39367..d50eaaa 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -18,6 +18,23 @@ #include <stack> #include <float.h> +class TestComparator +{ +public: + TestComparator(cmCTestMultiProcessHandler* handler) : Handler(handler) {} + ~TestComparator() {} + + // Sorts tests in descending order of cost + bool operator() (int index1, int index2) const + { + return Handler->Properties[index1]->Cost > + Handler->Properties[index2]->Cost; + } + +private: + cmCTestMultiProcessHandler* Handler; +}; + cmCTestMultiProcessHandler::cmCTestMultiProcessHandler() { this->ParallelLevel = 1; @@ -154,15 +171,8 @@ void cmCTestMultiProcessHandler::UnlockResources(int index) void cmCTestMultiProcessHandler::EraseTest(int test) { this->Tests.erase(test); - for(TestCostMap::iterator i = this->TestCosts.begin(); - i != this->TestCosts.end(); ++i) - { - if(i->second.find(test) != i->second.end()) - { - i->second.erase(test); - return; - } - } + this->SortedTests.erase( + std::find(this->SortedTests.begin(), this->SortedTests.end(), test)); } //--------------------------------------------------------- @@ -244,41 +254,36 @@ void cmCTestMultiProcessHandler::StartNextTests() return; } - for(TestCostMap::reverse_iterator i = this->TestCosts.rbegin(); - i != this->TestCosts.rend(); ++i) + TestList copy = this->SortedTests; + for(TestList::iterator test = copy.begin(); test != copy.end(); ++test) { - TestSet tests = i->second; //copy the test set - for(TestSet::iterator test = tests.begin(); - test != tests.end(); ++test) + //in case this test has already been started due to dependency + if(this->TestRunningMap[*test] || this->TestFinishMap[*test]) { - //in case this test has already been started due to dependency - if(this->TestRunningMap[*test] || this->TestFinishMap[*test]) - { - continue; - } - size_t processors = GetProcessorsUsed(*test); - if(processors > numToStart) - { - return; - } - if(this->StartTest(*test)) - { - if(this->StopTimePassed) - { - return; - } - numToStart -= processors; - } - else - { - cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl - << "Test did not start waiting on depends to finish: " - << *test << "\n"); - } - if(numToStart == 0) + continue; + } + size_t processors = GetProcessorsUsed(*test); + if(processors > numToStart) + { + return; + } + if(this->StartTest(*test)) + { + if(this->StopTimePassed) { return; } + numToStart -= processors; + } + else + { + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl + << "Test did not start waiting on depends to finish: " + << *test << "\n"); + } + if(numToStart == 0) + { + return; } } } @@ -468,27 +473,22 @@ void cmCTestMultiProcessHandler::CreateTestCostList() for(TestMap::iterator i = this->Tests.begin(); i != this->Tests.end(); ++i) { - //We only want to schedule them by cost in a parallel situation - if(this->ParallelLevel > 1) - { - std::string name = this->Properties[i->first]->Name; - if(std::find(this->LastTestsFailed.begin(), this->LastTestsFailed.end(), - name) != this->LastTestsFailed.end()) - { - this->TestCosts[FLT_MAX].insert(i->first); - } - else - { - this->TestCosts[this->Properties[i->first]->Cost].insert(i->first); - } - } - else //we ignore their cost + SortedTests.push_back(i->first); + + //If the test failed last time, it should be run first, so max the cost + if(std::find(this->LastTestsFailed.begin(), + this->LastTestsFailed.end(), + this->Properties[i->first]->Name) + != this->LastTestsFailed.end()) { - size_t index = this->Tests.size() - - static_cast<size_t>(this->Properties[i->first]->Index); - this->TestCosts[index].insert(i->first); + this->Properties[i->first]->Cost = FLT_MAX; } } + if(this->ParallelLevel > 1) + { + TestComparator comp(this); + std::sort(SortedTests.begin(), SortedTests.end(), comp); + } } //--------------------------------------------------------- @@ -611,7 +611,7 @@ int cmCTestMultiProcessHandler::FindMaxIndex() //Returns true if no cycles exist in the dependency graph bool cmCTestMultiProcessHandler::CheckCycles() { - cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Checking test dependency graph..." << std::endl); for(TestMap::iterator it = this->Tests.begin(); it != this->Tests.end(); ++it) @@ -619,34 +619,29 @@ bool cmCTestMultiProcessHandler::CheckCycles() //DFS from each element to itself std::stack<int> s; std::vector<int> visited; + s.push(it->first); - visited.push_back(it->first); while(!s.empty()) { int test = s.top(); s.pop(); - + for(TestSet::iterator d = this->Tests[test].begin(); d != this->Tests[test].end(); ++d) { - s.push(*d); - for(std::vector<int>::iterator v = visited.begin(); - v != visited.end(); ++v) + if(std::find(visited.begin(), visited.end(), *d) != visited.end()) { - if(*v == *d) - { - //cycle exists - cmCTestLog(this->CTest, ERROR_MESSAGE, "Error: a cycle exists in " - "the test dependency graph for the test \"" - << this->Properties[*d]->Name << "\"." << std::endl - << "Please fix the cycle and run ctest again." << std::endl); - return false; - } + //cycle exists + cmCTestLog(this->CTest, ERROR_MESSAGE, "Error: a cycle exists in " + "the test dependency graph for the test \"" + << this->Properties[it->first]->Name << "\"." << std::endl + << "Please fix the cycle and run ctest again." << std::endl); + return false; } - visited.push_back(*d); + s.push(*d); } - visited.pop_back(); + visited.push_back(test); } } return true; diff --git a/Source/CTest/cmCTestMultiProcessHandler.h b/Source/CTest/cmCTestMultiProcessHandler.h index 4f51b0b..cc330f7 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.h +++ b/Source/CTest/cmCTestMultiProcessHandler.h @@ -23,10 +23,11 @@ */ class cmCTestMultiProcessHandler { + friend class TestComparator; public: struct TestSet : public std::set<int> {}; struct TestMap : public std::map<int, TestSet> {}; - struct TestCostMap : public std::map<float, TestSet> {}; + struct TestList : public std::vector<int> {}; struct PropertiesMap : public std::map<int, cmCTestTestHandler::cmCTestTestProperties*> {}; @@ -88,7 +89,7 @@ protected: void UnlockResources(int index); // map from test number to set of depend tests TestMap Tests; - TestCostMap TestCosts; + TestList SortedTests; //Total number of tests we'll be running size_t Total; //Number of tests that are complete diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx index d1226da..24974e3 100644 --- a/Source/CTest/cmCTestSubmitCommand.cxx +++ b/Source/CTest/cmCTestSubmitCommand.cxx @@ -147,6 +147,13 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() static_cast<cmCTestSubmitHandler*>(handler)->SelectParts(this->Parts); } + static_cast<cmCTestSubmitHandler*>(handler)->SetOption("RetryDelay", + this->RetryDelay.c_str()); + static_cast<cmCTestSubmitHandler*>(handler)->SetOption("RetryCount", + this->RetryCount.c_str()); + static_cast<cmCTestSubmitHandler*>(handler)->SetOption("InternalTest", + this->InternalTest ? "ON" : "OFF"); + return handler; } @@ -169,6 +176,24 @@ bool cmCTestSubmitCommand::CheckArgumentKeyword(std::string const& arg) return true; } + if(arg == "RETRY_COUNT") + { + this->ArgumentDoing = ArgumentDoingRetryCount; + return true; + } + + if(arg == "RETRY_DELAY") + { + this->ArgumentDoing = ArgumentDoingRetryDelay; + return true; + } + + if(arg == "INTERNAL_TEST_CHECKSUM") + { + this->InternalTest = true; + return true; + } + // Look for other arguments. return this->Superclass::CheckArgumentKeyword(arg); } @@ -213,6 +238,18 @@ bool cmCTestSubmitCommand::CheckArgumentValue(std::string const& arg) return true; } + if(this->ArgumentDoing == ArgumentDoingRetryCount) + { + this->RetryCount = arg; + return true; + } + + if(this->ArgumentDoing == ArgumentDoingRetryDelay) + { + this->RetryDelay = arg; + return true; + } + // Look for other arguments. return this->Superclass::CheckArgumentValue(arg); } diff --git a/Source/CTest/cmCTestSubmitCommand.h b/Source/CTest/cmCTestSubmitCommand.h index ccaef7e..edc9c65 100644 --- a/Source/CTest/cmCTestSubmitCommand.h +++ b/Source/CTest/cmCTestSubmitCommand.h @@ -29,6 +29,9 @@ public: { this->PartsMentioned = false; this->FilesMentioned = false; + this->InternalTest = false; + this->RetryCount = ""; + this->RetryDelay = ""; } /** @@ -61,7 +64,8 @@ public: virtual const char* GetFullDocumentation() { return - " ctest_submit([PARTS ...] [FILES ...] [RETURN_VALUE res])\n" + " ctest_submit([PARTS ...] [FILES ...] [RETRY_COUNT count] " + " [RETRY_DELAY delay][RETURN_VALUE res])\n" "By default all available parts are submitted if no PARTS or FILES " "are specified. " "The PARTS option lists a subset of parts to be submitted. " @@ -77,7 +81,11 @@ public: " ExtraFiles = Files listed by CTEST_EXTRA_SUBMIT_FILES\n" " Submit = nothing\n" "The FILES option explicitly lists specific files to be submitted. " - "Each individual file must exist at the time of the call.\n"; + "Each individual file must exist at the time of the call.\n" + "The RETRY_DELAY option specifies how long in seconds to wait after " + "a timed-out submission before attempting to re-submit.\n" + "The RETRY_COUNT option specifies how many times to retry a timed-out " + "submission.\n"; } cmTypeMacro(cmCTestSubmitCommand, cmCTestHandlerCommand); @@ -92,13 +100,18 @@ protected: { ArgumentDoingParts = Superclass::ArgumentDoingLast1, ArgumentDoingFiles, + ArgumentDoingRetryDelay, + ArgumentDoingRetryCount, ArgumentDoingLast2 }; bool PartsMentioned; std::set<cmCTest::Part> Parts; bool FilesMentioned; + bool InternalTest; cmCTest::SetOfStrings Files; + std::string RetryCount; + std::string RetryDelay; }; diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 06c08b4..9f9f85a 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -15,6 +15,7 @@ #include "cmVersion.h" #include "cmGeneratedFileStream.h" #include "cmCTest.h" +#include "cmXMLParser.h" #include <cmsys/Process.h> #include <cmsys/Base64.h> @@ -31,6 +32,90 @@ typedef std::vector<char> cmCTestSubmitHandlerVectorOfChar; +//---------------------------------------------------------------------------- +class cmCTestSubmitHandler::ResponseParser: public cmXMLParser +{ +public: + ResponseParser() { this->Status = STATUS_OK; } + ~ResponseParser() {} + +public: + + enum StatusType + { + STATUS_OK, + STATUS_WARNING, + STATUS_ERROR + }; + + StatusType Status; + std::string CDashVersion; + std::string Filename; + std::string MD5; + std::string Message; + +private: + + std::vector<char> CurrentValue; + + std::string GetCurrentValue() + { + std::string val; + if(this->CurrentValue.size()) + { + val.assign(&this->CurrentValue[0], this->CurrentValue.size()); + } + return val; + } + + virtual void StartElement(const char* name, const char** atts) + { + this->CurrentValue.clear(); + if(strcmp(name, "cdash") == 0) + { + this->CDashVersion = this->FindAttribute(atts, "version"); + } + } + + virtual void CharacterDataHandler(const char* data, int length) + { + this->CurrentValue.insert(this->CurrentValue.end(), data, data+length); + } + + virtual void EndElement(const char* name) + { + if(strcmp(name, "status") == 0) + { + std::string status = cmSystemTools::UpperCase(this->GetCurrentValue()); + if(status == "OK" || status == "SUCCESS") + { + this->Status = STATUS_OK; + } + else if(status == "WARNING") + { + this->Status = STATUS_WARNING; + } + else + { + this->Status = STATUS_ERROR; + } + } + else if(strcmp(name, "filename") == 0) + { + this->Filename = this->GetCurrentValue(); + } + else if(strcmp(name, "md5") == 0) + { + this->MD5 = this->GetCurrentValue(); + } + else if(strcmp(name, "message") == 0) + { + this->Message = this->GetCurrentValue(); + } + } +}; + + static size_t cmCTestSubmitHandlerWriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data) @@ -367,6 +452,20 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, = url + ((url.find("?",0) == cmStdString::npos) ? "?" : "&") + "FileName=" + ofile; + upload_as += "&MD5="; + + if(cmSystemTools::IsOn(this->GetOption("InternalTest"))) + { + upload_as += "bad_md5sum"; + } + else + { + char md5[33]; + cmSystemTools::ComputeFileMD5(local_file.c_str(), md5); + md5[32] = 0; + upload_as += md5; + } + struct stat st; if ( ::stat(local_file.c_str(), &st) ) { @@ -382,7 +481,6 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, << local_file.c_str() << " to " << upload_as.c_str() << " Size: " << st.st_size << std::endl); - // specify target ::curl_easy_setopt(curl,CURLOPT_URL, upload_as.c_str()); @@ -411,6 +509,19 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, // Now run off and do what you've been told! res = ::curl_easy_perform(curl); + if(cmSystemTools::IsOn(this->GetOption("InternalTest")) && + cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, + this->CTest->GetCDashVersion().c_str(), "1.7")) + { + // mock failure output for internal test case + std::string mock_output = "<cdash version=\"1.7.0\">\n" + " <status>ERROR</status>\n" + " <message>Checksum failed for file.</message>\n" + "</cdash>\n"; + chunk.clear(); + chunk.assign(mock_output.begin(), mock_output.end()); + } + if ( chunk.size() > 0 ) { cmCTestLog(this->CTest, DEBUG, "CURL output: [" @@ -425,6 +536,60 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, << std::endl); } + // If curl failed for any reason, or checksum fails, wait and retry + // + if(res != CURLE_OK || this->HasErrors) + { + std::string retryDelay = this->GetOption("RetryDelay") == NULL ? + "" : this->GetOption("RetryDelay"); + std::string retryCount = this->GetOption("RetryCount") == NULL ? + "" : this->GetOption("RetryCount"); + + int delay = retryDelay == "" ? atoi(this->CTest->GetCTestConfiguration( + "CTestSubmitRetryDelay").c_str()) : atoi(retryDelay.c_str()); + int count = retryCount == "" ? atoi(this->CTest->GetCTestConfiguration( + "CTestSubmitRetryCount").c_str()) : atoi(retryCount.c_str()); + + for(int i = 0; i < count; i++) + { + cmCTestLog(this->CTest, HANDLER_OUTPUT, + " Submit failed, waiting " << delay << " seconds...\n"); + + double stop = cmSystemTools::GetTime() + delay; + while(cmSystemTools::GetTime() < stop) + { + cmSystemTools::Delay(100); + } + + cmCTestLog(this->CTest, HANDLER_OUTPUT, + " Retry submission: Attempt " << (i + 1) << " of " + << count << std::endl); + + ::fclose(ftpfile); + ftpfile = ::fopen(local_file.c_str(), "rb"); + ::curl_easy_setopt(curl, CURLOPT_INFILE, ftpfile); + + chunk.clear(); + chunkDebug.clear(); + this->HasErrors = false; + + res = ::curl_easy_perform(curl); + + if ( chunk.size() > 0 ) + { + cmCTestLog(this->CTest, DEBUG, "CURL output: [" + << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" + << std::endl); + this->ParseResponse(chunk); + } + + if(res == CURLE_OK && !this->HasErrors) + { + break; + } + } + } + fclose(ftpfile); if ( res ) { @@ -467,14 +632,22 @@ void cmCTestSubmitHandler ::ParseResponse(cmCTestSubmitHandlerVectorOfChar chunk) { std::string output = ""; + output.append(chunk.begin(), chunk.end()); - for(cmCTestSubmitHandlerVectorOfChar::iterator i = chunk.begin(); - i != chunk.end(); ++i) + if(output.find("<cdash") != output.npos) { - output += *i; + ResponseParser parser; + parser.Parse(output.c_str()); + + if(parser.Status != ResponseParser::STATUS_OK) + { + this->HasErrors = true; + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Submission failed: " << + parser.Message << std::endl); + return; + } } output = cmSystemTools::UpperCase(output); - if(output.find("WARNING") != std::string::npos) { this->HasWarnings = true; @@ -483,13 +656,12 @@ void cmCTestSubmitHandler { this->HasErrors = true; } - + if(this->HasWarnings || this->HasErrors) { cmCTestLog(this->CTest, HANDLER_OUTPUT, " Server Response:\n" << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "\n"); } - } //---------------------------------------------------------------------------- diff --git a/Source/CTest/cmCTestSubmitHandler.h b/Source/CTest/cmCTestSubmitHandler.h index 8b011ea..e7755b1 100644 --- a/Source/CTest/cmCTestSubmitHandler.h +++ b/Source/CTest/cmCTestSubmitHandler.h @@ -79,6 +79,7 @@ private: std::string GetSubmitResultsPrefix(); + class ResponseParser; cmStdString HTTPProxy; int HTTPProxyType; cmStdString HTTPProxyAuth; diff --git a/Source/CursesDialog/cmCursesLongMessageForm.cxx b/Source/CursesDialog/cmCursesLongMessageForm.cxx index c66147b..1c48d8c 100644 --- a/Source/CursesDialog/cmCursesLongMessageForm.cxx +++ b/Source/CursesDialog/cmCursesLongMessageForm.cxx @@ -53,13 +53,13 @@ void cmCursesLongMessageForm::UpdateStatusBar() getmaxyx(stdscr, y, x); char bar[cmCursesMainForm::MAX_WIDTH]; - int size = strlen(this->Title.c_str()); + size_t size = strlen(this->Title.c_str()); if ( size >= cmCursesMainForm::MAX_WIDTH ) { size = cmCursesMainForm::MAX_WIDTH-1; } strncpy(bar, this->Title.c_str(), size); - for(int i=size-1; i<cmCursesMainForm::MAX_WIDTH; i++) bar[i] = ' '; + for(size_t i=size-1; i<cmCursesMainForm::MAX_WIDTH; i++) bar[i] = ' '; int width; if (x < cmCursesMainForm::MAX_WIDTH ) @@ -76,8 +76,8 @@ void cmCursesLongMessageForm::UpdateStatusBar() char version[cmCursesMainForm::MAX_WIDTH]; char vertmp[128]; sprintf(vertmp,"CMake Version %s", cmVersion::GetCMakeVersion()); - int sideSpace = (width-strlen(vertmp)); - for(int i=0; i<sideSpace; i++) { version[i] = ' '; } + size_t sideSpace = (width-strlen(vertmp)); + for(size_t i=0; i<sideSpace; i++) { version[i] = ' '; } sprintf(version+sideSpace, "%s", vertmp); version[width] = '\0'; diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index cd231ad..389ec7f 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -242,7 +242,7 @@ void cmCursesMainForm::RePost() // Assign the fields: 3 for each entry: label, new entry marker // ('*' or ' ') and entry widget this->Fields = new FIELD*[3*this->NumberOfVisibleEntries+1]; - int cc; + size_t cc; for ( cc = 0; cc < 3 * this->NumberOfVisibleEntries+1; cc ++ ) { this->Fields[cc] = 0; @@ -454,7 +454,7 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */) if (cw) { sprintf(firstLine, "Page %d of %d", cw->GetPage(), this->NumberOfPages); - curses_move(0,65-strlen(firstLine)-1); + curses_move(0,65-static_cast<unsigned int>(strlen(firstLine))-1); printw(firstLine); } // } @@ -526,10 +526,10 @@ void cmCursesMainForm::UpdateStatusBar(const char* message) // Join the key, help string and pad with spaces // (or truncate) as necessary char bar[cmCursesMainForm::MAX_WIDTH]; - int i, curFieldLen = strlen(curField); - int helpLen = strlen(help); + size_t i, curFieldLen = strlen(curField); + size_t helpLen = strlen(help); - int width; + size_t width; if (x < cmCursesMainForm::MAX_WIDTH ) { width = x; @@ -592,7 +592,7 @@ void cmCursesMainForm::UpdateStatusBar(const char* message) char version[cmCursesMainForm::MAX_WIDTH]; char vertmp[128]; sprintf(vertmp,"CMake Version %s", cmVersion::GetCMakeVersion()); - int sideSpace = (width-strlen(vertmp)); + size_t sideSpace = (width-strlen(vertmp)); for(i=0; i<sideSpace; i++) { version[i] = ' '; } sprintf(version+sideSpace, "%s", vertmp); version[width] = '\0'; @@ -795,8 +795,8 @@ void cmCursesMainForm::RemoveEntry(const char* value) // copy from the list box to the cache manager void cmCursesMainForm::FillCacheManagerFromUI() { - int size = this->Entries->size(); - for(int i=0; i < size; i++) + size_t size = this->Entries->size(); + for(size_t i=0; i < size; i++) { cmCacheManager::CacheIterator it = this->CMakeInstance->GetCacheManager()->GetCacheIterator( @@ -866,7 +866,7 @@ void cmCursesMainForm::HandleInput() std::string searchstr = "Search: " + this->SearchString; this->UpdateStatusBar( searchstr.c_str() ); this->PrintKeys(1); - curses_move(y-5,searchstr.size()); + curses_move(y-5,static_cast<unsigned int>(searchstr.size())); //curses_move(1,1); touchwin(stdscr); refresh(); @@ -961,7 +961,7 @@ void cmCursesMainForm::HandleInput() else if ( key == KEY_DOWN || key == ctrl('n') ) { FIELD* cur = current_field(this->Form); - int findex = field_index(cur); + size_t findex = field_index(cur); if ( findex == 3*this->NumberOfVisibleEntries-1 ) { continue; @@ -1108,7 +1108,7 @@ void cmCursesMainForm::HandleInput() { this->OkToGenerate = false; FIELD* cur = current_field(this->Form); - int findex = field_index(cur); + size_t findex = field_index(cur); // make the next or prev. current field after deletion // each entry consists of fields: label, isnew, value @@ -1199,7 +1199,7 @@ void cmCursesMainForm::JumpToCacheEntry(int idx, const char* astr) str = cmSystemTools::LowerCase(astr); } - if ( idx > this->NumberOfVisibleEntries ) + if ( size_t(idx) > this->NumberOfVisibleEntries ) { return; } @@ -1232,7 +1232,7 @@ void cmCursesMainForm::JumpToCacheEntry(int idx, const char* astr) } } } - if ( findex >= 3* this->NumberOfVisibleEntries-1 ) + if ( size_t(findex) >= 3* this->NumberOfVisibleEntries-1 ) { set_current_field(this->Form, this->Fields[2]); } diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h index 9751999..4084415 100644 --- a/Source/CursesDialog/cmCursesMainForm.h +++ b/Source/CursesDialog/cmCursesMainForm.h @@ -147,7 +147,7 @@ protected: // Where is cmake executable std::string WhereCMake; // Number of entries shown (depends on mode -normal or advanced-) - int NumberOfVisibleEntries; + size_t NumberOfVisibleEntries; bool AdvancedMode; // Did the iteration converge (no new entries) ? bool OkToGenerate; diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index a723b49..3a777d5 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1169,7 +1169,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string* output, if ( tick % tick_line_len == 0 && tick > 0 ) { cmCTestLog(this, HANDLER_OUTPUT, " Size: " - << int((output->size() / 1024.0) + 1) << "K" << std::endl + << int((double(output->size()) / 1024.0) + 1) << "K" << std::endl << " " << std::flush); } } @@ -1181,7 +1181,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string* output, } } cmCTestLog(this, OUTPUT, " Size of output: " - << int(output->size() / 1024.0) << "K" << std::endl); + << int(double(output->size()) / 1024.0) << "K" << std::endl); cmsysProcess_WaitForExit(cp, 0); diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index dab0c0d..b8a0c95 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -175,6 +175,23 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) { fprintf(fout, "SET(CMAKE_MODULE_PATH %s)\n", def); } + + const char* rulesOverrideBase = "CMAKE_USER_MAKE_RULES_OVERRIDE"; + std::string rulesOverrideLang = + rulesOverrideBase + (lang ? std::string("_") + lang : std::string("")); + if(const char* rulesOverridePath = + this->Makefile->GetDefinition(rulesOverrideLang.c_str())) + { + fprintf(fout, "SET(%s \"%s\")\n", + rulesOverrideLang.c_str(), rulesOverridePath); + } + else if(const char* rulesOverridePath2 = + this->Makefile->GetDefinition(rulesOverrideBase)) + { + fprintf(fout, "SET(%s \"%s\")\n", + rulesOverrideBase, rulesOverridePath2); + } + if(lang) { fprintf(fout, "PROJECT(CMAKE_TRY_COMPILE %s)\n", lang); diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx index 147f6ac..c198727 100644 --- a/Source/cmELF.cxx +++ b/Source/cmELF.cxx @@ -576,7 +576,7 @@ unsigned int cmELFInternalImpl<Types>::GetDynamicEntryCount() return i; } } - return this->DynamicSectionEntries.size(); + return static_cast<unsigned int>(this->DynamicSectionEntries.size()); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index b687fe1..4e8e7e6 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -750,8 +750,9 @@ cmGlobalUnixMakefileGenerator3 cmLocalGenerator::FULL, cmLocalGenerator::SHELL); progCmd << " "; - std::vector<int> &progFiles = this->ProgressMap[&t->second].Marks; - for (std::vector<int>::iterator i = progFiles.begin(); + std::vector<unsigned long>& progFiles = + this->ProgressMap[&t->second].Marks; + for (std::vector<unsigned long>::iterator i = progFiles.begin(); i != progFiles.end(); ++i) { progCmd << " " << *i; diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 401888f..f499536 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -177,7 +177,7 @@ protected: TargetProgress(): NumberOfActions(0) {} unsigned long NumberOfActions; std::string VariableFile; - std::vector<int> Marks; + std::vector<unsigned long> Marks; void WriteProgressVariables(unsigned long total, unsigned long& current); }; struct ProgressMapCompare { bool operator()(cmTarget*,cmTarget*) const; }; diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index 8df0ffa..57d8653 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -37,7 +37,7 @@ class cmVS10XMLParser : public cmXMLParser { return; } - if(strcmp("ProjectGUID", name) == 0) + if(strcmp("ProjectGUID", name) == 0 || strcmp("ProjectGuid", name) == 0) { this->DoGUID = true; } diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index 3bd47a4..19f5c0f 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -739,7 +739,7 @@ bool cmStringCommand alphabet = cmStringCommandDefaultAlphabet; } - double sizeofAlphabet = alphabet.size(); + double sizeofAlphabet = static_cast<double>(alphabet.size()); if ( sizeofAlphabet < 1 ) { this->SetError("sub-command RANDOM invoked with bad alphabet."); diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 5f7cfa3..0badbba 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1204,6 +1204,7 @@ bool cmSystemTools::ComputeFileMD5(const char* source, char* md5out) // Should be efficient enough on most system: const int bufferSize = 4096; char buffer[bufferSize]; + unsigned char const* buffer_uc = reinterpret_cast<unsigned char const*>(buffer); // This copy loop is very sensitive on certain platforms with // slightly broken stream libraries (like HPUX). Normally, it is // incorrect to not check the error condition on the fin.read() @@ -1212,10 +1213,9 @@ bool cmSystemTools::ComputeFileMD5(const char* source, char* md5out) while(fin) { fin.read(buffer, bufferSize); - if(fin.gcount()) + if(int gcount = static_cast<int>(fin.gcount())) { - cmsysMD5_Append(md5, reinterpret_cast<unsigned char const*>(buffer), - fin.gcount()); + cmsysMD5_Append(md5, buffer_uc, gcount); } } cmsysMD5_FinalizeHex(md5, md5out); @@ -1989,9 +1989,9 @@ namespace{ # pragma warn -8066 /* unreachable code */ #endif -int copy_data(struct archive *ar, struct archive *aw) +long copy_data(struct archive *ar, struct archive *aw) { - int r; + long r; const void *buff; size_t size; off_t offset; @@ -2136,7 +2136,7 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line, } else if(*outiter == '\n' || *outiter == '\0') { - int length = outiter-out.begin(); + std::vector<char>::size_type length = outiter-out.begin(); if(length > 1 && *(outiter-1) == '\r') { --length; @@ -2159,7 +2159,7 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line, } else if(*erriter == '\n' || *erriter == '\0') { - int length = erriter-err.begin(); + std::vector<char>::size_type length = erriter-err.begin(); if(length > 1 && *(erriter-1) == '\r') { --length; diff --git a/Source/cm_utf8.c b/Source/cm_utf8.c index 3d4ca16..c9bf259 100644 --- a/Source/cm_utf8.c +++ b/Source/cm_utf8.c @@ -50,7 +50,7 @@ const char* cm_utf8_decode_character(const char* first, const char* last, unsigned int* pc) { /* Count leading ones in the first byte. */ - unsigned char c = *first++; + unsigned char c = (unsigned char)*first++; unsigned char const ones = cm_utf8_ones[c]; switch(ones) { @@ -62,10 +62,10 @@ const char* cm_utf8_decode_character(const char* first, const char* last, /* Extract bits from this multi-byte character. */ { unsigned int uc = c & cm_utf8_mask[ones]; - unsigned char left; + int left; for(left = ones-1; left && first != last; --left) { - c = *first++; + c = (unsigned char)*first++; if(cm_utf8_ones[c] != 1) { return 0; diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 6ec7305..7a99139 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2010) SET(KWSYS_DATE_STAMP_MONTH 07) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 04) +SET(KWSYS_DATE_STAMP_DAY 20) diff --git a/Source/kwsys/testProcess.c b/Source/kwsys/testProcess.c index 6044917..877002a 100644 --- a/Source/kwsys/testProcess.c +++ b/Source/kwsys/testProcess.c @@ -94,9 +94,8 @@ int test4(int argc, const char* argv[]) fprintf(stderr, "Output before crash on stderr from crash test.\n"); fflush(stdout); fflush(stderr); -#if defined(__APPLE__) && defined(__x86_64__) && defined(__OPTIMIZE__) \ - && defined(__clang__) - *(int*)1 = 0; /* Clang's optimizer produces bad code for 0-ptr. */ +#if defined(__clang__) + *(int*)1 = 0; /* Clang warns about 0-ptr; undefined behavior. */ #else *(int*)0 = 0; #endif diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 2c7056d..9865134 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1373,7 +1373,29 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ) SET_TESTS_PROPERTIES(CTestTestTimeout PROPERTIES PASS_REGULAR_EXPRESSION "TestTimeout *\\.+ *\\*\\*\\*Timeout.*CheckChild *\\.+ *Passed") - + + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestDepends/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestDepends/test.cmake" + @ONLY ESCAPE_QUOTES) + ADD_TEST(CTestTestDepends ${CMAKE_CTEST_COMMAND} + -C "\${CTestTest_CONFIG}" + -S "${CMake_BINARY_DIR}/Tests/CTestTestDepends/test.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestDepends/testOutput.log" + ) + + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestCycle/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestCycle/test.cmake" + @ONLY ESCAPE_QUOTES) + ADD_TEST(CTestTestCycle ${CMAKE_CTEST_COMMAND} + -C "\${CTestTest_CONFIG}" + -S "${CMake_BINARY_DIR}/Tests/CTestTestCycle/test.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestCycle/testOutput.log" + ) + SET_TESTS_PROPERTIES(CTestTestCycle PROPERTIES + PASS_REGULAR_EXPRESSION "a cycle exists in the test dependency graph") + CONFIGURE_FILE( "${CMake_SOURCE_DIR}/Tests/CTestTestRunScript/test.cmake.in" "${CMake_BINARY_DIR}/Tests/CTestTestRunScript/test.cmake" @@ -1410,6 +1432,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ set(regex "${regex}|Error message was: ") set(regex "${regex}([Cc]ould *n.t resolve host") set(regex "${regex}|[Cc]ould *n.t connect to host") + set(regex "${regex}|Empty reply from server") set(regex "${regex}|The requested URL returned error") set(regex "${regex}|libcurl was built with SSL disabled. https: not supported)") set(regex "${regex}|Submission method .xmlrpc. not compiled into CTest") @@ -1470,6 +1493,17 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --output-log "${CMake_BINARY_DIR}/Tests/CTestTest2/testOutput.log" ) + CONFIGURE_FILE("${CMake_SOURCE_DIR}/Tests/CTestTestChecksum/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestChecksum/test.cmake" @ONLY + ESCAPE_QUOTES) + ADD_TEST(CTestTestChecksum ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTestChecksum/test.cmake" -V + --output-log + "${CMake_BINARY_DIR}/Tests/CTestTestChecksum/testOutput.log" + ) + SET_TESTS_PROPERTIES(CTestTestChecksum PROPERTIES PASS_REGULAR_EXPRESSION + "Submission failed: Checksum failed for file") + # these tests take a long time, make sure they have it # if timeouts have not already been set GET_TEST_PROPERTY(CTestTest TIMEOUT PREVIOUS_TIMEOUT) diff --git a/Tests/CTestTestChecksum/test.cmake.in b/Tests/CTestTestChecksum/test.cmake.in new file mode 100644 index 0000000..c3c41a5 --- /dev/null +++ b/Tests/CTestTestChecksum/test.cmake.in @@ -0,0 +1,28 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.1) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Checksum") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestParallel") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestParallel") +SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") +SET(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "@MEMORYCHECK_SUPPRESSIONS_FILE@") +SET(CTEST_MEMORYCHECK_COMMAND_OPTIONS "@MEMORYCHECK_COMMAND_OPTIONS@") +SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res PARALLEL_LEVEL 4) + +SET(CTEST_DROP_METHOD "@protocol@") +SET(CTEST_DROP_SITE "@server@") +SET(CTEST_DROP_LOCATION "@path@/submit.php?project=PublicDashboard") + +CTEST_SUBMIT(RETRY_DELAY 3 RETRY_COUNT 2 INTERNAL_TEST_CHECKSUM RETURN_VALUE res) diff --git a/Tests/CTestTestCycle/CMakeLists.txt b/Tests/CTestTestCycle/CMakeLists.txt new file mode 100644 index 0000000..6ba6b8c --- /dev/null +++ b/Tests/CTestTestCycle/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required (VERSION 2.6) +project(CTestTestCycle) +include(CTest) + +add_executable (simple simple.cxx) +add_test (one simple) +add_test (two simple) +add_test (three simple) + +# Add cyclical test dependency +set_tests_properties(one PROPERTIES DEPENDS "two") +set_tests_properties(two PROPERTIES DEPENDS "three") +set_tests_properties(three PROPERTIES DEPENDS "one") diff --git a/Tests/CTestTestCycle/CTestConfig.cmake b/Tests/CTestTestCycle/CTestConfig.cmake new file mode 100644 index 0000000..43e9986 --- /dev/null +++ b/Tests/CTestTestCycle/CTestConfig.cmake @@ -0,0 +1,7 @@ +set (CTEST_PROJECT_NAME "CTestTestCycle") +set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set (CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestCycle/simple.cxx b/Tests/CTestTestCycle/simple.cxx new file mode 100644 index 0000000..766b775 --- /dev/null +++ b/Tests/CTestTestCycle/simple.cxx @@ -0,0 +1,5 @@ + +int main() +{ + return 0; +} diff --git a/Tests/CTestTestCycle/test.cmake.in b/Tests/CTestTestCycle/test.cmake.in new file mode 100644 index 0000000..a17adca --- /dev/null +++ b/Tests/CTestTestCycle/test.cmake.in @@ -0,0 +1,22 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.1) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Cycle") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestCycle") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestCycle") +SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") +SET(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "@MEMORYCHECK_SUPPRESSIONS_FILE@") +SET(CTEST_MEMORYCHECK_COMMAND_OPTIONS "@MEMORYCHECK_COMMAND_OPTIONS@") +SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestDepends/CMakeLists.txt b/Tests/CTestTestDepends/CMakeLists.txt new file mode 100644 index 0000000..26367a6 --- /dev/null +++ b/Tests/CTestTestDepends/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required (VERSION 2.6) +project(CTestTestDepends) +include(CTest) + +add_executable (simple simple.cxx) +add_test (one simple) +add_test (two simple) +add_test (three simple) + +# Add redundant (but not cyclical) dependencies +set_tests_properties(two PROPERTIES DEPENDS "one") +set_tests_properties(three PROPERTIES DEPENDS "one;two") diff --git a/Tests/CTestTestDepends/CTestConfig.cmake b/Tests/CTestTestDepends/CTestConfig.cmake new file mode 100644 index 0000000..e3af7dd --- /dev/null +++ b/Tests/CTestTestDepends/CTestConfig.cmake @@ -0,0 +1,7 @@ +set (CTEST_PROJECT_NAME "CTestTestDepends") +set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set (CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestDepends/simple.cxx b/Tests/CTestTestDepends/simple.cxx new file mode 100644 index 0000000..766b775 --- /dev/null +++ b/Tests/CTestTestDepends/simple.cxx @@ -0,0 +1,5 @@ + +int main() +{ + return 0; +} diff --git a/Tests/CTestTestDepends/test.cmake.in b/Tests/CTestTestDepends/test.cmake.in new file mode 100644 index 0000000..ed4e182 --- /dev/null +++ b/Tests/CTestTestDepends/test.cmake.in @@ -0,0 +1,22 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.1) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Depends") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestDepends") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestDepends") +SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") +SET(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "@MEMORYCHECK_SUPPRESSIONS_FILE@") +SET(CTEST_MEMORYCHECK_COMMAND_OPTIONS "@MEMORYCHECK_COMMAND_OPTIONS@") +SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt index 99da9c4..26c6deb 100644 --- a/Tests/ExternalProject/CMakeLists.txt +++ b/Tests/ExternalProject/CMakeLists.txt @@ -79,6 +79,7 @@ if(can_build_tutorial_step5) URL "${CMAKE_CURRENT_SOURCE_DIR}/../Tutorial/Step5" CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR> TEST_BEFORE_INSTALL 1 + LOG_INSTALL 1 ) ExternalProject_Get_Property(${proj} install_dir) set(TutorialStep5_install_dir ${install_dir}) @@ -88,6 +89,7 @@ if(can_build_tutorial_step5) URL "${CMAKE_CURRENT_SOURCE_DIR}/../Tutorial/Step5" CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR> TEST_AFTER_INSTALL 1 + LOG_TEST 1 ) endif() @@ -104,6 +106,7 @@ ExternalProject_Add(${proj} CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -DTEST_LIST:STRING=A::B::C INSTALL_COMMAND "" + LOG_CONFIGURE 1 ) set(proj TutorialStep1-LocalNoDirTAR) @@ -132,6 +135,7 @@ ExternalProject_Add(${proj} URL_MD5 38c648e817339c356f6be00eeed79bd0 CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR> INSTALL_COMMAND "" + LOG_BUILD 1 ) set(proj TutorialStep1-LocalNoDirTGZ) @@ -356,6 +360,7 @@ if(do_svn_tests) CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> INSTALL_COMMAND "" DEPENDS "SetupLocalSVNRepository" + LOG_DOWNLOAD 1 ) endif() @@ -430,6 +435,7 @@ if(do_git_tests) CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> INSTALL_COMMAND "" DEPENDS "SetupLocalGITRepository" + LOG_UPDATE 1 ) endif() diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt index 510851a..0f98e5a 100644 --- a/Utilities/cmcurl/CMakeLists.txt +++ b/Utilities/cmcurl/CMakeLists.txt @@ -731,6 +731,7 @@ FOREACH(var SIZEOF_LONG_LONG SIZEOF___INT64 SIZEOF_SIZE_T + SIZEOF_SSIZE_T SIZEOF_TIME_T ) IF(NOT ${var}_CODE) @@ -650,11 +650,74 @@ if ${cmake_system_haiku}; then cmake_ld_flags="${LDFLAGS} -lroot -lbe" fi +#----------------------------------------------------------------------------- +# Detect known toolchains on some platforms. +cmake_toolchains='' +case "${cmake_system}" in + *AIX*) cmake_toolchains='XL GNU' ;; + *CYGWIN*) cmake_toolchains='GNU' ;; + *Darwin*) cmake_toolchains='GNU Clang' ;; + *Linux*) cmake_toolchains='GNU Clang XL PGI PathScale' ;; + *MINGW*) cmake_toolchains='GNU' ;; +esac + +# Toolchain compiler name table. +cmake_toolchain_Clang_CC='clang' +cmake_toolchain_Clang_CXX='clang++' +cmake_toolchain_GNU_CC='gcc' +cmake_toolchain_GNU_CXX='g++' +cmake_toolchain_PGI_CC='pgcc' +cmake_toolchain_PGI_CXX='pgCC' +cmake_toolchain_PathScale_CC='pathcc' +cmake_toolchain_PathScale_CXX='pathCC' +cmake_toolchain_XL_CC='xlc' +cmake_toolchain_XL_CXX='xlC' + +cmake_toolchain_try() +{ + tc="$1" + TMPFILE=`cmake_tmp_file` + + eval "tc_CC=\${cmake_toolchain_${tc}_CC}" + echo 'int main() { return 0; }' > "${TMPFILE}.c" + cmake_try_run "$tc_CC" "" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1 + tc_result_CC="$?" + rm -f "${TMPFILE}.c" + test "${tc_result_CC}" = "0" || return 1 + + eval "tc_CXX=\${cmake_toolchain_${tc}_CXX}" + echo 'int main() { return 0; }' > "${TMPFILE}.cpp" + cmake_try_run "$tc_CXX" "" "${TMPFILE}.cpp" >> cmake_bootstrap.log 2>&1 + tc_result_CXX="$?" + rm -f "${TMPFILE}.cpp" + test "${tc_result_CXX}" = "0" || return 1 + + cmake_toolchain="$tc" +} + +cmake_toolchain_detect() +{ + cmake_toolchain= + for tc in ${cmake_toolchains}; do + echo "Checking for $tc toolchain" >> cmake_bootstrap.log 2>&1 + cmake_toolchain_try "$tc" && + echo "Found $tc toolchain" && + break + done +} + +if [ -z "${CC}" -a -z "${CXX}" ]; then + cmake_toolchain_detect +fi + +#----------------------------------------------------------------------------- # Test C compiler cmake_c_compiler= # If CC is set, use that for compiler, otherwise use list of known compilers -if [ -n "${CC}" ]; then +if [ -n "${cmake_toolchain}" ]; then + eval cmake_c_compilers="\${cmake_toolchain_${cmake_toolchain}_CC}" +elif [ -n "${CC}" ]; then cmake_c_compilers="${CC}" else cmake_c_compilers="${CMAKE_KNOWN_C_COMPILERS}" @@ -697,13 +760,16 @@ See cmake_bootstrap.log for compilers attempted. fi echo "C compiler on this system is: ${cmake_c_compiler} ${cmake_c_flags}" +#----------------------------------------------------------------------------- # Test CXX compiler cmake_cxx_compiler= # On Mac OSX, CC is the same as cc, so make sure not to try CC as c++ compiler. # If CC is set, use that for compiler, otherwise use list of known compilers -if [ -n "${CXX}" ]; then +if [ -n "${cmake_toolchain}" ]; then + eval cmake_cxx_compilers="\${cmake_toolchain_${cmake_toolchain}_CXX}" +elif [ -n "${CXX}" ]; then cmake_cxx_compilers="${CXX}" else cmake_cxx_compilers="${CMAKE_KNOWN_CXX_COMPILERS}" @@ -754,6 +820,7 @@ See cmake_bootstrap.log for compilers attempted." fi echo "C++ compiler on this system is: ${cmake_cxx_compiler} ${cmake_cxx_flags}" +#----------------------------------------------------------------------------- # Test Make cmake_make_processor= |