diff options
author | Brad King <brad.king@kitware.com> | 2010-01-28 21:48:20 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2010-01-28 21:48:20 (GMT) |
commit | dc1d2189ae922be9d6e7f5fde698532db47e46aa (patch) | |
tree | 28ef61aac78f0bdc190a760d53b6cb89b24262cd | |
parent | 612409e5b01a7e4823bb379ee9e002177793eb75 (diff) | |
download | CMake-dc1d2189ae922be9d6e7f5fde698532db47e46aa.zip CMake-dc1d2189ae922be9d6e7f5fde698532db47e46aa.tar.gz CMake-dc1d2189ae922be9d6e7f5fde698532db47e46aa.tar.bz2 |
CMake 2.8.1-rc1
358 files changed, 7287 insertions, 3143 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 872370a..0d77ed4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,8 @@ MARK_AS_ADVANCED(CMAKE_BACKWARDS_COMPATIBILITY) # Allow empty endif() and such with CMake 2.4. SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS 1) +SET(CMake_BIN_DIR ${CMake_BINARY_DIR}/bin) + IF(NOT ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.4) # Since the built CMake will install itself instead of the # generating CMake, tell it that the install rules were generated @@ -27,6 +29,17 @@ IF(NOT ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.4) INSTALL(CODE "SET(CMAKE_INSTALL_SELF_2_4 1)") ENDIF() +IF("${CMake_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}") + # Disallow architecture-specific try_run. It may not run on the host. + MACRO(TRY_RUN) + IF(CMAKE_TRY_COMPILE_OSX_ARCHITECTURES) + MESSAGE(FATAL_ERROR "TRY_RUN not allowed with CMAKE_TRY_COMPILE_OSX_ARCHITECTURES=[${CMAKE_TRY_COMPILE_OSX_ARCHITECTURES}]") + ELSE() + _TRY_RUN(${ARGV}) + ENDIF() + ENDMACRO() +ENDIF() + #----------------------------------------------------------------------- # a macro to deal with system libraries, implemented as a macro # simply to improve readability of the main script @@ -139,9 +152,9 @@ MACRO(CMAKE_SETUP_TESTING) # the ctest from this cmake is used for testing # and not the ctest from the cmake building and testing # cmake. - SET(CMAKE_CTEST_COMMAND "${EXECUTABLE_OUTPUT_PATH}/ctest") - SET(CMAKE_CMAKE_COMMAND "${EXECUTABLE_OUTPUT_PATH}/cmake") - SET(CMAKE_CPACK_COMMAND "${EXECUTABLE_OUTPUT_PATH}/cpack") + SET(CMAKE_CTEST_COMMAND "${CMake_BIN_DIR}/ctest") + SET(CMAKE_CMAKE_COMMAND "${CMake_BIN_DIR}/cmake") + SET(CMAKE_CPACK_COMMAND "${CMake_BIN_DIR}/cpack") ENDIF(BUILD_TESTING) # configure some files for testing @@ -183,7 +196,7 @@ MACRO (CMAKE_BUILD_UTILITIES) SET(KWSYS_USE_CommandLineArguments 1) SET(KWSYS_HEADER_ROOT ${CMake_BINARY_DIR}/Source) SET(KWSYS_INSTALL_DOC_DIR "${CMake_DOC_DEST}") - SUBDIRS(Source/kwsys) + ADD_SUBDIRECTORY(Source/kwsys) #--------------------------------------------------------------------- # Setup third-party libraries. @@ -212,7 +225,7 @@ MACRO (CMAKE_BUILD_UTILITIES) ELSE(CMAKE_USE_SYSTEM_ZLIB) SET(CMAKE_ZLIB_INCLUDES) SET(CMAKE_ZLIB_LIBRARIES cmzlib) - SUBDIRS(Utilities/cmzlib) + ADD_SUBDIRECTORY(Utilities/cmzlib) ENDIF(CMAKE_USE_SYSTEM_ZLIB) #--------------------------------------------------------------------- @@ -235,7 +248,7 @@ MACRO (CMAKE_BUILD_UTILITIES) ENDIF(NOT CMAKE_BUILD_CURL_SHARED) SET(CMAKE_CURL_INCLUDES) SET(CMAKE_CURL_LIBRARIES cmcurl) - SUBDIRS(Utilities/cmcurl) + ADD_SUBDIRECTORY(Utilities/cmcurl) ENDIF(CMAKE_USE_SYSTEM_CURL) #--------------------------------------------------------------------- @@ -252,7 +265,7 @@ MACRO (CMAKE_BUILD_UTILITIES) SET(CMAKE_COMPRESS_INCLUDES "${CMAKE_CURRENT_BINARY_DIR}/Utilities/cmcompress") SET(CMAKE_COMPRESS_LIBRARIES "cmcompress") - SUBDIRS(Utilities/cmcompress) + ADD_SUBDIRECTORY(Utilities/cmcompress) #--------------------------------------------------------------------- # Build expat library for CMake and CTest. @@ -267,7 +280,7 @@ MACRO (CMAKE_BUILD_UTILITIES) ELSE(CMAKE_USE_SYSTEM_EXPAT) SET(CMAKE_EXPAT_INCLUDES) SET(CMAKE_EXPAT_LIBRARIES cmexpat) - SUBDIRS(Utilities/cmexpat) + ADD_SUBDIRECTORY(Utilities/cmexpat) ENDIF(CMAKE_USE_SYSTEM_EXPAT) #--------------------------------------------------------------------- @@ -302,7 +315,7 @@ MACRO (CMAKE_BUILD_UTILITIES) SET(BUILD_CursesDialog 0) ENDIF (UNIX) IF(BUILD_CursesDialog) - SUBDIRS(Source/CursesDialog/form) + ADD_SUBDIRECTORY(Source/CursesDialog/form) ENDIF(BUILD_CursesDialog) ENDMACRO (CMAKE_BUILD_UTILITIES) @@ -315,8 +328,8 @@ ENDMACRO (CMAKE_BUILD_UTILITIES) # The CMake version number. SET(CMake_VERSION_MAJOR 2) SET(CMake_VERSION_MINOR 8) -SET(CMake_VERSION_PATCH 0) -#SET(CMake_VERSION_RC 8) +SET(CMake_VERSION_PATCH 1) +SET(CMake_VERSION_RC 1) # We use odd minor numbers for development versions. # Use a date for the development patch level. @@ -334,13 +347,15 @@ SET(CMake_VERSION_FULL "${CMake_VERSION}.${CMake_VERSION_PATCH}") ENABLE_TESTING() INCLUDE (${CMAKE_ROOT}/Modules/Dart.cmake) +# Set up test-time configuration. +SET_DIRECTORY_PROPERTIES(PROPERTIES + TEST_INCLUDE_FILE "${CMake_BINARY_DIR}/Tests/EnforceConfig.cmake") + # where to write the resulting executables and libraries SET(BUILD_SHARED_LIBS OFF) -SET(EXECUTABLE_OUTPUT_PATH ${CMake_BINARY_DIR}/bin CACHE INTERNAL - "Where to put the executables for CMake") +SET(EXECUTABLE_OUTPUT_PATH "" CACHE INTERNAL "No configurable exe dir.") SET(LIBRARY_OUTPUT_PATH "" CACHE INTERNAL "Where to put the libraries for CMake") -INCLUDE_REGULAR_EXPRESSION("^.*$") # The CMake executables usually do not need any rpath to run in the build or # install tree. @@ -356,6 +371,10 @@ MARK_AS_ADVANCED(CMAKE_DATA_DIR CMAKE_DOC_DIR CMAKE_MAN_DIR) STRING(REGEX REPLACE "^/" "" CMake_DATA_DEST "${CMAKE_DATA_DIR}") STRING(REGEX REPLACE "^/" "" CMake_DOC_DEST "${CMAKE_DOC_DIR}") +IF(BUILD_TESTING) + INCLUDE(${CMake_SOURCE_DIR}/Tests/CMakeInstall.cmake) +ENDIF() + # include special compile flags for some compilers INCLUDE(CompileFlags.cmake) @@ -442,9 +461,9 @@ MARK_AS_ADVANCED(CMAKE_STRICT) # build the remaining subdirectories -SUBDIRS(Source) -SUBDIRS(Utilities) -SUBDIRS(Tests) +ADD_SUBDIRECTORY(Source) +ADD_SUBDIRECTORY(Utilities) +ADD_SUBDIRECTORY(Tests) # add a test ADD_TEST(SystemInformationNew "${CMAKE_CMAKE_COMMAND}" @@ -470,3 +489,10 @@ INSTALL( #----------------------------------------------------------------------- # End of the main section of the CMakeLists file #----------------------------------------------------------------------- + +# As a special case when building CMake itself, CMake 2.8.0 and below +# look up EXECUTABLE_OUTPUT_PATH in the top-level CMakeLists.txt file +# to compute the location of the "cmake" executable. We set it here +# so that those CMake versions can find it. We wait until after all +# the add_subdirectory() calls to avoid affecting the subdirectories. +SET(EXECUTABLE_OUTPUT_PATH ${CMake_BIN_DIR}) diff --git a/CTestConfig.cmake b/CTestConfig.cmake index 8553b4b..145792b 100644 --- a/CTestConfig.cmake +++ b/CTestConfig.cmake @@ -16,6 +16,7 @@ set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "www.cdash.org") set(CTEST_DROP_LOCATION "/CDash/submit.php?project=CMake") set(CTEST_DROP_SITE_CDASH TRUE) +set(CTEST_CDASH_VERSION "1.4") # use old trigger stuff so that cmake 2.4 and below will not # get errors on trigger diff --git a/ChangeLog.manual b/ChangeLog.manual index 275ae3e..cb2bc06 100644 --- a/ChangeLog.manual +++ b/ChangeLog.manual @@ -1,3 +1,61 @@ +Changes in CMake 2.8.1 RC 1 +- Add "NMake Makefiles JOM" generator +- Add PathScale compiler support +- Add per-configuration OUTPUT_DIRECTORY properties +- Add per-target OSX_ARCHITECTURES property +- check_type_size(): Handle mixed-size universal binaries +- CPack: Document Mac generators +- CPack: Improve RPM spec files +- Create CMAKE_FORCE_Fortran_COMPILER for cross-compiling +- CTest: Add --http1.0 command-line option +- CTest: Add --timeout command-line option +- CTest: Do not munge UTF-8 output in XML files +- CTest: Document CTEST_USE_LAUNCHERS option +- CTest: Fix killing of whole test process trees +- CTest: Handle failure of running invalid executables +- CTest: Honor the -C arg to ctest (#2336) +- CTest: Improve host system introspection +- CTest: Optionally randomize test order (--schedule-random) +- CTest: Skip tests with unsatisfied REQUIRED_FILES test property +- CTest: Submit arbitrary results with ATTACHED_FILES test property +- ctest_build(): Enhance signature +- ctest_start(): Add APPEND option +- ctest_start(): Move CTEST_CHECKOUT_COMMAND from ctest_update +- ctest_update(): Submit global tree revision in Update.xml +- Cygwin: Do not export all symbols from DLLs (#10122) +- Cygwin: Name DLLs with SOVERSION, not VERSION (#10122) +- Detect 32/64-bit Windows with Intel compiler +- Eclipse generator enhancements +- ExternalProject: Add TIMEOUT parameter +- FindCUDA: Respect CUDA version differences +- FindCURL: Find import libraries on Windows +- FindDCMTK: Look in more places +- FindGTest: Handle spaces better (#10065) +- FindGTK2: Look in fink locations on Mac OS X +- FindHDF5: Follow find-module API conventions +- FindJava: Support for versioned find +- FindJNI: Honor find_package() REQUIRED and QUIET options +- FindMPI: Improve Windows support +- FindOpenSSL: Fix MinGW support +- FindPythonLibs: Look in config for static library +- FindQt4: Misc enhancements, sync with KDE vesion +- FindRuby: Fix version convention on Windows +- FindX11: Improve documentation +- Fortran: Detect address size (#10119) +- FortranCInterface: Honor user flags +- Improve VS 2010 beta2 support +- link_directories(): Treat relative paths consistently (CMP0015) +- Modernize FindLibXslt and FindLibXml.cmake +- Refactor platform info to simplify adding new compilers +- Support cross-compiling versioned DLLs +- UseQt4: Provide dependencies only for static Qt (#10021) +- Address issues: + #2336, #3571, #5041, #7541, #8725, #9011, #9042, #9054, #9163, + #9171, #9450, #9697, #9764, #9782, #9792, #9862, #9894, #9913, + #9916, #9917, #9918, #9949, #9965, #9970, #9982, #9985, #10003, + #10014, #10021, #10032, #10055, #10060, #10065, #10114, #10119, + #10122, #10126, #10136. + Changes in CMake 2.8.0 Release - CPack: Honor CPACK_NSIS_DISPLAY_NAME (fixes regression) diff --git a/Modules/CMakeBackwardCompatibilityC.cmake b/Modules/CMakeBackwardCompatibilityC.cmake index b7014cf..c6537cf 100644 --- a/Modules/CMakeBackwardCompatibilityC.cmake +++ b/Modules/CMakeBackwardCompatibilityC.cmake @@ -23,6 +23,17 @@ IF(CMAKE_GENERATOR MATCHES "Visual Studio 6") ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 6") IF(NOT CMAKE_SKIP_COMPATIBILITY_TESTS) + # Old CMake versions did not support OS X universal binaries anyway, + # so just get through this with at least some size for the types. + LIST(LENGTH CMAKE_OSX_ARCHITECTURES NUM_ARCHS) + IF(${NUM_ARCHS} GREATER 1) + IF(NOT DEFINED CMAKE_TRY_COMPILE_OSX_ARCHITECTURES) + MESSAGE(WARNING "This module does not work with OS X universal binaries.") + SET(__ERASE_CMAKE_TRY_COMPILE_OSX_ARCHITECTURES 1) + LIST(GET CMAKE_OSX_ARCHITECTURES 0 CMAKE_TRY_COMPILE_OSX_ARCHITECTURES) + ENDIF() + ENDIF() + INCLUDE (CheckTypeSize) CHECK_TYPE_SIZE(int CMAKE_SIZEOF_INT) CHECK_TYPE_SIZE(long CMAKE_SIZEOF_LONG) @@ -70,6 +81,11 @@ IF(NOT CMAKE_SKIP_COMPATIBILITY_TESTS) SET (CMAKE_USE_SPROC ${CMAKE_USE_SPROC_INIT} CACHE BOOL "Use sproc libs.") + + IF(__ERASE_CMAKE_TRY_COMPILE_OSX_ARCHITECTURES) + SET(CMAKE_TRY_COMPILE_OSX_ARCHITECTURES) + SET(__ERASE_CMAKE_TRY_COMPILE_OSX_ARCHITECTURES) + ENDIF() ENDIF(NOT CMAKE_SKIP_COMPATIBILITY_TESTS) MARK_AS_ADVANCED( diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in index 8428857..9e355a0 100644 --- a/Modules/CMakeCCompiler.cmake.in +++ b/Modules/CMakeCCompiler.cmake.in @@ -2,8 +2,10 @@ SET(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@") SET(CMAKE_C_COMPILER_ARG1 "@CMAKE_C_COMPILER_ARG1@") SET(CMAKE_C_COMPILER_ID "@CMAKE_C_COMPILER_ID@") SET(CMAKE_C_PLATFORM_ID "@CMAKE_C_PLATFORM_ID@") +@SET_MSVC_C_ARCHITECTURE_ID@ SET(CMAKE_AR "@CMAKE_AR@") SET(CMAKE_RANLIB "@CMAKE_RANLIB@") +SET(CMAKE_LINKER "@CMAKE_LINKER@") SET(CMAKE_COMPILER_IS_GNUCC @CMAKE_COMPILER_IS_GNUCC@) SET(CMAKE_C_COMPILER_LOADED 1) SET(CMAKE_COMPILER_IS_MINGW @CMAKE_COMPILER_IS_MINGW@) diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in index a999e8d..5d004c7 100644 --- a/Modules/CMakeCCompilerId.c.in +++ b/Modules/CMakeCCompilerId.c.in @@ -36,6 +36,9 @@ #elif defined(__PGI) # define COMPILER_ID "PGI" +#elif defined(__PATHSCALE__) +# define COMPILER_ID "PathScale" + #elif defined(__GNUC__) # define COMPILER_ID "GNU" @@ -93,6 +96,7 @@ int main(int argc, char* argv[]) int require = 0; require += info_compiler[argc]; require += info_platform[argc]; + require += info_arch[argc]; (void)argv; return require; } diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index 0cd4618..5e71d1f 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -2,8 +2,10 @@ SET(CMAKE_CXX_COMPILER "@CMAKE_CXX_COMPILER@") SET(CMAKE_CXX_COMPILER_ARG1 "@CMAKE_CXX_COMPILER_ARG1@") SET(CMAKE_CXX_COMPILER_ID "@CMAKE_CXX_COMPILER_ID@") SET(CMAKE_CXX_PLATFORM_ID "@CMAKE_CXX_PLATFORM_ID@") +@SET_MSVC_CXX_ARCHITECTURE_ID@ SET(CMAKE_AR "@CMAKE_AR@") SET(CMAKE_RANLIB "@CMAKE_RANLIB@") +SET(CMAKE_LINKER "@CMAKE_LINKER@") SET(CMAKE_COMPILER_IS_GNUCXX @CMAKE_COMPILER_IS_GNUCXX@) SET(CMAKE_CXX_COMPILER_LOADED 1) SET(CMAKE_COMPILER_IS_MINGW @CMAKE_COMPILER_IS_MINGW@) diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in index 2c8aa3c..00ab8e2 100644 --- a/Modules/CMakeCXXCompilerId.cpp.in +++ b/Modules/CMakeCXXCompilerId.cpp.in @@ -38,6 +38,9 @@ #elif defined(__PGI) # define COMPILER_ID "PGI" +#elif defined(__PATHSCALE__) +# define COMPILER_ID "PathScale" + #elif defined(__GNUC__) # define COMPILER_ID "GNU" diff --git a/Modules/CMakeCXXInformation.cmake b/Modules/CMakeCXXInformation.cmake index 9929dfa..0a7e990 100644 --- a/Modules/CMakeCXXInformation.cmake +++ b/Modules/CMakeCXXInformation.cmake @@ -114,6 +114,14 @@ IF(NOT CMAKE_SHARED_LIBRARY_RPATH_LINK_CXX_FLAG) SET(CMAKE_SHARED_LIBRARY_RPATH_LINK_CXX_FLAG ${CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG}) ENDIF(NOT CMAKE_SHARED_LIBRARY_RPATH_LINK_CXX_FLAG) +IF(NOT DEFINED CMAKE_EXE_EXPORTS_CXX_FLAG) + SET(CMAKE_EXE_EXPORTS_CXX_FLAG ${CMAKE_EXE_EXPORTS_C_FLAG}) +ENDIF() + +IF(NOT DEFINED CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG) + SET(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG ${CMAKE_SHARED_LIBRARY_SONAME_C_FLAG}) +ENDIF() + IF(NOT CMAKE_EXECUTABLE_RUNTIME_CXX_FLAG) SET(CMAKE_EXECUTABLE_RUNTIME_CXX_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG}) ENDIF(NOT CMAKE_EXECUTABLE_RUNTIME_CXX_FLAG) @@ -147,14 +155,6 @@ IF(NOT CMAKE_SHARED_MODULE_CXX_FLAGS) SET(CMAKE_SHARED_MODULE_CXX_FLAGS ${CMAKE_SHARED_MODULE_C_FLAGS}) ENDIF(NOT CMAKE_SHARED_MODULE_CXX_FLAGS) -IF(NOT CMAKE_SHARED_MODULE_RUNTIME_CXX_FLAG) - SET(CMAKE_SHARED_MODULE_RUNTIME_CXX_FLAG ${CMAKE_SHARED_MODULE_RUNTIME_FLAG}) -ENDIF(NOT CMAKE_SHARED_MODULE_RUNTIME_CXX_FLAG) - -IF(NOT CMAKE_SHARED_MODULE_RUNTIME_CXX_FLAG_SEP) - SET(CMAKE_SHARED_MODULE_RUNTIME_CXX_FLAG_SEP ${CMAKE_SHARED_MODULE_RUNTIME_FLAG_SEP}) -ENDIF(NOT CMAKE_SHARED_MODULE_RUNTIME_CXX_FLAG_SEP) - # Initialize CXX link type selection flags from C versions. FOREACH(type SHARED_LIBRARY SHARED_MODULE EXE) IF(NOT CMAKE_${type}_LINK_STATIC_CXX_FLAGS) diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index a655b0f..17fa05f 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -171,11 +171,13 @@ ENDIF (CMAKE_CROSSCOMPILING INCLUDE(CMakeFindBinUtils) - +IF(MSVC_C_ARCHITECTURE_ID) + SET(SET_MSVC_C_ARCHITECTURE_ID + "SET(MSVC_C_ARCHITECTURE_ID ${MSVC_C_ARCHITECTURE_ID})") +ENDIF(MSVC_C_ARCHITECTURE_ID) # configure variables set in this file for fast reload later on CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeCCompiler.cmake.in "${CMAKE_PLATFORM_ROOT_BIN}/CMakeCCompiler.cmake" @ONLY IMMEDIATE # IMMEDIATE must be here for compatibility mode <= 2.0 - ) - + ) SET(CMAKE_C_COMPILER_ENV_VAR "CC") diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 13d944e..1170106 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -176,7 +176,10 @@ ENDIF (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) INCLUDE(CMakeFindBinUtils) - +IF(MSVC_CXX_ARCHITECTURE_ID) + SET(SET_MSVC_CXX_ARCHITECTURE_ID + "SET(MSVC_CXX_ARCHITECTURE_ID ${MSVC_CXX_ARCHITECTURE_ID})") +ENDIF(MSVC_CXX_ARCHITECTURE_ID) # configure all variables set in this file CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeCXXCompiler.cmake.in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCXXCompiler.cmake diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 3899462..a70c6ab 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -57,6 +57,8 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) SET(CMAKE_${lang}_COMPILER_ID "${CMAKE_${lang}_COMPILER_ID}" PARENT_SCOPE) SET(CMAKE_${lang}_PLATFORM_ID "${CMAKE_${lang}_PLATFORM_ID}" PARENT_SCOPE) + SET(MSVC_${lang}_ARCHITECTURE_ID "${MSVC_${lang}_ARCHITECTURE_ID}" + PARENT_SCOPE) ENDFUNCTION(CMAKE_DETERMINE_COMPILER_ID) #----------------------------------------------------------------------------- @@ -171,7 +173,7 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) SET(COMPILER_ID) SET(PLATFORM_ID) FILE(STRINGS ${file} - CMAKE_${lang}_COMPILER_ID_STRINGS LIMIT_COUNT 2 REGEX "INFO:") + CMAKE_${lang}_COMPILER_ID_STRINGS LIMIT_COUNT 3 REGEX "INFO:") SET(HAVE_COMPILER_TWICE 0) FOREACH(info ${CMAKE_${lang}_COMPILER_ID_STRINGS}) IF("${info}" MATCHES ".*INFO:compiler\\[([^]\"]*)\\].*") @@ -185,12 +187,17 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) STRING(REGEX REPLACE ".*INFO:platform\\[([^]]*)\\].*" "\\1" PLATFORM_ID "${info}") ENDIF("${info}" MATCHES ".*INFO:platform\\[([^]\"]*)\\].*") + IF("${info}" MATCHES ".*INFO:arch\\[([^]\"]*)\\].*") + STRING(REGEX REPLACE ".*INFO:arch\\[([^]]*)\\].*" "\\1" + ARCHITECTURE_ID "${info}") + ENDIF("${info}" MATCHES ".*INFO:arch\\[([^]\"]*)\\].*") ENDFOREACH(info) # Check if a valid compiler and platform were found. IF(COMPILER_ID AND NOT COMPILER_ID_TWICE) SET(CMAKE_${lang}_COMPILER_ID "${COMPILER_ID}") SET(CMAKE_${lang}_PLATFORM_ID "${PLATFORM_ID}") + SET(MSVC_${lang}_ARCHITECTURE_ID "${ARCHITECTURE_ID}") ENDIF(COMPILER_ID AND NOT COMPILER_ID_TWICE) # Check the compiler identification string. @@ -234,5 +241,7 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) # Return the information extracted. SET(CMAKE_${lang}_COMPILER_ID "${CMAKE_${lang}_COMPILER_ID}" PARENT_SCOPE) SET(CMAKE_${lang}_PLATFORM_ID "${CMAKE_${lang}_PLATFORM_ID}" PARENT_SCOPE) + SET(MSVC_${lang}_ARCHITECTURE_ID "${MSVC_${lang}_ARCHITECTURE_ID}" + PARENT_SCOPE) SET(CMAKE_EXECUTABLE_FORMAT "${CMAKE_EXECUTABLE_FORMAT}" PARENT_SCOPE) ENDFUNCTION(CMAKE_DETERMINE_COMPILER_ID_CHECK lang) diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index 8adacd6..44e45d8 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -62,9 +62,6 @@ IF(NOT CMAKE_Fortran_COMPILER) # The order is 95 or newer compilers first, then 90, # then 77 or older compilers, gnu is always last in the group, # so if you paid for a compiler it is picked by default. - # NOTE for testing purposes this list is DUPLICATED in - # CMake/Source/CMakeLists.txt, IF YOU CHANGE THIS LIST, - # PLEASE UPDATE THAT FILE AS WELL! SET(CMAKE_Fortran_COMPILER_LIST ifort ifc efc f95 pgf95 lf95 xlf95 fort gfortran gfortran-4 g95 f90 pgf90 xlf90 epcf90 fort77 frt pgf77 xlf fl32 af77 g77 f77 diff --git a/Modules/CMakeForceCompiler.cmake b/Modules/CMakeForceCompiler.cmake index c9793b4..b7a681a 100644 --- a/Modules/CMakeForceCompiler.cmake +++ b/Modules/CMakeForceCompiler.cmake @@ -16,6 +16,13 @@ # It also bypasses the check for working compiler and basic compiler # information tests. # +# Macro CMAKE_FORCE_Fortran_COMPILER has the following signature: +# CMAKE_FORCE_Fortran_COMPILER(<compiler> <compiler-id>) +# It sets CMAKE_Fortran_COMPILER to the given compiler and the cmake +# internal variable CMAKE_Fortran_COMPILER_ID to the given compiler-id. +# It also bypasses the check for working compiler and basic compiler +# information tests. +# # So a simple toolchain file could look like this: # INCLUDE (CMakeForceCompiler) # SET(CMAKE_SYSTEM_NAME Generic) @@ -60,3 +67,16 @@ MACRO(CMAKE_FORCE_CXX_COMPILER compiler id) SET(CMAKE_COMPILER_IS_GNUCXX 1) ENDIF("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") ENDMACRO(CMAKE_FORCE_CXX_COMPILER) + +MACRO(CMAKE_FORCE_Fortran_COMPILER compiler id) + SET(CMAKE_Fortran_COMPILER "${compiler}") + SET(CMAKE_Fortran_COMPILER_ID_RUN TRUE) + SET(CMAKE_Fortran_COMPILER_ID ${id}) + SET(CMAKE_Fortran_COMPILER_WORKS TRUE) + SET(CMAKE_Fortran_COMPILER_FORCED TRUE) + + # Set old compiler id variables. + IF("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU") + SET(CMAKE_COMPILER_IS_GNUG77 1) + ENDIF("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU") +ENDMACRO(CMAKE_FORCE_Fortran_COMPILER) diff --git a/Modules/CMakeFortranCompiler.cmake.in b/Modules/CMakeFortranCompiler.cmake.in index d8a9ed6..ba2b46d 100644 --- a/Modules/CMakeFortranCompiler.cmake.in +++ b/Modules/CMakeFortranCompiler.cmake.in @@ -30,5 +30,17 @@ ELSE(UNIX) SET(CMAKE_Fortran_OUTPUT_EXTENSION .obj) ENDIF(UNIX) +# Save compiler ABI information. +SET(CMAKE_Fortran_SIZEOF_DATA_PTR "@CMAKE_Fortran_SIZEOF_DATA_PTR@") +SET(CMAKE_Fortran_COMPILER_ABI "@CMAKE_Fortran_COMPILER_ABI@") + +IF(CMAKE_Fortran_SIZEOF_DATA_PTR) + SET(CMAKE_SIZEOF_VOID_P "${CMAKE_Fortran_SIZEOF_DATA_PTR}") +ENDIF(CMAKE_Fortran_SIZEOF_DATA_PTR) + +IF(CMAKE_Fortran_COMPILER_ABI) + SET(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_Fortran_COMPILER_ABI}") +ENDIF(CMAKE_Fortran_COMPILER_ABI) + SET(CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES "@CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES@") SET(CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES "@CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES@") diff --git a/Modules/CMakeFortranCompilerABI.F b/Modules/CMakeFortranCompilerABI.F index cf8662f..b8efb42 100644 --- a/Modules/CMakeFortranCompilerABI.F +++ b/Modules/CMakeFortranCompilerABI.F @@ -1,3 +1,33 @@ - PROGRAM CMakeFortranCompilerId - PRINT *, 'ABI Detection Binary' + PROGRAM CMakeFortranCompilerABI +#if 0 +! Address Size +#endif +#if defined(_LP64) + PRINT *, 'INFO:sizeof_dptr[8]' +#elif defined(_M_IA64) + PRINT *, 'INFO:sizeof_dptr[8]' +#elif defined(_M_X64) + PRINT *, 'INFO:sizeof_dptr[8]' +#elif defined(_M_AMD64) + PRINT *, 'INFO:sizeof_dptr[8]' + +#elif defined(_ILP32) + PRINT *, 'INFO:sizeof_dptr[4]' +#elif defined(_M_IX86) + PRINT *, 'INFO:sizeof_dptr[4]' +#endif + +#if 0 +! Application Binary Interface +#endif +#if defined(__sgi) && defined(_ABIO32) + PRINT *, 'INFO:abi[ELF O32]' +#elif defined(__sgi) && defined(_ABIN32) + PRINT *, 'INFO:abi[ELF N32]' +#elif defined(__sgi) && defined(_ABI64) + PRINT *, 'INFO:abi[ELF 64]' +#elif defined(__ELF__) + PRINT *, 'INFO:abi[ELF]' +#endif + PRINT *, 'ABI Detection' END diff --git a/Modules/CMakeFortranCompilerId.F.in b/Modules/CMakeFortranCompilerId.F.in index c92f127..107470c 100644 --- a/Modules/CMakeFortranCompilerId.F.in +++ b/Modules/CMakeFortranCompilerId.F.in @@ -8,6 +8,8 @@ PRINT *, 'INFO:compiler[SunPro]' #elif defined(__G95__) PRINT *, 'INFO:compiler[G95]' +#elif defined(__PATHSCALE__) + PRINT *, 'INFO:compiler[PathScale]' #elif defined(__GNUC__) PRINT *, 'INFO:compiler[GNU]' #elif defined(__IBMC__) diff --git a/Modules/CMakeFortranInformation.cmake b/Modules/CMakeFortranInformation.cmake index ea4feb0..97a5e7e 100644 --- a/Modules/CMakeFortranInformation.cmake +++ b/Modules/CMakeFortranInformation.cmake @@ -89,6 +89,14 @@ IF(NOT CMAKE_SHARED_LIBRARY_RPATH_LINK_Fortran_FLAG) SET(CMAKE_SHARED_LIBRARY_RPATH_LINK_Fortran_FLAG ${CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG}) ENDIF(NOT CMAKE_SHARED_LIBRARY_RPATH_LINK_Fortran_FLAG) +IF(NOT DEFINED CMAKE_EXE_EXPORTS_Fortran_FLAG) + SET(CMAKE_EXE_EXPORTS_Fortran_FLAG ${CMAKE_EXE_EXPORTS_C_FLAG}) +ENDIF() + +IF(NOT DEFINED CMAKE_SHARED_LIBRARY_SONAME_Fortran_FLAG) + SET(CMAKE_SHARED_LIBRARY_SONAME_Fortran_FLAG ${CMAKE_SHARED_LIBRARY_SONAME_C_FLAG}) +ENDIF() + # repeat for modules IF(NOT CMAKE_SHARED_MODULE_CREATE_Fortran_FLAGS) SET(CMAKE_SHARED_MODULE_CREATE_Fortran_FLAGS ${CMAKE_SHARED_MODULE_CREATE_C_FLAGS}) @@ -98,14 +106,6 @@ IF(NOT CMAKE_SHARED_MODULE_Fortran_FLAGS) SET(CMAKE_SHARED_MODULE_Fortran_FLAGS ${CMAKE_SHARED_MODULE_C_FLAGS}) ENDIF(NOT CMAKE_SHARED_MODULE_Fortran_FLAGS) -IF(NOT CMAKE_SHARED_MODULE_RUNTIME_Fortran_FLAG) - SET(CMAKE_SHARED_MODULE_RUNTIME_Fortran_FLAG ${CMAKE_SHARED_MODULE_RUNTIME_C_FLAG}) -ENDIF(NOT CMAKE_SHARED_MODULE_RUNTIME_Fortran_FLAG) - -IF(NOT CMAKE_SHARED_MODULE_RUNTIME_Fortran_FLAG_SEP) - SET(CMAKE_SHARED_MODULE_RUNTIME_Fortran_FLAG_SEP ${CMAKE_SHARED_MODULE_RUNTIME_C_FLAG_SEP}) -ENDIF(NOT CMAKE_SHARED_MODULE_RUNTIME_Fortran_FLAG_SEP) - IF(NOT CMAKE_EXECUTABLE_RUNTIME_Fortran_FLAG) SET(CMAKE_EXECUTABLE_RUNTIME_Fortran_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_Fortran_FLAG}) ENDIF(NOT CMAKE_EXECUTABLE_RUNTIME_Fortran_FLAG) diff --git a/Modules/CMakeGenericSystem.cmake b/Modules/CMakeGenericSystem.cmake index c66d5c5..c0f3aa6 100644 --- a/Modules/CMakeGenericSystem.cmake +++ b/Modules/CMakeGenericSystem.cmake @@ -88,6 +88,3 @@ MARK_AS_ADVANCED( CMAKE_SKIP_RPATH CMAKE_VERBOSE_MAKEFILE ) - -# always include the gcc compiler information -INCLUDE(Platform/gcc) diff --git a/Modules/CMakeJOMFindMake.cmake b/Modules/CMakeJOMFindMake.cmake new file mode 100644 index 0000000..a72420a --- /dev/null +++ b/Modules/CMakeJOMFindMake.cmake @@ -0,0 +1,18 @@ + +#============================================================================= +# Copyright 2002-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.) + + +SET (CMAKE_MAKE_PROGRAM "jom" CACHE STRING + "Program used to build from makefiles.") +MARK_AS_ADVANCED(CMAKE_MAKE_PROGRAM) diff --git a/Modules/CMakePlatformId.h.in b/Modules/CMakePlatformId.h.in index 8e786ba..e20348a 100644 --- a/Modules/CMakePlatformId.h.in +++ b/Modules/CMakePlatformId.h.in @@ -82,8 +82,33 @@ #endif +/* For windows compilers MSVC and Intel we can determine + the architecture of the compiler being used. This is becase + the compilers do not have flags that can change the architecture, + but rather depend on which compiler is being used +*/ +#if defined(_WIN32) && defined(_MSC_VER) +# if defined(_M_IA64) +# define ARCHITECTURE_ID "IA64" + +# elif defined(_M_X64) || defined(_M_AMD64) +# define ARCHITECTURE_ID "x64" + +# elif defined(_M_IX86) +# define ARCHITECTURE_ID "X86" + +# else /* unknown architecture */ +# define ARCHITECTURE_ID "" +# endif + +#else +# define ARCHITECTURE_ID "" +#endif + /* Construct the string literal in pieces to prevent the source from getting matched. Store it in a pointer rather than an array because some compilers will just produce instructions to fill the array rather than assigning a pointer to a static array. */ char* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]"; +char* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]"; + diff --git a/Modules/CMakeSystemSpecificInformation.cmake b/Modules/CMakeSystemSpecificInformation.cmake index 8d4d51f..75d737f 100644 --- a/Modules/CMakeSystemSpecificInformation.cmake +++ b/Modules/CMakeSystemSpecificInformation.cmake @@ -63,8 +63,6 @@ ENDIF(CMAKE_EXTRA_GENERATOR) IF(NOT CMAKE_MODULE_EXISTS) SET(CMAKE_SHARED_MODULE_PREFIX "${CMAKE_SHARED_LIBRARY_PREFIX}") SET(CMAKE_SHARED_MODULE_SUFFIX "${CMAKE_SHARED_LIBRARY_SUFFIX}") - SET(CMAKE_SHARED_MODULE_RUNTIME_C_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG}) - SET(CMAKE_SHARED_MODULE_RUNTIME_C_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP}) ENDIF(NOT CMAKE_MODULE_EXISTS) diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index 93cf28e..6e682b4 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -107,6 +107,66 @@ # that won't be packaged when building a source package. This is a # list of patterns, e.g., /CVS/;/\\.svn/;\\.swp$;\\.#;/#;.*~;cscope.* # +# The following variables are specific to the DragNDrop installers +# built on Mac OS X: +# +# CPACK_DMG_VOLUME_NAME - The volume name of the generated disk +# image. Defaults to CPACK_PACKAGE_FILE_NAME. +# +# CPACK_DMG_FORMAT - The disk image format. Common values are UDRO +# (UDIF read-only), UDZO (UDIF zlib-compressed) or UDBZ (UDIF +# bzip2-compressed). Refer to hdiutil(1) for more information on +# other available formats. +# +# CPACK_DMG_DS_STORE - Path to a custom .DS_Store file which e.g. +# can be used to specify the Finder window position/geometry and +# layout (such as hidden toolbars, placement of the icons etc.). +# This file has to be generated by the Finder (either manually or +# through OSA-script) using a normal folder from which the .DS_Store +# file can then be extracted. +# +# CPACK_DMG_BACKGROUND_IMAGE - Path to an image file which is to be +# used as the background for the Finder Window when the disk image +# is opened. By default no background image is set. The background +# image is applied after applying the custom .DS_Store file. +# +# CPACK_COMMAND_HDIUTIL - Path to the hdiutil(1) command used to +# operate on disk image files on Mac OS X. This variable can be used +# to override the automatically detected command (or specify its +# location if the auto-detection fails to find it.) +# +# CPACK_COMMAND_SETFILE - Path to the SetFile(1) command used to set +# extended attributes on files and directories on Mac OS X. This +# variable can be used to override the automatically detected +# command (or specify its location if the auto-detection fails to +# find it.) +# +# CPACK_COMMAND_REZ - Path to the Rez(1) command used to compile +# resources on Mac OS X. This variable can be used to override the +# automatically detected command (or specify its location if the +# auto-detection fails to find it.) +# +# Installers built on Mac OS X using the Bundle generator use the +# aforementioned DragNDrop variables, plus the following Bundle-specific +# parameters: +# +# CPACK_BUNDLE_NAME - The name of the generated bundle. This +# appears in the OSX finder as the bundle name. Required. +# +# CPACK_BUNDLE_PLIST - Path to an OSX plist file that will be used +# as the Info.plist for the generated bundle. This assumes that +# the caller has generated or specified their own Info.plist file. +# Required. +# +# CPACK_BUNDLE_ICON - Path to an OSX icns file that will be used as +# the icon for the generated bundle. This is the icon that appears +# in the OSX finder for the bundle, and in the OSX dock when the +# bundle is opened. Required. +# +# CPACK_BUNDLE_STARTUP_SCRIPT - Path to an executable or script that +# will be run whenever an end-user double-clicks the generated bundle +# in the OSX Finder. Optional. +# # The following variables are specific to the graphical installers built # on Windows using the Nullsoft Installation System. # diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index 5167fa7..29a1218 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -4,7 +4,7 @@ # used by CPack : http://www.cmake.org/Wiki/CMake:CPackConfiguration # # However CPackRPM has specific features which are controlled by -# the specifics CPACK_RPM_XXX variables.You'll find a detailed usage on +# the specifics CPACK_RPM_XXX variables. You'll find a detailed usage on # the wiki: # http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#RPM_.28Unix_Only.29 # However as a handy reminder here comes the list of specific variables: @@ -44,7 +44,7 @@ # The RPM package group. # CPACK_RPM_PACKAGE_VENDOR # Mandatory : YES -# Default : CPACK_PACKAGE_VENDOR if set or"unknown" +# Default : CPACK_PACKAGE_VENDOR if set or "unknown" # The RPM package group. # CPACK_RPM_PACKAGE_DESCRIPTION # Mandatory : YES @@ -52,7 +52,14 @@ # CPACK_RPM_PACKAGE_REQUIRES # Mandatory : NO # Default : - -# May be used to set RPM dependencies. +# May be used to set RPM dependencies (requires). +# Note that you must enclose the complete requires string between quotes, +# for example: +# set(CPACK_RPM_PACKAGE_REQUIRES "python >= 2.5.0, cmake >= 2.8") +# CPACK_RPM_PACKAGES_PROVIDES +# Mandatory : NO +# Default : - +# May be used to set RPM dependencies (provides). # CPACK_RPM_SPEC_INSTALL_POST # Mandatory : NO # Default : - @@ -69,6 +76,38 @@ # May be set when invoking cpack in order to trace debug informations # during CPack RPM run. For example you may launch CPack like this # cpack -D CPACK_RPM_PACKAGE_DEBUG=1 -G RPM +# CPACK_RPM_USER_BINARY_SPECFILE +# Mandatory : NO +# Default : - +# May be set by the user in order to specify a USER binary spec file +# to be used by CPackRPM instead of generating the file. +# The specified file will be processed by CONFIGURE_FILE( @ONLY). +# CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE +# Mandatory : NO +# Default : - +# If set CPack will generate a template for USER specified binary +# spec file and stop with an error. For example launch CPack like this +# cpack -D CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE=1 -G RPM +# The user may then use this file in order to hand-craft is own +# binary spec file which may be used with CPACK_RPM_USER_BINARY_SPECFILE. +# CPACK_RPM_PRE_INSTALL_SCRIPT_FILE +# CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE +# Mandatory : NO +# Default : - +# May be used to embbed a pre (un)installation script in the spec file. +# The refered script file(s) will be read and directly +# put after the %pre or %preun section +# One may verify which scriptlet has been included with +# rpm -qp --scripts package.rpm +# CPACK_RPM_POST_INSTALL_SCRIPT_FILE +# CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE +# Mandatory : NO +# Default : - +# May be used to embbed a post (un)installation script in the spec file. +# The refered script file(s) will be read and directly +# put after the %post or %postun section +# One may verify which scriptlet has been included with +# rpm -qp --scripts package.rpm #============================================================================= # Copyright 2007-2009 Kitware, Inc. @@ -236,6 +275,16 @@ IF(CPACK_RPM_PACKAGE_REQUIRES) SET(TMP_RPM_REQUIRES "Requires: ${CPACK_RPM_PACKAGE_REQUIRES}") ENDIF(CPACK_RPM_PACKAGE_REQUIRES) +# CPACK_RPM_PACKAGE_PROVIDES +# Placeholder used to specify binary RPM dependencies (if any) +# see http://www.rpm.org/max-rpm/s1-rpm-depend-manual-dependencies.html +IF(CPACK_RPM_PACKAGE_PROVIDES) + IF(CPACK_RPM_PACKAGE_DEBUG) + MESSAGE("CPackRPM:Debug: User defined Provides:\n ${CPACK_RPM_PACKAGE_PROVIDES}") + ENDIF(CPACK_RPM_PACKAGE_DEBUG) + SET(TMP_RPM_PROVIDES "Provides: ${CPACK_RPM_PACKAGE_PROVIDES}") +ENDIF(CPACK_RPM_PACKAGE_PROVIDES) + # CPACK_RPM_SPEC_INSTALL_POST # May be used to define a RPM post intallation script # for example setting it to "/bin/true" may prevent @@ -247,6 +296,48 @@ IF(CPACK_RPM_SPEC_INSTALL_POST) SET(TMP_RPM_SPEC_INSTALL_POST "%define __spec_install_post ${CPACK_RPM_SPEC_INSTALL_POST}") ENDIF(CPACK_RPM_SPEC_INSTALL_POST) +# CPACK_RPM_POST_INSTALL_SCRIPT_FILE +# CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE +# May be used to embbed a post (un)installation script in the spec file. +# The refered script file(s) will be read and directly +# put after the %post or %postun section +if(CPACK_RPM_POST_INSTALL_SCRIPT_FILE) + if(EXISTS ${CPACK_RPM_POST_INSTALL_SCRIPT_FILE}) + file(READ ${CPACK_RPM_POST_INSTALL_SCRIPT_FILE} CPACK_RPM_SPEC_POSTINSTALL) + else(EXISTS ${CPACK_RPM_POST_INSTALL_SCRIPT_FILE}) + message("CPackRPM:Warning: CPACK_RPM_POST_INSTALL_SCRIPT_FILE <${CPACK_RPM_POST_INSTALL_SCRIPT_FILE}> does not exists - ignoring") + endif(EXISTS ${CPACK_RPM_POST_INSTALL_SCRIPT_FILE}) +endif(CPACK_RPM_POST_INSTALL_SCRIPT_FILE) + +if(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE) + if(EXISTS ${CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE}) + file(READ ${CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE} CPACK_RPM_SPEC_POSTUNINSTALL) + else(EXISTS ${CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE}) + message("CPackRPM:Warning: CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE <${CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE}> does not exists - ignoring") + endif(EXISTS ${CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE}) +endif(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE) + +# CPACK_RPM_PRE_INSTALL_SCRIPT_FILE +# CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE +# May be used to embbed a pre (un)installation script in the spec file. +# The refered script file(s) will be read and directly +# put after the %pre or %preun section +if(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE) + if(EXISTS ${CPACK_RPM_PRE_INSTALL_SCRIPT_FILE}) + file(READ ${CPACK_RPM_PRE_INSTALL_SCRIPT_FILE} CPACK_RPM_SPEC_PREINSTALL) + else(EXISTS ${CPACK_RPM_PRE_INSTALL_SCRIPT_FILE}) + message("CPackRPM:Warning: CPACK_RPM_PRE_INSTALL_SCRIPT_FILE <${CPACK_RPM_PRE_INSTALL_SCRIPT_FILE}> does not exists - ignoring") + endif(EXISTS ${CPACK_RPM_PRE_INSTALL_SCRIPT_FILE}) +endif(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE) + +if(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE) + if(EXISTS ${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE}) + file(READ ${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE} CPACK_RPM_SPEC_PREUNINSTALL) + else(EXISTS ${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE}) + message("CPackRPM:Warning: CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE <${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE}> does not exists - ignoring") + endif(EXISTS ${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE}) +endif(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE) + # CPACK_RPM_SPEC_MORE_DEFINE # This is a generated spec rpm file spaceholder IF(CPACK_RPM_SPEC_MORE_DEFINE) @@ -255,10 +346,6 @@ IF(CPACK_RPM_SPEC_MORE_DEFINE) ENDIF(CPACK_RPM_PACKAGE_DEBUG) ENDIF(CPACK_RPM_SPEC_MORE_DEFINE) -# CPACK_RPM_USER_BINARY_SPECFILE -# FIXME when this is set then CPack should us the -# user provided file. - # Now we may create the RPM build tree structure SET(CPACK_RPM_ROOTDIR "${CPACK_TOPLEVEL_DIRECTORY}") MESSAGE(STATUS "CPackRPM:Debug: Using CPACK_RPM_ROOTDIR=${CPACK_RPM_ROOTDIR}") @@ -279,75 +366,111 @@ SET(CPACK_RPM_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}") SET(CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}") # Use files tree to construct files command (spec file) -EXECUTE_PROCESS(COMMAND find -type f +# We should not forget to include symlinks (thus -o -type l) +# We must remove the './' due to the local search (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.*\\/.*/&*/} WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}" OUTPUT_VARIABLE CPACK_RPM_INSTALL_FILES) - + +# The name of the final spec file to be used by rpmbuild SET(CPACK_RPM_BINARY_SPECFILE "${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_NAME}.spec") -IF(CPACK_RPM_USER_BINARY_SPECFILE) - # User may have specified SPECFILE just use it - MESSAGE("CPackRPM: Will use user specified spec file: ${CPACK_RPM_USER_BINARY_SPECFILE}") - # Note that user provided file is processed for @var replacement - CONFIGURE_FILE(${CPACK_RPM_USER_BINARY_SPECFILE} ${CPACK_RPM_BINARY_SPECFILE} @ONLY) -ELSE(CPACK_RPM_USER_BINARY_SPECFILE) - # No User specified spec file generate a valid one using var values - IF(CPACK_RPM_PACKAGE_DEBUG) - MESSAGE("CPackRPM:Debug: CPACK_TOPLEVEL_DIRECTORY = ${CPACK_TOPLEVEL_DIRECTORY}") - MESSAGE("CPackRPM:Debug: CPACK_TOPLEVEL_TAG = ${CPACK_TOPLEVEL_TAG}") - MESSAGE("CPackRPM:Debug: CPACK_TEMPORARY_DIRECTORY = ${CPACK_TEMPORARY_DIRECTORY}") - MESSAGE("CPackRPM:Debug: CPACK_OUTPUT_FILE_NAME = ${CPACK_OUTPUT_FILE_NAME}") - MESSAGE("CPackRPM:Debug: CPACK_OUTPUT_FILE_PATH = ${CPACK_OUTPUT_FILE_PATH}") - MESSAGE("CPackRPM:Debug: CPACK_PACKAGE_FILE_NAME = ${CPACK_PACKAGE_FILE_NAME}") - MESSAGE("CPackRPM:Debug: CPACK_RPM_BINARY_SPECFILE = ${CPACK_RPM_BINARY_SPECFILE}") - MESSAGE("CPackRPM:Debug: CPACK_PACKAGE_INSTALL_DIRECTORY = ${CPACK_PACKAGE_INSTALL_DIRECTORY}") - MESSAGE("CPackRPM:Debug: CPACK_TEMPORARY_PACKAGE_FILE_NAME = ${CPACK_TEMPORARY_PACKAGE_FILE_NAME}") - ENDIF(CPACK_RPM_PACKAGE_DEBUG) - FILE(WRITE ${CPACK_RPM_BINARY_SPECFILE} - "# -*- rpm-spec -*- -Buildroot: ${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME} -Summary: ${CPACK_RPM_PACKAGE_SUMMARY} -Name: ${CPACK_RPM_PACKAGE_NAME} -Version: ${CPACK_RPM_PACKAGE_VERSION} -Release: ${CPACK_RPM_PACKAGE_RELEASE} -License: ${CPACK_RPM_PACKAGE_LICENSE} -Group: ${CPACK_RPM_PACKAGE_GROUP} -Vendor: ${CPACK_RPM_PACKAGE_VENDOR} -${TMP_RPM_REQUIRES} -${TMP_RPM_BUILDARCH} - -#p define prefix ${CMAKE_INSTALL_PREFIX} -%define _rpmdir ${CPACK_RPM_DIRECTORY} -%define _rpmfilename ${CPACK_RPM_FILE_NAME} + +# Print out some debug information if we were asked for that +IF(CPACK_RPM_PACKAGE_DEBUG) + MESSAGE("CPackRPM:Debug: CPACK_TOPLEVEL_DIRECTORY = ${CPACK_TOPLEVEL_DIRECTORY}") + MESSAGE("CPackRPM:Debug: CPACK_TOPLEVEL_TAG = ${CPACK_TOPLEVEL_TAG}") + MESSAGE("CPackRPM:Debug: CPACK_TEMPORARY_DIRECTORY = ${CPACK_TEMPORARY_DIRECTORY}") + MESSAGE("CPackRPM:Debug: CPACK_OUTPUT_FILE_NAME = ${CPACK_OUTPUT_FILE_NAME}") + MESSAGE("CPackRPM:Debug: CPACK_OUTPUT_FILE_PATH = ${CPACK_OUTPUT_FILE_PATH}") + MESSAGE("CPackRPM:Debug: CPACK_PACKAGE_FILE_NAME = ${CPACK_PACKAGE_FILE_NAME}") + MESSAGE("CPackRPM:Debug: CPACK_RPM_BINARY_SPECFILE = ${CPACK_RPM_BINARY_SPECFILE}") + MESSAGE("CPackRPM:Debug: CPACK_PACKAGE_INSTALL_DIRECTORY = ${CPACK_PACKAGE_INSTALL_DIRECTORY}") + MESSAGE("CPackRPM:Debug: CPACK_TEMPORARY_PACKAGE_FILE_NAME = ${CPACK_TEMPORARY_PACKAGE_FILE_NAME}") +ENDIF(CPACK_RPM_PACKAGE_DEBUG) + +# USER generated spec file handling. +# We should generate a spec file template: +# - either because the user asked for it : CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE +# - or the user did not provide one : NOT CPACK_RPM_USER_BINARY_SPECFILE +# +IF(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE OR NOT CPACK_RPM_USER_BINARY_SPECFILE) + FILE(WRITE ${CPACK_RPM_BINARY_SPECFILE}.in + "# -*- rpm-spec -*- +Buildroot: \@CPACK_RPM_DIRECTORY\@/\@CPACK_PACKAGE_FILE_NAME\@ +Summary: \@CPACK_RPM_PACKAGE_SUMMARY\@ +Name: \@CPACK_RPM_PACKAGE_NAME\@ +Version: \@CPACK_RPM_PACKAGE_VERSION\@ +Release: \@CPACK_RPM_PACKAGE_RELEASE\@ +License: \@CPACK_RPM_PACKAGE_LICENSE\@ +Group: \@CPACK_RPM_PACKAGE_GROUP\@ +Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@ +\@TMP_RPM_REQUIRES\@ +\@TMP_RPM_PROVIDES\@ +\@TMP_RPM_BUILDARCH\@ + +#p define prefix \@CMAKE_INSTALL_PREFIX\@ +%define _rpmdir \@CPACK_RPM_DIRECTORY\@ +%define _rpmfilename \@CPACK_RPM_FILE_NAME\@ %define _unpackaged_files_terminate_build 0 -%define _topdir ${CPACK_RPM_DIRECTORY} -${TMP_RPM_SPEC_INSTALL_POST} -${CPACK_RPM_SPEC_MORE_DEFINE} - +%define _topdir \@CPACK_RPM_DIRECTORY\@ +\@TMP_RPM_SPEC_INSTALL_POST\@ +\@CPACK_RPM_SPEC_MORE_DEFINE\@ + %description -${CPACK_RPM_PACKAGE_DESCRIPTION} +\@CPACK_RPM_PACKAGE_DESCRIPTION\@ -# This is a shortcutted spec file -# generated by CMake RPM generator -# we skip the _prepn _build and _install -# steps because CPack does that for us -# WE MUST NOT DO ANYTHING in those steps because they -# may fail for non-privileged user -#p prep +# This is a shortcutted spec file generated by CMake RPM generator +# we skip _install step because CPack does that for us. +# We do only save CPack installed tree in _prepr +# and then restore it in build. +%prep +mv $RPM_BUILD_ROOT \@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot #p build -#p install +%install +if [ -e $RPM_BUILD_ROOT ]; +then + mv \@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot/* $RPM_BUILD_ROOT +else + mv \@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot $RPM_BUILD_ROOT +fi %clean +%post +\@CPACK_RPM_SPEC_POSTINSTALL\@ + +%postun +\@CPACK_RPM_SPEC_POSTUNINSTALL\@ + +%pre +\@CPACK_RPM_SPEC_PREINSTALL\@ + +%preun +\@CPACK_RPM_SPEC_PREUNINSTALL\@ + %files %defattr(-,root,root,-) -#p dir %{prefix} -#p {prefix}/* ${CPACK_RPM_INSTALL_FILES} %changelog +* Sat Nov 28 2009 Erk <eric.noulard@gmail.com> + Refix backup/restore install tree for OpenSuSE 11.2 +* Sun Nov 22 2009 Erk <eric.noulard@gmail.com> + Include symlinks in the file list. +* Sat Nov 14 2009 Erk <eric.noulard@gmail.com> + Replace prep and build step with backup and restore + of the previously CPack installed tree. This should + mimic what is expected in rpmbuild usual steps +* Wed Nov 11 2009 Erk <eric.noulard@gmail.com> + Add support for USER defined pre/post[un]install scripts +* Wed Oct 07 2009 Erk <eric.noulard@gmail.com> + Add user custom spec file support * Sat Oct 03 2009 Kami <cmoidavid@gmail.com> Update to handle more precisely the files section * Mon Oct 03 2008 Erk <eric.noulard@gmail.com> @@ -358,9 +481,28 @@ ${CPACK_RPM_INSTALL_FILES} * Tue Aug 16 2007 Erk <eric.noulard@gmail.com> Generated by CPack RPM Generator and associated macros ") + # Stop here if we were asked to only generate a template USER spec file + # The generated file may then be used as a template by user who wants + # to customize their own spec file. + IF(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE) + MESSAGE(FATAL_ERROR "CPackRPM: STOP here Generated USER binary spec file templare is: ${CPACK_RPM_BINARY_SPECFILE}.in") + ENDIF(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE) +ENDIF(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE OR NOT CPACK_RPM_USER_BINARY_SPECFILE) + +# After that we may either use a user provided spec file +# or generate one using appropriate variables value. +IF(CPACK_RPM_USER_BINARY_SPECFILE) + # User may have specified SPECFILE just use it + MESSAGE("CPackRPM: Will use USER specified spec file: ${CPACK_RPM_USER_BINARY_SPECFILE}") + # The user provided file is processed for @var replacement + CONFIGURE_FILE(${CPACK_RPM_USER_BINARY_SPECFILE} ${CPACK_RPM_BINARY_SPECFILE} @ONLY) +ELSE(CPACK_RPM_USER_BINARY_SPECFILE) + # No User specified spec file, will use the generated spec file + MESSAGE("CPackRPM: Will use GENERATED spec file: ${CPACK_RPM_BINARY_SPECFILE}") + # Note the just created file is processed for @var replacement + CONFIGURE_FILE(${CPACK_RPM_BINARY_SPECFILE}.in ${CPACK_RPM_BINARY_SPECFILE} @ONLY) ENDIF(CPACK_RPM_USER_BINARY_SPECFILE) - IF(RPMBUILD_EXECUTABLE) # Now call rpmbuild using the SPECFILE EXECUTE_PROCESS( diff --git a/Modules/CTest.cmake b/Modules/CTest.cmake index aaa6040..28835ce 100644 --- a/Modules/CTest.cmake +++ b/Modules/CTest.cmake @@ -1,13 +1,49 @@ # - Configure a project for testing with CTest/CDash -# This file configures a project to use the CTest/CDash/Dart -# testing/dashboard process. This module should be included -# in the CMakeLists.txt file at the top of a project. Typical usage: -# INCLUDE(CTest) -# IF(BUILD_TESTING) -# # ... testing related CMake code ... -# ENDIF(BUILD_TESTING) -# The BUILD_TESTING option is created by the CTest module to determine -# whether testing support should be enabled. The default is ON. +# Include this module in the top CMakeLists.txt file of a project to +# enable testing with CTest and dashboard submissions to CDash: +# project(MyProject) +# ... +# include(CTest) +# The module automatically creates a BUILD_TESTING option that selects +# whether to enable testing support (ON by default). After including +# the module, use code like +# if(BUILD_TESTING) +# # ... CMake code to create tests ... +# endif() +# to creating tests when testing is enabled. +# +# To enable submissions to a CDash server, create a CTestConfig.cmake +# file at the top of the project with content such as +# set(CTEST_PROJECT_NAME "MyProject") +# set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC") +# set(CTEST_DROP_METHOD "http") +# set(CTEST_DROP_SITE "my.cdash.org") +# set(CTEST_DROP_LOCATION "/submit.php?project=MyProject") +# set(CTEST_DROP_SITE_CDASH TRUE) +# (the CDash server can provide the file to a project administrator +# who configures 'MyProject'). +# Settings in the config file are shared by both this CTest module and +# the CTest command-line tool's dashboard script mode (ctest -S). +# +# While building a project for submission to CDash, CTest scans the +# build output for errors and warnings and reports them with +# surrounding context from the build log. This generic approach works +# for all build tools, but does not give details about the command +# invocation that produced a given problem. One may get more detailed +# reports by adding +# set(CTEST_USE_LAUNCHERS 1) +# to the CTestConfig.cmake file. When this option is enabled, the +# CTest module tells CMake's Makefile generators to invoke every +# command in the generated build system through a CTest launcher +# program. (Currently the CTEST_USE_LAUNCHERS option is ignored on +# non-Makefile generators.) During a manual build each launcher +# transparently runs the command it wraps. During a CTest-driven +# build for submission to CDash each launcher reports detailed +# information when its command fails or warns. +# (Setting CTEST_USE_LAUNCHERS in CTestConfig.cmake is convenient, but +# also adds the launcher overhead even for manual builds. One may +# instead set it in a CTest dashboard script and add it to the CMake +# cache for the build tree.) #============================================================================= # Copyright 2005-2009 Kitware, Inc. @@ -84,10 +120,6 @@ IF(BUILD_TESTING) ENDIF(EXISTS "${PROJECT_SOURCE_DIR}/DartConfig.cmake") SET_IF_NOT_SET (NIGHTLY_START_TIME "00:00:00 EDT") - # make program just needs to use CMAKE_MAKE_PROGRAM which is required - # to be defined by cmake - SET(MAKEPROGRAM ${CMAKE_MAKE_PROGRAM}) - FIND_PROGRAM(CVSCOMMAND cvs ) SET(CVS_UPDATE_OPTIONS "-d -A -P" CACHE STRING "Options passed to the cvs update command.") @@ -202,8 +234,17 @@ IF(BUILD_TESTING) ENDIF(DART_CXX_NAME MATCHES "devenv") SET(BUILDNAME "${BUILD_NAME_SYSTEM_NAME}-${DART_CXX_NAME}") ENDIF(NOT BUILDNAME) - # set the build command - BUILD_COMMAND(MAKECOMMAND ${MAKEPROGRAM} ) + + # the build command + BUILD_COMMAND(MAKECOMMAND CONFIGURATION "\${CTEST_CONFIGURATION_TYPE}") + SET(MAKECOMMAND ${MAKECOMMAND} CACHE STRING "Command to build the project") + + # the default build configuration the ctest build handler will use + # if there is no -C arg given to ctest: + SET(DEFAULT_CTEST_CONFIGURATION_TYPE "$ENV{CMAKE_CONFIG_TYPE}") + IF(DEFAULT_CTEST_CONFIGURATION_TYPE STREQUAL "") + SET(DEFAULT_CTEST_CONFIGURATION_TYPE "Release") + ENDIF(DEFAULT_CTEST_CONFIGURATION_TYPE STREQUAL "") IF(NOT "${CMAKE_GENERATOR}" MATCHES "Make") SET(CTEST_USE_LAUNCHERS 0) diff --git a/Modules/CheckTypeSize.c.in b/Modules/CheckTypeSize.c.in new file mode 100644 index 0000000..b6c3688 --- /dev/null +++ b/Modules/CheckTypeSize.c.in @@ -0,0 +1,37 @@ +@headers@ + +#undef KEY +#if defined(__i386) +# define KEY '_','_','i','3','8','6' +#elif defined(__x86_64) +# define KEY '_','_','x','8','6','_','6','4' +#elif defined(__ppc__) +# define KEY '_','_','p','p','c','_','_' +#elif defined(__ppc64__) +# define KEY '_','_','p','p','c','6','4','_','_' +#endif + +#define SIZE (sizeof(@type@)) +char info_size[] = {'I', 'N', 'F', 'O', ':', 's','i','z','e','[', + ('0' + ((SIZE / 10000)%10)), + ('0' + ((SIZE / 1000)%10)), + ('0' + ((SIZE / 100)%10)), + ('0' + ((SIZE / 10)%10)), + ('0' + (SIZE % 10)), + ']', +#ifdef KEY + ' ','k','e','y','[', KEY, ']', +#endif + '\0'}; + +#ifdef __CLASSIC_C__ +int main(argc, argv) int argc; char *argv[]; +#else +int main(int argc, char *argv[]) +#endif +{ + int require = 0; + require += info_size[argc]; + (void)argv; + return require; +} diff --git a/Modules/CheckTypeSize.cmake b/Modules/CheckTypeSize.cmake index 3701467..6f4b437 100644 --- a/Modules/CheckTypeSize.cmake +++ b/Modules/CheckTypeSize.cmake @@ -1,16 +1,29 @@ # - Check sizeof a type # CHECK_TYPE_SIZE(TYPE VARIABLE [BUILTIN_TYPES_ONLY]) -# Check if the type exists and determine size of type. if the type -# exists, the size will be stored to the variable. This also -# calls check_include_file for sys/types.h stdint.h -# and stddef.h, setting HAVE_SYS_TYPES_H, HAVE_STDINT_H, -# and HAVE_STDDEF_H. This is because many types are stored -# in these include files. -# VARIABLE - variable to store size if the type exists. -# HAVE_${VARIABLE} - does the variable exists or not -# BUILTIN_TYPES_ONLY - The third argument is optional and if -# it is set to the string BUILTIN_TYPES_ONLY -# this macro will not check for any header files. +# Check if the type exists and determine its size. +# On return, "HAVE_${VARIABLE}" holds the existence of the type, +# and "${VARIABLE}" holds one of the following: +# <size> = type has non-zero size <size> +# "0" = type has arch-dependent size (see below) +# "" = type does not exist +# Furthermore, the variable "${VARIABLE}_CODE" holds C preprocessor +# code to define the macro "${VARIABLE}" to the size of the type, or +# leave the macro undefined if the type does not exist. +# +# The variable "${VARIABLE}" may be "0" when CMAKE_OSX_ARCHITECTURES +# has multiple architectures for building OS X universal binaries. +# This indicates that the type size varies across architectures. +# In this case "${VARIABLE}_CODE" contains C preprocessor tests +# mapping from each architecture macro to the corresponding type size. +# The list of architecture macros is stored in "${VARIABLE}_KEYS", and +# the value for each key is stored in "${VARIABLE}-${KEY}". +# +# If the BUILTIN_TYPES_ONLY option is not given, the macro checks for +# headers <sys/types.h>, <stdint.h>, and <stddef.h>, and saves results +# in HAVE_SYS_TYPES_H, HAVE_STDINT_H, and HAVE_STDDEF_H. The type +# size check automatically includes the available headers, thus +# supporting checks of types defined in the headers. +# # The following variables may be set before calling this macro to # modify the way the check is run: # @@ -18,9 +31,7 @@ # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_INCLUDES = list of include directories # CMAKE_REQUIRED_LIBRARIES = list of libraries to link - -# These variables are referenced in CheckTypeSizeC.c so we have -# to check for them. +# CMAKE_EXTRA_INCLUDE_FILES = list of extra headers to include #============================================================================= # Copyright 2002-2009 Kitware, Inc. @@ -37,81 +48,144 @@ include(CheckIncludeFile) -MACRO(CHECK_TYPE_SIZE TYPE VARIABLE) - IF(NOT "${ARGV2}" STREQUAL "BUILTIN_TYPES_ONLY") +cmake_policy(PUSH) +cmake_minimum_required(VERSION 2.6 FATAL_ERROR) + +get_filename_component(__check_type_size_dir "${CMAKE_CURRENT_LIST_FILE}" PATH) + +#----------------------------------------------------------------------------- +# Helper function. DO NOT CALL DIRECTLY. +function(__check_type_size_impl type var map builtin) + message(STATUS "Check size of ${type}") + + # Include header files. + set(headers) + if(builtin) + if(HAVE_SYS_TYPES_H) + set(headers "${headers}#include <sys/types.h>\n") + endif() + if(HAVE_STDINT_H) + set(headers "${headers}#include <stdint.h>\n") + endif() + if(HAVE_STDDEF_H) + set(headers "${headers}#include <stddef.h>\n") + endif() + endif() + foreach(h ${CMAKE_EXTRA_INCLUDE_FILES}) + set(headers "${headers}#include \"${h}\"\n") + endforeach() + + # Perform the check. + set(src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${var}.c) + set(bin ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${var}.bin) + configure_file(${__check_type_size_dir}/CheckTypeSize.c.in ${src} @ONLY) + try_compile(HAVE_${var} ${CMAKE_BINARY_DIR} ${src} + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} + CMAKE_FLAGS + "-DCOMPILE_DEFINITIONS:STRING=${CMAKE_REQUIRED_FLAGS}" + "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}" + "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}" + OUTPUT_VARIABLE output + COPY_FILE ${bin} + ) + + if(HAVE_${var}) + # The check compiled. Load information from the binary. + file(STRINGS ${bin} strings LIMIT_COUNT 10 REGEX "INFO:size") + + # Parse the information strings. + set(regex_size ".*INFO:size\\[0*([^]]*)\\].*") + set(regex_key " key\\[([^]]*)\\]") + set(keys) + set(code) + set(mismatch) + set(first 1) + foreach(info ${strings}) + if("${info}" MATCHES "${regex_size}") + # Get the type size. + string(REGEX REPLACE "${regex_size}" "\\1" size "${info}") + if(first) + set(${var} ${size}) + elseif(NOT "${size}" STREQUAL "${${var}}") + set(mismatch 1) + endif() + set(first 0) + + # Get the architecture map key. + string(REGEX MATCH "${regex_key}" key "${info}") + string(REGEX REPLACE "${regex_key}" "\\1" key "${key}") + if(key) + set(code "${code}\nset(${var}-${key} \"${size}\")") + list(APPEND keys ${key}) + endif() + endif() + endforeach() + + # Update the architecture-to-size map. + if(mismatch AND keys) + configure_file(${__check_type_size_dir}/CheckTypeSizeMap.cmake.in ${map} @ONLY) + set(${var} 0) + else() + file(REMOVE ${map}) + endif() + + if(mismatch AND NOT keys) + message(SEND_ERROR "CHECK_TYPE_SIZE found different results, consider setting CMAKE_OSX_ARCHITECTURES or CMAKE_TRY_COMPILE_OSX_ARCHITECTURES to one or no architecture !") + endif() + + message(STATUS "Check size of ${type} - done") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining size of ${type} passed with the following output:\n${output}\n\n") + set(${var} "${${var}}" CACHE INTERNAL "CHECK_TYPE_SIZE: sizeof(${type})") + else(HAVE_${var}) + # The check failed to compile. + message(STATUS "Check size of ${type} - failed") + file(READ ${src} content) + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining size of ${type} failed with the following output:\n${output}\n${src}:\n${content}\n\n") + set(${var} "" CACHE INTERNAL "CHECK_TYPE_SIZE: ${type} unknown") + file(REMOVE ${map}) + endif(HAVE_${var}) +endfunction() + +#----------------------------------------------------------------------------- +macro(CHECK_TYPE_SIZE TYPE VARIABLE) + # Optionally check for standard headers. + if("${ARGV2}" STREQUAL "BUILTIN_TYPES_ONLY") + set(_builtin 0) + else() + set(_builtin 1) check_include_file(sys/types.h HAVE_SYS_TYPES_H) check_include_file(stdint.h HAVE_STDINT_H) check_include_file(stddef.h HAVE_STDDEF_H) - ENDIF(NOT "${ARGV2}" STREQUAL "BUILTIN_TYPES_ONLY") - - IF("HAVE_${VARIABLE}" MATCHES "^HAVE_${VARIABLE}$") - MESSAGE(STATUS "Check size of ${TYPE}") - SET(CHECK_TYPE_SIZE_TYPE "${TYPE}") - SET(MACRO_CHECK_TYPE_SIZE_FLAGS - "${CMAKE_REQUIRED_FLAGS}") - FOREACH(def HAVE_SYS_TYPES_H HAVE_STDINT_H HAVE_STDDEF_H) - IF("${def}") - SET(MACRO_CHECK_TYPE_SIZE_FLAGS - "${MACRO_CHECK_TYPE_SIZE_FLAGS} -D${def}") - ENDIF("${def}") - ENDFOREACH(def) - SET(CHECK_TYPE_SIZE_PREINCLUDE) - SET(CHECK_TYPE_SIZE_PREMAIN) - SET(CHECK_TYPE_SIZE_ADD_LIBRARIES) - SET(CHECK_TYPE_SIZE_ADD_INCLUDES) - - FOREACH(def ${CMAKE_EXTRA_INCLUDE_FILES}) - SET(CHECK_TYPE_SIZE_PREMAIN "${CHECK_TYPE_SIZE_PREMAIN}#include \"${def}\"\n") - ENDFOREACH(def) - IF(CMAKE_REQUIRED_LIBRARIES) - SET(CHECK_TYPE_SIZE_ADD_LIBRARIES - "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") - ENDIF(CMAKE_REQUIRED_LIBRARIES) - IF(CMAKE_REQUIRED_INCLUDES) - SET(CHECK_TYPE_SIZE_ADD_INCLUDES - "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") - ENDIF(CMAKE_REQUIRED_INCLUDES) - - CONFIGURE_FILE("${CMAKE_ROOT}/Modules/CheckTypeSizeC.c.in" - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckTypeSizeC.c" IMMEDIATE @ONLY) - FILE(READ "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckTypeSizeC.c" - CHECK_TYPE_SIZE_FILE_CONTENT) - TRY_COMPILE(HAVE_${VARIABLE} - ${CMAKE_BINARY_DIR} - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckTypeSizeC.c" - COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} - CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_TYPE_SIZE_FLAGS} - "${CHECK_TYPE_SIZE_ADD_LIBRARIES}" - "${CHECK_TYPE_SIZE_ADD_INCLUDES}" - OUTPUT_VARIABLE OUTPUT - COPY_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize.bin" ) - - IF(HAVE_${VARIABLE}) - FILE(STRINGS "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize.bin" - CMAKE_CHECKTYPESIZE_STRINGS LIMIT_COUNT 2 REGEX "INFO:sizeof") - - SET(CMAKE_CHECKTYPESIZE_FIRST_RESULT "FIRST_LOOP") - FOREACH(info ${CMAKE_CHECKTYPESIZE_STRINGS}) - IF("${info}" MATCHES ".*INFO:sizeof\\[0*([^]]*)\\].*") - STRING(REGEX REPLACE ".*INFO:sizeof\\[0*([^]]*)\\].*" "\\1" ${VARIABLE} "${info}") - ENDIF("${info}" MATCHES ".*INFO:sizeof\\[0*([^]]*)\\].*") - IF("${CMAKE_CHECKTYPESIZE_FIRST_RESULT}" STREQUAL "FIRST_LOOP") - SET(CMAKE_CHECKTYPESIZE_FIRST_RESULT "${${VARIABLE}}") - ENDIF("${CMAKE_CHECKTYPESIZE_FIRST_RESULT}" STREQUAL "FIRST_LOOP") - IF(NOT "${CMAKE_CHECKTYPESIZE_FIRST_RESULT}" STREQUAL "${${VARIABLE}}") - MESSAGE(SEND_ERROR "CHECK_TYPE_SIZE found different results, consider setting CMAKE_OSX_ARCHITECTURES or CMAKE_TRY_COMPILE_OSX_ARCHITECTURES to one or no architecture !") - ENDIF(NOT "${CMAKE_CHECKTYPESIZE_FIRST_RESULT}" STREQUAL "${${VARIABLE}}") - - ENDFOREACH(info ${CMAKE_CHECKTYPESIZE_STRINGS}) - MESSAGE(STATUS "Check size of ${TYPE} - done") - FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining size of ${TYPE} passed with the following output:\n${OUTPUT}\n\n") - ELSE(HAVE_${VARIABLE}) - MESSAGE(STATUS "Check size of ${TYPE} - failed") - FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining size of ${TYPE} failed with the following output:\n${OUTPUT}\nCheckTypeSizeC.c:\n${CHECK_TYPE_SIZE_FILE_CONTENT}\n\n") - SET(${VARIABLE}) - ENDIF(HAVE_${VARIABLE}) - SET(${VARIABLE} "${${VARIABLE}}" CACHE INTERNAL "Result of CHECK_TYPE_SIZE" FORCE) - ENDIF("HAVE_${VARIABLE}" MATCHES "^HAVE_${VARIABLE}$") -ENDMACRO(CHECK_TYPE_SIZE) + endif() + + # Compute or load the size or size map. + set(${VARIABLE}_KEYS) + set(_map_file ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${VARIABLE}.cmake) + if(NOT DEFINED HAVE_${VARIABLE}) + __check_type_size_impl(${TYPE} ${VARIABLE} ${_map_file} ${_builtin}) + endif() + include(${_map_file} OPTIONAL) + set(_map_file) + set(_builtin) + + # Create preprocessor code. + if(${VARIABLE}_KEYS) + set(${VARIABLE}_CODE) + set(_if if) + foreach(key ${${VARIABLE}_KEYS}) + set(${VARIABLE}_CODE "${${VARIABLE}_CODE}#${_if} defined(${key})\n# define ${VARIABLE} ${${VARIABLE}-${key}}\n") + set(_if elif) + endforeach() + set(${VARIABLE}_CODE "${${VARIABLE}_CODE}#else\n# error ${VARIABLE} unknown\n#endif") + set(_if) + elseif(${VARIABLE}) + set(${VARIABLE}_CODE "#define ${VARIABLE} ${${VARIABLE}}") + else() + set(${VARIABLE}_CODE "/* #undef ${VARIABLE} */") + endif() +endmacro() + +#----------------------------------------------------------------------------- +cmake_policy(POP) diff --git a/Modules/CheckTypeSizeC.c.in b/Modules/CheckTypeSizeC.c.in deleted file mode 100644 index 8bcf1a0..0000000 --- a/Modules/CheckTypeSizeC.c.in +++ /dev/null @@ -1,48 +0,0 @@ -#cmakedefine CHECK_TYPE_SIZE_TYPE @CHECK_TYPE_SIZE_TYPE@ -#ifdef CHECK_TYPE_SIZE_TYPE - -@CHECK_TYPE_SIZE_PREINCLUDE@ -#ifdef HAVE_SYS_TYPES_H -# include <sys/types.h> -#endif /* HAVE_SYS_TYPES_H */ - -#ifdef HAVE_STDINT_H -# include <stdint.h> -#endif /* HAVE_STDINT_H */ - -#ifdef HAVE_STDDEF_H -# include <stddef.h> -#endif /* HAVE_STDDEF_H */ - -@CHECK_TYPE_SIZE_PREMAIN@ - -#ifdef __CLASSIC_C__ -# define const -#endif - -#define SIZE (sizeof(@CHECK_TYPE_SIZE_TYPE@)) -const char info_sizeof[] = {'I', 'N', 'F', 'O', ':', 's','i','z','e','o','f','[', - ('0' + ((SIZE / 10000)%10)), - ('0' + ((SIZE / 1000)%10)), - ('0' + ((SIZE / 100)%10)), - ('0' + ((SIZE / 10)%10)), - ('0' + (SIZE % 10)), - ']','\0'}; - -#ifdef __CLASSIC_C__ -int main(argc, argv) int argc; char *argv[]; -#else -int main(int argc, char *argv[]) -#endif -{ - int require = 0; - require += info_sizeof[argc]; - (void)argv; - return require; -} - -#else /* CHECK_TYPE_SIZE_TYPE */ - -# error "CHECK_TYPE_SIZE_TYPE has to specify the type" - -#endif /* CHECK_TYPE_SIZE_TYPE */ diff --git a/Modules/CheckTypeSizeMap.cmake.in b/Modules/CheckTypeSizeMap.cmake.in new file mode 100644 index 0000000..1e73cff --- /dev/null +++ b/Modules/CheckTypeSizeMap.cmake.in @@ -0,0 +1 @@ +set(@var@_KEYS "@keys@")@code@ diff --git a/Modules/Compiler/GNU-C.cmake b/Modules/Compiler/GNU-C.cmake index abf384a..9a5137a 100644 --- a/Modules/Compiler/GNU-C.cmake +++ b/Modules/Compiler/GNU-C.cmake @@ -1 +1,2 @@ -SET(CMAKE_C_VERBOSE_FLAG "-v") +include(Compiler/GNU) +__compiler_gnu(C) diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake index f3c6b5f..879ab8f 100644 --- a/Modules/Compiler/GNU-CXX.cmake +++ b/Modules/Compiler/GNU-CXX.cmake @@ -1 +1,2 @@ -SET(CMAKE_CXX_VERBOSE_FLAG "-v") +include(Compiler/GNU) +__compiler_gnu(CXX) diff --git a/Modules/Compiler/GNU-Fortran.cmake b/Modules/Compiler/GNU-Fortran.cmake index 7f7c128..6e0f5f3 100644 --- a/Modules/Compiler/GNU-Fortran.cmake +++ b/Modules/Compiler/GNU-Fortran.cmake @@ -1 +1,14 @@ -SET(CMAKE_Fortran_VERBOSE_FLAG "-v") +include(Compiler/GNU) +__compiler_gnu(Fortran) + +# No -DNDEBUG for Fortran. +SET(CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "-Os") +SET(CMAKE_Fortran_FLAGS_RELEASE_INIT "-O3") + +# We require updates to CMake C++ code to support preprocessing rules +# for Fortran. +SET(CMAKE_Fortran_CREATE_PREPROCESSED_SOURCE) +SET(CMAKE_Fortran_CREATE_ASSEMBLY_SOURCE) + +# Fortran-specific feature flags. +SET(CMAKE_Fortran_MODDIR_FLAG -J) diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake new file mode 100644 index 0000000..63652b6 --- /dev/null +++ b/Modules/Compiler/GNU.cmake @@ -0,0 +1,38 @@ + +#============================================================================= +# Copyright 2002-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.) + +# This module is shared by multiple languages; use include blocker. +if(__COMPILER_GNU) + return() +endif() +set(__COMPILER_GNU 1) + +macro(__compiler_gnu lang) + # Feature flags. + set(CMAKE_${lang}_VERBOSE_FLAG "-v") + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") + + # Initial configuration flags. + set(CMAKE_${lang}_FLAGS_INIT "") + set(CMAKE_${lang}_FLAGS_DEBUG_INIT "-g") + set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG") + set(CMAKE_${lang}_FLAGS_RELEASE_INIT "-O3 -DNDEBUG") + set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "-O2 -g") + set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") + set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") + if(NOT APPLE) + set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ") + endif(NOT APPLE) +endmacro() diff --git a/Modules/Compiler/PGI-C.cmake b/Modules/Compiler/PGI-C.cmake index abf384a..da88c01 100644 --- a/Modules/Compiler/PGI-C.cmake +++ b/Modules/Compiler/PGI-C.cmake @@ -1 +1,4 @@ -SET(CMAKE_C_VERBOSE_FLAG "-v") +include(Compiler/PGI) +__compiler_pgi(C) +set(CMAKE_C_FLAGS_MINSIZEREL_INIT "${CMAKE_C_FLAGS_MINSIZEREL_INIT} -DNDEBUG") +set(CMAKE_C_FLAGS_RELEASE_INIT "${CMAKE_C_FLAGS_RELEASE_INIT} -DNDEBUG") diff --git a/Modules/Compiler/PGI-CXX.cmake b/Modules/Compiler/PGI-CXX.cmake index f3c6b5f..97c9555 100644 --- a/Modules/Compiler/PGI-CXX.cmake +++ b/Modules/Compiler/PGI-CXX.cmake @@ -1 +1,4 @@ -SET(CMAKE_CXX_VERBOSE_FLAG "-v") +include(Compiler/PGI) +__compiler_pgi(CXX) +set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "${CMAKE_CXX_FLAGS_MINSIZEREL_INIT} -DNDEBUG") +set(CMAKE_CXX_FLAGS_RELEASE_INIT "${CMAKE_CXX_FLAGS_RELEASE_INIT} -DNDEBUG") diff --git a/Modules/Compiler/PGI-Fortran.cmake b/Modules/Compiler/PGI-Fortran.cmake index 7f7c128..1d26315 100644 --- a/Modules/Compiler/PGI-Fortran.cmake +++ b/Modules/Compiler/PGI-Fortran.cmake @@ -1 +1,12 @@ -SET(CMAKE_Fortran_VERBOSE_FLAG "-v") +include(Compiler/PGI) +__compiler_pgi(Fortran) + +SET(CMAKE_Fortran_FLAGS_INIT "${CMAKE_Fortran_FLAGS_INIT} -Mpreprocess -Kieee") +SET(CMAKE_Fortran_FLAGS_DEBUG_INIT "${CMAKE_Fortran_FLAGS_DEBUG_INIT} -Mbounds") + +# We require updates to CMake C++ code to support preprocessing rules +# for Fortran. +SET(CMAKE_Fortran_CREATE_PREPROCESSED_SOURCE) +SET(CMAKE_Fortran_CREATE_ASSEMBLY_SOURCE) + +SET(CMAKE_Fortran_MODDIR_FLAG "-module ") diff --git a/Modules/Compiler/PGI.cmake b/Modules/Compiler/PGI.cmake new file mode 100644 index 0000000..c6960fc --- /dev/null +++ b/Modules/Compiler/PGI.cmake @@ -0,0 +1,35 @@ + +#============================================================================= +# Copyright 2002-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.) + +# This module is shared by multiple languages; use include blocker. +if(__COMPILER_PGI) + return() +endif() +set(__COMPILER_PGI 1) + +macro(__compiler_pgi lang) + # Feature flags. + set(CMAKE_${lang}_VERBOSE_FLAG "-v") + + # Initial configuration flags. + set(CMAKE_${lang}_FLAGS_INIT "") + set(CMAKE_${lang}_FLAGS_DEBUG_INIT "-g -O0") + set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "-O2 -s") + set(CMAKE_${lang}_FLAGS_RELEASE_INIT "-fast -O3 -Mipa=fast") + set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "-O2 -gopt") + + # Preprocessing and assembly rules. + set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") + set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") +endmacro() diff --git a/Modules/Compiler/PathScale-C.cmake b/Modules/Compiler/PathScale-C.cmake new file mode 100644 index 0000000..9db54af --- /dev/null +++ b/Modules/Compiler/PathScale-C.cmake @@ -0,0 +1,4 @@ +include(Compiler/PathScale) +__compiler_pathscale(C) +set(CMAKE_C_FLAGS_MINSIZEREL_INIT "${CMAKE_C_FLAGS_MINSIZEREL_INIT} -DNDEBUG") +set(CMAKE_C_FLAGS_RELEASE_INIT "${CMAKE_C_FLAGS_RELEASE_INIT} -DNDEBUG") diff --git a/Modules/Compiler/PathScale-CXX.cmake b/Modules/Compiler/PathScale-CXX.cmake new file mode 100644 index 0000000..4dd7660 --- /dev/null +++ b/Modules/Compiler/PathScale-CXX.cmake @@ -0,0 +1,4 @@ +include(Compiler/PathScale) +__compiler_pathscale(CXX) +set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "${CMAKE_CXX_FLAGS_MINSIZEREL_INIT} -DNDEBUG") +set(CMAKE_CXX_FLAGS_RELEASE_INIT "${CMAKE_CXX_FLAGS_RELEASE_INIT} -DNDEBUG") diff --git a/Modules/Compiler/PathScale-Fortran.cmake b/Modules/Compiler/PathScale-Fortran.cmake new file mode 100644 index 0000000..20c9d7e --- /dev/null +++ b/Modules/Compiler/PathScale-Fortran.cmake @@ -0,0 +1,4 @@ +include(Compiler/PathScale) +__compiler_pathscale(Fortran) + +SET(CMAKE_Fortran_MODDIR_FLAG "-module ") diff --git a/Modules/Compiler/PathScale.cmake b/Modules/Compiler/PathScale.cmake new file mode 100644 index 0000000..a53112b --- /dev/null +++ b/Modules/Compiler/PathScale.cmake @@ -0,0 +1,31 @@ + +#============================================================================= +# Copyright 2002-2010 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.) + +# This module is shared by multiple languages; use include blocker. +if(__COMPILER_PATHSCALE) + return() +endif() +set(__COMPILER_PATHSCALE 1) + +macro(__compiler_pathscale lang) + # Feature flags. + set(CMAKE_${lang}_VERBOSE_FLAG "-v") + + # Initial configuration flags. + set(CMAKE_${lang}_FLAGS_INIT "") + set(CMAKE_${lang}_FLAGS_DEBUG_INIT "-g -O0") + set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "-Os") + set(CMAKE_${lang}_FLAGS_RELEASE_INIT "-O3") + set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "-g -O2") +endmacro() diff --git a/Modules/Compiler/SunPro-C.cmake b/Modules/Compiler/SunPro-C.cmake index 4e7e50b..4ac918e 100644 --- a/Modules/Compiler/SunPro-C.cmake +++ b/Modules/Compiler/SunPro-C.cmake @@ -1,6 +1,5 @@ SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-KPIC") SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-G") -SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-R") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-h") diff --git a/Modules/Compiler/SunPro-CXX.cmake b/Modules/Compiler/SunPro-CXX.cmake index c3f079d..fe549d6 100644 --- a/Modules/Compiler/SunPro-CXX.cmake +++ b/Modules/Compiler/SunPro-CXX.cmake @@ -1,6 +1,5 @@ SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-KPIC") SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-G") -SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") SET(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG "-R") SET(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG_SEP ":") SET(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-h") diff --git a/Modules/Compiler/SunPro-Fortran.cmake b/Modules/Compiler/SunPro-Fortran.cmake index 0933bf7..ae38f86 100644 --- a/Modules/Compiler/SunPro-Fortran.cmake +++ b/Modules/Compiler/SunPro-Fortran.cmake @@ -1,6 +1,5 @@ SET(CMAKE_SHARED_LIBRARY_Fortran_FLAGS "-KPIC") SET(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "-G") -SET(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS "") SET(CMAKE_SHARED_LIBRARY_RUNTIME_Fortran_FLAG "-R") SET(CMAKE_SHARED_LIBRARY_RUNTIME_Fortran_FLAG_SEP ":") SET(CMAKE_SHARED_LIBRARY_SONAME_Fortran_FLAG "-h") diff --git a/Modules/DartConfiguration.tcl.in b/Modules/DartConfiguration.tcl.in index 2eea45c..98d7cd2 100644 --- a/Modules/DartConfiguration.tcl.in +++ b/Modules/DartConfiguration.tcl.in @@ -15,6 +15,7 @@ BuildName: @BUILDNAME@ # Submission information IsCDash: @CTEST_DROP_SITE_CDASH@ +CDashVersion: @CTEST_CDASH_VERSION@ DropSite: @DROP_SITE@ DropLocation: @DROP_LOCATION@ DropSiteUser: @DROP_SITE_USER@ @@ -30,6 +31,7 @@ NightlyStartTime: @NIGHTLY_START_TIME@ # Commands for the build/test/submit cycle ConfigureCommand: "@CMAKE_COMMAND@" "@PROJECT_SOURCE_DIR@" MakeCommand: @MAKECOMMAND@ +DefaultCTestConfigurationType: @DEFAULT_CTEST_CONFIGURATION_TYPE@ # CVS options # Default is "-d -P -A" diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 84c7322..0302d5c 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -17,6 +17,7 @@ # [SVN_REPOSITORY url] # URL of Subversion repo # [SVN_REVISION rev] # Revision to checkout from Subversion repo # [URL /.../src.tgz] # Full path or URL of source +# [TIMEOUT seconds] # Time allowed for file download operations # #--Update/Patch step---------- # [UPDATE_COMMAND cmd...] # Source work-tree update command # [PATCH_COMMAND cmd...] # Command to patch downloaded source @@ -203,19 +204,24 @@ define_property(DIRECTORY PROPERTY "EP_PREFIX" INHERITED function(_ep_write_downloadfile_script script_filename remote local timeout) - if(NOT timeout) - set(timeout 30) + if(timeout) + set(timeout_args TIMEOUT ${timeout}) + set(timeout_msg "${timeout} seconds") + else() + set(timeout_args "# no TIMEOUT") + set(timeout_msg "none") endif() file(WRITE ${script_filename} "message(STATUS \"downloading... src='${remote}' - dst='${local}'\") + dst='${local}' + timeout='${timeout_msg}'\") file(DOWNLOAD \"${remote}\" \"${local}\" - TIMEOUT ${timeout} + ${timeout_args} STATUS status LOG log) @@ -694,7 +700,8 @@ function(_ep_add_download_command name) message(FATAL_ERROR "Could not extract tarball filename from url:\n ${url}") endif() set(file ${download_dir}/${fname}) - _ep_write_downloadfile_script("${stamp_dir}/download-${name}.cmake" "${url}" "${file}" "") + get_property(timeout TARGET ${name} PROPERTY _EP_TIMEOUT) + _ep_write_downloadfile_script("${stamp_dir}/download-${name}.cmake" "${url}" "${file}" "${timeout}") set(cmd ${CMAKE_COMMAND} -P ${stamp_dir}/download-${name}.cmake COMMAND) set(comment "Performing download step (download and extract) for '${name}'") diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 428be9e..ea9eb25 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -63,7 +63,7 @@ # Currently this module searches for the following version numbers: # 1.33, 1.33.0, 1.33.1, 1.34, 1.34.0, 1.34.1, 1.35, 1.35.0, 1.35.1, # 1.36, 1.36.0, 1.36.1, 1.37, 1.37.0, 1.38, 1.38.0, 1.39, 1.39.0, -# 1.40, 1.40.0 +# 1.40, 1.40.0, 1.41, 1.41.0 # # NOTE: If you add a new major 1.x version in Boost_ADDITIONAL_VERSIONS you should # add both 1.x and 1.x.0 as shown above. Official Boost include directories @@ -265,6 +265,17 @@ FUNCTION(_Boost_COMPILER_DUMPVERSION _OUTPUT_VERSION) ENDFUNCTION() # +# A convenience function for marking desired components +# as found or not +# +function(_Boost_MARK_COMPONENTS_FOUND _yes_or_no) + foreach(COMPONENT ${Boost_FIND_COMPONENTS}) + string(TOUPPER ${COMPONENT} UPPERCOMPONENT) + set(Boost_${UPPERCOMPONENT}_FOUND ${_yes_or_no} CACHE INTERNAL "Whether the Boost ${COMPONENT} library found" FORCE) + endforeach() +endfunction() + +# # End functions/macros # #------------------------------------------------------------------------------- @@ -286,7 +297,7 @@ else(Boost_FIND_VERSION_EXACT) # The user has not requested an exact version. Among known # versions, find those that are acceptable to the user request. set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS} - "1.40.0" "1.40" "1.39.0" "1.39" "1.38.0" "1.38" "1.37.0" "1.37" + "1.41.0" "1.41" "1.40.0" "1.40" "1.39.0" "1.39" "1.38.0" "1.38" "1.37.0" "1.37" "1.36.1" "1.36.0" "1.36" "1.35.1" "1.35.0" "1.35" "1.34.1" "1.34.0" "1.34" "1.33.1" "1.33.0" "1.33") set(_boost_TEST_VERSIONS) @@ -760,6 +771,10 @@ ELSE (_boost_IN_CACHE) endif( Boost_MINOR_VERSION LESS "${Boost_FIND_VERSION_MINOR}" ) endif( Boost_MAJOR_VERSION LESS "${Boost_FIND_VERSION_MAJOR}" ) + if (NOT Boost_FOUND) + _Boost_MARK_COMPONENTS_FOUND(OFF) + endif() + if (Boost_FOUND AND Boost_FIND_VERSION_EXACT) # If the user requested an exact version of Boost, check # that. We already know that the Boost version we have is >= the @@ -773,10 +788,12 @@ ELSE (_boost_IN_CACHE) # We'll set Boost_FOUND true again if we have an exact version match. set(Boost_FOUND FALSE) + _Boost_MARK_COMPONENTS_FOUND(OFF) if(Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" ) if(Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" ) if(Boost_SUBMINOR_VERSION EQUAL "${Boost_FIND_VERSION_PATCH}" ) set( Boost_FOUND TRUE ) + _Boost_MARK_COMPONENTS_FOUND(ON) endif(Boost_SUBMINOR_VERSION EQUAL "${Boost_FIND_VERSION_PATCH}" ) endif( Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" ) endif( Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" ) @@ -796,19 +813,18 @@ ELSE (_boost_IN_CACHE) set(Boost_ERROR_REASON "${Boost_ERROR_REASON}.") endif (NOT Boost_FOUND) - if (Boost_FOUND) - set(_boost_CHECKED_COMPONENT FALSE) - set(_Boost_MISSING_COMPONENTS) - foreach(COMPONENT ${Boost_FIND_COMPONENTS}) - string(TOUPPER ${COMPONENT} COMPONENT) - set(_boost_CHECKED_COMPONENT TRUE) - if(NOT Boost_${COMPONENT}_FOUND) - string(TOLOWER ${COMPONENT} COMPONENT) - list(APPEND _Boost_MISSING_COMPONENTS ${COMPONENT}) - set( Boost_FOUND FALSE) - endif(NOT Boost_${COMPONENT}_FOUND) - endforeach(COMPONENT) - endif (Boost_FOUND) + # Always check for missing components + set(_boost_CHECKED_COMPONENT FALSE) + set(_Boost_MISSING_COMPONENTS "") + foreach(COMPONENT ${Boost_FIND_COMPONENTS}) + string(TOUPPER ${COMPONENT} COMPONENT) + set(_boost_CHECKED_COMPONENT TRUE) + if(NOT Boost_${COMPONENT}_FOUND) + string(TOLOWER ${COMPONENT} COMPONENT) + list(APPEND _Boost_MISSING_COMPONENTS ${COMPONENT}) + set( Boost_FOUND FALSE) + endif(NOT Boost_${COMPONENT}_FOUND) + endforeach(COMPONENT) if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] Boost_FOUND = ${Boost_FOUND}") @@ -876,9 +892,9 @@ ELSE (_boost_IN_CACHE) IF (Boost_FOUND) IF (NOT Boost_FIND_QUIETLY) MESSAGE(STATUS "Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}") - ENDIF(NOT Boost_FIND_QUIETLY) - IF (NOT Boost_FIND_QUIETLY) - MESSAGE(STATUS "Found the following Boost libraries:") + if(Boost_FIND_COMPONENTS) + message(STATUS "Found the following Boost libraries:") + endif() ENDIF(NOT Boost_FIND_QUIETLY) FOREACH ( COMPONENT ${Boost_FIND_COMPONENTS} ) STRING( TOUPPER ${COMPONENT} UPPERCOMPONENT ) diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 7c28498..9601bc7 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -476,7 +476,7 @@ mark_as_advanced(CUDA_NVCC_EXECUTABLE) if(CUDA_NVCC_EXECUTABLE AND NOT CUDA_VERSION) # Compute the version. - exec_program(${CUDA_NVCC_EXECUTABLE} ARGS "--version" OUTPUT_VARIABLE NVCC_OUT) + execute_process (COMMAND ${CUDA_NVCC_EXECUTABLE} "--version" OUTPUT_VARIABLE NVCC_OUT) string(REGEX REPLACE ".*release ([0-9]+)\\.([0-9]+).*" "\\1" CUDA_VERSION_MAJOR ${NVCC_OUT}) string(REGEX REPLACE ".*release ([0-9]+)\\.([0-9]+).*" "\\2" CUDA_VERSION_MINOR ${NVCC_OUT}) set(CUDA_VERSION "${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR}" CACHE STRING "Version of CUDA as computed from nvcc.") @@ -813,7 +813,11 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files) if(CUDA_HOST_COMPILATION_CPP) set(CUDA_C_OR_CXX CXX) else(CUDA_HOST_COMPILATION_CPP) - set(nvcc_flags ${nvcc_flags} --host-compilation C) + if(CUDA_VERSION VERSION_LESS "3.0") + set(nvcc_flags ${nvcc_flags} --host-compilation C) + else() + message(WARNING "--host-compilation flag is deprecated in CUDA version >= 3.0. Removing --host-compilation C flag" ) + endif() set(CUDA_C_OR_CXX C) endif(CUDA_HOST_COMPILATION_CPP) diff --git a/Modules/FindCUDA/run_nvcc.cmake b/Modules/FindCUDA/run_nvcc.cmake index 4a9a7d4..31bd74e 100644 --- a/Modules/FindCUDA/run_nvcc.cmake +++ b/Modules/FindCUDA/run_nvcc.cmake @@ -150,18 +150,32 @@ cuda_execute_process( COMMAND "${CMAKE_COMMAND}" -E remove "${generated_file}" ) +# For CUDA 2.3 and below, -G -M doesn't work, so remove the -G flag +# for dependency generation and hope for the best. +set(depends_CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS}") +set(CUDA_VERSION @CUDA_VERSION@) +if(CUDA_VERSION VERSION_LESS "3.0") + cmake_policy(PUSH) + # CMake policy 0007 NEW states that empty list elements are not + # ignored. I'm just setting it to avoid the warning that's printed. + cmake_policy(SET CMP0007 NEW) + # Note that this will remove all occurances of -G. + list(REMOVE_ITEM depends_CUDA_NVCC_FLAGS "-G") + cmake_policy(POP) +endif() + # Generate the dependency file cuda_execute_process( "Generating dependency file: ${NVCC_generated_dependency_file}" COMMAND "${CUDA_NVCC_EXECUTABLE}" + -M "${source_file}" - ${CUDA_NVCC_FLAGS} - ${nvcc_flags} + -o "${NVCC_generated_dependency_file}" ${CCBIN} + ${nvcc_flags} ${nvcc_host_compiler_flags} + ${depends_CUDA_NVCC_FLAGS} -DNVCC - -M - -o "${NVCC_generated_dependency_file}" ${CUDA_NVCC_INCLUDE_ARGS} ) @@ -209,12 +223,12 @@ cuda_execute_process( "Generating ${generated_file}" COMMAND "${CUDA_NVCC_EXECUTABLE}" "${source_file}" - ${CUDA_NVCC_FLAGS} - ${nvcc_flags} + ${format_flag} -o "${generated_file}" ${CCBIN} + ${nvcc_flags} ${nvcc_host_compiler_flags} + ${CUDA_NVCC_FLAGS} -DNVCC - ${format_flag} -o "${generated_file}" ${CUDA_NVCC_INCLUDE_ARGS} ) diff --git a/Modules/FindCURL.cmake b/Modules/FindCURL.cmake index 3d8ae3a..f301b24 100644 --- a/Modules/FindCURL.cmake +++ b/Modules/FindCURL.cmake @@ -23,7 +23,13 @@ FIND_PATH(CURL_INCLUDE_DIR NAMES curl/curl.h) MARK_AS_ADVANCED(CURL_INCLUDE_DIR) # Look for the library. -FIND_LIBRARY(CURL_LIBRARY NAMES curl) +FIND_LIBRARY(CURL_LIBRARY NAMES + curl + # Windows MSVC prebuilts: + curllib + libcurl_imp + curllib_static +) MARK_AS_ADVANCED(CURL_LIBRARY) # handle the QUIETLY and REQUIRED arguments and set CURL_FOUND to TRUE if @@ -34,7 +40,4 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(CURL DEFAULT_MSG CURL_LIBRARY CURL_INCLUDE_DIR IF(CURL_FOUND) SET(CURL_LIBRARIES ${CURL_LIBRARY}) SET(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIR}) -ELSE(CURL_FOUND) - SET(CURL_LIBRARIES) - SET(CURL_INCLUDE_DIRS) ENDIF(CURL_FOUND) diff --git a/Modules/FindDCMTK.cmake b/Modules/FindDCMTK.cmake index 335826b..2c3fce5 100644 --- a/Modules/FindDCMTK.cmake +++ b/Modules/FindDCMTK.cmake @@ -1,4 +1,4 @@ -# - find DCMTK libraries +# - find DCMTK libraries and applications # # DCMTK_INCLUDE_DIR - Directories to include to use DCMTK @@ -9,10 +9,11 @@ # DCMTK_DIR can be used to make it simpler to find the various include # directories and compiled libraries if you've just compiled it in the # source tree. Just set it to the root of the tree where you extracted -# the source. +# the source (default to /usr/include/dcmtk/) #============================================================================= # Copyright 2004-2009 Kitware, Inc. +# Copyright 2009 Mathieu Malaterre <mathieu.malaterre@gmail.com> # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -26,14 +27,26 @@ # # Written for VXL by Amitha Perera. +# Upgraded for GDCM by Mathieu Malaterre. # +IF( NOT DCMTK_FOUND ) + SET( DCMTK_DIR "/usr/include/dcmtk/" + CACHE PATH "Root of DCMTK source tree (optional)." ) + MARK_AS_ADVANCED( DCMTK_DIR ) +ENDIF( NOT DCMTK_FOUND ) + + FIND_PATH( DCMTK_config_INCLUDE_DIR osconfig.h - ${DCMTK_DIR}/config/include ${DCMTK_DIR}/include + ${DCMTK_DIR}/config/include + ${DCMTK_DIR}/config + ${DCMTK_DIR}/include ) FIND_PATH( DCMTK_ofstd_INCLUDE_DIR ofstdinc.h - ${DCMTK_DIR}/ofstd/include ${DCMTK_DIR}/include/ofstd + ${DCMTK_DIR}/ofstd/include + ${DCMTK_DIR}/ofstd + ${DCMTK_DIR}/include/ofstd ) FIND_LIBRARY( DCMTK_ofstd_LIBRARY ofstd @@ -47,8 +60,9 @@ FIND_LIBRARY( DCMTK_ofstd_LIBRARY ofstd FIND_PATH( DCMTK_dcmdata_INCLUDE_DIR dctypes.h - ${DCMTK_DIR}/dcmdata/include ${DCMTK_DIR}/include/dcmdata + ${DCMTK_DIR}/dcmdata + ${DCMTK_DIR}/dcmdata/include ) FIND_LIBRARY( DCMTK_dcmdata_LIBRARY dcmdata @@ -63,6 +77,7 @@ FIND_LIBRARY( DCMTK_dcmdata_LIBRARY dcmdata FIND_PATH( DCMTK_dcmimgle_INCLUDE_DIR dcmimage.h ${DCMTK_DIR}/dcmimgle/include + ${DCMTK_DIR}/dcmimgle ${DCMTK_DIR}/include/dcmimgle ) @@ -75,17 +90,18 @@ FIND_LIBRARY( DCMTK_dcmimgle_LIBRARY dcmimgle ${DCMTK_DIR}/lib ) +# MM: I could not find this library on debian system / dcmtk 3.5.4 FIND_LIBRARY(DCMTK_imagedb_LIBRARY imagedb -${DCMTK_DIR}/imagectn/libsrc/Release -${DCMTK_DIR}/imagectn/libsrc/ -${DCMTK_DIR}/imagectn/libsrc/Debug -) + ${DCMTK_DIR}/imagectn/libsrc/Release + ${DCMTK_DIR}/imagectn/libsrc/ + ${DCMTK_DIR}/imagectn/libsrc/Debug + ) FIND_LIBRARY(DCMTK_dcmnet_LIBRARY dcmnet -${DCMTK_DIR}/dcmnet/libsrc/Release -${DCMTK_DIR}/dcmnet/libsrc/Debug -${DCMTK_DIR}/dcmnet/libsrc/ -) + ${DCMTK_DIR}/dcmnet/libsrc/Release + ${DCMTK_DIR}/dcmnet/libsrc/Debug + ${DCMTK_DIR}/dcmnet/libsrc/ + ) IF( DCMTK_config_INCLUDE_DIR @@ -137,7 +153,30 @@ ENDIF( DCMTK_config_INCLUDE_DIR AND DCMTK_dcmimgle_INCLUDE_DIR AND DCMTK_dcmimgle_LIBRARY ) -IF( NOT DCMTK_FOUND ) - SET( DCMTK_DIR "" CACHE PATH "Root of DCMTK source tree (optional)." ) - MARK_AS_ADVANCED( DCMTK_DIR ) -ENDIF( NOT DCMTK_FOUND ) +FIND_PROGRAM(DCMTK_DCMDUMP_EXECUTABLE dcmdump + ${DCMTK_DIR}/bin + ) + +FIND_PROGRAM(DCMTK_DCMDJPEG_EXECUTABLE dcmdjpeg + ${DCMTK_DIR}/bin + ) + +FIND_PROGRAM(DCMTK_DCMDRLE_EXECUTABLE dcmdrle + ${DCMTK_DIR}/bin + ) + +MARK_AS_ADVANCED( + DCMTK_DCMDUMP_EXECUTABLE + DCMTK_DCMDJPEG_EXECUTABLE + DCMTK_DCMDRLE_EXECUTABLE + DCMTK_config_INCLUDE_DIR + DCMTK_dcmdata_INCLUDE_DIR + DCMTK_dcmdata_LIBRARY + DCMTK_dcmimgle_INCLUDE_DIR + DCMTK_dcmimgle_LIBRARY + DCMTK_imagedb_LIBRARY + DCMTK_dcmnet_LIBRARY + DCMTK_ofstd_INCLUDE_DIR + DCMTK_ofstd_LIBRARY + ) + diff --git a/Modules/FindGTK2.cmake b/Modules/FindGTK2.cmake index 39beae9..c871417 100644 --- a/Modules/FindGTK2.cmake +++ b/Modules/FindGTK2.cmake @@ -64,6 +64,9 @@ # (To distributed this file outside of CMake, substitute the full # License text for the above reference.) +# Version 0.8 (1/4/2010) +# * Get module working under MacOSX fink by adding /sw/include, /sw/lib +# to PATHS and the gobject library # Version 0.7 (3/22/09) # * Checked into CMake CVS # * Added versioning support @@ -167,6 +170,8 @@ function(_GTK2_FIND_INCLUDE_DIR _var _hdr) /opt/gnome/lib /opt/openwin/include /usr/openwin/lib + /sw/include + /sw/lib $ENV{GTKMM_BASEPATH}/include $ENV{GTKMM_BASEPATH}/lib [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]/include @@ -277,6 +282,7 @@ function(_GTK2_FIND_LIBRARY _var _lib _expand_vc _append_version) /opt/gnome/lib64 /usr/openwin/lib /usr/openwin/lib64 + /sw/lib $ENV{GTKMM_BASEPATH}/lib [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]/lib [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]/lib @@ -386,10 +392,12 @@ endif() foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) if(_GTK2_component STREQUAL "gtk") - _GTK2_FIND_INCLUDE_DIR(GTK2_GLIB_INCLUDE_DIR glib.h) _GTK2_FIND_INCLUDE_DIR(GTK2_GLIBCONFIG_INCLUDE_DIR glibconfig.h) _GTK2_FIND_LIBRARY (GTK2_GLIB_LIBRARY glib false true) + + _GTK2_FIND_INCLUDE_DIR(GTK2_GOBJECT_INCLUDE_DIR gobject/gobject.h) + _GTK2_FIND_LIBRARY (GTK2_GOBJECT_LIBRARY gobject false true) _GTK2_FIND_INCLUDE_DIR(GTK2_GDK_INCLUDE_DIR gdk/gdk.h) _GTK2_FIND_INCLUDE_DIR(GTK2_GDKCONFIG_INCLUDE_DIR gdkconfig.h) diff --git a/Modules/FindGTest.cmake b/Modules/FindGTest.cmake index 4960b38..1bcd469 100644 --- a/Modules/FindGTest.cmake +++ b/Modules/FindGTest.cmake @@ -15,16 +15,17 @@ # # Accepts the following variables as input: # -# GTEST_ROOT - (as CMake or env. variable) +# GTEST_ROOT - (as a CMake or environment variable) # The root directory of the gtest install prefix # -# GTEST_MSVC_SEARCH - If on MSVC, enables searching the build tree of -# GTest if set to MD or MT (defaults: MD) +# GTEST_MSVC_SEARCH - If compiling with MSVC, this variable can be set to +# "MD" or "MT" to enable searching a GTest build tree +# (defaults: "MD") # #----------------------- # Example Usage: # -# enable_testing(true) +# enable_testing() # find_package(GTest REQUIRED) # include_directories(${GTEST_INCLUDE_DIRS}) # @@ -36,8 +37,10 @@ #----------------------- # # If you would like each Google test to show up in CTest as -# a test you may use the following macro. NOTE: It WILL slow -# down your tests, so be warned. +# a test you may use the following macro. +# NOTE: It will slow down your tests by running an executable +# for each test and test fixture. You will also have to rerun +# CMake after adding or removing tests or test fixtures. # # GTEST_ADD_TESTS(executable extra_args ARGN) # executable = The path to the test executable @@ -76,7 +79,7 @@ function(GTEST_ADD_TESTS executable extra_args) file(READ "${source}" contents) string(REGEX MATCHALL "TEST_?F?\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents}) foreach(hit ${found_tests}) - string(REGEX REPLACE ".*\\(([A-Za-z_0-9]+)[, ]*([A-Za-z_0-9]+)\\).*" "\\1.\\2" test_name ${hit}) + string(REGEX REPLACE ".*\\( *([A-Za-z_0-9]+), *([A-Za-z_0-9]+) *\\).*" "\\1.\\2" test_name ${hit}) add_test(${test_name} ${executable} --gtest_filter=${test_name} ${extra_args}) endforeach() endforeach() diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index d2092ef..a84e677 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -28,7 +28,8 @@ # with the HDF5 distribution that may be useful for regression testing. # # This module will define the following variables: -# HDF5_INCLUDE_DIR - Location of the hdf5 includes +# HDF5_INCLUDE_DIRS - Location of the hdf5 includes +# HDF5_INCLUDE_DIR - Location of the hdf5 includes (deprecated) # HDF5_DEFINITIONS - Required compiler definitions for HDF5 # HDF5_C_LIBRARIES - Required libraries for the HDF5 C bindings. # HDF5_CXX_LIBRARIES - Required libraries for the HDF5 C++ bindings @@ -106,7 +107,7 @@ endmacro() # Parse a compile line for definitions, includes, library paths, and libraries. macro( _HDF5_parse_compile_line - compile_line + compile_line_var include_paths definitions library_paths @@ -114,7 +115,7 @@ macro( _HDF5_parse_compile_line # Match the include paths string( REGEX MATCHALL "-I([^\" ]+)" include_path_flags - "${compile_line}" + "${${compile_line_var}}" ) foreach( IPATH ${include_path_flags} ) string( REGEX REPLACE "^-I" "" IPATH ${IPATH} ) @@ -123,14 +124,14 @@ macro( _HDF5_parse_compile_line endforeach() # Match the definitions - string( REGEX MATCHALL "-D[^ ]*" definition_flags "${compile_line}" ) + string( REGEX MATCHALL "-D[^ ]*" definition_flags "${${compile_line_var}}" ) foreach( DEF ${definition_flags} ) list( APPEND ${definitions} ${DEF} ) endforeach() # Match the library paths string( REGEX MATCHALL "-L([^\" ]+|\"[^\"]+\")" library_path_flags - "${compile_line}" + "${${compile_line_var}}" ) foreach( LPATH ${library_path_flags} ) @@ -143,7 +144,7 @@ macro( _HDF5_parse_compile_line # match only -l's preceded by a space or comma # this is to exclude directory names like xxx-linux/ string( REGEX MATCHALL "[, ]-l([^\", ]+)" library_name_flags - "${compile_line}" ) + "${${compile_line_var}}" ) # strip the -l from all of the library flags and add to the search list foreach( LIB ${library_name_flags} ) string( REGEX REPLACE "^[, ]-l" "" LIB ${LIB} ) @@ -151,7 +152,7 @@ macro( _HDF5_parse_compile_line endforeach() endmacro() -if( HDF5_INCLUDE_DIR AND HDF5_LIBRARIES ) +if( HDF5_INCLUDE_DIRS AND HDF5_LIBRARIES ) # Do nothing: we already have HDF5_INCLUDE_PATH and HDF5_LIBRARIES in the # cache, it would be a shame to override them else() @@ -179,7 +180,7 @@ else() foreach( LANGUAGE ${HDF5_LANGUAGE_BINDINGS} ) if( HDF5_${LANGUAGE}_COMPILE_LINE ) - _HDF5_parse_compile_line( ${HDF5_${LANGUAGE}_COMPILE_LINE} + _HDF5_parse_compile_line( HDF5_${LANGUAGE}_COMPILE_LINE HDF5_${LANGUAGE}_INCLUDE_FLAGS HDF5_${LANGUAGE}_DEFINITIONS HDF5_${LANGUAGE}_LIBRARY_DIRS @@ -209,7 +210,7 @@ else() Include ) mark_as_advanced( HDF5_${LANGUAGE}_INCLUDE_DIR ) - list( APPEND HDF5_INCLUDE_DIR ${HDF5_${LANGUAGE}_INCLUDE_DIR} ) + list( APPEND HDF5_INCLUDE_DIRS ${HDF5_${LANGUAGE}_INCLUDE_DIR} ) set( HDF5_${LANGUAGE}_LIBRARY_NAMES ${HDF5_${LANGUAGE}_LIBRARY_NAMES_INIT} @@ -266,8 +267,8 @@ else() # We may have picked up some duplicates in various lists during the above # process for the language bindings (both the C and C++ bindings depend on # libz for example). Remove the duplicates. - if( HDF5_INCLUDE_DIR ) - list( REMOVE_DUPLICATES HDF5_INCLUDE_DIR ) + if( HDF5_INCLUDE_DIRS ) + list( REMOVE_DUPLICATES HDF5_INCLUDE_DIRS ) endif() if( HDF5_LIBRARIES_DEBUG ) list( REMOVE_DUPLICATES HDF5_LIBRARIES_DEBUG ) @@ -292,16 +293,16 @@ else() # If the HDF5 include directory was found, open H5pubconf.h to determine if # HDF5 was compiled with parallel IO support set( HDF5_IS_PARALLEL FALSE ) - if( HDF5_INCLUDE_DIR ) - if( EXISTS "${HDF5_INCLUDE_DIR}/h5pubconf.h" ) - file( STRINGS "${HDF5_INCLUDE_DIR}/H5pubconf.h" + foreach( _dir HDF5_INCLUDE_DIRS ) + if( EXISTS "${_dir}/H5pubconf.h" ) + file( STRINGS "${_dir}/H5pubconf.h" HDF5_HAVE_PARALLEL_DEFINE REGEX "HAVE_PARALLEL 1" ) if( HDF5_HAVE_PARALLEL_DEFINE ) set( HDF5_IS_PARALLEL TRUE ) endif() endif() - endif() + endforeach() set( HDF5_IS_PARALLEL ${HDF5_IS_PARALLEL} CACHE BOOL "HDF5 library compiled with parallel IO support" ) mark_as_advanced( HDF5_IS_PARALLEL ) @@ -310,14 +311,18 @@ endif() find_package_handle_standard_args( HDF5 DEFAULT_MSG HDF5_LIBRARIES - HDF5_INCLUDE_DIR + HDF5_INCLUDE_DIRS ) mark_as_advanced( - HDF5_INCLUDE_DIR + HDF5_INCLUDE_DIRS HDF5_LIBRARIES HDF5_DEFINTIONS HDF5_LIBRARY_DIRS HDF5_C_COMPILER_EXECUTABLE HDF5_CXX_COMPILER_EXECUTABLE ) +# For backwards compatibility we set HDF5_INCLUDE_DIR to the value of +# HDF5_INCLUDE_DIRS +set( HDF5_INCLUDE_DIR "${HDF5_INCLUDE_DIRS}" ) + diff --git a/Modules/FindJNI.cmake b/Modules/FindJNI.cmake index 47f96e0..a61c683 100644 --- a/Modules/FindJNI.cmake +++ b/Modules/FindJNI.cmake @@ -5,6 +5,7 @@ # # JNI_INCLUDE_DIRS = the include dirs to use # JNI_LIBRARIES = the libraries to use +# JNI_FOUND = TRUE if JNI headers and libraries were found. # JAVA_AWT_LIBRARY = the path to the jawt library # JAVA_JVM_LIBRARY = the path to the jvm library # JAVA_INCLUDE_PATH = the include path to jni.h @@ -206,6 +207,10 @@ FIND_PATH(JAVA_AWT_INCLUDE_PATH jawt.h ${JAVA_INCLUDE_PATH} ) +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(JNI DEFAULT_MSG JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY + JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH) + MARK_AS_ADVANCED( JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY diff --git a/Modules/FindJava.cmake b/Modules/FindJava.cmake index 4fddfee..7eb6d900c 100644 --- a/Modules/FindJava.cmake +++ b/Modules/FindJava.cmake @@ -3,13 +3,34 @@ # include files and libraries are. This code sets the following # variables: # -# JAVA_RUNTIME = the full path to the Java runtime -# JAVA_COMPILE = the full path to the Java compiler -# JAVA_ARCHIVE = the full path to the Java archiver +# Java_JAVA_EXECUTABLE = the full path to the Java runtime +# Java_JAVAC_EXECUTABLE = the full path to the Java compiler +# Java_JAR_EXECUTABLE = the full path to the Java archiver +# Java_VERSION_STRING = Version of the package found (java version), eg. 1.6.0_12 +# Java_VERSION_MAJOR = The major version of the package found. +# Java_VERSION_MINOR = The minor version of the package found. +# Java_VERSION_PATCH = The patch version of the package found. +# Java_VERSION_TWEAK = The tweak version of the package found (after '_') +# Java_VERSION = This is set to: $major.$minor.$patch(.$tweak) # +# NOTE: ${Java_VERSION} and ${Java_VERSION_STRING} are not guaranteed to be +# identical. For example some java version may return: +# Java_VERSION_STRING = 1.5.0_17 +# and +# Java_VERSION = 1.5.0.17 +# +# another example is the Java OEM, with: +# Java_VERSION_STRING = 1.6.0-oem +# and +# Java_VERSION = 1.6.0 +# +# NOTE: At the moment this script will look for javac and jar component, +# which means it will fail if javac or jar is not found.:w +# See Bug #9840 #============================================================================= # Copyright 2002-2009 Kitware, Inc. +# Copyright 2009 Mathieu Malaterre <mathieu.malaterre@gmail.com> # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -21,20 +42,23 @@ # (To distributed this file outside of CMake, substitute the full # License text for the above reference.) -SET(JAVA_BIN_PATH - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\2.0;JavaHome]/bin" - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.9;JavaHome]/bin" - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.8;JavaHome]/bin" - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.7;JavaHome]/bin" - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.6;JavaHome]/bin" - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.5;JavaHome]/bin" - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/bin" - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/bin" +# The HINTS option should only be used for values computed from the system. +SET(_JAVA_HINTS + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\2.0;JavaHome]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.9;JavaHome]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.8;JavaHome]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.7;JavaHome]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.6;JavaHome]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.5;JavaHome]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/bin" $ENV{JAVA_HOME}/bin - /usr/bin + ) +# Hard-coded guesses should still go in PATHS. This ensures that the user +# environment can always override hard guesses. +SET(_JAVA_PATHS /usr/lib/java/bin /usr/share/java/bin - /usr/local/bin /usr/local/java/bin /usr/local/java/share/bin /usr/java/j2sdk1.4.2_04 @@ -43,23 +67,102 @@ SET(JAVA_BIN_PATH /usr/lib/j2sdk1.5-sun/bin /opt/sun-jdk-1.5.0.04/bin ) -FIND_PROGRAM(JAVA_RUNTIME +FIND_PROGRAM(Java_JAVA_EXECUTABLE NAMES java - PATHS ${JAVA_BIN_PATH} + HINTS ${_JAVA_HINTS} + PATHS ${_JAVA_PATHS} ) -FIND_PROGRAM(JAVA_ARCHIVE +IF(Java_JAVA_EXECUTABLE) + set(_java_version_acceptable TRUE) + EXECUTE_PROCESS(COMMAND ${Java_JAVA_EXECUTABLE} -version + RESULT_VARIABLE res + OUTPUT_VARIABLE var + ERROR_VARIABLE var # sun-java output to stderr + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_STRIP_TRAILING_WHITESPACE) + IF( res ) + MESSAGE( FATAL_ERROR "Error executing java -version" ) + ELSE() + # extract major/minor version and patch level from "java -version" output + # Tested on linux using + # 1. Sun / Sun OEM + # 2. OpenJDK 1.6 + # 3. GCJ 1.5 + # 4. Kaffe 1.4.2 + IF(var MATCHES "java version \"[0-9]+\\.[0-9]+\\.[0-9_]+[oem-]*\".*") + # This is most likely Sun / OpenJDK, or maybe GCJ-java compat layer + STRING( REGEX REPLACE ".* version \"([0-9]+\\.[0-9]+\\.[0-9_]+)[oem-]*\".*" + "\\1" Java_VERSION_STRING "${var}" ) + ELSEIF(var MATCHES "java full version \"kaffe-[0-9]+\\.[0-9]+\\.[0-9_]+\".*") + # Kaffe style + STRING( REGEX REPLACE "java full version \"kaffe-([0-9]+\\.[0-9]+\\.[0-9_]+).*" + "\\1" Java_VERSION_STRING "${var}" ) + ELSE() + IF(NOT Java_FIND_QUIETLY) + message(WARNING "regex not supported: ${var}. Please report") + set(_java_version_acceptable FALSE) + ENDIF(NOT Java_FIND_QUIETLY) + ENDIF() + STRING( REGEX REPLACE "([0-9]+).*" "\\1" Java_VERSION_MAJOR "${Java_VERSION_STRING}" ) + STRING( REGEX REPLACE "[0-9]+\\.([0-9]+).*" "\\1" Java_VERSION_MINOR "${Java_VERSION_STRING}" ) + STRING( REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" Java_VERSION_PATCH "${Java_VERSION_STRING}" ) + # warning tweak version can be empty: + STRING( REGEX REPLACE "[0-9]+\\.[0-9]+\\.[0-9]+\\_?([0-9]*)$" "\\1" Java_VERSION_TWEAK "${Java_VERSION_STRING}" ) + if( Java_VERSION_TWEAK STREQUAL "" ) # check case where tweak is not defined + set(Java_VERSION ${Java_VERSION_MAJOR}.${Java_VERSION_MINOR}.${Java_VERSION_PATCH}) + else( ) + set(Java_VERSION ${Java_VERSION_MAJOR}.${Java_VERSION_MINOR}.${Java_VERSION_PATCH}.${Java_VERSION_TWEAK}) + endif( ) + # display info + #MESSAGE( STATUS "Java version ${Java_VERSION_STRING} configured successfully!" ) # keep me, used for debug + IF(NOT Java_FIND_QUIETLY) + MESSAGE( STATUS "Java version ${Java_VERSION} configured successfully!" ) + ENDIF(NOT Java_FIND_QUIETLY) + ENDIF() + + # check version if requested: + if( Java_FIND_VERSION ) + if("${Java_VERSION}" VERSION_LESS "${Java_FIND_VERSION}") + set(_java_version_acceptable FALSE) + endif("${Java_VERSION}" VERSION_LESS "${Java_FIND_VERSION}") + if( Java_FIND_VERSION_EXACT ) + if("${Java_VERSION}" VERSION_GREATER "${Java_FIND_VERSION}") + set(_java_version_acceptable FALSE) + endif("${Java_VERSION}" VERSION_GREATER "${Java_FIND_VERSION}") + endif( Java_FIND_VERSION_EXACT ) + endif( Java_FIND_VERSION ) +ENDIF(Java_JAVA_EXECUTABLE) + + +FIND_PROGRAM(Java_JAR_EXECUTABLE NAMES jar - PATHS ${JAVA_BIN_PATH} + HINTS ${_JAVA_HINTS} + PATHS ${_JAVA_PATHS} ) -FIND_PROGRAM(JAVA_COMPILE +FIND_PROGRAM(Java_JAVAC_EXECUTABLE NAMES javac - PATHS ${JAVA_BIN_PATH} + HINTS ${_JAVA_HINTS} + PATHS ${_JAVA_PATHS} ) -MARK_AS_ADVANCED( -JAVA_RUNTIME -JAVA_ARCHIVE -JAVA_COMPILE +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Java DEFAULT_MSG + Java_JAVA_EXECUTABLE + Java_JAR_EXECUTABLE + Java_JAVAC_EXECUTABLE + _java_version_acceptable ) + +MARK_AS_ADVANCED( + Java_JAVA_EXECUTABLE + Java_JAR_EXECUTABLE + Java_JAVAC_EXECUTABLE + ) + +# LEGACY +SET(JAVA_RUNTIME ${Java_JAVA_EXECUTABLE}) +SET(JAVA_ARCHIVE ${Java_JAR_EXECUTABLE}) +SET(JAVA_COMPILE ${Java_JAVAC_EXECUTABLE}) + diff --git a/Modules/FindLibXml2.cmake b/Modules/FindLibXml2.cmake index fc4c23d..9139aad 100644 --- a/Modules/FindLibXml2.cmake +++ b/Modules/FindLibXml2.cmake @@ -1,4 +1,4 @@ -# - Try to find LibXml2 +# - Try to find the LibXml2 xml processing library # Once done this will define # # LIBXML2_FOUND - System has LibXml2 @@ -21,20 +21,13 @@ # (To distributed this file outside of CMake, substitute the full # License text for the above reference.) -IF (LIBXML2_INCLUDE_DIR AND LIBXML2_LIBRARIES) - # in cache already - SET(LibXml2_FIND_QUIETLY TRUE) -ENDIF (LIBXML2_INCLUDE_DIR AND LIBXML2_LIBRARIES) +# use pkg-config to get the directories and then use these values +# in the FIND_PATH() and FIND_LIBRARY() calls +FIND_PACKAGE(PkgConfig) +PKG_CHECK_MODULES(PC_LIBXML libxml-2.0) +SET(LIBXML2_DEFINITIONS ${PC_LIBXML_CFLAGS_OTHER}) -IF (NOT WIN32) - # use pkg-config to get the directories and then use these values - # in the FIND_PATH() and FIND_LIBRARY() calls - FIND_PACKAGE(PkgConfig) - PKG_CHECK_MODULES(PC_LIBXML libxml-2.0) - SET(LIBXML2_DEFINITIONS ${PC_LIBXML_CFLAGS_OTHER}) -ENDIF (NOT WIN32) - -FIND_PATH(LIBXML2_INCLUDE_DIR libxml/xpath.h +FIND_PATH(LIBXML2_INCLUDE_DIR NAMES libxml/xpath.h HINTS ${PC_LIBXML_INCLUDEDIR} ${PC_LIBXML_INCLUDE_DIRS} diff --git a/Modules/FindLibXslt.cmake b/Modules/FindLibXslt.cmake index 5c3953a..d16d1ff 100644 --- a/Modules/FindLibXslt.cmake +++ b/Modules/FindLibXslt.cmake @@ -1,4 +1,4 @@ -# - Try to find LibXslt +# - Try to find the LibXslt library # Once done this will define # # LIBXSLT_FOUND - system has LibXslt @@ -20,26 +20,23 @@ # (To distributed this file outside of CMake, substitute the full # License text for the above reference.) -IF (LIBXSLT_INCLUDE_DIR AND LIBXSLT_LIBRARIES) - # in cache already - SET(LibXslt_FIND_QUIETLY TRUE) -ENDIF (LIBXSLT_INCLUDE_DIR AND LIBXSLT_LIBRARIES) - -IF (NOT WIN32) - # use pkg-config to get the directories and then use these values - # in the FIND_PATH() and FIND_LIBRARY() calls - INCLUDE(UsePkgConfig) - PKGCONFIG(libxslt _LibXsltIncDir _LibXsltLinkDir _LibXsltLinkFlags _LibXsltCflags) - SET(LIBXSLT_DEFINITIONS ${_LibXsltCflags}) -ENDIF (NOT WIN32) - -FIND_PATH(LIBXSLT_INCLUDE_DIR libxslt/xslt.h - ${_LibXsltIncDir} +# use pkg-config to get the directories and then use these values +# in the FIND_PATH() and FIND_LIBRARY() calls +FIND_PACKAGE(PkgConfig) +PKG_CHECK_MODULES(PC_LIBXSLT libxslt) +SET(LIBXSLT_DEFINITIONS ${PC_LIBXSLT_CFLAGS_OTHER}) + + +FIND_PATH(LIBXSLT_INCLUDE_DIR NAMES libxslt/xslt.h + HINTS + ${PC_LIBXSLT_INCLUDEDIR} + ${PC_LIBXSLT_INCLUDE_DIRS} ) FIND_LIBRARY(LIBXSLT_LIBRARIES NAMES xslt libxslt - PATHS - ${_LibXsltLinkDir} + HINTS + ${PC_LIBXSLT_LIBDIR} + ${PC_LIBXSLT_LIBRARY_DIRS} ) INCLUDE(FindPackageHandleStandardArgs) diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index e945ec5..094f9e6 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -72,7 +72,7 @@ # Microsoft HPC SDK is automatically added to the system path # Argonne National Labs MPICH2 sets a registry key that we can use. -set(MPI_PACKAGE_DIR +set(_MPI_PACKAGE_DIR mpi mpich openmpi @@ -83,15 +83,15 @@ set(MPI_PACKAGE_DIR "Microsoft Compute Cluster Pack" ) -set(MPI_PREFIX_PATH) +set(_MPI_PREFIX_PATH) if(WIN32) - list(APPEND MPI_PREFIX_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH\\SMPD;binary]/..") + list(APPEND _MPI_PREFIX_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH\\SMPD;binary]/..") endif() foreach(SystemPrefixDir ${CMAKE_SYSTEM_PREFIX_PATH}) - foreach(MpiPackageDir ${MPI_PREFIX_PATH}) + foreach(MpiPackageDir ${_MPI_PREFIX_PATH}) if(EXISTS ${SystemPrefixDir}/${MpiPackageDir}) - list(APPEND MPI_PREFIX_PATH "${SystemPrefixDir}/${MpiPackageDir}") + list(APPEND _MPI_PREFIX_PATH "${SystemPrefixDir}/${MpiPackageDir}") endif() endforeach(MpiPackageDir) endforeach(SystemPrefixDir) @@ -99,21 +99,21 @@ endforeach(SystemPrefixDir) # Most mpi distros have some form of mpiexec which gives us something we can reliably look for. find_program(MPIEXEC NAMES mpiexec mpirun lamexec - PATHS ${MPI_PREFIX_PATH} + PATHS ${_MPI_PREFIX_PATH} PATH_SUFFIXES bin DOC "Executable for running MPI programs." ) # call get_filename_component twice to remove mpiexec and the directory it exists in (typically bin). # This gives us a fairly reliable base directory to search for /bin /lib and /include from. -get_filename_component(MPI_BASE_DIR "${MPIEXEC}" PATH) -get_filename_component(MPI_BASE_DIR "${MPI_BASE_DIR}" PATH) +get_filename_component(_MPI_BASE_DIR "${MPIEXEC}" PATH) +get_filename_component(_MPI_BASE_DIR "${_MPI_BASE_DIR}" PATH) # If there is an mpi compiler find it and interogate (farther below) it for the include -# and lib dirs otherwise we will continue to search from ${MPI_BASE_DIR}. +# and lib dirs otherwise we will continue to search from ${_MPI_BASE_DIR}. find_program(MPI_COMPILER NAMES mpic++ mpicxx mpiCC mpicc - HINTS "${MPI_BASE_DIR}" + HINTS "${_MPI_BASE_DIR}" PATH_SUFFIXES bin DOC "MPI compiler. Used only to detect MPI compilation flags.") mark_as_advanced(MPI_COMPILER) @@ -222,7 +222,7 @@ elseif (MPI_COMPILE_CMDLINE) # If all else fails, just search for mpi.h in the normal include # paths. find_path(MPI_INCLUDE_PATH mpi.h - HINTS ${MPI_BASE_DIR} ${MPI_PREFIX_PATH} + HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH} PATH_SUFFIXES include ) set(MPI_INCLUDE_PATH_WORK ${MPI_INCLUDE_PATH}) @@ -304,7 +304,7 @@ elseif (MPI_COMPILE_CMDLINE) else (MPI_COMPILE_CMDLINE) # No MPI compiler to interogate so attempt to find everything with find functions. find_path(MPI_INCLUDE_PATH mpi.h - HINTS ${MPI_BASE_DIR} ${MPI_PREFIX_PATH} + HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH} PATH_SUFFIXES include ) @@ -317,13 +317,13 @@ else (MPI_COMPILE_CMDLINE) find_library(MPI_LIBRARY NAMES mpi mpich msmpi - HINTS ${MPI_BASE_DIR} ${MPI_PREFIX_PATH} + HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH} PATH_SUFFIXES lib lib/${MS_MPI_ARCH_DIR} Lib Lib/${MS_MPI_ARCH_DIR} ) find_library(MPI_EXTRA_LIBRARY NAMES mpi++ - HINTS ${MPI_BASE_DIR} ${MPI_PREFIX_PATH} + HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH} PATH_SUFFIXES lib DOC "Extra MPI libraries to link against.") @@ -358,6 +358,6 @@ mark_as_advanced(MPI_INCLUDE_PATH MPI_COMPILE_FLAGS MPI_LINK_FLAGS MPI_LIBRARY MPI_EXTRA_LIBRARY) # unset to cleanup namespace -unset(MPI_PACKAGE_DIR) -unset(MPI_PREFIX_PATH) -unset(MPI_BASE_DIR) +unset(_MPI_PACKAGE_DIR) +unset(_MPI_PREFIX_PATH) +unset(_MPI_BASE_DIR) diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index 95b23e1..b056020 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -20,79 +20,86 @@ # (To distributed this file outside of CMake, substitute the full # License text for the above reference.) -IF(OPENSSL_LIBRARIES) - SET(OpenSSL_FIND_QUIETLY TRUE) -ENDIF(OPENSSL_LIBRARIES) - -IF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE) - SET(LIB_FOUND 1) -ENDIF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE) - # http://www.slproweb.com/products/Win32OpenSSL.html FIND_PATH(OPENSSL_INCLUDE_DIR openssl/ssl.h PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]/include" ) -IF(WIN32 AND MSVC) - # /MD and /MDd are the standard values - if somone wants to use - # others, the libnames have to change here too - # use also ssl and ssleay32 in debug as fallback for openssl < 0.9.8b - - FIND_LIBRARY(LIB_EAY_DEBUG NAMES libeay32MDd libeay32 - PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]/lib/VC" - ) - FIND_LIBRARY(LIB_EAY_RELEASE NAMES libeay32MD libeay32 - PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]/lib/VC" - ) - FIND_LIBRARY(SSL_EAY_DEBUG NAMES ssleay32MDd ssl ssleay32 - PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]/lib/VC" - ) - FIND_LIBRARY(SSL_EAY_RELEASE NAMES ssleay32MD ssl ssleay32 - PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]/lib/VC" - ) +IF(WIN32 AND NOT CYGWIN) + # MINGW should go here too + IF(MSVC) + # /MD and /MDd are the standard values - if someone wants to use + # others, the libnames have to change here too + # use also ssl and ssleay32 in debug as fallback for openssl < 0.9.8b + # TODO: handle /MT and static lib + # In Visual C++ naming convention each of these four kinds of Windows libraries has it's standard suffix: + # * MD for dynamic-release + # * MDd for dynamic-debug + # * MT for static-release + # * MTd for static-debug - IF(MSVC_IDE) - IF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE) - SET(OPENSSL_LIBRARIES optimized ${SSL_EAY_RELEASE} ${LIB_EAY_RELEASE} debug ${SSL_EAY_DEBUG} ${LIB_EAY_DEBUG}) - ELSE(SSL_EAY_DEBUG AND SSL_EAY_RELEASE) - SET(OPENSSL_LIBRARIES NOTFOUND) - MESSAGE(STATUS "Could not find the debug and release version of openssl") - ENDIF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE) - ELSE(MSVC_IDE) - STRING(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER) - IF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug) - SET(OPENSSL_LIBRARIES ${SSL_EAY_DEBUG} ${LIB_EAY_DEBUG}) - ELSE(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug) - SET(OPENSSL_LIBRARIES ${SSL_EAY_RELEASE} ${LIB_EAY_RELEASE}) - ENDIF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug) - ENDIF(MSVC_IDE) - MARK_AS_ADVANCED(SSL_EAY_DEBUG SSL_EAY_RELEASE) - MARK_AS_ADVANCED(LIB_EAY_DEBUG LIB_EAY_RELEASE) -ELSE(WIN32 AND MSVC) + # Implementation details: + # We are using the libraries located in the VC subdir instead of the parent directory eventhough : + # libeay32MD.lib is identical to ../libeay32.lib, and + # ssleay32MD.lib is identical to ../ssleay32.lib + FIND_LIBRARY(LIB_EAY_DEBUG NAMES libeay32MDd libeay32 + PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]/lib/VC" + ) + FIND_LIBRARY(LIB_EAY_RELEASE NAMES libeay32MD libeay32 + PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]/lib/VC" + ) + FIND_LIBRARY(SSL_EAY_DEBUG NAMES ssleay32MDd ssleay32 ssl + PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]/lib/VC" + ) + FIND_LIBRARY(SSL_EAY_RELEASE NAMES ssleay32MD ssleay32 ssl + PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]/lib/VC" + ) + if( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) + set( OPENSSL_LIBRARIES + optimized ${SSL_EAY_RELEASE} ${LIB_EAY_RELEASE} + debug ${SSL_EAY_DEBUG} ${LIB_EAY_DEBUG} + ) + else() + set( OPENSSL_LIBRARIES ${SSL_EAY_RELEASE} ${LIB_EAY_RELEASE} ) + endif() + MARK_AS_ADVANCED(SSL_EAY_DEBUG SSL_EAY_RELEASE) + MARK_AS_ADVANCED(LIB_EAY_DEBUG LIB_EAY_RELEASE) + ELSEIF(MINGW) + # same player, for MingW + FIND_LIBRARY(LIB_EAY NAMES libeay32 + PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]/lib/MinGW" + ) + FIND_LIBRARY(SSL_EAY NAMES ssleay32 + PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]/lib/MinGW" + ) + MARK_AS_ADVANCED(SSL_EAY LIB_EAY) + set( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} ) + ELSE(MSVC) + # Not sure what to pick for -say- intel, let's use the toplevel ones and hope someone report issues: + FIND_LIBRARY(LIB_EAY NAMES libeay32 + PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]/lib" + ) + FIND_LIBRARY(SSL_EAY NAMES ssleay32 + PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]/lib" + ) + MARK_AS_ADVANCED(SSL_EAY LIB_EAY) + set( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} ) + ENDIF(MSVC) +ELSE(WIN32 AND NOT CYGWIN) - FIND_LIBRARY(OPENSSL_SSL_LIBRARIES NAMES ssl ssleay32 ssleay32MD) - FIND_LIBRARY(OPENSSL_CRYPTO_LIBRARIES NAMES crypto) - MARK_AS_ADVANCED(OPENSSL_CRYPTO_LIBRARIES OPENSSL_SSL_LIBRARIES) + FIND_LIBRARY(OPENSSL_SSL_LIBRARIES NAMES ssl ssleay32 ssleay32MD) + FIND_LIBRARY(OPENSSL_CRYPTO_LIBRARIES NAMES crypto) + MARK_AS_ADVANCED(OPENSSL_CRYPTO_LIBRARIES OPENSSL_SSL_LIBRARIES) - SET(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARIES}) + SET(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARIES}) -ENDIF(WIN32 AND MSVC) +ENDIF(WIN32 AND NOT CYGWIN) -IF(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES) - SET(OPENSSL_FOUND TRUE) -ELSE(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES) - SET(OPENSSL_FOUND FALSE) -ENDIF (OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES) - -IF (OPENSSL_FOUND) - IF (NOT OpenSSL_FIND_QUIETLY) - MESSAGE(STATUS "Found OpenSSL: ${OPENSSL_LIBRARIES}") - ENDIF (NOT OpenSSL_FIND_QUIETLY) -ELSE (OPENSSL_FOUND) - IF (OpenSSL_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Could NOT find OpenSSL") - ENDIF (OpenSSL_FIND_REQUIRED) -ENDIF (OPENSSL_FOUND) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(OpenSSL DEFAULT_MSG + OPENSSL_LIBRARIES + OPENSSL_INCLUDE_DIR +) MARK_AS_ADVANCED(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES) diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake index 81d1179..5c99e3f 100644 --- a/Modules/FindPythonLibs.cmake +++ b/Modules/FindPythonLibs.cmake @@ -44,6 +44,14 @@ FOREACH(_CURRENT_VERSION 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5) # Avoid finding the .dll in the PATH. We want the .lib. NO_SYSTEM_ENVIRONMENT_PATH ) + # Look for the static library in the Python config directory + FIND_LIBRARY(PYTHON_LIBRARY + NAMES python${_CURRENT_VERSION_NO_DOTS} python${_CURRENT_VERSION} + # Avoid finding the .dll in the PATH. We want the .lib. + NO_SYSTEM_ENVIRONMENT_PATH + # This is where the static library is usually located + PATH_SUFFIXES python${_CURRENT_VERSION}/config + ) # For backward compatibility, honour value of PYTHON_INCLUDE_PATH, if # PYTHON_INCLUDE_DIR is not set. diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index 411e390..1d24009 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -34,6 +34,7 @@ # QT_USE_QTDESIGNER # QT_USE_QTMOTIF # QT_USE_QTMAIN +# QT_USE_QTMULTIMEDIA # QT_USE_QTNETWORK # QT_USE_QTNSPLUGIN # QT_USE_QTOPENGL @@ -51,6 +52,18 @@ # QT_USE_PHONON # QT_USE_QTSCRIPTTOOLS # +# QT_USE_IMPORTED_TARGETS +# If this variable is set to TRUE, FindQt4.cmake will create imported +# library targets for the various Qt libraries and set the +# library variables like QT_QTCORE_LIBRARY to point at these imported +# targets instead of the library file on disk. This provides much better +# handling of the release and debug versions of the Qt libraries and is +# also always backwards compatible, except for the case that dependencies +# of libraries are exported, these will then also list the names of the +# imported targets as dependency and not the file location on disk. This +# is much more flexible, but requires that FindQt4.cmake is executed before +# such an exported dependency file is processed. +# # There are also some files that need processing by some Qt tools such as moc # and uic. Listed below are macros that may be used to process those files. # @@ -151,27 +164,28 @@ # QT_QTGUI_FOUND True if QtGui was found. # QT_QT3SUPPORT_FOUND True if Qt3Support was found. # QT_QTASSISTANT_FOUND True if QtAssistant was found. -# QT_QAXCONTAINER_FOUND True if QAxContainer was found (Windows only). -# QT_QAXSERVER_FOUND True if QAxServer was found (Windows only). +# QT_QTASSISTANTCLIENT_FOUND True if QtAssistantClient was found. +# QT_QAXCONTAINER_FOUND True if QAxContainer was found (Windows only). +# QT_QAXSERVER_FOUND True if QAxServer was found (Windows only). # QT_QTDBUS_FOUND True if QtDBus was found. # QT_QTDESIGNER_FOUND True if QtDesigner was found. # QT_QTDESIGNERCOMPONENTS True if QtDesignerComponents was found. +# QT_QTHELP_FOUND True if QtHelp was found. # QT_QTMOTIF_FOUND True if QtMotif was found. +# QT_QTMULTIMEDIA_FOUND True if QtMultimedia was found (since Qt 4.6.0). # QT_QTNETWORK_FOUND True if QtNetwork was found. # QT_QTNSPLUGIN_FOUND True if QtNsPlugin was found. # QT_QTOPENGL_FOUND True if QtOpenGL was found. # QT_QTSQL_FOUND True if QtSql was found. -# QT_QTXML_FOUND True if QtXml was found. # QT_QTSVG_FOUND True if QtSvg was found. # QT_QTSCRIPT_FOUND True if QtScript was found. +# QT_QTSCRIPTTOOLS_FOUND True if QtScriptTools was found. # QT_QTTEST_FOUND True if QtTest was found. # QT_QTUITOOLS_FOUND True if QtUiTools was found. -# QT_QTASSISTANTCLIENT_FOUND True if QtAssistantClient was found. -# QT_QTHELP_FOUND True if QtHelp was found. # QT_QTWEBKIT_FOUND True if QtWebKit was found. +# QT_QTXML_FOUND True if QtXml was found. # QT_QTXMLPATTERNS_FOUND True if QtXmlPatterns was found. # QT_PHONON_FOUND True if phonon was found. -# QT_QTSCRIPTTOOLS_FOUND True if QtScriptTools was found. # # QT_MAC_USE_COCOA For Mac OS X, its whether Cocoa or Carbon is used. # In general, this should not be used, but its useful @@ -198,15 +212,16 @@ # QT_QT3SUPPORT_INCLUDE_DIR Path to "include/Qt3Support" # QT_QTASSISTANT_INCLUDE_DIR Path to "include/QtAssistant" # QT_QTASSISTANTCLIENT_INCLUDE_DIR Path to "include/QtAssistant" -# QT_QAXCONTAINER_INCLUDE_DIR Path to "include/ActiveQt" (Windows only) -# QT_QAXSERVER_INCLUDE_DIR Path to "include/ActiveQt" (Windows only) +# QT_QAXCONTAINER_INCLUDE_DIR Path to "include/ActiveQt" (Windows only) +# QT_QAXSERVER_INCLUDE_DIR Path to "include/ActiveQt" (Windows only) # QT_QTCORE_INCLUDE_DIR Path to "include/QtCore" +# QT_QTDBUS_INCLUDE_DIR Path to "include/QtDBus" # QT_QTDESIGNER_INCLUDE_DIR Path to "include/QtDesigner" # QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR Path to "include/QtDesigner" -# QT_QTDBUS_INCLUDE_DIR Path to "include/QtDBus" # QT_QTGUI_INCLUDE_DIR Path to "include/QtGui" # QT_QTHELP_INCLUDE_DIR Path to "include/QtHelp" # QT_QTMOTIF_INCLUDE_DIR Path to "include/QtMotif" +# QT_QTMULTIMEDIA_INCLUDE_DIR Path to "include/QtMultimedia" # QT_QTNETWORK_INCLUDE_DIR Path to "include/QtNetwork" # QT_QTNSPLUGIN_INCLUDE_DIR Path to "include/QtNsPlugin" # QT_QTOPENGL_INCLUDE_DIR Path to "include/QtOpenGL" @@ -226,7 +241,7 @@ # QT_TRANSLATIONS_DIR Path to "translations" of Qt4 # QT_DOC_DIR Path to "doc" of Qt4 # QT_MKSPECS_DIR Path to "mkspecs" of Qt4 -# +# # # The Qt toolkit may contain both debug and release libraries. # In that case, the following library variables will contain both. @@ -245,6 +260,7 @@ # QT_QTGUI_LIBRARY The QtGui library # QT_QTHELP_LIBRARY The QtHelp library # QT_QTMOTIF_LIBRARY The QtMotif library +# QT_QTMULTIMEDIA_LIBRARY The QtMultimedia library # QT_QTNETWORK_LIBRARY The QtNetwork library # QT_QTNSPLUGIN_LIBRARY The QtNsPLugin library # QT_QTOPENGL_LIBRARY The QtOpenGL library @@ -270,6 +286,8 @@ # QT_LUPDATE_EXECUTABLE Where to find the lupdate tool. # QT_LRELEASE_EXECUTABLE Where to find the lrelease tool. # QT_QCOLLECTIONGENERATOR_EXECUTABLE Where to find the qcollectiongenerator tool. +# QT_DESIGNER_EXECUTABLE Where to find the Qt designer tool. +# QT_LINGUIST_EXECUTABLE Where to find the Qt linguist tool. # # # These are around for backwards compatibility @@ -367,7 +385,9 @@ ENDMACRO(QT_QUERY_QMAKE) GET_FILENAME_COMPONENT(qt_install_version "[HKEY_CURRENT_USER\\Software\\trolltech\\Versions;DefaultQtVersion]" NAME) # check for qmake -FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake qmake4 qmake-qt4 PATHS +# Debian uses qmake-qt4 +# macports' Qt uses qmake-mac +FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake qmake4 qmake-qt4 qmake-mac PATHS "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin" "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin" "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\${qt_install_version};InstallDir]/bin" @@ -569,6 +589,47 @@ IF (QT4_QMAKE_FOUND) QT_PLUGINS_DIR QT_TRANSLATIONS_DIR) + ############################################# + # + # Find out what window system we're using + # + ############################################# + # Save required variable + 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 ) + # 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) + CHECK_SYMBOL_EXISTS(Q_WS_QWS "QtCore/qglobal.h" Q_WS_QWS) + CHECK_SYMBOL_EXISTS(Q_WS_MAC "QtCore/qglobal.h" Q_WS_MAC) + IF(Q_WS_MAC) + IF(QT_QMAKE_CHANGED) + UNSET(QT_MAC_USE_COCOA CACHE) + ENDIF(QT_QMAKE_CHANGED) + CHECK_SYMBOL_EXISTS(QT_MAC_USE_COCOA "QtCore/qconfig.h" QT_MAC_USE_COCOA) + ENDIF(Q_WS_MAC) + + IF (QT_QTCOPY_REQUIRED) + CHECK_SYMBOL_EXISTS(QT_IS_QTCOPY "QtCore/qglobal.h" QT_KDE_QT_COPY) + IF (NOT QT_IS_QTCOPY) + MESSAGE(FATAL_ERROR "qt-copy is required, but hasn't been found") + ENDIF (NOT QT_IS_QTCOPY) + ENDIF (QT_QTCOPY_REQUIRED) + + # Restore CMAKE_REQUIRED_INCLUDES and CMAKE_REQUIRED_FLAGS variables + SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) + SET(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE}) + # + ############################################# + + + ######################################## # # Setting the INCLUDE-Variables @@ -576,8 +637,12 @@ IF (QT4_QMAKE_FOUND) ######################################## SET(QT_MODULES QtCore QtGui Qt3Support QtSvg QtScript QtTest QtUiTools - QtHelp QtWebKit QtXmlPatterns phonon QtMotif QtNetwork + QtHelp QtWebKit QtXmlPatterns phonon QtNetwork QtMultimedia QtNsPlugin QtOpenGL QtSql QtXml QtDesigner QtDBus QtScriptTools) + + IF(Q_WS_X11) + SET(QT_MODULES ${QT_MODULES} QtMotif) + ENDIF(Q_WS_X11) IF(QT_QMAKE_CHANGED) FOREACH(QT_MODULE ${QT_MODULES}) @@ -617,6 +682,16 @@ IF (QT4_QMAKE_FOUND) ${QT_LIBRARY_DIR}/${QT_MODULE}.framework/Headers NO_DEFAULT_PATH ) + # phonon doesn't seem consistent, let's try phonondefs.h for some + # installations + IF(${QT_MODULE} STREQUAL "phonon") + FIND_PATH(QT_${_upper_qt_module}_INCLUDE_DIR phonondefs.h + PATHS + ${QT_HEADERS_DIR}/${QT_MODULE} + ${QT_LIBRARY_DIR}/${QT_MODULE}.framework/Headers + NO_DEFAULT_PATH + ) + ENDIF(${QT_MODULE} STREQUAL "phonon") ENDFOREACH(QT_MODULE) IF(WIN32) @@ -681,44 +756,6 @@ IF (QT4_QMAKE_FOUND) SET( QT_INCLUDES ${QT_MKSPECS_DIR}/default ${QT_INCLUDE_DIR} ) - ############################################# - # - # Find out what window system we're using - # - ############################################# - # Save required variable - 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_INCLUDE_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 ) - # 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) - CHECK_SYMBOL_EXISTS(Q_WS_QWS "QtCore/qglobal.h" Q_WS_QWS) - CHECK_SYMBOL_EXISTS(Q_WS_MAC "QtCore/qglobal.h" Q_WS_MAC) - IF(Q_WS_MAC) - IF(QT_QMAKE_CHANGED) - UNSET(QT_MAC_USE_COCOA CACHE) - ENDIF(QT_QMAKE_CHANGED) - CHECK_SYMBOL_EXISTS(QT_MAC_USE_COCOA "QtCore/qconfig.h" QT_MAC_USE_COCOA) - ENDIF(Q_WS_MAC) - - IF (QT_QTCOPY_REQUIRED) - CHECK_SYMBOL_EXISTS(QT_IS_QTCOPY "QtCore/qglobal.h" QT_KDE_QT_COPY) - IF (NOT QT_IS_QTCOPY) - MESSAGE(FATAL_ERROR "qt-copy is required, but hasn't been found") - ENDIF (NOT QT_IS_QTCOPY) - ENDIF (QT_QTCOPY_REQUIRED) - - # Restore CMAKE_REQUIRED_INCLUDES and CMAKE_REQUIRED_FLAGS variables - SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) - SET(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE}) - # - ############################################# @@ -811,41 +848,85 @@ IF (QT4_QMAKE_FOUND) # ############################################ - MACRO (_QT4_ADJUST_LIB_VARS basename) + # On OSX when Qt is found as framework, never use the imported targets for now, since + # in this case the handling of the framework directory currently does not work correctly. + IF(QT_USE_FRAMEWORKS) + SET(QT_USE_IMPORTED_TARGETS FALSE) + 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 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) - - 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) - - SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY} CACHE STRING "The Qt ${basename} library" FORCE) - - IF (QT_${basename}_LIBRARY) - SET(QT_${basename}_FOUND 1) - ENDIF (QT_${basename}_LIBRARY) + 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) @@ -861,41 +942,50 @@ IF (QT4_QMAKE_FOUND) # 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) - _QT4_ADJUST_LIB_VARS(QTASSISTANT) - _QT4_ADJUST_LIB_VARS(QTDESIGNER) - _QT4_ADJUST_LIB_VARS(QTDESIGNERCOMPONENTS) - _QT4_ADJUST_LIB_VARS(QTNETWORK) - _QT4_ADJUST_LIB_VARS(QTNSPLUGIN) - _QT4_ADJUST_LIB_VARS(QTOPENGL) - _QT4_ADJUST_LIB_VARS(QTSQL) - _QT4_ADJUST_LIB_VARS(QTXML) - _QT4_ADJUST_LIB_VARS(QTSVG) - _QT4_ADJUST_LIB_VARS(QTSCRIPT) - _QT4_ADJUST_LIB_VARS(QTUITOOLS) - _QT4_ADJUST_LIB_VARS(QTTEST) - _QT4_ADJUST_LIB_VARS(QTDBUS) - _QT4_ADJUST_LIB_VARS(QTASSISTANTCLIENT) - _QT4_ADJUST_LIB_VARS(QTHELP) - _QT4_ADJUST_LIB_VARS(QTWEBKIT) - _QT4_ADJUST_LIB_VARS(QTXMLPATTERNS) - _QT4_ADJUST_LIB_VARS(PHONON) - _QT4_ADJUST_LIB_VARS(QTCLUCENE) - _QT4_ADJUST_LIB_VARS(QTSCRIPTTOOLS) - + _QT4_ADJUST_LIB_VARS(QtCore) + _QT4_ADJUST_LIB_VARS(QtGui) + _QT4_ADJUST_LIB_VARS(Qt3Support) + _QT4_ADJUST_LIB_VARS(QtAssistant) + _QT4_ADJUST_LIB_VARS(QtAssistantClient) + _QT4_ADJUST_LIB_VARS(QtCLucene) + _QT4_ADJUST_LIB_VARS(QtDBus) + _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) + _QT4_ADJUST_LIB_VARS(QtMotif) ENDIF(Q_WS_X11) IF(WIN32) - _QT4_ADJUST_LIB_VARS(QTMAIN) - _QT4_ADJUST_LIB_VARS(QAXSERVER) - _QT4_ADJUST_LIB_VARS(QAXCONTAINER) + _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) + + ####################################### # @@ -915,6 +1005,8 @@ IF (QT4_QMAKE_FOUND) SET(QT_LUPDATE_EXECUTABLE NOTFOUND) SET(QT_LRELEASE_EXECUTABLE NOTFOUND) SET(QT_QCOLLECTIONGENERATOR_EXECUTABLE NOTFOUND) + SET(QT_DESIGNER_EXECUTABLE NOTFOUND) + SET(QT_LINGUIST_EXECUTABLE NOTFOUND) ENDIF(QT_QMAKE_CHANGED) FIND_PROGRAM(QT_MOC_EXECUTABLE @@ -971,6 +1063,18 @@ IF (QT4_QMAKE_FOUND) NO_DEFAULT_PATH ) + FIND_PROGRAM(QT_DESIGNER_EXECUTABLE + NAMES designer-qt4 designer + PATHS ${QT_BINARY_DIR} + NO_DEFAULT_PATH + ) + + FIND_PROGRAM(QT_LINGUIST_EXECUTABLE + NAMES linguist-qt4 linguist + PATHS ${QT_BINARY_DIR} + NO_DEFAULT_PATH + ) + IF (QT_MOC_EXECUTABLE) SET(QT_WRAP_CPP "YES") ENDIF (QT_MOC_EXECUTABLE) @@ -983,7 +1087,12 @@ IF (QT4_QMAKE_FOUND) MARK_AS_ADVANCED( QT_UIC_EXECUTABLE QT_UIC3_EXECUTABLE QT_MOC_EXECUTABLE QT_RCC_EXECUTABLE QT_DBUSXML2CPP_EXECUTABLE QT_DBUSCPP2XML_EXECUTABLE - QT_LUPDATE_EXECUTABLE QT_LRELEASE_EXECUTABLE QT_QCOLLECTIONGENERATOR_EXECUTABLE) + QT_LUPDATE_EXECUTABLE QT_LRELEASE_EXECUTABLE QT_QCOLLECTIONGENERATOR_EXECUTABLE + QT_DESIGNER_EXECUTABLE QT_LINGUIST_EXECUTABLE) + + + # get the directory of the current file, used later on in the file + GET_FILENAME_COMPONENT( _qt4_current_dir "${CMAKE_CURRENT_LIST_FILE}" PATH) ###################################### # @@ -991,378 +1100,7 @@ IF (QT4_QMAKE_FOUND) # ###################################### - MACRO (QT4_EXTRACT_OPTIONS _qt4_files _qt4_options) - SET(${_qt4_files}) - SET(${_qt4_options}) - SET(_QT4_DOING_OPTIONS FALSE) - FOREACH(_currentArg ${ARGN}) - IF ("${_currentArg}" STREQUAL "OPTIONS") - SET(_QT4_DOING_OPTIONS TRUE) - ELSE ("${_currentArg}" STREQUAL "OPTIONS") - IF(_QT4_DOING_OPTIONS) - LIST(APPEND ${_qt4_options} "${_currentArg}") - ELSE(_QT4_DOING_OPTIONS) - LIST(APPEND ${_qt4_files} "${_currentArg}") - ENDIF(_QT4_DOING_OPTIONS) - ENDIF ("${_currentArg}" STREQUAL "OPTIONS") - ENDFOREACH(_currentArg) - ENDMACRO (QT4_EXTRACT_OPTIONS) - - # macro used to create the names of output files preserving relative dirs - MACRO (QT4_MAKE_OUTPUT_FILE infile prefix ext outfile ) - STRING(LENGTH ${CMAKE_CURRENT_BINARY_DIR} _binlength) - STRING(LENGTH ${infile} _infileLength) - SET(_checkinfile ${CMAKE_CURRENT_SOURCE_DIR}) - IF(_infileLength GREATER _binlength) - STRING(SUBSTRING "${infile}" 0 ${_binlength} _checkinfile) - IF(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") - FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_BINARY_DIR} ${infile}) - ELSE(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") - FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile}) - ENDIF(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") - ELSE(_infileLength GREATER _binlength) - FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile}) - ENDIF(_infileLength GREATER _binlength) - IF(WIN32 AND rel MATCHES "^[a-zA-Z]:") # absolute path - STRING(REGEX REPLACE "^([a-zA-Z]):(.*)$" "\\1_\\2" rel "${rel}") - ENDIF(WIN32 AND rel MATCHES "^[a-zA-Z]:") - SET(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${rel}") - STRING(REPLACE ".." "__" _outfile ${_outfile}) - GET_FILENAME_COMPONENT(outpath ${_outfile} PATH) - GET_FILENAME_COMPONENT(_outfile ${_outfile} NAME_WE) - FILE(MAKE_DIRECTORY ${outpath}) - SET(${outfile} ${outpath}/${prefix}${_outfile}.${ext}) - ENDMACRO (QT4_MAKE_OUTPUT_FILE ) - - MACRO (QT4_GET_MOC_FLAGS _moc_flags) - SET(${_moc_flags}) - GET_DIRECTORY_PROPERTY(_inc_DIRS INCLUDE_DIRECTORIES) - - FOREACH(_current ${_inc_DIRS}) - IF("${_current}" MATCHES ".framework/?$") - STRING(REGEX REPLACE "/[^/]+.framework" "" framework_path "${_current}") - SET(${_moc_flags} ${${_moc_flags}} "-F${framework_path}") - ELSE("${_current}" MATCHES ".framework/?$") - SET(${_moc_flags} ${${_moc_flags}} "-I${_current}") - ENDIF("${_current}" MATCHES ".framework/?$") - ENDFOREACH(_current ${_inc_DIRS}) - - GET_DIRECTORY_PROPERTY(_defines COMPILE_DEFINITIONS) - FOREACH(_current ${_defines}) - SET(${_moc_flags} ${${_moc_flags}} "-D${_current}") - ENDFOREACH(_current ${_defines}) - - IF(Q_WS_WIN) - SET(${_moc_flags} ${${_moc_flags}} -DWIN32) - ENDIF(Q_WS_WIN) - - ENDMACRO(QT4_GET_MOC_FLAGS) - - # helper macro to set up a moc rule - MACRO (QT4_CREATE_MOC_COMMAND infile outfile moc_flags moc_options) - # For Windows, create a parameters file to work around command line length limit - IF (WIN32) - # Pass the parameters in a file. Set the working directory to - # be that containing the parameters file and reference it by - # just the file name. This is necessary because the moc tool on - # MinGW builds does not seem to handle spaces in the path to the - # file given with the @ syntax. - GET_FILENAME_COMPONENT(_moc_outfile_name "${outfile}" NAME) - GET_FILENAME_COMPONENT(_moc_outfile_dir "${outfile}" PATH) - IF(_moc_outfile_dir) - SET(_moc_working_dir WORKING_DIRECTORY ${_moc_outfile_dir}) - ENDIF(_moc_outfile_dir) - SET (_moc_parameters_file ${outfile}_parameters) - SET (_moc_parameters ${moc_flags} ${moc_options} -o "${outfile}" "${infile}") - FILE (REMOVE ${_moc_parameters_file}) - FOREACH(arg ${_moc_parameters}) - FILE (APPEND ${_moc_parameters_file} "${arg}\n") - ENDFOREACH(arg) - ADD_CUSTOM_COMMAND(OUTPUT ${outfile} - COMMAND ${QT_MOC_EXECUTABLE} @${_moc_outfile_name}_parameters - DEPENDS ${infile} - ${_moc_working_dir} - VERBATIM) - ELSE (WIN32) - ADD_CUSTOM_COMMAND(OUTPUT ${outfile} - COMMAND ${QT_MOC_EXECUTABLE} - ARGS ${moc_flags} ${moc_options} -o ${outfile} ${infile} - DEPENDS ${infile}) - ENDIF (WIN32) - ENDMACRO (QT4_CREATE_MOC_COMMAND) - - - MACRO (QT4_GENERATE_MOC infile outfile ) - # get include dirs and flags - QT4_GET_MOC_FLAGS(moc_flags) - GET_FILENAME_COMPONENT(abs_infile ${infile} ABSOLUTE) - QT4_CREATE_MOC_COMMAND(${abs_infile} ${outfile} "${moc_flags}" "") - SET_SOURCE_FILES_PROPERTIES(${outfile} PROPERTIES SKIP_AUTOMOC TRUE) # dont run automoc on this file - ENDMACRO (QT4_GENERATE_MOC) - - - # QT4_WRAP_CPP(outfiles inputfile ... ) - - MACRO (QT4_WRAP_CPP outfiles ) - # get include dirs - QT4_GET_MOC_FLAGS(moc_flags) - QT4_EXTRACT_OPTIONS(moc_files moc_options ${ARGN}) - - FOREACH (it ${moc_files}) - GET_FILENAME_COMPONENT(it ${it} ABSOLUTE) - QT4_MAKE_OUTPUT_FILE(${it} moc_ cxx outfile) - QT4_CREATE_MOC_COMMAND(${it} ${outfile} "${moc_flags}" "${moc_options}") - SET(${outfiles} ${${outfiles}} ${outfile}) - ENDFOREACH(it) - - ENDMACRO (QT4_WRAP_CPP) - - - # QT4_WRAP_UI(outfiles inputfile ... ) - - MACRO (QT4_WRAP_UI outfiles ) - QT4_EXTRACT_OPTIONS(ui_files ui_options ${ARGN}) - - FOREACH (it ${ui_files}) - GET_FILENAME_COMPONENT(outfile ${it} NAME_WE) - GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE) - SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h) - ADD_CUSTOM_COMMAND(OUTPUT ${outfile} - COMMAND ${QT_UIC_EXECUTABLE} - ARGS ${ui_options} -o ${outfile} ${infile} - MAIN_DEPENDENCY ${infile}) - SET(${outfiles} ${${outfiles}} ${outfile}) - ENDFOREACH (it) - - ENDMACRO (QT4_WRAP_UI) - - - # QT4_ADD_RESOURCES(outfiles inputfile ... ) - - MACRO (QT4_ADD_RESOURCES outfiles ) - QT4_EXTRACT_OPTIONS(rcc_files rcc_options ${ARGN}) - - FOREACH (it ${rcc_files}) - GET_FILENAME_COMPONENT(outfilename ${it} NAME_WE) - GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE) - GET_FILENAME_COMPONENT(rc_path ${infile} PATH) - SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cxx) - # parse file for dependencies - # all files are absolute paths or relative to the location of the qrc file - FILE(READ "${infile}" _RC_FILE_CONTENTS) - STRING(REGEX MATCHALL "<file[^<]+" _RC_FILES "${_RC_FILE_CONTENTS}") - SET(_RC_DEPENDS) - FOREACH(_RC_FILE ${_RC_FILES}) - STRING(REGEX REPLACE "^<file[^>]*>" "" _RC_FILE "${_RC_FILE}") - STRING(REGEX MATCH "^/|([A-Za-z]:/)" _ABS_PATH_INDICATOR "${_RC_FILE}") - IF(NOT _ABS_PATH_INDICATOR) - SET(_RC_FILE "${rc_path}/${_RC_FILE}") - ENDIF(NOT _ABS_PATH_INDICATOR) - SET(_RC_DEPENDS ${_RC_DEPENDS} "${_RC_FILE}") - ENDFOREACH(_RC_FILE) - ADD_CUSTOM_COMMAND(OUTPUT ${outfile} - COMMAND ${QT_RCC_EXECUTABLE} - ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile} - MAIN_DEPENDENCY ${infile} - DEPENDS ${_RC_DEPENDS}) - SET(${outfiles} ${${outfiles}} ${outfile}) - ENDFOREACH (it) - - ENDMACRO (QT4_ADD_RESOURCES) - - MACRO(QT4_ADD_DBUS_INTERFACE _sources _interface _basename) - GET_FILENAME_COMPONENT(_infile ${_interface} ABSOLUTE) - SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h) - SET(_impl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp) - SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc) - - # handling more arguments (as in FindQt4.cmake from KDE4) will come soon, then - # _params will be used for more than just -m - SET(_params -m) - - ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header} - COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} ${_params} -p ${_basename} ${_infile} - DEPENDS ${_infile}) - - SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE) - - QT4_GENERATE_MOC(${_header} ${_moc}) - - SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc}) - MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc}) - - ENDMACRO(QT4_ADD_DBUS_INTERFACE) - - - MACRO(QT4_ADD_DBUS_INTERFACES _sources) - FOREACH (_current_FILE ${ARGN}) - GET_FILENAME_COMPONENT(_infile ${_current_FILE} ABSOLUTE) - # get the part before the ".xml" suffix - STRING(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2" _basename ${_current_FILE}) - STRING(TOLOWER ${_basename} _basename) - QT4_ADD_DBUS_INTERFACE(${_sources} ${_infile} ${_basename}interface) - ENDFOREACH (_current_FILE) - ENDMACRO(QT4_ADD_DBUS_INTERFACES) - - - MACRO(QT4_GENERATE_DBUS_INTERFACE _header) # _customName OPTIONS -some -options ) - QT4_EXTRACT_OPTIONS(_customName _qt4_dbus_options ${ARGN}) - - GET_FILENAME_COMPONENT(_in_file ${_header} ABSOLUTE) - GET_FILENAME_COMPONENT(_basename ${_header} NAME_WE) - - IF (_customName) - SET(_target ${CMAKE_CURRENT_BINARY_DIR}/${_customName}) - ELSE (_customName) - SET(_target ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.xml) - ENDIF (_customName) - - ADD_CUSTOM_COMMAND(OUTPUT ${_target} - COMMAND ${QT_DBUSCPP2XML_EXECUTABLE} ${_qt4_dbus_options} ${_in_file} -o ${_target} - DEPENDS ${_in_file} - ) - ENDMACRO(QT4_GENERATE_DBUS_INTERFACE) - - - MACRO(QT4_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optionalBasename _optionalClassName) - GET_FILENAME_COMPONENT(_infile ${_xml_file} ABSOLUTE) - - SET(_optionalBasename "${ARGV4}") - IF (_optionalBasename) - SET(_basename ${_optionalBasename} ) - ELSE (_optionalBasename) - STRING(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2adaptor" _basename ${_infile}) - STRING(TOLOWER ${_basename} _basename) - ENDIF (_optionalBasename) - - SET(_optionalClassName "${ARGV5}") - SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h) - SET(_impl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp) - SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc) - - IF(_optionalClassName) - ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header} - COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -c ${_optionalClassName} -i ${_include} -l ${_parentClass} ${_infile} - DEPENDS ${_infile} - ) - ELSE(_optionalClassName) - ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header} - COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -i ${_include} -l ${_parentClass} ${_infile} - DEPENDS ${_infile} - ) - ENDIF(_optionalClassName) - - QT4_GENERATE_MOC(${_header} ${_moc}) - SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE) - MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc}) - - SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc}) - ENDMACRO(QT4_ADD_DBUS_ADAPTOR) - - MACRO(QT4_AUTOMOC) - QT4_GET_MOC_FLAGS(_moc_INCS) - - SET(_matching_FILES ) - FOREACH (_current_FILE ${ARGN}) - - GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE) - # if "SKIP_AUTOMOC" is set to true, we will not handle this file here. - # This is required to make uic work correctly: - # we need to add generated .cpp files to the sources (to compile them), - # but we cannot let automoc handle them, as the .cpp files don't exist yet when - # cmake is run for the very first time on them -> however the .cpp files might - # exist at a later run. at that time we need to skip them, so that we don't add two - # different rules for the same moc file - GET_SOURCE_FILE_PROPERTY(_skip ${_abs_FILE} SKIP_AUTOMOC) - - IF ( NOT _skip AND EXISTS ${_abs_FILE} ) - - FILE(READ ${_abs_FILE} _contents) - - GET_FILENAME_COMPONENT(_abs_PATH ${_abs_FILE} PATH) - - STRING(REGEX MATCHALL "# *include +[^ ]+\\.moc[\">]" _match "${_contents}") - IF(_match) - FOREACH (_current_MOC_INC ${_match}) - STRING(REGEX MATCH "[^ <\"]+\\.moc" _current_MOC "${_current_MOC_INC}") - - GET_FILENAME_COMPONENT(_basename ${_current_MOC} NAME_WE) - IF(EXISTS ${_abs_PATH}/${_basename}.hpp) - SET(_header ${_abs_PATH}/${_basename}.hpp) - ELSE(EXISTS ${_abs_PATH}/${_basename}.hpp) - SET(_header ${_abs_PATH}/${_basename}.h) - ENDIF(EXISTS ${_abs_PATH}/${_basename}.hpp) - SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC}) - QT4_CREATE_MOC_COMMAND(${_header} ${_moc} "${_moc_INCS}" "") - MACRO_ADD_FILE_DEPENDENCIES(${_abs_FILE} ${_moc}) - ENDFOREACH (_current_MOC_INC) - ENDIF(_match) - ENDIF ( NOT _skip AND EXISTS ${_abs_FILE} ) - ENDFOREACH (_current_FILE) - ENDMACRO(QT4_AUTOMOC) - - MACRO(QT4_CREATE_TRANSLATION _qm_files) - QT4_EXTRACT_OPTIONS(_lupdate_files _lupdate_options ${ARGN}) - SET(_my_sources) - SET(_my_dirs) - SET(_my_tsfiles) - SET(_ts_pro) - FOREACH (_file ${_lupdate_files}) - GET_FILENAME_COMPONENT(_ext ${_file} EXT) - GET_FILENAME_COMPONENT(_abs_FILE ${_file} ABSOLUTE) - IF(_ext MATCHES "ts") - LIST(APPEND _my_tsfiles ${_abs_FILE}) - ELSE(_ext MATCHES "ts") - IF(NOT _ext) - LIST(APPEND _my_dirs ${_abs_FILE}) - ELSE(NOT _ext) - LIST(APPEND _my_sources ${_abs_FILE}) - ENDIF(NOT _ext) - ENDIF(_ext MATCHES "ts") - ENDFOREACH(_file) - FOREACH(_ts_file ${_my_tsfiles}) - IF(_my_sources) - # make a .pro file to call lupdate on, so we don't make our commands too - # long for some systems - GET_FILENAME_COMPONENT(_ts_name ${_ts_file} NAME_WE) - SET(_ts_pro ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_ts_name}_lupdate.pro) - SET(_pro_srcs) - FOREACH(_pro_src ${_my_sources}) - SET(_pro_srcs "${_pro_srcs} \"${_pro_src}\"") - ENDFOREACH(_pro_src ${_my_sources}) - FILE(WRITE ${_ts_pro} "SOURCES = ${_pro_srcs}") - ENDIF(_my_sources) - ADD_CUSTOM_COMMAND(OUTPUT ${_ts_file} - COMMAND ${QT_LUPDATE_EXECUTABLE} - ARGS ${_lupdate_options} ${_ts_pro} ${_my_dirs} -ts ${_ts_file} - DEPENDS ${_my_sources} ${_ts_pro}) - ENDFOREACH(_ts_file) - QT4_ADD_TRANSLATION(${_qm_files} ${_my_tsfiles}) - ENDMACRO(QT4_CREATE_TRANSLATION) - - MACRO(QT4_ADD_TRANSLATION _qm_files) - FOREACH (_current_FILE ${ARGN}) - GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE) - GET_FILENAME_COMPONENT(qm ${_abs_FILE} NAME_WE) - GET_SOURCE_FILE_PROPERTY(output_location ${_abs_FILE} OUTPUT_LOCATION) - IF(output_location) - FILE(MAKE_DIRECTORY "${output_location}") - SET(qm "${output_location}/${qm}.qm") - ELSE(output_location) - SET(qm "${CMAKE_CURRENT_BINARY_DIR}/${qm}.qm") - ENDIF(output_location) - - ADD_CUSTOM_COMMAND(OUTPUT ${qm} - COMMAND ${QT_LRELEASE_EXECUTABLE} - ARGS ${_abs_FILE} -qm ${qm} - DEPENDS ${_abs_FILE} - ) - SET(${_qm_files} ${${_qm_files}} ${qm}) - ENDFOREACH (_current_FILE) - ENDMACRO(QT4_ADD_TRANSLATION) - - - + INCLUDE("${_qt4_current_dir}/Qt4Macros.cmake") ###################################### @@ -1396,303 +1134,9 @@ IF (QT4_QMAKE_FOUND) # configuration/system dependent settings # ############################################### - - # find dependencies for some Qt modules - # when doing builds against a static Qt, they are required - # when doing builds against a shared Qt, they are sometimes not required - # even some Linux distros do not require these dependencies - # if a user needs the dependencies, and they couldn't be found, they can set - # the variables themselves. - - SET(QT_QTGUI_LIB_DEPENDENCIES "") - SET(QT_QTCORE_LIB_DEPENDENCIES "") - SET(QT_QTNETWORK_LIB_DEPENDENCIES "") - SET(QT_QTOPENGL_LIB_DEPENDENCIES "") - SET(QT_QTDBUS_LIB_DEPENDENCIES "") - SET(QT_QTHELP_LIB_DEPENDENCIES ${QT_QTCLUCENE_LIBRARY}) - - # build using shared Qt needs -DQT_DLL - IF(NOT QT_CONFIG MATCHES "static") - # warning currently only qconfig.pri on Windows potentially contains "static" - # so QT_DLL might not get defined properly on other platforms. - SET(QT_DEFINITIONS ${QT_DEFINITIONS} -DQT_DLL) - ENDIF(NOT QT_CONFIG MATCHES "static") - - # QtOpenGL dependencies - QT_QUERY_QMAKE(QMAKE_LIBS_OPENGL "QMAKE_LIBS_OPENGL") - SET (QT_QTOPENGL_LIB_DEPENDENCIES ${QT_QTOPENGL_LIB_DEPENDENCIES} ${QMAKE_LIBS_OPENGL}) - - ## system png - IF(QT_QCONFIG MATCHES "system-png") - FIND_LIBRARY(QT_PNG_LIBRARY NAMES png) - MARK_AS_ADVANCED(QT_PNG_LIBRARY) - IF(QT_PNG_LIBRARY) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_PNG_LIBRARY}) - ENDIF(QT_PNG_LIBRARY) - ENDIF(QT_QCONFIG MATCHES "system-png") - - # for X11, get X11 library directory - IF(Q_WS_X11) - QT_QUERY_QMAKE(QMAKE_LIBDIR_X11 "QMAKE_LIBDIR_X11") - ENDIF(Q_WS_X11) - ## X11 SM - IF(QT_QCONFIG MATCHES "x11sm") - # ask qmake where the x11 libs are - FIND_LIBRARY(QT_X11_SM_LIBRARY NAMES SM PATHS ${QMAKE_LIBDIR_X11}) - FIND_LIBRARY(QT_X11_ICE_LIBRARY NAMES ICE PATHS ${QMAKE_LIBDIR_X11}) - MARK_AS_ADVANCED(QT_X11_SM_LIBRARY) - MARK_AS_ADVANCED(QT_X11_ICE_LIBRARY) - IF(QT_X11_SM_LIBRARY AND QT_X11_ICE_LIBRARY) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_X11_SM_LIBRARY} ${QT_X11_ICE_LIBRARY}) - ENDIF(QT_X11_SM_LIBRARY AND QT_X11_ICE_LIBRARY) - ENDIF(QT_QCONFIG MATCHES "x11sm") - - ## Xi - IF(QT_QCONFIG MATCHES "tablet") - FIND_LIBRARY(QT_XI_LIBRARY NAMES Xi PATHS ${QMAKE_LIBDIR_X11}) - MARK_AS_ADVANCED(QT_XI_LIBRARY) - IF(QT_XI_LIBRARY) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XI_LIBRARY}) - ENDIF(QT_XI_LIBRARY) - ENDIF(QT_QCONFIG MATCHES "tablet") - - ## Xrender - IF(QT_QCONFIG MATCHES "xrender") - FIND_LIBRARY(QT_XRENDER_LIBRARY NAMES Xrender PATHS ${QMAKE_LIBDIR_X11}) - MARK_AS_ADVANCED(QT_XRENDER_LIBRARY) - IF(QT_XRENDER_LIBRARY) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XRENDER_LIBRARY}) - ENDIF(QT_XRENDER_LIBRARY) - ENDIF(QT_QCONFIG MATCHES "xrender") - - ## Xrandr - IF(QT_QCONFIG MATCHES "xrandr") - FIND_LIBRARY(QT_XRANDR_LIBRARY NAMES Xrandr PATHS ${QMAKE_LIBDIR_X11}) - MARK_AS_ADVANCED(QT_XRANDR_LIBRARY) - IF(QT_XRANDR_LIBRARY) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XRANDR_LIBRARY}) - ENDIF(QT_XRANDR_LIBRARY) - ENDIF(QT_QCONFIG MATCHES "xrandr") - - ## Xcursor - IF(QT_QCONFIG MATCHES "xcursor") - FIND_LIBRARY(QT_XCURSOR_LIBRARY NAMES Xcursor PATHS ${QMAKE_LIBDIR_X11}) - MARK_AS_ADVANCED(QT_XCURSOR_LIBRARY) - IF(QT_XCURSOR_LIBRARY) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XCURSOR_LIBRARY}) - ENDIF(QT_XCURSOR_LIBRARY) - ENDIF(QT_QCONFIG MATCHES "xcursor") - - ## Xinerama - IF(QT_QCONFIG MATCHES "xinerama") - FIND_LIBRARY(QT_XINERAMA_LIBRARY NAMES Xinerama PATHS ${QMAKE_LIBDIR_X11}) - MARK_AS_ADVANCED(QT_XINERAMA_LIBRARY) - IF(QT_XINERAMA_LIBRARY) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XINERAMA_LIBRARY}) - ENDIF(QT_XINERAMA_LIBRARY) - ENDIF(QT_QCONFIG MATCHES "xinerama") - - ## Xfixes - IF(QT_QCONFIG MATCHES "xfixes") - FIND_LIBRARY(QT_XFIXES_LIBRARY NAMES Xfixes PATHS ${QMAKE_LIBDIR_X11}) - MARK_AS_ADVANCED(QT_XFIXES_LIBRARY) - IF(QT_XFIXES_LIBRARY) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XFIXES_LIBRARY}) - ENDIF(QT_XFIXES_LIBRARY) - ENDIF(QT_QCONFIG MATCHES "xfixes") - - ## system-freetype - IF(QT_QCONFIG MATCHES "system-freetype") - FIND_LIBRARY(QT_FREETYPE_LIBRARY NAMES freetype) - MARK_AS_ADVANCED(QT_FREETYPE_LIBRARY) - IF(QT_FREETYPE_LIBRARY) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_FREETYPE_LIBRARY}) - ENDIF(QT_FREETYPE_LIBRARY) - ENDIF(QT_QCONFIG MATCHES "system-freetype") - - ## fontconfig - IF(QT_QCONFIG MATCHES "fontconfig") - FIND_LIBRARY(QT_FONTCONFIG_LIBRARY NAMES fontconfig) - MARK_AS_ADVANCED(QT_FONTCONFIG_LIBRARY) - IF(QT_FONTCONFIG_LIBRARY) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_FONTCONFIG_LIBRARY}) - ENDIF(QT_FONTCONFIG_LIBRARY) - ENDIF(QT_QCONFIG MATCHES "fontconfig") - - ## system-zlib - IF(QT_QCONFIG MATCHES "system-zlib") - FIND_LIBRARY(QT_ZLIB_LIBRARY NAMES z) - MARK_AS_ADVANCED(QT_ZLIB_LIBRARY) - IF(QT_ZLIB_LIBRARY) - SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_ZLIB_LIBRARY}) - ENDIF(QT_ZLIB_LIBRARY) - ENDIF(QT_QCONFIG MATCHES "system-zlib") - - ## openssl - IF(NOT Q_WS_WIN) - SET(_QT_NEED_OPENSSL 0) - IF(QT_VERSION_MINOR LESS 4 AND QT_QCONFIG MATCHES "openssl") - SET(_QT_NEED_OPENSSL 1) - ENDIF(QT_VERSION_MINOR LESS 4 AND QT_QCONFIG MATCHES "openssl") - IF(QT_VERSION_MINOR GREATER 3 AND QT_QCONFIG MATCHES "openssl-linked") - SET(_QT_NEED_OPENSSL 1) - ENDIF(QT_VERSION_MINOR GREATER 3 AND QT_QCONFIG MATCHES "openssl-linked") - IF(_QT_NEED_OPENSSL) - FIND_PACKAGE(OpenSSL) - IF(OPENSSL_LIBRARIES) - SET(QT_QTNETWORK_LIB_DEPENDENCIES ${QT_QTNETWORK_LIB_DEPENDENCIES} ${OPENSSL_LIBRARIES}) - ENDIF(OPENSSL_LIBRARIES) - ENDIF(_QT_NEED_OPENSSL) - ENDIF(NOT Q_WS_WIN) - - ## dbus - IF(QT_QCONFIG MATCHES "dbus") - - # if the dbus library isn't found, we'll assume its not required to build - # shared Qt on Linux doesn't require it - IF(NOT QT_DBUS_LIBRARY) - EXECUTE_PROCESS(COMMAND pkg-config --libs-only-L dbus-1 - OUTPUT_VARIABLE _dbus_query_output - RESULT_VARIABLE _dbus_result - ERROR_VARIABLE _dbus_query_output ) - - IF(_dbus_result MATCHES 0) - STRING(REPLACE "-L" "" _dbus_query_output "${_dbus_query_output}") - SEPARATE_ARGUMENTS(_dbus_query_output) - ELSE(_dbus_result MATCHES 0) - SET(_dbus_query_output) - ENDIF(_dbus_result MATCHES 0) - - FIND_LIBRARY(QT_DBUS_LIBRARY NAMES dbus-1 PATHS ${_dbus_query_output} ) - - IF(QT_DBUS_LIBRARY) - SET(QT_QTDBUS_LIB_DEPENDENCIES ${QT_QTDBUS_LIB_DEPENDENCIES} ${QT_DBUS_LIBRARY}) - ENDIF(QT_DBUS_LIBRARY) - - MARK_AS_ADVANCED(QT_DBUS_LIBRARY) - ENDIF(NOT QT_DBUS_LIBRARY) - - ENDIF(QT_QCONFIG MATCHES "dbus") - - ## glib - IF(QT_QCONFIG MATCHES "glib") - - # if the glib libraries aren't found, we'll assume its not required to build - # shared Qt on Linux doesn't require it - - # Qt 4.2.0+ uses glib-2.0 - IF(NOT QT_GLIB_LIBRARY OR NOT QT_GTHREAD_LIBRARY) - EXECUTE_PROCESS(COMMAND pkg-config --libs-only-L glib-2.0 gthread-2.0 - OUTPUT_VARIABLE _glib_query_output - RESULT_VARIABLE _glib_result - ERROR_VARIABLE _glib_query_output ) - - IF(_glib_result MATCHES 0) - STRING(REPLACE "-L" "" _glib_query_output "${_glib_query_output}") - SEPARATE_ARGUMENTS(_glib_query_output) - ELSE(_glib_result MATCHES 0) - SET(_glib_query_output) - ENDIF(_glib_result MATCHES 0) - - FIND_LIBRARY(QT_GLIB_LIBRARY NAMES glib-2.0 PATHS ${_glib_query_output} ) - FIND_LIBRARY(QT_GTHREAD_LIBRARY NAMES gthread-2.0 PATHS ${_glib_query_output} ) - - MARK_AS_ADVANCED(QT_GLIB_LIBRARY) - MARK_AS_ADVANCED(QT_GTHREAD_LIBRARY) - ENDIF(NOT QT_GLIB_LIBRARY OR NOT QT_GTHREAD_LIBRARY) - - IF(QT_GLIB_LIBRARY AND QT_GTHREAD_LIBRARY) - SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} - ${QT_GTHREAD_LIBRARY} ${QT_GLIB_LIBRARY}) - ENDIF(QT_GLIB_LIBRARY AND QT_GTHREAD_LIBRARY) - - - # Qt 4.5+ also links to gobject-2.0 - IF(QT_VERSION_MINOR GREATER 4) - IF(NOT QT_GOBJECT_LIBRARY) - EXECUTE_PROCESS(COMMAND pkg-config --libs-only-L gobject-2.0 - OUTPUT_VARIABLE _glib_query_output - RESULT_VARIABLE _glib_result - ERROR_VARIABLE _glib_query_output ) - - IF(_glib_result MATCHES 0) - STRING(REPLACE "-L" "" _glib_query_output "${_glib_query_output}") - SEPARATE_ARGUMENTS(_glib_query_output) - ELSE(_glib_result MATCHES 0) - SET(_glib_query_output) - ENDIF(_glib_result MATCHES 0) - - FIND_LIBRARY(QT_GOBJECT_LIBRARY NAMES gobject-2.0 PATHS ${_glib_query_output} ) - - MARK_AS_ADVANCED(QT_GOBJECT_LIBRARY) - ENDIF(NOT QT_GOBJECT_LIBRARY) - - IF(QT_GOBJECT_LIBRARY) - SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} - ${QT_GOBJECT_LIBRARY}) - ENDIF(QT_GOBJECT_LIBRARY) - ENDIF(QT_VERSION_MINOR GREATER 4) - - ENDIF(QT_QCONFIG MATCHES "glib") - - ## clock-monotonic, just see if we need to link with rt - IF(QT_QCONFIG MATCHES "clock-monotonic") - SET(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) - SET(CMAKE_REQUIRED_LIBRARIES rt) - CHECK_SYMBOL_EXISTS(_POSIX_TIMERS "unistd.h;time.h" QT_POSIX_TIMERS) - SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) - IF(QT_POSIX_TIMERS) - FIND_LIBRARY(QT_RT_LIBRARY NAMES rt) - MARK_AS_ADVANCED(QT_RT_LIBRARY) - IF(QT_RT_LIBRARY) - SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_RT_LIBRARY}) - ENDIF(QT_RT_LIBRARY) - ENDIF(QT_POSIX_TIMERS) - ENDIF(QT_QCONFIG MATCHES "clock-monotonic") - - IF(Q_WS_X11) - # X11 libraries Qt absolutely depends on - QT_QUERY_QMAKE(QT_LIBS_X11 "QMAKE_LIBS_X11") - SEPARATE_ARGUMENTS(QT_LIBS_X11) - FOREACH(QT_X11_LIB ${QT_LIBS_X11}) - STRING(REGEX REPLACE "-l" "" QT_X11_LIB "${QT_X11_LIB}") - SET(QT_TMP_STR "QT_X11_${QT_X11_LIB}_LIBRARY") - FIND_LIBRARY(${QT_TMP_STR} NAMES "${QT_X11_LIB}" PATHS ${QMAKE_LIBDIR_X11}) - MARK_AS_ADVANCED(${QT_TMP_STR}) - IF(${QT_TMP_STR}) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${${QT_TMP_STR}}) - ENDIF(${QT_TMP_STR}) - ENDFOREACH(QT_X11_LIB) - - QT_QUERY_QMAKE(QT_LIBS_THREAD "QMAKE_LIBS_THREAD") - SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_LIBS_THREAD}) - - QT_QUERY_QMAKE(QMAKE_LIBS_DYNLOAD "QMAKE_LIBS_DYNLOAD") - SET (QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QMAKE_LIBS_DYNLOAD}) - - ENDIF(Q_WS_X11) - - IF(Q_WS_WIN) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} imm32 winmm) - SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ws2_32) - ENDIF(Q_WS_WIN) - - IF(Q_WS_MAC) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} "-framework Carbon") - - # Qt 4.0, 4.1, 4.2 use QuickTime - IF(QT_VERSION_MINOR LESS 3) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} "-framework QuickTime") - ENDIF(QT_VERSION_MINOR LESS 3) - - # Qt 4.2+ use AppKit - IF(QT_VERSION_MINOR GREATER 1) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} "-framework AppKit") - ENDIF(QT_VERSION_MINOR GREATER 1) + INCLUDE("${_qt4_current_dir}/Qt4ConfigDependentSettings.cmake") - SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} "-framework ApplicationServices") - ENDIF(Q_WS_MAC) ####################################### # diff --git a/Modules/FindRuby.cmake b/Modules/FindRuby.cmake index cf7710e..45e2da6 100644 --- a/Modules/FindRuby.cmake +++ b/Modules/FindRuby.cmake @@ -152,6 +152,7 @@ ENDIF(NOT RUBY_VERSION_MAJOR) SET(RUBY_VERSION "${RUBY_VERSION_MAJOR}.${RUBY_VERSION_MINOR}.${RUBY_VERSION_PATCH}") SET(_RUBY_VERSION_SHORT "${RUBY_VERSION_MAJOR}.${RUBY_VERSION_MINOR}") SET(_RUBY_VERSION_SHORT_NODOT "${RUBY_VERSION_MAJOR}${RUBY_VERSION_MINOR}") +SET(_RUBY_NODOT_VERSION "${RUBY_VERSION_MAJOR}${RUBY_VERSION_MINOR}${RUBY_VERSION_PATCH}") # Now we know which version we found IF(Ruby_FIND_VERSION) @@ -180,7 +181,6 @@ SET(RUBY_INCLUDE_DIRS ${RUBY_INCLUDE_DIR} ) # if ruby > 1.8 is required or if ruby > 1.8 was found, search for the config.h dir IF( ${Ruby_FIND_VERSION_SHORT_NODOT} GREATER 18 OR ${_RUBY_VERSION_SHORT_NODOT} GREATER 18 OR RUBY_HDR_DIR) - message(STATUS "lookign for config.h") FIND_PATH(RUBY_CONFIG_INCLUDE_DIR NAMES ruby/config.h config.h HINTS @@ -214,10 +214,10 @@ IF(WIN32) ENDIF( MSVC90 ) LIST(APPEND _RUBY_POSSIBLE_LIB_NAMES - "msvcr${_RUBY_MSVC_RUNTIME}-ruby${RUBY_NODOT_VERSION}" - "msvcr${_RUBY_MSVC_RUNTIME}-ruby${RUBY_NODOT_VERSION}-static" - "msvcrt-ruby${RUBY_NODOT_VERSION}" - "msvcrt-ruby${RUBY_NODOT_VERSION}-static" ) + "msvcr${_RUBY_MSVC_RUNTIME}-ruby${_RUBY_NODOT_VERSION}" + "msvcr${_RUBY_MSVC_RUNTIME}-ruby${_RUBY_NODOT_VERSION}-static" + "msvcrt-ruby${_RUBY_NODOT_VERSION}" + "msvcrt-ruby${_RUBY_NODOT_VERSION}-static" ) ENDIF(WIN32) FIND_LIBRARY(RUBY_LIBRARY NAMES ${_RUBY_POSSIBLE_LIB_NAMES} HINTS ${RUBY_POSSIBLE_LIB_DIR} ) diff --git a/Modules/FindTclsh.cmake b/Modules/FindTclsh.cmake index ff0d0a5..9b7529b 100644 --- a/Modules/FindTclsh.cmake +++ b/Modules/FindTclsh.cmake @@ -20,9 +20,9 @@ # (To distributed this file outside of CMake, substitute the full # License text for the above reference.) -IF(WIN32 AND UNIX) +IF(CYGWIN) FIND_PROGRAM(TCL_TCLSH NAMES cygtclsh83 cygtclsh80) -ENDIF(WIN32 AND UNIX) +ENDIF(CYGWIN) GET_FILENAME_COMPONENT(TK_WISH_PATH "${TK_WISH}" PATH) GET_FILENAME_COMPONENT(TK_WISH_PATH_PARENT "${TK_WISH_PATH}" PATH) diff --git a/Modules/FindX11.cmake b/Modules/FindX11.cmake index 531c026..c084df0 100644 --- a/Modules/FindX11.cmake +++ b/Modules/FindX11.cmake @@ -6,6 +6,7 @@ # # and also the following more fine grained variables: # Include paths: X11_ICE_INCLUDE_PATH, X11_ICE_LIB, X11_ICE_FOUND +# X11_X11_INCLUDE_PATH, X11_X11_LIB # X11_Xaccessrules_INCLUDE_PATH, X11_Xaccess_FOUND # X11_Xaccessstr_INCLUDE_PATH, X11_Xaccess_FOUND # X11_Xau_INCLUDE_PATH, X11_Xau_LIB, X11_Xau_FOUND diff --git a/Modules/FortranCInterface.cmake b/Modules/FortranCInterface.cmake index 7a360de..a7d5571 100644 --- a/Modules/FortranCInterface.cmake +++ b/Modules/FortranCInterface.cmake @@ -100,6 +100,10 @@ if(FortranCInterface_SOURCE_DIR) return() endif() +# Use CMake 2.8.0 behavior for this module regardless of including context. +cmake_policy(PUSH) +cmake_policy(VERSION 2.8.0) + #----------------------------------------------------------------------------- # Verify that C and Fortran are available. foreach(lang C Fortran) @@ -244,6 +248,9 @@ function(FortranCInterface_VERIFY) VerifyFortranC CMAKE_FLAGS -DVERIFY_CXX=${verify_cxx} -DCMAKE_VERBOSE_MAKEFILE=ON + "-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}" + "-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS}" + "-DCMAKE_Fortran_FLAGS:STRING=${CMAKE_Fortran_FLAGS}" OUTPUT_VARIABLE _output) file(WRITE "${FortranCInterface_BINARY_DIR}/Verify${lang}/output.txt" "${_output}") @@ -273,3 +280,6 @@ function(FortranCInterface_VERIFY) "The output was:\n ${_output}") endif() endfunction() + +# Restore including context policies. +cmake_policy(POP) diff --git a/Modules/FortranCInterface/CMakeLists.txt b/Modules/FortranCInterface/CMakeLists.txt index d014d9a..18014af 100644 --- a/Modules/FortranCInterface/CMakeLists.txt +++ b/Modules/FortranCInterface/CMakeLists.txt @@ -56,6 +56,7 @@ list(REMOVE_DUPLICATES module_symbols) # Note that some compiler manglings cannot be invoked from C: # MIPSpro uses "MY_SUB.in.MY_MODULE" # SunPro uses "my_module.my_sub_" +# PathScale uses "MY_SUB.in.MY_MODULE" # Add module symbols only with Fortran90. if(CMAKE_Fortran_COMPILER_SUPPORTS_F90) diff --git a/Modules/FortranCInterface/Detect.cmake b/Modules/FortranCInterface/Detect.cmake index 70dbe27..2ea43d1 100644 --- a/Modules/FortranCInterface/Detect.cmake +++ b/Modules/FortranCInterface/Detect.cmake @@ -39,6 +39,9 @@ try_compile(FortranCInterface_COMPILED ${FortranCInterface_BINARY_DIR} ${FortranCInterface_SOURCE_DIR} FortranCInterface + CMAKE_FLAGS + "-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}" + "-DCMAKE_Fortran_FLAGS:STRING=${CMAKE_Fortran_FLAGS}" OUTPUT_VARIABLE FortranCInterface_OUTPUT) set(FortranCInterface_COMPILED ${FortranCInterface_COMPILED}) unset(FortranCInterface_COMPILED CACHE) diff --git a/Modules/FortranCInterface/mymodule_.c b/Modules/FortranCInterface/mymodule_.c index a7152af..b5feda6 100644 --- a/Modules/FortranCInterface/mymodule_.c +++ b/Modules/FortranCInterface/mymodule_.c @@ -1,2 +1,8 @@ +#if defined(__PATHSCALE__) +/* PathScale Fortran wants mymodule_ when calling any mymodule symbol, + but module symbols use '.in.' so we cannot provide them anyway. */ +void pathscale_mymodule_(void) {} +#else /* PGI Fortran wants mymodule_ when calling any mymodule symbol. */ void mymodule_(void) {} +#endif diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake index 67d4a14..123b433 100644 --- a/Modules/GetPrerequisites.cmake +++ b/Modules/GetPrerequisites.cmake @@ -389,7 +389,7 @@ function(gp_resolved_file_type original_file file exepath dirs type_var) string(TOLOWER "$ENV{windir}" windir) string(REGEX REPLACE "\\\\" "/" windir "${windir}") - if(lower MATCHES "^(${sysroot}/system|${windir}/system|(.*/)*msvc[^/]+dll)") + if(lower MATCHES "^(${sysroot}/sys(tem|wow)|${windir}/sys(tem|wow)|(.*/)*msvc[^/]+dll)") set(is_system 1) endif() endif() diff --git a/Modules/InstallRequiredSystemLibraries.cmake b/Modules/InstallRequiredSystemLibraries.cmake index 6f24cd6..97c6ccb 100644 --- a/Modules/InstallRequiredSystemLibraries.cmake +++ b/Modules/InstallRequiredSystemLibraries.cmake @@ -1,11 +1,11 @@ # By including this file, all files in the CMAKE_INSTALL_DEBUG_LIBRARIES, # will be installed with INSTALL_PROGRAMS into /bin for WIN32 and /lib # for non-win32. If CMAKE_SKIP_INSTALL_RULES is set to TRUE before including -# this file, then the INSTALL command is not called. The use can use +# this file, then the INSTALL command is not called. The user can use # the variable CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS to use a custom install # command and install them into any directory they want. # If it is the MSVC compiler, then the microsoft run -# time libraries will be found add automatically added to the +# time libraries will be found and automatically added to the # CMAKE_INSTALL_DEBUG_LIBRARIES, and installed. # If CMAKE_INSTALL_DEBUG_LIBRARIES is set and it is the MSVC # compiler, then the debug libraries are installed when available. @@ -114,6 +114,34 @@ IF(MSVC) ENDIF(CMAKE_INSTALL_DEBUG_LIBRARIES) ENDIF(MSVC90) + IF(MSVC10) + # Find the runtime library redistribution directory. + FIND_PATH(MSVC10_REDIST_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.VC100.CRT + PATHS + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;InstallDir]/../../VC/redist" + "${base_dir}/VC/redist" + ) + MARK_AS_ADVANCED(MSVC10_REDIST_DIR) + SET(MSVC10_CRT_DIR "${MSVC10_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC100.CRT") + + # Install the manifest that allows DLLs to be loaded from the + # directory containing the executable. + SET(__install__libs + "${MSVC10_CRT_DIR}/Microsoft.VC100.CRT.manifest" + "${MSVC10_CRT_DIR}/msvcp100.dll" + "${MSVC10_CRT_DIR}/msvcr100.dll" + ) + IF(CMAKE_INSTALL_DEBUG_LIBRARIES) + SET(MSVC10_CRT_DIR + "${MSVC10_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC90.DebugCRT") + SET(__install__libs ${__install__libs} + "${MSVC10_CRT_DIR}/Microsoft.VC100.DebugCRT.manifest" + "${MSVC10_CRT_DIR}/msvcp100d.dll" + "${MSVC10_CRT_DIR}/msvcr100d.dll" + ) + ENDIF(CMAKE_INSTALL_DEBUG_LIBRARIES) + ENDIF(MSVC10) + IF(CMAKE_INSTALL_MFC_LIBRARIES) IF(MSVC70) SET(__install__libs ${__install__libs} @@ -207,6 +235,47 @@ IF(MSVC) ) ENDIF(MSVC90) + IF(MSVC10) + IF(CMAKE_INSTALL_DEBUG_LIBRARIES) + SET(MSVC10_MFC_DIR + "${MSVC10_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC100.DebugMFC") + SET(__install__libs ${__install__libs} + "${MSVC10_MFC_DIR}/Microsoft.VC100.DebugMFC.manifest" + "${MSVC10_MFC_DIR}/mfc100d.dll" + "${MSVC10_MFC_DIR}/mfc100ud.dll" + "${MSVC10_MFC_DIR}/mfcm100d.dll" + "${MSVC10_MFC_DIR}/mfcm100ud.dll" + ) + ENDIF(CMAKE_INSTALL_DEBUG_LIBRARIES) + + SET(MSVC10_MFC_DIR "${MSVC10_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC100.MFC") + # Install the manifest that allows DLLs to be loaded from the + # directory containing the executable. + SET(__install__libs ${__install__libs} + "${MSVC10_MFC_DIR}/Microsoft.VC100.MFC.manifest" + "${MSVC10_MFC_DIR}/mfc100.dll" + "${MSVC10_MFC_DIR}/mfc100u.dll" + "${MSVC10_MFC_DIR}/mfcm100.dll" + "${MSVC10_MFC_DIR}/mfcm100u.dll" + ) + # include the language dll's for vs10 as well as the actuall dll's + SET(MSVC10_MFCLOC_DIR "${MSVC10_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC100.MFCLOC") + # Install the manifest that allows DLLs to be loaded from the + # directory containing the executable. + SET(__install__libs ${__install__libs} + "${MSVC10_MFCLOC_DIR}/Microsoft.VC100.MFCLOC.manifest" + "${MSVC10_MFCLOC_DIR}/mfc100chs.dll" + "${MSVC10_MFCLOC_DIR}/mfc100cht.dll" + "${MSVC10_MFCLOC_DIR}/mfc100enu.dll" + "${MSVC10_MFCLOC_DIR}/mfc100esp.dll" + "${MSVC10_MFCLOC_DIR}/mfc100deu.dll" + "${MSVC10_MFCLOC_DIR}/mfc100fra.dll" + "${MSVC10_MFCLOC_DIR}/mfc100ita.dll" + "${MSVC10_MFCLOC_DIR}/mfc100jpn.dll" + "${MSVC10_MFCLOC_DIR}/mfc100kor.dll" + ) + ENDIF(MSVC10) + ENDIF(CMAKE_INSTALL_MFC_LIBRARIES) FOREACH(lib diff --git a/Modules/KDE3Macros.cmake b/Modules/KDE3Macros.cmake index f358cd7..0f2d479 100644 --- a/Modules/KDE3Macros.cmake +++ b/Modules/KDE3Macros.cmake @@ -322,7 +322,11 @@ MACRO(KDE3_INSTALL_LIBTOOL_FILE _target) FILE(APPEND ${_laname} "# The name that we can dlopen(3).\n") FILE(APPEND ${_laname} "dlname='${_soname}'\n") FILE(APPEND ${_laname} "# Names of this library\n") - FILE(APPEND ${_laname} "library_names='${_soname} ${_soname} ${_soname}'\n") + IF(CYGWIN) + FILE(APPEND ${_laname} "library_names='${_soname}'\n") + ELSE(CYGWIN) + FILE(APPEND ${_laname} "library_names='${_soname} ${_soname} ${_soname}'\n") + ENDIF(CYGWIN) FILE(APPEND ${_laname} "# The name of the static archive\n") FILE(APPEND ${_laname} "old_library=''\n") FILE(APPEND ${_laname} "# Libraries that this one depends upon.\n") diff --git a/Modules/NSIS.template.in b/Modules/NSIS.template.in index d90967d..26a936e 100644 --- a/Modules/NSIS.template.in +++ b/Modules/NSIS.template.in @@ -74,7 +74,7 @@ Var AR_RegFlags ClearErrors ;Reading component status from registry - ReadRegDWORD $AR_RegFlags HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@\Components\${SecName}" "Installed" + ReadRegDWORD $AR_RegFlags HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@\Components\${SecName}" "Installed" IfErrors "default_${SecName}" ;Status will stay default if registry value not found ;(component was never installed) @@ -107,13 +107,13 @@ Var AR_RegFlags ;Section is not selected: ;Calling Section uninstall macro and writing zero installed flag !insertmacro "Remove_${${SecName}}" - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@\Components\${SecName}" \ + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@\Components\${SecName}" \ "Installed" 0 Goto "exit_${SecName}" "leave_${SecName}:" ;Section is selected: - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@\Components\${SecName}" \ + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@\Components\${SecName}" \ "Installed" 1 "exit_${SecName}:" @@ -484,7 +484,7 @@ Function ConditionalAddToRegisty Pop $0 Pop $1 StrCmp "$0" "" ConditionalAddToRegisty_EmptyString - WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@" \ + WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@" \ "$1" "$0" ;MessageBox MB_OK "Set Registry: '$1' to '$0'" DetailPrint "Set install registry entry: '$1' to '$0'" @@ -794,17 +794,17 @@ FunctionEnd Section "Uninstall" ReadRegStr $START_MENU SHCTX \ - "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@" "StartMenu" + "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@" "StartMenu" ;MessageBox MB_OK "Start menu is in: $START_MENU" ReadRegStr $DO_NOT_ADD_TO_PATH SHCTX \ - "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@" "DoNotAddToPath" + "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@" "DoNotAddToPath" ReadRegStr $ADD_TO_PATH_ALL_USERS SHCTX \ - "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@" "AddToPathAllUsers" + "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@" "AddToPathAllUsers" ReadRegStr $ADD_TO_PATH_CURRENT_USER SHCTX \ - "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@" "AddToPathCurrentUser" + "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@" "AddToPathCurrentUser" ;MessageBox MB_OK "Add to path: $DO_NOT_ADD_TO_PATH all users: $ADD_TO_PATH_ALL_USERS" ReadRegStr $INSTALL_DESKTOP SHCTX \ - "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@" "InstallToDesktop" + "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@" "InstallToDesktop" ;MessageBox MB_OK "Install to desktop: $INSTALL_DESKTOP " @CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS@ @@ -821,7 +821,7 @@ Section "Uninstall" ;Remove the uninstaller itself. Delete "$INSTDIR\Uninstall.exe" - DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@" + DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@" ;Remove the installation directory if it is empty. RMDir "$INSTDIR" diff --git a/Modules/Platform/AIX-GNU-C.cmake b/Modules/Platform/AIX-GNU-C.cmake new file mode 100644 index 0000000..f49d528 --- /dev/null +++ b/Modules/Platform/AIX-GNU-C.cmake @@ -0,0 +1,2 @@ +include(Platform/AIX-GNU) +__aix_compiler_gnu(C) diff --git a/Modules/Platform/AIX-GNU-CXX.cmake b/Modules/Platform/AIX-GNU-CXX.cmake new file mode 100644 index 0000000..ec8e83f --- /dev/null +++ b/Modules/Platform/AIX-GNU-CXX.cmake @@ -0,0 +1,2 @@ +include(Platform/AIX-GNU) +__aix_compiler_gnu(CXX) diff --git a/Modules/Platform/AIX-GNU-Fortran.cmake b/Modules/Platform/AIX-GNU-Fortran.cmake new file mode 100644 index 0000000..07772a7 --- /dev/null +++ b/Modules/Platform/AIX-GNU-Fortran.cmake @@ -0,0 +1,2 @@ +include(Platform/AIX-GNU) +__aix_compiler_gnu(Fortran) diff --git a/Modules/Platform/AIX-GNU.cmake b/Modules/Platform/AIX-GNU.cmake new file mode 100644 index 0000000..fc3880e --- /dev/null +++ b/Modules/Platform/AIX-GNU.cmake @@ -0,0 +1,23 @@ + +#============================================================================= +# Copyright 2002-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.) + +# This module is shared by multiple languages; use include blocker. +if(__AIX_COMPILER_GNU) + return() +endif() +set(__AIX_COMPILER_GNU 1) + +macro(__aix_compiler_gnu lang) + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS} -Wl,-G") +endmacro() diff --git a/Modules/Platform/AIX.cmake b/Modules/Platform/AIX.cmake index c8a33c3..0ab0cce 100644 --- a/Modules/Platform/AIX.cmake +++ b/Modules/Platform/AIX.cmake @@ -15,16 +15,6 @@ SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") # Files named "libfoo.a" may actually be shared libraries. SET_PROPERTY(GLOBAL PROPERTY TARGET_ARCHIVES_MAY_BE_SHARED_LIBS 1) -# CXX Compiler -IF(CMAKE_COMPILER_IS_GNUCXX) - SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-shared -Wl,-G") # -shared -ENDIF(CMAKE_COMPILER_IS_GNUCXX) - -# C Compiler -IF(CMAKE_COMPILER_IS_GNUCC) - SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared -Wl,-G") # -shared -ENDIF(CMAKE_COMPILER_IS_GNUCC) - # since .a can be a static or shared library on AIX, we can not do this. # at some point if we wanted it, we would have to figure out if a .a is # static or shared, then we could add this back: diff --git a/Modules/Platform/BeOS.cmake b/Modules/Platform/BeOS.cmake index f4d84d7..41aa8f7 100644 --- a/Modules/Platform/BeOS.cmake +++ b/Modules/Platform/BeOS.cmake @@ -1,14 +1,10 @@ SET(BEOS 1) -# GCC is the default compiler on BeOS. -INCLUDE(${CMAKE_ROOT}/Modules/Platform/gcc.cmake) - SET(CMAKE_DL_LIBS root be) SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-nostart") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") -SET(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-Wl,-soname,") INCLUDE(Platform/UnixPaths) diff --git a/Modules/Platform/CYGWIN-GNU-C.cmake b/Modules/Platform/CYGWIN-GNU-C.cmake new file mode 100644 index 0000000..9eb0ecf --- /dev/null +++ b/Modules/Platform/CYGWIN-GNU-C.cmake @@ -0,0 +1,2 @@ +include(Platform/CYGWIN-GNU) +__cygwin_compiler_gnu(C) diff --git a/Modules/Platform/CYGWIN-GNU-CXX.cmake b/Modules/Platform/CYGWIN-GNU-CXX.cmake new file mode 100644 index 0000000..2603dcd --- /dev/null +++ b/Modules/Platform/CYGWIN-GNU-CXX.cmake @@ -0,0 +1,2 @@ +include(Platform/CYGWIN-GNU) +__cygwin_compiler_gnu(CXX) diff --git a/Modules/Platform/CYGWIN-GNU-Fortran.cmake b/Modules/Platform/CYGWIN-GNU-Fortran.cmake new file mode 100644 index 0000000..d3b49b6 --- /dev/null +++ b/Modules/Platform/CYGWIN-GNU-Fortran.cmake @@ -0,0 +1,2 @@ +include(Platform/CYGWIN-GNU) +__cygwin_compiler_gnu(Fortran) diff --git a/Modules/Platform/CYGWIN-GNU.cmake b/Modules/Platform/CYGWIN-GNU.cmake new file mode 100644 index 0000000..6a80f62 --- /dev/null +++ b/Modules/Platform/CYGWIN-GNU.cmake @@ -0,0 +1,51 @@ + +#============================================================================= +# Copyright 2002-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.) + +# This module is shared by multiple languages; use include blocker. +if(__CYGWIN_COMPILER_GNU) + return() +endif() +set(__CYGWIN_COMPILER_GNU 1) + +# TODO: Is -Wl,--enable-auto-import now always default? +set(CMAKE_EXE_LINKER_FLAGS_INIT "-Wl,--enable-auto-import") +set(CMAKE_CREATE_WIN32_EXE "-mwindows") + +set(CMAKE_GNULD_IMAGE_VERSION + "-Wl,--major-image-version,<TARGET_VERSION_MAJOR>,--minor-image-version,<TARGET_VERSION_MINOR>") + +macro(__cygwin_compiler_gnu lang) + # Binary link rules. + set(CMAKE_${lang}_CREATE_SHARED_MODULE + "<CMAKE_${lang}_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_MODULE_${lang}_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>") + set(CMAKE_${lang}_CREATE_SHARED_LIBRARY + "<CMAKE_${lang}_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>") + set(CMAKE_${lang}_LINK_EXECUTABLE + "<CMAKE_${lang}_COMPILER> <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>") + + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "") # No -fPIC on cygwin + + # Initialize C link type selection flags. These flags are used when + # building a shared library, shared module, or executable that links + # to other libraries to select whether to use the static or shared + # versions of the libraries. + FOREACH(type SHARED_LIBRARY SHARED_MODULE EXE) + SET(CMAKE_${type}_LINK_STATIC_${lang}_FLAGS "-Wl,-Bstatic") + SET(CMAKE_${type}_LINK_DYNAMIC_${lang}_FLAGS "-Wl,-Bdynamic") + ENDFOREACH(type) + + # TODO: Is -Wl,--enable-auto-import now always default? + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS} -Wl,--enable-auto-import") + set(CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS}") +endmacro() diff --git a/Modules/Platform/CYGWIN-g77.cmake b/Modules/Platform/CYGWIN-g77.cmake deleted file mode 100644 index 942319f..0000000 --- a/Modules/Platform/CYGWIN-g77.cmake +++ /dev/null @@ -1,6 +0,0 @@ -SET(CMAKE_SHARED_LIBRARY_PREFIX "lib") -SET(CMAKE_SHARED_LIBRARY_SUFFIX ".dll") -SET(CMAKE_SHARED_LIBRARY_Fortran_FLAGS "") -SET(CMAKE_SHARED_LIBRARY_Fortran_FLAGS "") -SET(CMAKE_EXECUTABLE_SUFFIX ".exe") # .exe -INCLUDE(Platform/g77) diff --git a/Modules/Platform/CYGWIN.cmake b/Modules/Platform/CYGWIN.cmake index dd179a4..b157f72 100644 --- a/Modules/Platform/CYGWIN.cmake +++ b/Modules/Platform/CYGWIN.cmake @@ -1,55 +1,20 @@ SET(WIN32 1) SET(CYGWIN 1) -SET(CMAKE_EXE_LINKER_FLAGS_INIT "-Wl,--enable-auto-import") -SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared -Wl,--export-all-symbols -Wl,--enable-auto-import") -SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS}) -SET(CMAKE_DL_LIBS "-lgdi32" ) SET(CMAKE_SHARED_LIBRARY_PREFIX "cyg") SET(CMAKE_SHARED_LIBRARY_SUFFIX ".dll") SET(CMAKE_SHARED_MODULE_PREFIX "lib") SET(CMAKE_SHARED_MODULE_SUFFIX ".dll") SET(CMAKE_IMPORT_LIBRARY_PREFIX "lib") SET(CMAKE_IMPORT_LIBRARY_SUFFIX ".dll.a") -# no pic for gcc on cygwin -SET(CMAKE_SHARED_LIBRARY_C_FLAGS "") -SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "") SET(CMAKE_EXECUTABLE_SUFFIX ".exe") # .exe -SET(CMAKE_CREATE_WIN32_EXE "-mwindows") # Modules have a different default prefix that shared libs. SET(CMAKE_MODULE_EXISTS 1) -SET(CMAKE_FIND_LIBRARY_PREFIXES "cyg" "lib") -SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dll" ".dll.a" ".a") - -SET(CMAKE_GNULD_IMAGE_VERSION - "-Wl,--major-image-version,<TARGET_VERSION_MAJOR>,--minor-image-version,<TARGET_VERSION_MINOR>") - -SET(CMAKE_C_CREATE_SHARED_MODULE - "<CMAKE_C_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_MODULE_C_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_MODULE_CREATE_C_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>") -SET(CMAKE_CXX_CREATE_SHARED_MODULE - "<CMAKE_CXX_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_MODULE_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>") - -SET(CMAKE_C_CREATE_SHARED_LIBRARY - "<CMAKE_C_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_C_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>") -SET(CMAKE_CXX_CREATE_SHARED_LIBRARY - "<CMAKE_CXX_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>") - -SET(CMAKE_C_LINK_EXECUTABLE - "<CMAKE_C_COMPILER> <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>") -SET(CMAKE_CXX_LINK_EXECUTABLE - "<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>") +SET(CMAKE_FIND_LIBRARY_PREFIXES "lib") +SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a" ".a") # Shared libraries on cygwin can be named with their version number. SET(CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION 1) -# Initialize C link type selection flags. These flags are used when -# building a shared library, shared module, or executable that links -# to other libraries to select whether to use the static or shared -# versions of the libraries. -FOREACH(type SHARED_LIBRARY SHARED_MODULE EXE) - SET(CMAKE_${type}_LINK_STATIC_C_FLAGS "-Wl,-Bstatic") - SET(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-Wl,-Bdynamic") -ENDFOREACH(type) - INCLUDE(Platform/UnixPaths) diff --git a/Modules/Platform/Darwin-GNU-C.cmake b/Modules/Platform/Darwin-GNU-C.cmake index 100e8b1..155d594 100644 --- a/Modules/Platform/Darwin-GNU-C.cmake +++ b/Modules/Platform/Darwin-GNU-C.cmake @@ -1,2 +1,3 @@ include(Platform/Darwin-GNU) +__darwin_compiler_gnu(C) cmake_gnu_has_isysroot(C) diff --git a/Modules/Platform/Darwin-GNU-CXX.cmake b/Modules/Platform/Darwin-GNU-CXX.cmake index a2c2e16..6cc0812 100644 --- a/Modules/Platform/Darwin-GNU-CXX.cmake +++ b/Modules/Platform/Darwin-GNU-CXX.cmake @@ -1,2 +1,3 @@ include(Platform/Darwin-GNU) +__darwin_compiler_gnu(CXX) cmake_gnu_has_isysroot(CXX) diff --git a/Modules/Platform/Darwin-GNU-Fortran.cmake b/Modules/Platform/Darwin-GNU-Fortran.cmake new file mode 100644 index 0000000..8e8acc3 --- /dev/null +++ b/Modules/Platform/Darwin-GNU-Fortran.cmake @@ -0,0 +1,2 @@ +include(Platform/Darwin-GNU) +__darwin_compiler_gnu(Fortran) diff --git a/Modules/Platform/Darwin-GNU.cmake b/Modules/Platform/Darwin-GNU.cmake index 8bbad88..b528c88 100644 --- a/Modules/Platform/Darwin-GNU.cmake +++ b/Modules/Platform/Darwin-GNU.cmake @@ -1,3 +1,29 @@ + +#============================================================================= +# Copyright 2002-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.) + +# This module is shared by multiple languages; use include blocker. +if(__DARWIN_COMPILER_GNU) + return() +endif() +set(__DARWIN_COMPILER_GNU 1) + +macro(__darwin_compiler_gnu lang) + # GNU does not have -shared on OS X + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-dynamiclib -headerpad_max_install_names") + set(CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS "-bundle -headerpad_max_install_names") +endmacro() + macro(cmake_gnu_has_isysroot lang) if("x${CMAKE_${lang}_HAS_ISYSROOT}" STREQUAL "x") set(_doc "${lang} compiler has -isysroot") diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake index 825f218..1d88bf1 100644 --- a/Modules/Platform/Darwin.cmake +++ b/Modules/Platform/Darwin.cmake @@ -172,8 +172,6 @@ IF(NOT XCODE) # but the fact that the setting exists will cause the generators to support # soname computation. SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-install_name") - SET(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-install_name") - SET(CMAKE_SHARED_LIBRARY_SONAME_Fortran_FLAG "-install_name") ENDIF(NOT XCODE) # Xcode does not support -isystem yet. diff --git a/Modules/Platform/FreeBSD.cmake b/Modules/Platform/FreeBSD.cmake index e7b26ac..033db06 100644 --- a/Modules/Platform/FreeBSD.cmake +++ b/Modules/Platform/FreeBSD.cmake @@ -7,9 +7,7 @@ IF(EXISTS /usr/include/dlfcn.h) SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") # : or empty SET(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,") SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") - SET(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-Wl,-soname,") SET(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") - SET(CMAKE_EXE_EXPORTS_CXX_FLAG "-Wl,--export-dynamic") ENDIF(EXISTS /usr/include/dlfcn.h) # Shared libraries with no builtin soname may not be linked safely by diff --git a/Modules/Platform/GNU.cmake b/Modules/Platform/GNU.cmake index 26615e1..fe3d47b 100644 --- a/Modules/Platform/GNU.cmake +++ b/Modules/Platform/GNU.cmake @@ -2,9 +2,7 @@ SET(CMAKE_DL_LIBS "dl") SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") -SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-rdynamic") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") -SET(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-Wl,-soname,") INCLUDE(Platform/UnixPaths) diff --git a/Modules/Platform/HP-UX-GNU-C.cmake b/Modules/Platform/HP-UX-GNU-C.cmake new file mode 100644 index 0000000..5f9ac42 --- /dev/null +++ b/Modules/Platform/HP-UX-GNU-C.cmake @@ -0,0 +1,2 @@ +include(Platform/HP-UX-GNU) +__hpux_compiler_gnu(C) diff --git a/Modules/Platform/HP-UX-GNU-CXX.cmake b/Modules/Platform/HP-UX-GNU-CXX.cmake new file mode 100644 index 0000000..689bed0 --- /dev/null +++ b/Modules/Platform/HP-UX-GNU-CXX.cmake @@ -0,0 +1,2 @@ +include(Platform/HP-UX-GNU) +__hpux_compiler_gnu(CXX) diff --git a/Modules/Platform/HP-UX-GNU-Fortran.cmake b/Modules/Platform/HP-UX-GNU-Fortran.cmake new file mode 100644 index 0000000..ee0181f --- /dev/null +++ b/Modules/Platform/HP-UX-GNU-Fortran.cmake @@ -0,0 +1,2 @@ +include(Platform/HP-UX-GNU) +__hpux_compiler_gnu(Fortran) diff --git a/Modules/Platform/HP-UX-GNU.cmake b/Modules/Platform/HP-UX-GNU.cmake new file mode 100644 index 0000000..da9fe48 --- /dev/null +++ b/Modules/Platform/HP-UX-GNU.cmake @@ -0,0 +1,27 @@ + +#============================================================================= +# Copyright 2002-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.) + +# This module is shared by multiple languages; use include blocker. +if(__HPUX_COMPILER_GNU) + return() +endif() +set(__HPUX_COMPILER_GNU 1) + +macro(__hpux_compiler_gnu lang) + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS} -Wl,-E,-b,+nodefaultrpath") + set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-Wl,+s,-E,+nodefaultrpath") + set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,+b") + set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":") + set(CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG "-Wl,+h") +endmacro() diff --git a/Modules/Platform/HP-UX.cmake b/Modules/Platform/HP-UX.cmake index 9584cbd..f8893d8 100644 --- a/Modules/Platform/HP-UX.cmake +++ b/Modules/Platform/HP-UX.cmake @@ -15,13 +15,6 @@ SET(CMAKE_PLATFORM_USES_PATH_WHEN_NO_SONAME 1) # fortran IF(CMAKE_COMPILER_IS_GNUG77) - SET(CMAKE_SHARED_LIBRARY_Fortran_FLAGS "-fPIC") # -pic - SET(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "-shared -Wl,-E,-b,+nodefaultrpath") # -shared - SET(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS "-Wl,+s,-E,+nodefaultrpath") # +s, flag for exe link to use shared lib - SET(CMAKE_SHARED_LIBRARY_RUNTIME_Fortran_FLAG "-Wl,+b") # -rpath - SET(CMAKE_SHARED_LIBRARY_RUNTIME_Fortran_FLAG_SEP ":") # : or empty - SET(CMAKE_SHARED_LIBRARY_SONAME_Fortran_FLAG "-Wl,+h") - SET(CMAKE_SHARED_LIBRARY_Fortran_FLAGS "-fPIC") # -pic ELSE(CMAKE_COMPILER_IS_GNUG77) # use ld directly to create shared libraries for hp cc SET(CMAKE_Fortran_CREATE_SHARED_LIBRARY @@ -37,14 +30,6 @@ ENDIF(CMAKE_COMPILER_IS_GNUG77) # C compiler IF(CMAKE_COMPILER_IS_GNUCC) - # gnu gcc - SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic - SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared -Wl,-E,-b,+nodefaultrpath") # -shared - SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-Wl,+s,-E,+nodefaultrpath") # +s, flag for exe link to use shared lib - SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,+b") # -rpath - SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") # : or empty - SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,+h") - SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic ELSE(CMAKE_COMPILER_IS_GNUCC) # hp cc # use ld directly to create shared libraries for hp cc @@ -64,14 +49,6 @@ ENDIF(CMAKE_COMPILER_IS_GNUCC) # CXX compiler IF(CMAKE_COMPILER_IS_GNUCXX) - # for gnu C++ - SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-fPIC") # -pic - SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-shared -Wl,-E,-b,+nodefaultrpath") # -shared - SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "-Wl,+s,-E,+nodefaultrpath") # +s, flag for exe link to use shared lib - SET(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG "-Wl,+b") # -rpath - SET(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG_SEP ":") # : or empty - SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-fPIC") # -pic - SET(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-Wl,+h") ELSE(CMAKE_COMPILER_IS_GNUCXX) # for hp aCC SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "+Z") # -pic diff --git a/Modules/Platform/Haiku.cmake b/Modules/Platform/Haiku.cmake index 6676f24..8277a24 100644 --- a/Modules/Platform/Haiku.cmake +++ b/Modules/Platform/Haiku.cmake @@ -1,15 +1,11 @@ SET(BEOS 1) -# GCC is the default compiler on Haiku. -INCLUDE(${CMAKE_ROOT}/Modules/Platform/gcc.cmake) - SET(CMAKE_DL_LIBS root be) SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-nostart") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") -SET(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-Wl,-soname,") INCLUDE(Platform/UnixPaths) LIST(APPEND CMAKE_SYSTEM_PREFIX_PATH /boot/common) diff --git a/Modules/Platform/IRIX.cmake b/Modules/Platform/IRIX.cmake index 58c1037..fac941f 100644 --- a/Modules/Platform/IRIX.cmake +++ b/Modules/Platform/IRIX.cmake @@ -1,6 +1,5 @@ SET(CMAKE_DL_LIBS "") SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared -rdata_shared") -SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-shared -rdata_shared") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") # -rpath SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP "") # : or empty IF(NOT CMAKE_COMPILER_IS_GNUCXX) diff --git a/Modules/Platform/IRIX64.cmake b/Modules/Platform/IRIX64.cmake index d83ca60..b60a7f2 100644 --- a/Modules/Platform/IRIX64.cmake +++ b/Modules/Platform/IRIX64.cmake @@ -1,10 +1,8 @@ SET(CMAKE_DL_LIBS "") SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared -rdata_shared") -SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-shared -rdata_shared") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") # -rpath SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP "") # : or empty SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") -SET(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-Wl,-soname,") IF(NOT CMAKE_COMPILER_IS_GNUCC) # Set default flags init. SET(CMAKE_C_FLAGS_INIT "") diff --git a/Modules/Platform/Linux-GNU-C.cmake b/Modules/Platform/Linux-GNU-C.cmake new file mode 100644 index 0000000..3ab142f --- /dev/null +++ b/Modules/Platform/Linux-GNU-C.cmake @@ -0,0 +1,2 @@ +INCLUDE(Platform/Linux-GNU) +__linux_compiler_gnu(C) diff --git a/Modules/Platform/Linux-GNU-CXX.cmake b/Modules/Platform/Linux-GNU-CXX.cmake new file mode 100644 index 0000000..9e4f904 --- /dev/null +++ b/Modules/Platform/Linux-GNU-CXX.cmake @@ -0,0 +1,2 @@ +INCLUDE(Platform/Linux-GNU) +__linux_compiler_gnu(CXX) diff --git a/Modules/Platform/Linux-GNU-Fortran.cmake b/Modules/Platform/Linux-GNU-Fortran.cmake index 16d63fc..e364c87 100644 --- a/Modules/Platform/Linux-GNU-Fortran.cmake +++ b/Modules/Platform/Linux-GNU-Fortran.cmake @@ -1,16 +1,2 @@ -SET(CMAKE_Fortran_MODDIR_FLAG -J) -SET (CMAKE_SHARED_LIBRARY_Fortran_FLAGS "-fPIC") # -pic -SET (CMAKE_Fortran_FLAGS_INIT "") -SET (CMAKE_Fortran_FLAGS_DEBUG_INIT "-g") -SET (CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "-Os") -SET (CMAKE_Fortran_FLAGS_RELEASE_INIT "-O3") -SET (CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "-O2 -g") - -IF(NOT APPLE) - SET (CMAKE_INCLUDE_SYSTEM_FLAG_Fortran "-isystem ") -ENDIF(NOT APPLE) - -# These will require updates to CMake C++ code to support -# preprocessing rules for Fortran. -#SET (CMAKE_Fortran_CREATE_PREPROCESSED_SOURCE "<CMAKE_Fortran_COMPILER> <DEFINES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") -#SET (CMAKE_Fortran_CREATE_ASSEMBLY_SOURCE "<CMAKE_Fortran_COMPILER> <DEFINES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") +INCLUDE(Platform/Linux-GNU) +__linux_compiler_gnu(Fortran) diff --git a/Modules/Platform/Linux-GNU.cmake b/Modules/Platform/Linux-GNU.cmake new file mode 100644 index 0000000..d257f34 --- /dev/null +++ b/Modules/Platform/Linux-GNU.cmake @@ -0,0 +1,25 @@ + +#============================================================================= +# Copyright 2010 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.) + +# This module is shared by multiple languages; use include blocker. +if(__LINUX_COMPILER_GNU) + return() +endif() +set(__LINUX_COMPILER_GNU 1) + +macro(__linux_compiler_gnu lang) + # We pass this for historical reasons. Projects may have + # executables that use dlopen but do not set ENABLE_EXPORTS. + set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-rdynamic") +endmacro() diff --git a/Modules/Platform/Linux-Intel-C.cmake b/Modules/Platform/Linux-Intel-C.cmake index 7be331e..c909e68 100644 --- a/Modules/Platform/Linux-Intel-C.cmake +++ b/Modules/Platform/Linux-Intel-C.cmake @@ -1,8 +1,2 @@ INCLUDE(Platform/Linux-Intel) -IF(XIAR) - # INTERPROCEDURAL_OPTIMIZATION - SET(CMAKE_C_COMPILE_OPTIONS_IPO -ipo) - SET(CMAKE_C_CREATE_STATIC_LIBRARY_IPO - "${XIAR} cr <TARGET> <LINK_FLAGS> <OBJECTS> " - "${XIAR} -s <TARGET> ") -ENDIF(XIAR) +__linux_compiler_intel(C) diff --git a/Modules/Platform/Linux-Intel-CXX.cmake b/Modules/Platform/Linux-Intel-CXX.cmake index cedb196..0b7daf4 100644 --- a/Modules/Platform/Linux-Intel-CXX.cmake +++ b/Modules/Platform/Linux-Intel-CXX.cmake @@ -1,8 +1,2 @@ INCLUDE(Platform/Linux-Intel) -IF(XIAR) - # INTERPROCEDURAL_OPTIMIZATION - SET(CMAKE_CXX_COMPILE_OPTIONS_IPO -ipo) - SET(CMAKE_CXX_CREATE_STATIC_LIBRARY_IPO - "${XIAR} cr <TARGET> <LINK_FLAGS> <OBJECTS> " - "${XIAR} -s <TARGET> ") -ENDIF(XIAR) +__linux_compiler_intel(CXX) diff --git a/Modules/Platform/Linux-Intel-Fortran.cmake b/Modules/Platform/Linux-Intel-Fortran.cmake index da3b935..342b5c2 100644 --- a/Modules/Platform/Linux-Intel-Fortran.cmake +++ b/Modules/Platform/Linux-Intel-Fortran.cmake @@ -1,16 +1,4 @@ INCLUDE(Platform/Linux-Intel) -IF(XIAR) - # INTERPROCEDURAL_OPTIMIZATION - SET(CMAKE_Fortran_COMPILE_OPTIONS_IPO -ipo) - SET(CMAKE_Fortran_CREATE_STATIC_LIBRARY_IPO - "${XIAR} cr <TARGET> <LINK_FLAGS> <OBJECTS> " - "${XIAR} -s <TARGET> ") -ENDIF(XIAR) - -SET(CMAKE_SHARED_LIBRARY_Fortran_FLAGS "-fPIC") -SET(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "-shared -i_dynamic -nofor_main") -SET(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS "-i_dynamic") -SET(CMAKE_SHARED_LIBRARY_RUNTIME_Fortran_FLAG "-Wl,-rpath,") -SET(CMAKE_SHARED_LIBRARY_RUNTIME_Fortran_FLAG_SEP ":") -SET(CMAKE_SHARED_LIBRARY_SONAME_Fortran_FLAG "-Wl,-soname,") -SET(CMAKE_DL_LIBS "dl") +__linux_compiler_intel(Fortran) +set(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS} -i_dynamic -nofor_main") +set(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS "-i_dynamic") diff --git a/Modules/Platform/Linux-Intel.cmake b/Modules/Platform/Linux-Intel.cmake index e7a67b6..dff90e9 100644 --- a/Modules/Platform/Linux-Intel.cmake +++ b/Modules/Platform/Linux-Intel.cmake @@ -1,3 +1,23 @@ + +#============================================================================= +# Copyright 2002-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.) + +# This module is shared by multiple languages; use include blocker. +if(__LINUX_COMPILER_INTEL) + return() +endif() +set(__LINUX_COMPILER_INTEL 1) + if(NOT XIAR) set(_intel_xiar_hints) foreach(lang C CXX Fortran) @@ -9,3 +29,20 @@ if(NOT XIAR) find_program(XIAR NAMES xiar HINTS ${_intel_xiar_hints}) mark_as_advanced(XIAR) endif(NOT XIAR) + +macro(__linux_compiler_intel lang) + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") + + # We pass this for historical reasons. Projects may have + # executables that use dlopen but do not set ENABLE_EXPORTS. + set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-rdynamic") + + if(XIAR) + # INTERPROCEDURAL_OPTIMIZATION + set(CMAKE_${lang}_COMPILE_OPTIONS_IPO -ipo) + set(CMAKE_${lang}_CREATE_STATIC_LIBRARY_IPO + "${XIAR} cr <TARGET> <LINK_FLAGS> <OBJECTS> " + "${XIAR} -s <TARGET> ") + endif() +endmacro() diff --git a/Modules/Platform/Linux-PGI-C.cmake b/Modules/Platform/Linux-PGI-C.cmake index df3c38e..edf4f3f 100644 --- a/Modules/Platform/Linux-PGI-C.cmake +++ b/Modules/Platform/Linux-PGI-C.cmake @@ -1,5 +1,2 @@ -SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") - -SET (CMAKE_C_CREATE_PREPROCESSED_SOURCE "<CMAKE_C_COMPILER> <DEFINES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") -SET (CMAKE_C_CREATE_ASSEMBLY_SOURCE "<CMAKE_C_COMPILER> <DEFINES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") - +include(Platform/Linux-PGI) +__linux_compiler_pgi(C) diff --git a/Modules/Platform/Linux-PGI-CXX.cmake b/Modules/Platform/Linux-PGI-CXX.cmake index 32a2a8e..d425f88 100644 --- a/Modules/Platform/Linux-PGI-CXX.cmake +++ b/Modules/Platform/Linux-PGI-CXX.cmake @@ -1,4 +1,2 @@ -SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") - -SET (CMAKE_CXX_CREATE_PREPROCESSED_SOURCE "<CMAKE_CXX_COMPILER> <DEFINES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") -SET (CMAKE_CXX_CREATE_ASSEMBLY_SOURCE "<CMAKE_CXX_COMPILER> <DEFINES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") +include(Platform/Linux-PGI) +__linux_compiler_pgi(CXX) diff --git a/Modules/Platform/Linux-PGI-Fortran.cmake b/Modules/Platform/Linux-PGI-Fortran.cmake index 7c99e79..e8731a3 100644 --- a/Modules/Platform/Linux-PGI-Fortran.cmake +++ b/Modules/Platform/Linux-PGI-Fortran.cmake @@ -1,9 +1,2 @@ -SET(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS "") - -SET(CMAKE_Fortran_MODDIR_FLAG "-module ") -SET(CMAKE_Fortran_FLAGS_INIT "-Mpreprocess -Kieee -fpic") -SET(CMAKE_Fortran_FLAGS_DEBUG_INIT "-g -O0 -Mbounds") -SET(CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "-O2 -s") -SET(CMAKE_Fortran_FLAGS_RELEASE_INIT "-fast -O3 -Mipa=fast") -SET(CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "-O2 -gopt") - +include(Platform/Linux-PGI) +__linux_compiler_pgi(Fortran) diff --git a/Modules/Platform/Linux-PGI.cmake b/Modules/Platform/Linux-PGI.cmake new file mode 100644 index 0000000..868ee33 --- /dev/null +++ b/Modules/Platform/Linux-PGI.cmake @@ -0,0 +1,25 @@ + +#============================================================================= +# Copyright 2002-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.) + +# This module is shared by multiple languages; use include blocker. +if(__LINUX_COMPILER_PGI) + return() +endif() +set(__LINUX_COMPILER_PGI 1) + +macro(__linux_compiler_pgi lang) + # Shared library compile and link flags. + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") +endmacro() diff --git a/Modules/Platform/Linux-PathScale-C.cmake b/Modules/Platform/Linux-PathScale-C.cmake new file mode 100644 index 0000000..009f398 --- /dev/null +++ b/Modules/Platform/Linux-PathScale-C.cmake @@ -0,0 +1,2 @@ +include(Platform/Linux-PathScale) +__linux_compiler_pathscale(C) diff --git a/Modules/Platform/Linux-PathScale-CXX.cmake b/Modules/Platform/Linux-PathScale-CXX.cmake new file mode 100644 index 0000000..b6a5771 --- /dev/null +++ b/Modules/Platform/Linux-PathScale-CXX.cmake @@ -0,0 +1,2 @@ +include(Platform/Linux-PathScale) +__linux_compiler_pathscale(CXX) diff --git a/Modules/Platform/Linux-PathScale-Fortran.cmake b/Modules/Platform/Linux-PathScale-Fortran.cmake new file mode 100644 index 0000000..5662d3d --- /dev/null +++ b/Modules/Platform/Linux-PathScale-Fortran.cmake @@ -0,0 +1,2 @@ +include(Platform/Linux-PathScale) +__linux_compiler_pathscale(Fortran) diff --git a/Modules/Platform/Linux-PathScale.cmake b/Modules/Platform/Linux-PathScale.cmake new file mode 100644 index 0000000..8537e4c --- /dev/null +++ b/Modules/Platform/Linux-PathScale.cmake @@ -0,0 +1,25 @@ + +#============================================================================= +# Copyright 2002-2010 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.) + +# This module is shared by multiple languages; use include blocker. +if(__LINUX_COMPILER_PATHSCALE) + return() +endif() +set(__LINUX_COMPILER_PATHSCALE 1) + +macro(__linux_compiler_pathscale lang) + # Shared library compile and link flags. + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") +endmacro() diff --git a/Modules/Platform/Linux-SunPro-C.cmake b/Modules/Platform/Linux-SunPro-C.cmake deleted file mode 100644 index 74aedd0..0000000 --- a/Modules/Platform/Linux-SunPro-C.cmake +++ /dev/null @@ -1,3 +0,0 @@ -# Linux sun studio c options -SET(CMAKE_DL_LIBS "dl") -SET(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") diff --git a/Modules/Platform/Linux-SunPro-CXX.cmake b/Modules/Platform/Linux-SunPro-CXX.cmake index 6d9d8a5..5490473 100644 --- a/Modules/Platform/Linux-SunPro-CXX.cmake +++ b/Modules/Platform/Linux-SunPro-CXX.cmake @@ -1,4 +1,2 @@ -# Linux sun studio c++ options -SET(CMAKE_DL_LIBS "dl") SET(CMAKE_SHARED_LIBRARY_RPATH_LINK_CXX_FLAG "-rpath-link ") SET(CMAKE_EXE_EXPORTS_CXX_FLAG "--export-dynamic") diff --git a/Modules/Platform/Linux-SunPro-Fortran.cmake b/Modules/Platform/Linux-SunPro-Fortran.cmake deleted file mode 100644 index 2355aad..0000000 --- a/Modules/Platform/Linux-SunPro-Fortran.cmake +++ /dev/null @@ -1,2 +0,0 @@ -# Linux sun studio fortran options -SET(CMAKE_DL_LIBS "dl") diff --git a/Modules/Platform/Linux-XL-C.cmake b/Modules/Platform/Linux-XL-C.cmake index efcdf87..b1b07f6 100644 --- a/Modules/Platform/Linux-XL-C.cmake +++ b/Modules/Platform/Linux-XL-C.cmake @@ -1,3 +1 @@ -SET(CMAKE_SHARED_LIBRARY_C_FLAGS "") -SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-qmkshrobj") diff --git a/Modules/Platform/Linux-XL-CXX.cmake b/Modules/Platform/Linux-XL-CXX.cmake index b1b6d85..071a975 100644 --- a/Modules/Platform/Linux-XL-CXX.cmake +++ b/Modules/Platform/Linux-XL-CXX.cmake @@ -1,5 +1 @@ -SET(CMAKE_SHARED_LIBRARY_C_FLAGS "") -SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") -SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "") -SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-qmkshrobj") diff --git a/Modules/Platform/Linux-XL-Fortran.cmake b/Modules/Platform/Linux-XL-Fortran.cmake index 3ebb89d..5da574e 100644 --- a/Modules/Platform/Linux-XL-Fortran.cmake +++ b/Modules/Platform/Linux-XL-Fortran.cmake @@ -1,3 +1 @@ -SET(CMAKE_SHARED_LIBRARY_C_FLAGS "") -SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") SET(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "-qmkshrobj") diff --git a/Modules/Platform/Linux-como.cmake b/Modules/Platform/Linux-como.cmake index 6c259f3..7ea7320 100644 --- a/Modules/Platform/Linux-como.cmake +++ b/Modules/Platform/Linux-como.cmake @@ -15,4 +15,3 @@ SET(CMAKE_CXX_LINK_EXECUTABLE SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "") SET(CMAKE_SHARED_LIBRARY_C_FLAGS "") -SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") diff --git a/Modules/Platform/Linux.cmake b/Modules/Platform/Linux.cmake index 4e4c2cb..6490dd1 100644 --- a/Modules/Platform/Linux.cmake +++ b/Modules/Platform/Linux.cmake @@ -1,16 +1,9 @@ -# GCC is the default compiler on Linux. SET(CMAKE_DL_LIBS "dl") -SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") -SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") -SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-rdynamic") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") SET(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,") SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") -SET(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-Wl,-soname,") -SET(CMAKE_SHARED_LIBRARY_SONAME_Fortran_FLAG "-Wl,-soname,") SET(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") -SET(CMAKE_EXE_EXPORTS_CXX_FLAG "-Wl,--export-dynamic") # Shared libraries with no builtin soname may not be linked safely by # specifying the file path. @@ -59,5 +52,3 @@ INCLUDE(Platform/UnixPaths) IF(EXISTS "/etc/debian_version") SET_PROPERTY(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE) ENDIF(EXISTS "/etc/debian_version") -# always include the gcc compiler information -INCLUDE(Platform/gcc) diff --git a/Modules/Platform/NetBSD.cmake b/Modules/Platform/NetBSD.cmake index abf0a61..0fb8636 100644 --- a/Modules/Platform/NetBSD.cmake +++ b/Modules/Platform/NetBSD.cmake @@ -7,9 +7,7 @@ IF(EXISTS /usr/include/dlfcn.h) SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") # : or empty SET(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,") SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") - SET(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-Wl,-soname,") SET(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") - SET(CMAKE_EXE_EXPORTS_CXX_FLAG "-Wl,--export-dynamic") ENDIF(EXISTS /usr/include/dlfcn.h) INCLUDE(Platform/UnixPaths) diff --git a/Modules/Platform/OSF1.cmake b/Modules/Platform/OSF1.cmake index 27af3b1..652bed4 100644 --- a/Modules/Platform/OSF1.cmake +++ b/Modules/Platform/OSF1.cmake @@ -12,7 +12,6 @@ ENDIF(CMAKE_SYSTEM MATCHES "OSF1-1.*") IF(CMAKE_SYSTEM MATCHES "OSF1-V.*") SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared -Wl,-expect_unresolved,\\*") # -shared - SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-shared -Wl,-expect_unresolved,\\*") # -shared IF(CMAKE_COMPILER_IS_GNUCXX) SET(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG "-Wl,-rpath,") ELSE(CMAKE_COMPILER_IS_GNUCXX) diff --git a/Modules/Platform/QNX.cmake b/Modules/Platform/QNX.cmake index b48383a..8cdbe02 100644 --- a/Modules/Platform/QNX.cmake +++ b/Modules/Platform/QNX.cmake @@ -1,8 +1,5 @@ SET(QNXNTO 1) -# GCC is the default compiler on QNX 6.3. -INCLUDE(Platform/gcc) - # The QNX GCC does not seem to have -isystem so remove the flag. SET(CMAKE_INCLUDE_SYSTEM_FLAG_C) SET(CMAKE_INCLUDE_SYSTEM_FLAG_CXX) @@ -15,9 +12,7 @@ SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") SET(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,") SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") -SET(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-Wl,-soname,") SET(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") -SET(CMAKE_EXE_EXPORTS_CXX_FLAG "-Wl,--export-dynamic") # Shared libraries with no builtin soname may not be linked safely by # specifying the file path. diff --git a/Modules/Platform/SunOS-GNU-C.cmake b/Modules/Platform/SunOS-GNU-C.cmake new file mode 100644 index 0000000..6a96c00 --- /dev/null +++ b/Modules/Platform/SunOS-GNU-C.cmake @@ -0,0 +1,2 @@ +include(Platform/SunOS-GNU) +__sunos_compiler_gnu(C) diff --git a/Modules/Platform/SunOS-GNU-CXX.cmake b/Modules/Platform/SunOS-GNU-CXX.cmake new file mode 100644 index 0000000..6b9f6fa --- /dev/null +++ b/Modules/Platform/SunOS-GNU-CXX.cmake @@ -0,0 +1,2 @@ +include(Platform/SunOS-GNU) +__sunos_compiler_gnu(CXX) diff --git a/Modules/Platform/SunOS-GNU-Fortran.cmake b/Modules/Platform/SunOS-GNU-Fortran.cmake new file mode 100644 index 0000000..c6b1888 --- /dev/null +++ b/Modules/Platform/SunOS-GNU-Fortran.cmake @@ -0,0 +1,2 @@ +include(Platform/SunOS-GNU) +__sunos_compiler_gnu(Fortran) diff --git a/Modules/Platform/SunOS-GNU.cmake b/Modules/Platform/SunOS-GNU.cmake new file mode 100644 index 0000000..613ea6b --- /dev/null +++ b/Modules/Platform/SunOS-GNU.cmake @@ -0,0 +1,34 @@ + +#============================================================================= +# Copyright 2002-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.) + +# This module is shared by multiple languages; use include blocker. +if(__SUNOS_COMPILER_GNU) + return() +endif() +set(__SUNOS_COMPILER_GNU 1) + +macro(__sunos_compiler_gnu lang) + set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-R") + set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":") + set(CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG "-Wl,-h") + + # Initialize C link type selection flags. These flags are used when + # building a shared library, shared module, or executable that links + # to other libraries to select whether to use the static or shared + # versions of the libraries. + foreach(type SHARED_LIBRARY SHARED_MODULE EXE) + set(CMAKE_${type}_LINK_STATIC_${lang}_FLAGS "-Wl,-Bstatic") + set(CMAKE_${type}_LINK_DYNAMIC_${lang}_FLAGS "-Wl,-Bdynamic") + endforeach() +endmacro() diff --git a/Modules/Platform/SunOS.cmake b/Modules/Platform/SunOS.cmake index 7d25577..9f2ee2e 100644 --- a/Modules/Platform/SunOS.cmake +++ b/Modules/Platform/SunOS.cmake @@ -5,23 +5,6 @@ IF(CMAKE_SYSTEM MATCHES "SunOS-4.*") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") ENDIF(CMAKE_SYSTEM MATCHES "SunOS-4.*") -IF(CMAKE_SYSTEM MATCHES "SunOS-5.*") - IF(CMAKE_COMPILER_IS_GNUCC) - SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") - SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") - SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-R") - SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") - SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-h") - ENDIF(CMAKE_COMPILER_IS_GNUCC) - IF(CMAKE_COMPILER_IS_GNUCXX) - SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-fPIC") - SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-shared") - SET(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG "-Wl,-R") - SET(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG_SEP ":") - SET(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-Wl,-h") - ENDIF(CMAKE_COMPILER_IS_GNUCXX) -ENDIF(CMAKE_SYSTEM MATCHES "SunOS-5.*") - IF(CMAKE_COMPILER_IS_GNUCXX) IF(CMAKE_COMPILER_IS_GNUCC) SET(CMAKE_CXX_CREATE_SHARED_LIBRARY @@ -38,23 +21,6 @@ IF("${CMAKE_C_COMPILER_ID} ${CMAKE_CXX_COMPILER_ID}" MATCHES SunPro) /opt/SUNWspro/lib /opt/SUNWspro/prod/lib /usr/ccs/lib) ENDIF("${CMAKE_C_COMPILER_ID} ${CMAKE_CXX_COMPILER_ID}" MATCHES SunPro) -# Initialize C link type selection flags. These flags are used when -# building a shared library, shared module, or executable that links -# to other libraries to select whether to use the static or shared -# versions of the libraries. -IF(CMAKE_COMPILER_IS_GNUCC) - FOREACH(type SHARED_LIBRARY SHARED_MODULE EXE) - SET(CMAKE_${type}_LINK_STATIC_C_FLAGS "-Wl,-Bstatic") - SET(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-Wl,-Bdynamic") - ENDFOREACH(type) -ENDIF(CMAKE_COMPILER_IS_GNUCC) -IF(CMAKE_COMPILER_IS_GNUCXX) - FOREACH(type SHARED_LIBRARY SHARED_MODULE EXE) - SET(CMAKE_${type}_LINK_STATIC_CXX_FLAGS "-Wl,-Bstatic") - SET(CMAKE_${type}_LINK_DYNAMIC_CXX_FLAGS "-Wl,-Bdynamic") - ENDFOREACH(type) -ENDIF(CMAKE_COMPILER_IS_GNUCXX) - # The Sun linker needs to find transitive shared library dependencies # in the -L path. SET(CMAKE_LINK_DEPENDENT_LIBRARY_DIRS 1) diff --git a/Modules/Platform/UnixPaths.cmake b/Modules/Platform/UnixPaths.cmake index ea64b78..025ae51 100644 --- a/Modules/Platform/UnixPaths.cmake +++ b/Modules/Platform/UnixPaths.cmake @@ -33,7 +33,7 @@ GET_FILENAME_COMPONENT(_CMAKE_INSTALL_DIR "${_CMAKE_INSTALL_DIR}" PATH) # search types. LIST(APPEND CMAKE_SYSTEM_PREFIX_PATH # Standard - /usr/local / /usr + /usr/local /usr / # CMake install location "${_CMAKE_INSTALL_DIR}" diff --git a/Modules/Platform/Windows-GNU-C.cmake b/Modules/Platform/Windows-GNU-C.cmake new file mode 100644 index 0000000..ecf89dc --- /dev/null +++ b/Modules/Platform/Windows-GNU-C.cmake @@ -0,0 +1,2 @@ +include(Platform/Windows-GNU) +__windows_compiler_gnu(C) diff --git a/Modules/Platform/Windows-GNU-CXX.cmake b/Modules/Platform/Windows-GNU-CXX.cmake new file mode 100644 index 0000000..23e6552 --- /dev/null +++ b/Modules/Platform/Windows-GNU-CXX.cmake @@ -0,0 +1,2 @@ +include(Platform/Windows-GNU) +__windows_compiler_gnu(CXX) diff --git a/Modules/Platform/Windows-GNU-Fortran.cmake b/Modules/Platform/Windows-GNU-Fortran.cmake new file mode 100644 index 0000000..c66feed --- /dev/null +++ b/Modules/Platform/Windows-GNU-Fortran.cmake @@ -0,0 +1,2 @@ +include(Platform/Windows-GNU) +__windows_compiler_gnu(Fortran) diff --git a/Modules/Platform/Windows-GNU.cmake b/Modules/Platform/Windows-GNU.cmake new file mode 100644 index 0000000..e5f86d9 --- /dev/null +++ b/Modules/Platform/Windows-GNU.cmake @@ -0,0 +1,77 @@ + +#============================================================================= +# Copyright 2002-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.) + +# This module is shared by multiple languages; use include blocker. +if(__WINDOWS_GNU) + return() +endif() +set(__WINDOWS_GNU 1) + +set(CMAKE_IMPORT_LIBRARY_PREFIX "lib") +set(CMAKE_SHARED_LIBRARY_PREFIX "lib") +set(CMAKE_SHARED_MODULE_PREFIX "lib") +set(CMAKE_STATIC_LIBRARY_PREFIX "lib") + +set(CMAKE_EXECUTABLE_SUFFIX ".exe") +set(CMAKE_IMPORT_LIBRARY_SUFFIX ".dll.a") +set(CMAKE_SHARED_LIBRARY_SUFFIX ".dll") +set(CMAKE_SHARED_MODULE_SUFFIX ".dll") +set(CMAKE_STATIC_LIBRARY_SUFFIX ".a") + +if(MSYS OR MINGW) + set(CMAKE_EXTRA_LINK_EXTENSIONS ".lib") # MinGW can also link to a MS .lib +endif() + +if(MINGW) + set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "") + set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll" ".dll.a" ".a" ".lib") + set(CMAKE_C_STANDARD_LIBRARIES_INIT "-lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32") + set(CMAKE_CXX_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}") +endif() + +set(CMAKE_DL_LIBS "") +set(CMAKE_LIBRARY_PATH_FLAG "-L") +set(CMAKE_LINK_LIBRARY_FLAG "-l") +set(CMAKE_LINK_LIBRARY_SUFFIX "") +set(CMAKE_CREATE_WIN32_EXE "-mwindows") + +set(CMAKE_GNULD_IMAGE_VERSION + "-Wl,--major-image-version,<TARGET_VERSION_MAJOR>,--minor-image-version,<TARGET_VERSION_MINOR>") + +macro(__windows_compiler_gnu lang) + + if(MSYS OR MINGW) + # Create archiving rules to support large object file lists for static libraries. + set(CMAKE_${lang}_ARCHIVE_CREATE "<CMAKE_AR> cr <TARGET> <LINK_FLAGS> <OBJECTS>") + set(CMAKE_${lang}_ARCHIVE_APPEND "<CMAKE_AR> r <TARGET> <LINK_FLAGS> <OBJECTS>") + set(CMAKE_${lang}_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>") + + # Initialize C link type selection flags. These flags are used when + # building a shared library, shared module, or executable that links + # to other libraries to select whether to use the static or shared + # versions of the libraries. + foreach(type SHARED_LIBRARY SHARED_MODULE EXE) + set(CMAKE_${type}_LINK_STATIC_${lang}_FLAGS "-Wl,-Bstatic") + set(CMAKE_${type}_LINK_DYNAMIC_${lang}_FLAGS "-Wl,-Bdynamic") + endforeach(type) + endif() + + # Binary link rules. + set(CMAKE_${lang}_CREATE_SHARED_MODULE + "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_MODULE_${lang}_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>") + set(CMAKE_${lang}_CREATE_SHARED_LIBRARY + "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>") + set(CMAKE_${lang}_LINK_EXECUTABLE + "<CMAKE_${lang}_COMPILER> <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>") +endmacro() diff --git a/Modules/Platform/Windows-cl.cmake b/Modules/Platform/Windows-cl.cmake index 303ef34..e369ac1 100644 --- a/Modules/Platform/Windows-cl.cmake +++ b/Modules/Platform/Windows-cl.cmake @@ -141,32 +141,14 @@ IF(CMAKE_GENERATOR MATCHES "Makefiles") SET(CMAKE_USING_VC_FREE_TOOLS 0) ENDIF(CMAKE_COMPILER_RETURN) MAKE_DIRECTORY("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp3") - MESSAGE(STATUS "Check CL platform") - EXEC_PROGRAM(${CMAKE_TEST_COMPILER} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp3 - ARGS /nologo - \"${testForFreeVCFile}\" - /link /machine:i386 - OUTPUT_VARIABLE CMAKE_COMPILER_OUTPUT - RETURN_VALUE CMAKE_COMPILER_RETURN - ) - # if there was an error assume it is a 64bit system - IF(CMAKE_COMPILER_RETURN) - FILE(APPEND - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining if this is a 64 bit system passed:\n" - "${CMAKE_COMPILER_OUTPUT}\n\n") - MESSAGE(STATUS "Check CL platform - 64 bit") - SET(CMAKE_CL_64 1) - ELSE(CMAKE_COMPILER_RETURN) - FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining if this is a 32 bit system passed:\n" - "${CMAKE_COMPILER_OUTPUT}\n\n") - MESSAGE(STATUS "Check CL platform - 32 bit") - SET(CMAKE_CL_64 0) - ENDIF(CMAKE_COMPILER_RETURN) ENDIF(NOT CMAKE_VC_COMPILER_TESTS_RUN) ENDIF(CMAKE_GENERATOR MATCHES "Makefiles") +IF(MSVC_C_ARCHITECTURE_ID MATCHES 64) + SET(CMAKE_CL_64 1) +ELSE(MSVC_C_ARCHITECTURE_ID MATCHES 64) + SET(CMAKE_CL_64 0) +ENDIF(MSVC_C_ARCHITECTURE_ID MATCHES 64) IF(CMAKE_FORCE_WIN64) SET(CMAKE_CL_64 1) ENDIF(CMAKE_FORCE_WIN64) @@ -235,13 +217,12 @@ SET(CMAKE_CXX_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}") # executable linker flags SET (CMAKE_LINK_DEF_FILE_FLAG "/DEF:") # set the stack size and the machine type -IF(CMAKE_CL_64) - SET (CMAKE_EXE_LINKER_FLAGS_INIT - "${CMAKE_EXE_LINKER_FLAGS_INIT} /STACK:10000000 /machine:x64") -ELSE(CMAKE_CL_64) - SET (CMAKE_EXE_LINKER_FLAGS_INIT - "${CMAKE_EXE_LINKER_FLAGS_INIT} /STACK:10000000 /machine:I386") -ENDIF(CMAKE_CL_64) +SET(_MACHINE_ARCH_FLAG ${MSVC_C_ARCHITECTURE_ID}) +IF(NOT _MACHINE_ARCH_FLAG) + SET(_MACHINE_ARCH_FLAG ${MSVC_CXX_ARCHITECTURE_ID}) +ENDIF(NOT _MACHINE_ARCH_FLAG) +SET (CMAKE_EXE_LINKER_FLAGS_INIT + "${CMAKE_EXE_LINKER_FLAGS_INIT} /STACK:10000000 /machine:${_MACHINE_ARCH_FLAG}") # add /debug and /INCREMENTAL:YES to DEBUG and RELWITHDEBINFO also add pdbtyp # on versions that support it diff --git a/Modules/Platform/Windows-g77.cmake b/Modules/Platform/Windows-g77.cmake deleted file mode 100644 index ed3a073..0000000 --- a/Modules/Platform/Windows-g77.cmake +++ /dev/null @@ -1,24 +0,0 @@ -SET(CMAKE_LINK_LIBRARY_SUFFIX "") -SET(CMAKE_STATIC_LIBRARY_PREFIX "lib") -SET(CMAKE_STATIC_LIBRARY_SUFFIX ".a") -SET(CMAKE_SHARED_LIBRARY_PREFIX "lib") # lib -SET(CMAKE_SHARED_LIBRARY_SUFFIX ".dll") # .so -SET(CMAKE_EXECUTABLE_SUFFIX ".exe") # .exe -SET(CMAKE_SHARED_MODULE_PREFIX "lib") # lib -SET(CMAKE_SHARED_MODULE_SUFFIX ".dll") # .so -SET(CMAKE_DL_LIBS "") -SET(CMAKE_SHARED_LIBRARY_C_FLAGS "") # -pic -SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared -SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib -SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "") # -rpath -SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP "") # : or empty -SET(CMAKE_LIBRARY_PATH_FLAG "-L") -SET(CMAKE_LINK_LIBRARY_FLAG "-l") -SET (CMAKE_Fortran_FLAGS_INIT "") -SET (CMAKE_Fortran_FLAGS_DEBUG_INIT "-g") -SET (CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "-O1") -SET (CMAKE_Fortran_FLAGS_RELEASE_INIT "-O2") -SET (CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "-02 -g") - -SET(CMAKE_Fortran_CREATE_SHARED_LIBRARY - "<CMAKE_Fortran_COMPILER> <CMAKE_SHARED_LIBRARY_Fortran_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>") diff --git a/Modules/Platform/Windows-gcc.cmake b/Modules/Platform/Windows-gcc.cmake deleted file mode 100644 index 73c10c1..0000000 --- a/Modules/Platform/Windows-gcc.cmake +++ /dev/null @@ -1,74 +0,0 @@ -SET(CMAKE_LINK_LIBRARY_SUFFIX "") -SET(CMAKE_STATIC_LIBRARY_PREFIX "lib") -SET(CMAKE_STATIC_LIBRARY_SUFFIX ".a") -SET(CMAKE_SHARED_LIBRARY_PREFIX "lib") # lib -SET(CMAKE_SHARED_LIBRARY_SUFFIX ".dll") # .so -SET(CMAKE_SHARED_MODULE_PREFIX "lib") # lib -SET(CMAKE_SHARED_MODULE_SUFFIX ".dll") # .so -SET(CMAKE_IMPORT_LIBRARY_PREFIX "lib") -SET(CMAKE_IMPORT_LIBRARY_SUFFIX ".dll.a") -SET(CMAKE_EXECUTABLE_SUFFIX ".exe") # .exe -SET(CMAKE_DL_LIBS "") -SET(CMAKE_SHARED_LIBRARY_C_FLAGS "") # -pic -SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "") # -pic -SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared -SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib -SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "") # -rpath -SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP "") # : or empty - -SET(CMAKE_SHARED_MODULE_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}") # -pic -SET(CMAKE_SHARED_MODULE_CXX_FLAGS - "${CMAKE_SHARED_LIBRARY_CXX_FLAGS}") # -pic -SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS - "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS}") # -shared -SET(CMAKE_LIBRARY_PATH_FLAG "-L") -SET(CMAKE_LINK_LIBRARY_FLAG "-l") -SET(CMAKE_EXTRA_LINK_EXTENSIONS ".lib") # MinGW can also link to a MS .lib -SET(CMAKE_CREATE_WIN32_EXE "-mwindows") - -IF(MINGW) - SET(CMAKE_FIND_LIBRARY_PREFIXES "lib" "") - SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dll" ".dll.a" ".a" ".lib") - SET (CMAKE_C_STANDARD_LIBRARIES_INIT "-lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32") - SET(CMAKE_CXX_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}") -ENDIF(MINGW) - -SET(CMAKE_GNULD_IMAGE_VERSION - "-Wl,--major-image-version,<TARGET_VERSION_MAJOR>,--minor-image-version,<TARGET_VERSION_MINOR>") - -SET(CMAKE_C_CREATE_SHARED_MODULE - "<CMAKE_C_COMPILER> <CMAKE_SHARED_MODULE_C_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_MODULE_CREATE_C_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>") -SET(CMAKE_CXX_CREATE_SHARED_MODULE - "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_MODULE_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>") - -SET(CMAKE_C_CREATE_SHARED_LIBRARY - "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_C_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>") -SET(CMAKE_CXX_CREATE_SHARED_LIBRARY - "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>") - -SET(CMAKE_C_LINK_EXECUTABLE - "<CMAKE_C_COMPILER> <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>") -SET(CMAKE_CXX_LINK_EXECUTABLE - "<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>") - -# Initialize C link type selection flags. These flags are used when -# building a shared library, shared module, or executable that links -# to other libraries to select whether to use the static or shared -# versions of the libraries. -IF(MSYS OR MINGW) - FOREACH(type SHARED_LIBRARY SHARED_MODULE EXE) - SET(CMAKE_${type}_LINK_STATIC_C_FLAGS "-Wl,-Bstatic") - SET(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-Wl,-Bdynamic") - ENDFOREACH(type) -ENDIF(MSYS OR MINGW) - -# Create archiving rules to support large object file lists for static -# libraries. -IF(MSYS OR MINGW) - SET(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> cr <TARGET> <LINK_FLAGS> <OBJECTS>") - SET(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> r <TARGET> <LINK_FLAGS> <OBJECTS>") - SET(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>") - SET(CMAKE_CXX_ARCHIVE_CREATE ${CMAKE_C_ARCHIVE_CREATE}) - SET(CMAKE_CXX_ARCHIVE_APPEND ${CMAKE_C_ARCHIVE_APPEND}) - SET(CMAKE_CXX_ARCHIVE_FINISH ${CMAKE_C_ARCHIVE_FINISH}) -ENDIF(MSYS OR MINGW) diff --git a/Modules/Platform/Windows-icl.cmake b/Modules/Platform/Windows-icl.cmake index 2f1ef29..c717c7c 100644 --- a/Modules/Platform/Windows-icl.cmake +++ b/Modules/Platform/Windows-icl.cmake @@ -71,7 +71,11 @@ SET(CMAKE_CXX_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}") # executable linker flags SET (CMAKE_LINK_DEF_FILE_FLAG "/DEF:") -SET (CMAKE_EXE_LINKER_FLAGS_INIT "/STACK:10000000 /INCREMENTAL:YES") +SET(_MACHINE_ARCH_FLAG ${MSVC_C_ARCHITECTURE_ID}) +IF(NOT _MACHINE_ARCH_FLAG) + SET(_MACHINE_ARCH_FLAG ${MSVC_CXX_ARCHITECTURE_ID}) +ENDIF(NOT _MACHINE_ARCH_FLAG) +SET (CMAKE_EXE_LINKER_FLAGS_INIT "/STACK:10000000 /INCREMENTAL:YES /machine:${_MACHINE_ARCH_FLAG}") SET (CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT "/debug") SET (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "/debug") @@ -82,6 +86,7 @@ SET (CMAKE_MODULE_LINKER_FLAGS_INIT ${CMAKE_SHARED_LINKER_FLAGS_INIT}) SET (CMAKE_MODULE_LINKER_FLAGS_DEBUG_INIT ${CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT}) SET (CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO_INIT ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT}) + INCLUDE(Platform/Windows-Intel) IF(_INTEL_COMPILER_SUPPORTS_MANIFEST) diff --git a/Modules/Platform/Windows-wcl386.cmake b/Modules/Platform/Windows-wcl386.cmake index 87a61d5..b260489 100644 --- a/Modules/Platform/Windows-wcl386.cmake +++ b/Modules/Platform/Windows-wcl386.cmake @@ -27,11 +27,11 @@ SET (CMAKE_C_STANDARD_LIBRARIES_INIT "library clbrdll.lib library plbrdll.lib l SET (CMAKE_CXX_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}") SET(CMAKE_C_CREATE_IMPORT_LIBRARY - "wlib -q -n -b <TARGET_IMPLIB> +<TARGET>") + "wlib -q -n -b <TARGET_IMPLIB> +'<TARGET_UNQUOTED>'") SET(CMAKE_CXX_CREATE_IMPORT_LIBRARY ${CMAKE_C_CREATE_IMPORT_LIBRARY}) SET(CMAKE_C_LINK_EXECUTABLE - "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name <TARGET> option caseexact file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}") + "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name '<TARGET_UNQUOTED>' option caseexact file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}") SET(CMAKE_CXX_LINK_EXECUTABLE ${CMAKE_C_LINK_EXECUTABLE}) @@ -52,7 +52,7 @@ SET(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE "<CMAKE_CXX_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} <FLAGS> -dWIN32 -d+ <DEFINES> -fo<PREPROCESSED_SOURCE> -pl -cc++ <SOURCE>${CMAKE_END_TEMP_FILE}") SET(CMAKE_CXX_CREATE_SHARED_MODULE - "wlink ${CMAKE_START_TEMP_FILE} system nt_dll ${CMAKE_WLINK_QUIET} name <TARGET> option caseexact file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}") + "wlink ${CMAKE_START_TEMP_FILE} system nt_dll ${CMAKE_WLINK_QUIET} name '<TARGET_UNQUOTED>' option caseexact file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}") SET(CMAKE_CXX_CREATE_SHARED_LIBRARY ${CMAKE_CXX_CREATE_SHARED_MODULE} ${CMAKE_CXX_CREATE_IMPORT_LIBRARY}) @@ -64,7 +64,7 @@ SET(CMAKE_C_CREATE_SHARED_LIBRARY ${CMAKE_CXX_CREATE_SHARED_LIBRARY}) SET(CMAKE_C_CREATE_SHARED_MODULE ${CMAKE_CXX_CREATE_SHARED_MODULE}) # create a C++ static library -SET(CMAKE_CXX_CREATE_STATIC_LIBRARY "wlib ${CMAKE_LIB_QUIET} -n -b <TARGET> <OBJECTS> ") +SET(CMAKE_CXX_CREATE_STATIC_LIBRARY "wlib ${CMAKE_LIB_QUIET} -n -b '<TARGET_UNQUOTED>' <OBJECTS> ") # create a C static library SET(CMAKE_C_CREATE_STATIC_LIBRARY ${CMAKE_CXX_CREATE_STATIC_LIBRARY}) diff --git a/Modules/Platform/g77.cmake b/Modules/Platform/g77.cmake deleted file mode 100644 index 8f7d448..0000000 --- a/Modules/Platform/g77.cmake +++ /dev/null @@ -1,7 +0,0 @@ -IF(CMAKE_COMPILER_IS_GNUG77) - SET (CMAKE_Fortran_FLAGS_INIT "") - SET (CMAKE_Fortran_FLAGS_DEBUG_INIT "-g") - SET (CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG") - SET (CMAKE_Fortran_FLAGS_RELEASE_INIT "-O3 -DNDEBUG") - SET (CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "-O2 -g") -ENDIF(CMAKE_COMPILER_IS_GNUG77) diff --git a/Modules/Platform/gcc.cmake b/Modules/Platform/gcc.cmake deleted file mode 100644 index 8c385ce..0000000 --- a/Modules/Platform/gcc.cmake +++ /dev/null @@ -1,27 +0,0 @@ -IF(CMAKE_COMPILER_IS_GNUCC) - SET (CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic - SET (CMAKE_C_FLAGS_INIT "") - SET (CMAKE_C_FLAGS_DEBUG_INIT "-g") - SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG") - SET (CMAKE_C_FLAGS_RELEASE_INIT "-O3 -DNDEBUG") - SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-O2 -g") - SET (CMAKE_C_CREATE_PREPROCESSED_SOURCE "<CMAKE_C_COMPILER> <DEFINES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") - SET (CMAKE_C_CREATE_ASSEMBLY_SOURCE "<CMAKE_C_COMPILER> <DEFINES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") - IF(NOT APPLE) - SET (CMAKE_INCLUDE_SYSTEM_FLAG_C "-isystem ") - ENDIF(NOT APPLE) -ENDIF(CMAKE_COMPILER_IS_GNUCC) - -IF(CMAKE_COMPILER_IS_GNUCXX) - SET (CMAKE_SHARED_LIBRARY_CXX_FLAGS "-fPIC") # -pic - SET (CMAKE_CXX_FLAGS_INIT "") - SET (CMAKE_CXX_FLAGS_DEBUG_INIT "-g") - SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG") - SET (CMAKE_CXX_FLAGS_RELEASE_INIT "-O3 -DNDEBUG") - SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O2 -g") - SET (CMAKE_CXX_CREATE_PREPROCESSED_SOURCE "<CMAKE_CXX_COMPILER> <DEFINES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") - SET (CMAKE_CXX_CREATE_ASSEMBLY_SOURCE "<CMAKE_CXX_COMPILER> <DEFINES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") - IF(NOT APPLE) - SET (CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ") - ENDIF(NOT APPLE) -ENDIF(CMAKE_COMPILER_IS_GNUCXX) diff --git a/Modules/Platform/syllable.cmake b/Modules/Platform/syllable.cmake index 2bcaf8c..3ce42f6 100644 --- a/Modules/Platform/syllable.cmake +++ b/Modules/Platform/syllable.cmake @@ -14,9 +14,7 @@ SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") -SET(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-Wl,-soname,") #SET(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") -#SET(CMAKE_EXE_EXPORTS_CXX_FLAG "-Wl,--export-dynamic") # Initialize C link type selection flags. These flags are used when # building a shared library, shared module, or executable that links diff --git a/Modules/Qt4ConfigDependentSettings.cmake b/Modules/Qt4ConfigDependentSettings.cmake new file mode 100644 index 0000000..1331f41 --- /dev/null +++ b/Modules/Qt4ConfigDependentSettings.cmake @@ -0,0 +1,359 @@ +# This file is included by FindQt4.cmake, don't include it directly. + +#============================================================================= +# Copyright 2005-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.) + + +############################################### +# +# configuration/system dependent settings +# +############################################### + +# find dependencies for some Qt modules +# when doing builds against a static Qt, they are required +# when doing builds against a shared Qt, they are not required +# if a user needs the dependencies, and they couldn't be found, they can set +# the variables themselves. + +SET(QT_QTGUI_LIB_DEPENDENCIES "") +SET(QT_QTCORE_LIB_DEPENDENCIES "") +SET(QT_QTNETWORK_LIB_DEPENDENCIES "") +SET(QT_QTOPENGL_LIB_DEPENDENCIES "") +SET(QT_QTDBUS_LIB_DEPENDENCIES "") +SET(QT_QTHELP_LIB_DEPENDENCIES ${QT_QTCLUCENE_LIBRARY}) + + +IF(WIN32) + # 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) + # 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) + IF("${qtcore_lib_ext}" STREQUAL "${CMAKE_STATIC_LIBRARY_SUFFIX}") + SET(QT_IS_STATIC 1) + ENDIF("${qtcore_lib_ext}" STREQUAL "${CMAKE_STATIC_LIBRARY_SUFFIX}") + ENDIF(QT_QTCORE_LIBRARY_RELEASE) + IF(QT_QTCORE_LIBRARY_DEBUG) + GET_FILENAME_COMPONENT(qtcore_lib_ext "${QT_QTCORE_LIBRARY_DEBUG}" EXT) + IF(${qtcore_lib_ext} STREQUAL ${CMAKE_STATIC_LIBRARY_SUFFIX}) + SET(QT_IS_STATIC 1) + ENDIF(${qtcore_lib_ext} STREQUAL ${CMAKE_STATIC_LIBRARY_SUFFIX}) + ENDIF(QT_QTCORE_LIBRARY_DEBUG) +ENDIF(WIN32) + +# build using shared Qt needs -DQT_DLL on Windows +IF(WIN32 AND NOT QT_IS_STATIC) + SET(QT_DEFINITIONS ${QT_DEFINITIONS} -DQT_DLL) +ENDIF(WIN32 AND NOT QT_IS_STATIC) + + +# QtOpenGL dependencies +QT_QUERY_QMAKE(QMAKE_LIBS_OPENGL "QMAKE_LIBS_OPENGL") +SEPARATE_ARGUMENTS(QMAKE_LIBS_OPENGL) +SET (QT_QTOPENGL_LIB_DEPENDENCIES ${QT_QTOPENGL_LIB_DEPENDENCIES} ${QMAKE_LIBS_OPENGL}) + + +## system png +IF(QT_QCONFIG MATCHES "system-png") + FIND_LIBRARY(QT_PNG_LIBRARY NAMES png) + MARK_AS_ADVANCED(QT_PNG_LIBRARY) + IF(QT_PNG_LIBRARY) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_PNG_LIBRARY}) + ENDIF(QT_PNG_LIBRARY) +ENDIF(QT_QCONFIG MATCHES "system-png") + + +# for X11, get X11 library directory +IF(Q_WS_X11) + QT_QUERY_QMAKE(QMAKE_LIBDIR_X11 "QMAKE_LIBDIR_X11") +ENDIF(Q_WS_X11) + + +## X11 SM +IF(QT_QCONFIG MATCHES "x11sm") + # ask qmake where the x11 libs are + FIND_LIBRARY(QT_X11_SM_LIBRARY NAMES SM PATHS ${QMAKE_LIBDIR_X11}) + FIND_LIBRARY(QT_X11_ICE_LIBRARY NAMES ICE PATHS ${QMAKE_LIBDIR_X11}) + MARK_AS_ADVANCED(QT_X11_SM_LIBRARY) + MARK_AS_ADVANCED(QT_X11_ICE_LIBRARY) + IF(QT_X11_SM_LIBRARY AND QT_X11_ICE_LIBRARY) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_X11_SM_LIBRARY} ${QT_X11_ICE_LIBRARY}) + ENDIF(QT_X11_SM_LIBRARY AND QT_X11_ICE_LIBRARY) +ENDIF(QT_QCONFIG MATCHES "x11sm") + + +## Xi +IF(QT_QCONFIG MATCHES "tablet") + FIND_LIBRARY(QT_XI_LIBRARY NAMES Xi PATHS ${QMAKE_LIBDIR_X11}) + MARK_AS_ADVANCED(QT_XI_LIBRARY) + IF(QT_XI_LIBRARY) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XI_LIBRARY}) + ENDIF(QT_XI_LIBRARY) +ENDIF(QT_QCONFIG MATCHES "tablet") + + +## Xrender +IF(QT_QCONFIG MATCHES "xrender") + FIND_LIBRARY(QT_XRENDER_LIBRARY NAMES Xrender PATHS ${QMAKE_LIBDIR_X11}) + MARK_AS_ADVANCED(QT_XRENDER_LIBRARY) + IF(QT_XRENDER_LIBRARY) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XRENDER_LIBRARY}) + ENDIF(QT_XRENDER_LIBRARY) +ENDIF(QT_QCONFIG MATCHES "xrender") + + +## Xrandr +IF(QT_QCONFIG MATCHES "xrandr") + FIND_LIBRARY(QT_XRANDR_LIBRARY NAMES Xrandr PATHS ${QMAKE_LIBDIR_X11}) + MARK_AS_ADVANCED(QT_XRANDR_LIBRARY) + IF(QT_XRANDR_LIBRARY) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XRANDR_LIBRARY}) + ENDIF(QT_XRANDR_LIBRARY) +ENDIF(QT_QCONFIG MATCHES "xrandr") + + +## Xcursor +IF(QT_QCONFIG MATCHES "xcursor") + FIND_LIBRARY(QT_XCURSOR_LIBRARY NAMES Xcursor PATHS ${QMAKE_LIBDIR_X11}) + MARK_AS_ADVANCED(QT_XCURSOR_LIBRARY) + IF(QT_XCURSOR_LIBRARY) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XCURSOR_LIBRARY}) + ENDIF(QT_XCURSOR_LIBRARY) +ENDIF(QT_QCONFIG MATCHES "xcursor") + + +## Xinerama +IF(QT_QCONFIG MATCHES "xinerama") + FIND_LIBRARY(QT_XINERAMA_LIBRARY NAMES Xinerama PATHS ${QMAKE_LIBDIR_X11}) + MARK_AS_ADVANCED(QT_XINERAMA_LIBRARY) + IF(QT_XINERAMA_LIBRARY) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XINERAMA_LIBRARY}) + ENDIF(QT_XINERAMA_LIBRARY) +ENDIF(QT_QCONFIG MATCHES "xinerama") + + +## Xfixes +IF(QT_QCONFIG MATCHES "xfixes") + FIND_LIBRARY(QT_XFIXES_LIBRARY NAMES Xfixes PATHS ${QMAKE_LIBDIR_X11}) + MARK_AS_ADVANCED(QT_XFIXES_LIBRARY) + IF(QT_XFIXES_LIBRARY) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XFIXES_LIBRARY}) + ENDIF(QT_XFIXES_LIBRARY) +ENDIF(QT_QCONFIG MATCHES "xfixes") + + +## system-freetype +IF(QT_QCONFIG MATCHES "system-freetype") + FIND_LIBRARY(QT_FREETYPE_LIBRARY NAMES freetype) + MARK_AS_ADVANCED(QT_FREETYPE_LIBRARY) + IF(QT_FREETYPE_LIBRARY) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_FREETYPE_LIBRARY}) + ENDIF(QT_FREETYPE_LIBRARY) +ENDIF(QT_QCONFIG MATCHES "system-freetype") + + +## fontconfig +IF(QT_QCONFIG MATCHES "fontconfig") + FIND_LIBRARY(QT_FONTCONFIG_LIBRARY NAMES fontconfig) + MARK_AS_ADVANCED(QT_FONTCONFIG_LIBRARY) + IF(QT_FONTCONFIG_LIBRARY) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_FONTCONFIG_LIBRARY}) + ENDIF(QT_FONTCONFIG_LIBRARY) +ENDIF(QT_QCONFIG MATCHES "fontconfig") + + +## system-zlib +IF(QT_QCONFIG MATCHES "system-zlib") + FIND_LIBRARY(QT_ZLIB_LIBRARY NAMES z) + MARK_AS_ADVANCED(QT_ZLIB_LIBRARY) + IF(QT_ZLIB_LIBRARY) + SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_ZLIB_LIBRARY}) + ENDIF(QT_ZLIB_LIBRARY) +ENDIF(QT_QCONFIG MATCHES "system-zlib") + + +## openssl +IF(NOT Q_WS_WIN) + SET(_QT_NEED_OPENSSL 0) + IF(QT_VERSION_MINOR LESS 4 AND QT_QCONFIG MATCHES "openssl") + SET(_QT_NEED_OPENSSL 1) + ENDIF(QT_VERSION_MINOR LESS 4 AND QT_QCONFIG MATCHES "openssl") + IF(QT_VERSION_MINOR GREATER 3 AND QT_QCONFIG MATCHES "openssl-linked") + SET(_QT_NEED_OPENSSL 1) + ENDIF(QT_VERSION_MINOR GREATER 3 AND QT_QCONFIG MATCHES "openssl-linked") + IF(_QT_NEED_OPENSSL) + FIND_PACKAGE(OpenSSL) + IF(OPENSSL_LIBRARIES) + SET(QT_QTNETWORK_LIB_DEPENDENCIES ${QT_QTNETWORK_LIB_DEPENDENCIES} ${OPENSSL_LIBRARIES}) + ENDIF(OPENSSL_LIBRARIES) + ENDIF(_QT_NEED_OPENSSL) +ENDIF(NOT Q_WS_WIN) + + +## dbus +IF(QT_QCONFIG MATCHES "dbus") + + # if the dbus library isn't found, we'll assume its not required to build + # shared Qt on Linux doesn't require it + IF(NOT QT_DBUS_LIBRARY) + EXECUTE_PROCESS(COMMAND pkg-config --libs-only-L dbus-1 + OUTPUT_VARIABLE _dbus_query_output + RESULT_VARIABLE _dbus_result + ERROR_VARIABLE _dbus_query_output ) + + IF(_dbus_result MATCHES 0) + STRING(REPLACE "-L" "" _dbus_query_output "${_dbus_query_output}") + SEPARATE_ARGUMENTS(_dbus_query_output) + ELSE(_dbus_result MATCHES 0) + SET(_dbus_query_output) + ENDIF(_dbus_result MATCHES 0) + + FIND_LIBRARY(QT_DBUS_LIBRARY NAMES dbus-1 PATHS ${_dbus_query_output} ) + + IF(QT_DBUS_LIBRARY) + SET(QT_QTDBUS_LIB_DEPENDENCIES ${QT_QTDBUS_LIB_DEPENDENCIES} ${QT_DBUS_LIBRARY}) + ENDIF(QT_DBUS_LIBRARY) + + MARK_AS_ADVANCED(QT_DBUS_LIBRARY) + ENDIF(NOT QT_DBUS_LIBRARY) + +ENDIF(QT_QCONFIG MATCHES "dbus") + + +## glib +IF(QT_QCONFIG MATCHES "glib") + + # if the glib libraries aren't found, we'll assume its not required to build + # shared Qt on Linux doesn't require it + + # Qt 4.2.0+ uses glib-2.0 + IF(NOT QT_GLIB_LIBRARY OR NOT QT_GTHREAD_LIBRARY) + EXECUTE_PROCESS(COMMAND pkg-config --libs-only-L glib-2.0 gthread-2.0 + OUTPUT_VARIABLE _glib_query_output + RESULT_VARIABLE _glib_result + ERROR_VARIABLE _glib_query_output ) + + IF(_glib_result MATCHES 0) + STRING(REPLACE "-L" "" _glib_query_output "${_glib_query_output}") + SEPARATE_ARGUMENTS(_glib_query_output) + ELSE(_glib_result MATCHES 0) + SET(_glib_query_output) + ENDIF(_glib_result MATCHES 0) + + FIND_LIBRARY(QT_GLIB_LIBRARY NAMES glib-2.0 PATHS ${_glib_query_output} ) + FIND_LIBRARY(QT_GTHREAD_LIBRARY NAMES gthread-2.0 PATHS ${_glib_query_output} ) + + MARK_AS_ADVANCED(QT_GLIB_LIBRARY) + MARK_AS_ADVANCED(QT_GTHREAD_LIBRARY) + ENDIF(NOT QT_GLIB_LIBRARY OR NOT QT_GTHREAD_LIBRARY) + + IF(QT_GLIB_LIBRARY AND QT_GTHREAD_LIBRARY) + SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} + ${QT_GTHREAD_LIBRARY} ${QT_GLIB_LIBRARY}) + ENDIF(QT_GLIB_LIBRARY AND QT_GTHREAD_LIBRARY) + + + # Qt 4.5+ also links to gobject-2.0 + IF(QT_VERSION_MINOR GREATER 4) + IF(NOT QT_GOBJECT_LIBRARY) + EXECUTE_PROCESS(COMMAND pkg-config --libs-only-L gobject-2.0 + OUTPUT_VARIABLE _glib_query_output + RESULT_VARIABLE _glib_result + ERROR_VARIABLE _glib_query_output ) + + IF(_glib_result MATCHES 0) + STRING(REPLACE "-L" "" _glib_query_output "${_glib_query_output}") + SEPARATE_ARGUMENTS(_glib_query_output) + ELSE(_glib_result MATCHES 0) + SET(_glib_query_output) + ENDIF(_glib_result MATCHES 0) + + FIND_LIBRARY(QT_GOBJECT_LIBRARY NAMES gobject-2.0 PATHS ${_glib_query_output} ) + + MARK_AS_ADVANCED(QT_GOBJECT_LIBRARY) + ENDIF(NOT QT_GOBJECT_LIBRARY) + + IF(QT_GOBJECT_LIBRARY) + SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} + ${QT_GOBJECT_LIBRARY}) + ENDIF(QT_GOBJECT_LIBRARY) + ENDIF(QT_VERSION_MINOR GREATER 4) + +ENDIF(QT_QCONFIG MATCHES "glib") + + +## clock-monotonic, just see if we need to link with rt +IF(QT_QCONFIG MATCHES "clock-monotonic") + SET(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) + SET(CMAKE_REQUIRED_LIBRARIES rt) + CHECK_SYMBOL_EXISTS(_POSIX_TIMERS "unistd.h;time.h" QT_POSIX_TIMERS) + SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) + IF(QT_POSIX_TIMERS) + FIND_LIBRARY(QT_RT_LIBRARY NAMES rt) + MARK_AS_ADVANCED(QT_RT_LIBRARY) + IF(QT_RT_LIBRARY) + SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_RT_LIBRARY}) + ENDIF(QT_RT_LIBRARY) + ENDIF(QT_POSIX_TIMERS) +ENDIF(QT_QCONFIG MATCHES "clock-monotonic") + + +IF(Q_WS_X11) + # X11 libraries Qt absolutely depends on + QT_QUERY_QMAKE(QT_LIBS_X11 "QMAKE_LIBS_X11") + SEPARATE_ARGUMENTS(QT_LIBS_X11) + FOREACH(QT_X11_LIB ${QT_LIBS_X11}) + STRING(REGEX REPLACE "-l" "" QT_X11_LIB "${QT_X11_LIB}") + SET(QT_TMP_STR "QT_X11_${QT_X11_LIB}_LIBRARY") + FIND_LIBRARY(${QT_TMP_STR} NAMES "${QT_X11_LIB}" PATHS ${QMAKE_LIBDIR_X11}) + MARK_AS_ADVANCED(${QT_TMP_STR}) + IF(${QT_TMP_STR}) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${${QT_TMP_STR}}) + ENDIF(${QT_TMP_STR}) + ENDFOREACH(QT_X11_LIB) + + QT_QUERY_QMAKE(QT_LIBS_THREAD "QMAKE_LIBS_THREAD") + SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_LIBS_THREAD}) + + QT_QUERY_QMAKE(QMAKE_LIBS_DYNLOAD "QMAKE_LIBS_DYNLOAD") + SET (QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QMAKE_LIBS_DYNLOAD}) + +ENDIF(Q_WS_X11) + + +IF(Q_WS_WIN) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} imm32 winmm) + SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ws2_32) +ENDIF(Q_WS_WIN) + + +IF(Q_WS_MAC) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} "-framework Carbon") + + # Qt 4.0, 4.1, 4.2 use QuickTime + IF(QT_VERSION_MINOR LESS 3) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} "-framework QuickTime") + ENDIF(QT_VERSION_MINOR LESS 3) + + # Qt 4.2+ use AppKit + IF(QT_VERSION_MINOR GREATER 1) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} "-framework AppKit") + ENDIF(QT_VERSION_MINOR GREATER 1) + + SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} "-framework ApplicationServices") +ENDIF(Q_WS_MAC) + diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake new file mode 100644 index 0000000..bd72c8f --- /dev/null +++ b/Modules/Qt4Macros.cmake @@ -0,0 +1,399 @@ +# This file is included by FindQt4.cmake, don't include it directly. + +#============================================================================= +# Copyright 2005-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.) + + +###################################### +# +# Macros for building Qt files +# +###################################### + + +MACRO (QT4_EXTRACT_OPTIONS _qt4_files _qt4_options) + SET(${_qt4_files}) + SET(${_qt4_options}) + SET(_QT4_DOING_OPTIONS FALSE) + FOREACH(_currentArg ${ARGN}) + IF ("${_currentArg}" STREQUAL "OPTIONS") + SET(_QT4_DOING_OPTIONS TRUE) + ELSE ("${_currentArg}" STREQUAL "OPTIONS") + IF(_QT4_DOING_OPTIONS) + LIST(APPEND ${_qt4_options} "${_currentArg}") + ELSE(_QT4_DOING_OPTIONS) + LIST(APPEND ${_qt4_files} "${_currentArg}") + ENDIF(_QT4_DOING_OPTIONS) + ENDIF ("${_currentArg}" STREQUAL "OPTIONS") + ENDFOREACH(_currentArg) +ENDMACRO (QT4_EXTRACT_OPTIONS) + + +# macro used to create the names of output files preserving relative dirs +MACRO (QT4_MAKE_OUTPUT_FILE infile prefix ext outfile ) + STRING(LENGTH ${CMAKE_CURRENT_BINARY_DIR} _binlength) + STRING(LENGTH ${infile} _infileLength) + SET(_checkinfile ${CMAKE_CURRENT_SOURCE_DIR}) + IF(_infileLength GREATER _binlength) + STRING(SUBSTRING "${infile}" 0 ${_binlength} _checkinfile) + IF(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") + FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_BINARY_DIR} ${infile}) + ELSE(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") + FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile}) + ENDIF(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") + ELSE(_infileLength GREATER _binlength) + FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile}) + ENDIF(_infileLength GREATER _binlength) + IF(WIN32 AND rel MATCHES "^[a-zA-Z]:") # absolute path + STRING(REGEX REPLACE "^([a-zA-Z]):(.*)$" "\\1_\\2" rel "${rel}") + ENDIF(WIN32 AND rel MATCHES "^[a-zA-Z]:") + SET(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${rel}") + STRING(REPLACE ".." "__" _outfile ${_outfile}) + GET_FILENAME_COMPONENT(outpath ${_outfile} PATH) + GET_FILENAME_COMPONENT(_outfile ${_outfile} NAME_WE) + FILE(MAKE_DIRECTORY ${outpath}) + SET(${outfile} ${outpath}/${prefix}${_outfile}.${ext}) +ENDMACRO (QT4_MAKE_OUTPUT_FILE ) + + +MACRO (QT4_GET_MOC_FLAGS _moc_flags) + SET(${_moc_flags}) + GET_DIRECTORY_PROPERTY(_inc_DIRS INCLUDE_DIRECTORIES) + + FOREACH(_current ${_inc_DIRS}) + IF("${_current}" MATCHES ".framework/?$") + STRING(REGEX REPLACE "/[^/]+.framework" "" framework_path "${_current}") + SET(${_moc_flags} ${${_moc_flags}} "-F${framework_path}") + ELSE("${_current}" MATCHES ".framework/?$") + SET(${_moc_flags} ${${_moc_flags}} "-I${_current}") + ENDIF("${_current}" MATCHES ".framework/?$") + ENDFOREACH(_current ${_inc_DIRS}) + + GET_DIRECTORY_PROPERTY(_defines COMPILE_DEFINITIONS) + FOREACH(_current ${_defines}) + SET(${_moc_flags} ${${_moc_flags}} "-D${_current}") + ENDFOREACH(_current ${_defines}) + + IF(Q_WS_WIN) + SET(${_moc_flags} ${${_moc_flags}} -DWIN32) + ENDIF(Q_WS_WIN) + +ENDMACRO(QT4_GET_MOC_FLAGS) + + +# helper macro to set up a moc rule +MACRO (QT4_CREATE_MOC_COMMAND infile outfile moc_flags moc_options) + # For Windows, create a parameters file to work around command line length limit + IF (WIN32) + # Pass the parameters in a file. Set the working directory to + # be that containing the parameters file and reference it by + # just the file name. This is necessary because the moc tool on + # MinGW builds does not seem to handle spaces in the path to the + # file given with the @ syntax. + GET_FILENAME_COMPONENT(_moc_outfile_name "${outfile}" NAME) + GET_FILENAME_COMPONENT(_moc_outfile_dir "${outfile}" PATH) + IF(_moc_outfile_dir) + SET(_moc_working_dir WORKING_DIRECTORY ${_moc_outfile_dir}) + ENDIF(_moc_outfile_dir) + SET (_moc_parameters_file ${outfile}_parameters) + SET (_moc_parameters ${moc_flags} ${moc_options} -o "${outfile}" "${infile}") + FILE (REMOVE ${_moc_parameters_file}) + FOREACH(arg ${_moc_parameters}) + FILE (APPEND ${_moc_parameters_file} "${arg}\n") + ENDFOREACH(arg) + ADD_CUSTOM_COMMAND(OUTPUT ${outfile} + COMMAND ${QT_MOC_EXECUTABLE} @${_moc_outfile_name}_parameters + DEPENDS ${infile} + ${_moc_working_dir} + VERBATIM) + ELSE (WIN32) + ADD_CUSTOM_COMMAND(OUTPUT ${outfile} + COMMAND ${QT_MOC_EXECUTABLE} + ARGS ${moc_flags} ${moc_options} -o ${outfile} ${infile} + DEPENDS ${infile}) + ENDIF (WIN32) +ENDMACRO (QT4_CREATE_MOC_COMMAND) + + +MACRO (QT4_GENERATE_MOC infile outfile ) +# get include dirs and flags + QT4_GET_MOC_FLAGS(moc_flags) + GET_FILENAME_COMPONENT(abs_infile ${infile} ABSOLUTE) + QT4_CREATE_MOC_COMMAND(${abs_infile} ${outfile} "${moc_flags}" "") + SET_SOURCE_FILES_PROPERTIES(${outfile} PROPERTIES SKIP_AUTOMOC TRUE) # dont run automoc on this file +ENDMACRO (QT4_GENERATE_MOC) + + +# QT4_WRAP_CPP(outfiles inputfile ... ) + +MACRO (QT4_WRAP_CPP outfiles ) + # get include dirs + QT4_GET_MOC_FLAGS(moc_flags) + QT4_EXTRACT_OPTIONS(moc_files moc_options ${ARGN}) + + FOREACH (it ${moc_files}) + GET_FILENAME_COMPONENT(it ${it} ABSOLUTE) + QT4_MAKE_OUTPUT_FILE(${it} moc_ cxx outfile) + QT4_CREATE_MOC_COMMAND(${it} ${outfile} "${moc_flags}" "${moc_options}") + SET(${outfiles} ${${outfiles}} ${outfile}) + ENDFOREACH(it) + +ENDMACRO (QT4_WRAP_CPP) + + +# QT4_WRAP_UI(outfiles inputfile ... ) + +MACRO (QT4_WRAP_UI outfiles ) + QT4_EXTRACT_OPTIONS(ui_files ui_options ${ARGN}) + + FOREACH (it ${ui_files}) + GET_FILENAME_COMPONENT(outfile ${it} NAME_WE) + GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE) + SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h) + ADD_CUSTOM_COMMAND(OUTPUT ${outfile} + COMMAND ${QT_UIC_EXECUTABLE} + ARGS ${ui_options} -o ${outfile} ${infile} + MAIN_DEPENDENCY ${infile}) + SET(${outfiles} ${${outfiles}} ${outfile}) + ENDFOREACH (it) + +ENDMACRO (QT4_WRAP_UI) + + +# QT4_ADD_RESOURCES(outfiles inputfile ... ) + +MACRO (QT4_ADD_RESOURCES outfiles ) + QT4_EXTRACT_OPTIONS(rcc_files rcc_options ${ARGN}) + + FOREACH (it ${rcc_files}) + GET_FILENAME_COMPONENT(outfilename ${it} NAME_WE) + GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE) + GET_FILENAME_COMPONENT(rc_path ${infile} PATH) + SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cxx) + # parse file for dependencies + # all files are absolute paths or relative to the location of the qrc file + FILE(READ "${infile}" _RC_FILE_CONTENTS) + STRING(REGEX MATCHALL "<file[^<]+" _RC_FILES "${_RC_FILE_CONTENTS}") + SET(_RC_DEPENDS) + FOREACH(_RC_FILE ${_RC_FILES}) + STRING(REGEX REPLACE "^<file[^>]*>" "" _RC_FILE "${_RC_FILE}") + STRING(REGEX MATCH "^/|([A-Za-z]:/)" _ABS_PATH_INDICATOR "${_RC_FILE}") + IF(NOT _ABS_PATH_INDICATOR) + SET(_RC_FILE "${rc_path}/${_RC_FILE}") + ENDIF(NOT _ABS_PATH_INDICATOR) + SET(_RC_DEPENDS ${_RC_DEPENDS} "${_RC_FILE}") + ENDFOREACH(_RC_FILE) + ADD_CUSTOM_COMMAND(OUTPUT ${outfile} + COMMAND ${QT_RCC_EXECUTABLE} + ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile} + MAIN_DEPENDENCY ${infile} + DEPENDS ${_RC_DEPENDS}) + SET(${outfiles} ${${outfiles}} ${outfile}) + ENDFOREACH (it) + +ENDMACRO (QT4_ADD_RESOURCES) + + +MACRO(QT4_ADD_DBUS_INTERFACE _sources _interface _basename) + GET_FILENAME_COMPONENT(_infile ${_interface} ABSOLUTE) + SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h) + SET(_impl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp) + SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc) + + # handling more arguments (as in FindQt4.cmake from KDE4) will come soon, then + # _params will be used for more than just -m + SET(_params -m) + + ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header} + COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} ${_params} -p ${_basename} ${_infile} + DEPENDS ${_infile}) + + SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE) + + QT4_GENERATE_MOC(${_header} ${_moc}) + + SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc}) + MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc}) + +ENDMACRO(QT4_ADD_DBUS_INTERFACE) + + +MACRO(QT4_ADD_DBUS_INTERFACES _sources) + FOREACH (_current_FILE ${ARGN}) + GET_FILENAME_COMPONENT(_infile ${_current_FILE} ABSOLUTE) + # get the part before the ".xml" suffix + STRING(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2" _basename ${_current_FILE}) + STRING(TOLOWER ${_basename} _basename) + QT4_ADD_DBUS_INTERFACE(${_sources} ${_infile} ${_basename}interface) + ENDFOREACH (_current_FILE) +ENDMACRO(QT4_ADD_DBUS_INTERFACES) + + +MACRO(QT4_GENERATE_DBUS_INTERFACE _header) # _customName OPTIONS -some -options ) + QT4_EXTRACT_OPTIONS(_customName _qt4_dbus_options ${ARGN}) + + GET_FILENAME_COMPONENT(_in_file ${_header} ABSOLUTE) + GET_FILENAME_COMPONENT(_basename ${_header} NAME_WE) + + IF (_customName) + SET(_target ${CMAKE_CURRENT_BINARY_DIR}/${_customName}) + ELSE (_customName) + SET(_target ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.xml) + ENDIF (_customName) + + ADD_CUSTOM_COMMAND(OUTPUT ${_target} + COMMAND ${QT_DBUSCPP2XML_EXECUTABLE} ${_qt4_dbus_options} ${_in_file} -o ${_target} + DEPENDS ${_in_file} + ) +ENDMACRO(QT4_GENERATE_DBUS_INTERFACE) + + +MACRO(QT4_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optionalBasename _optionalClassName) + GET_FILENAME_COMPONENT(_infile ${_xml_file} ABSOLUTE) + + SET(_optionalBasename "${ARGV4}") + IF (_optionalBasename) + SET(_basename ${_optionalBasename} ) + ELSE (_optionalBasename) + STRING(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2adaptor" _basename ${_infile}) + STRING(TOLOWER ${_basename} _basename) + ENDIF (_optionalBasename) + + SET(_optionalClassName "${ARGV5}") + SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h) + SET(_impl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp) + SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc) + + IF(_optionalClassName) + ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header} + COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -c ${_optionalClassName} -i ${_include} -l ${_parentClass} ${_infile} + DEPENDS ${_infile} + ) + ELSE(_optionalClassName) + ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header} + COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -i ${_include} -l ${_parentClass} ${_infile} + DEPENDS ${_infile} + ) + ENDIF(_optionalClassName) + + QT4_GENERATE_MOC(${_header} ${_moc}) + SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE) + MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc}) + + SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc}) +ENDMACRO(QT4_ADD_DBUS_ADAPTOR) + + +MACRO(QT4_AUTOMOC) + QT4_GET_MOC_FLAGS(_moc_INCS) + + SET(_matching_FILES ) + FOREACH (_current_FILE ${ARGN}) + + GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE) + # if "SKIP_AUTOMOC" is set to true, we will not handle this file here. + # This is required to make uic work correctly: + # we need to add generated .cpp files to the sources (to compile them), + # but we cannot let automoc handle them, as the .cpp files don't exist yet when + # cmake is run for the very first time on them -> however the .cpp files might + # exist at a later run. at that time we need to skip them, so that we don't add two + # different rules for the same moc file + GET_SOURCE_FILE_PROPERTY(_skip ${_abs_FILE} SKIP_AUTOMOC) + + IF ( NOT _skip AND EXISTS ${_abs_FILE} ) + + FILE(READ ${_abs_FILE} _contents) + + GET_FILENAME_COMPONENT(_abs_PATH ${_abs_FILE} PATH) + + STRING(REGEX MATCHALL "# *include +[^ ]+\\.moc[\">]" _match "${_contents}") + IF(_match) + FOREACH (_current_MOC_INC ${_match}) + STRING(REGEX MATCH "[^ <\"]+\\.moc" _current_MOC "${_current_MOC_INC}") + + GET_FILENAME_COMPONENT(_basename ${_current_MOC} NAME_WE) + IF(EXISTS ${_abs_PATH}/${_basename}.hpp) + SET(_header ${_abs_PATH}/${_basename}.hpp) + ELSE(EXISTS ${_abs_PATH}/${_basename}.hpp) + SET(_header ${_abs_PATH}/${_basename}.h) + ENDIF(EXISTS ${_abs_PATH}/${_basename}.hpp) + SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC}) + QT4_CREATE_MOC_COMMAND(${_header} ${_moc} "${_moc_INCS}" "") + MACRO_ADD_FILE_DEPENDENCIES(${_abs_FILE} ${_moc}) + ENDFOREACH (_current_MOC_INC) + ENDIF(_match) + ENDIF ( NOT _skip AND EXISTS ${_abs_FILE} ) + ENDFOREACH (_current_FILE) +ENDMACRO(QT4_AUTOMOC) + + +MACRO(QT4_CREATE_TRANSLATION _qm_files) + QT4_EXTRACT_OPTIONS(_lupdate_files _lupdate_options ${ARGN}) + SET(_my_sources) + SET(_my_dirs) + SET(_my_tsfiles) + SET(_ts_pro) + FOREACH (_file ${_lupdate_files}) + GET_FILENAME_COMPONENT(_ext ${_file} EXT) + GET_FILENAME_COMPONENT(_abs_FILE ${_file} ABSOLUTE) + IF(_ext MATCHES "ts") + LIST(APPEND _my_tsfiles ${_abs_FILE}) + ELSE(_ext MATCHES "ts") + IF(NOT _ext) + LIST(APPEND _my_dirs ${_abs_FILE}) + ELSE(NOT _ext) + LIST(APPEND _my_sources ${_abs_FILE}) + ENDIF(NOT _ext) + ENDIF(_ext MATCHES "ts") + ENDFOREACH(_file) + FOREACH(_ts_file ${_my_tsfiles}) + IF(_my_sources) + # make a .pro file to call lupdate on, so we don't make our commands too + # long for some systems + GET_FILENAME_COMPONENT(_ts_name ${_ts_file} NAME_WE) + SET(_ts_pro ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_ts_name}_lupdate.pro) + SET(_pro_srcs) + FOREACH(_pro_src ${_my_sources}) + SET(_pro_srcs "${_pro_srcs} \"${_pro_src}\"") + ENDFOREACH(_pro_src ${_my_sources}) + FILE(WRITE ${_ts_pro} "SOURCES = ${_pro_srcs}") + ENDIF(_my_sources) + ADD_CUSTOM_COMMAND(OUTPUT ${_ts_file} + COMMAND ${QT_LUPDATE_EXECUTABLE} + ARGS ${_lupdate_options} ${_ts_pro} ${_my_dirs} -ts ${_ts_file} + DEPENDS ${_my_sources} ${_ts_pro}) + ENDFOREACH(_ts_file) + QT4_ADD_TRANSLATION(${_qm_files} ${_my_tsfiles}) +ENDMACRO(QT4_CREATE_TRANSLATION) + + +MACRO(QT4_ADD_TRANSLATION _qm_files) + FOREACH (_current_FILE ${ARGN}) + GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE) + GET_FILENAME_COMPONENT(qm ${_abs_FILE} NAME_WE) + GET_SOURCE_FILE_PROPERTY(output_location ${_abs_FILE} OUTPUT_LOCATION) + IF(output_location) + FILE(MAKE_DIRECTORY "${output_location}") + SET(qm "${output_location}/${qm}.qm") + ELSE(output_location) + SET(qm "${CMAKE_CURRENT_BINARY_DIR}/${qm}.qm") + ENDIF(output_location) + + ADD_CUSTOM_COMMAND(OUTPUT ${qm} + COMMAND ${QT_LRELEASE_EXECUTABLE} + ARGS ${_abs_FILE} -qm ${qm} + DEPENDS ${_abs_FILE} + ) + SET(${_qm_files} ${${_qm_files}} ${qm}) + ENDFOREACH (_current_FILE) +ENDMACRO(QT4_ADD_TRANSLATION) diff --git a/Modules/SystemInformation.in b/Modules/SystemInformation.in index 7722da0..f2aef50 100644 --- a/Modules/SystemInformation.in +++ b/Modules/SystemInformation.in @@ -34,8 +34,6 @@ CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_C_FLAGS == "${CMAKE_SHARED_LIBRARY_LINK_DYNAMI // C shared module flags CMAKE_SHARED_MODULE_C_FLAGS == "${CMAKE_SHARED_MODULE_C_FLAGS}" CMAKE_SHARED_MODULE_CREATE_C_FLAGS == "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS}" -CMAKE_SHARED_MODULE_RUNTIME_FLAG == "${CMAKE_SHARED_MODULE_RUNTIME_FLAG}" -CMAKE_SHARED_MODULE_RUNTIME_FLAG_SEP == "${CMAKE_SHARED_MODULE_RUNTIME_FLAG_SEP}" CMAKE_SHARED_MODULE_LINK_STATIC_C_FLAGS == "${CMAKE_SHARED_MODULE_LINK_STATIC_C_FLAGS}" CMAKE_SHARED_MODULE_LINK_DYNAMIC_C_FLAGS == "${CMAKE_SHARED_MODULE_LINK_DYNAMIC_C_FLAGS}" @@ -55,8 +53,6 @@ CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_CXX_FLAGS == "${CMAKE_SHARED_LIBRARY_LINK_DYNA // CXX shared module flags CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS == "${CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS}" CMAKE_SHARED_MODULE_CXX_FLAGS == "${CMAKE_SHARED_MODULE_CXX_FLAGS}" -CMAKE_SHARED_MODULE_RUNTIME_CXX_FLAG == "${CMAKE_SHARED_MODULE_RUNTIME_CXX_FLAG}" -CMAKE_SHARED_MODULE_RUNTIME_CXX_FLAG_SEP == "${CMAKE_SHARED_MODULE_RUNTIME_CXX_FLAG_SEP}" CMAKE_SHARED_MODULE_LINK_STATIC_CXX_FLAGS == "${CMAKE_SHARED_MODULE_LINK_STATIC_CXX_FLAGS}" CMAKE_SHARED_MODULE_LINK_DYNAMIC_CXX_FLAGS == "${CMAKE_SHARED_MODULE_LINK_DYNAMIC_CXX_FLAGS}" diff --git a/Modules/UseQt4.cmake b/Modules/UseQt4.cmake index f92500b..a18beaf 100644 --- a/Modules/UseQt4.cmake +++ b/Modules/UseQt4.cmake @@ -23,9 +23,6 @@ SET_PROPERTY(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO QT_NO_ SET_PROPERTY(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL QT_NO_DEBUG) INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR}) -IF(Q_WS_MAC AND QT_USE_FRAMEWORKS) - INCLUDE_DIRECTORIES(${QT_QTCORE_LIBRARY}) -ENDIF(Q_WS_MAC AND QT_USE_FRAMEWORKS) SET(QT_LIBRARIES "") @@ -80,7 +77,10 @@ FOREACH(module QT3SUPPORT QTOPENGL QTASSISTANT QTDESIGNER QTMOTIF QTNSPLUGIN ADD_DEFINITIONS(-DQT_${qt_module_def}_LIB) INCLUDE_DIRECTORIES(${QT_${module}_INCLUDE_DIR}) ENDIF(QT_USE_${module}) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIBRARY} ${QT_${module}_LIB_DEPENDENCIES}) + SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIBRARY}) + IF(QT_IS_STATIC) + SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIB_DEPENDENCIES}) + ENDIF(QT_IS_STATIC) FOREACH(depend_module ${QT_${module}_MODULE_DEPENDS}) SET(QT_USE_${depend_module}_DEPENDS 1) ENDFOREACH(depend_module ${QT_${module}_MODULE_DEPENDS}) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 9099691..09713ef 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -18,6 +18,8 @@ ELSE(HAVE_ELF_H) SET(CMAKE_USE_ELF_PARSER) ENDIF(HAVE_ELF_H) +SET(EXECUTABLE_OUTPUT_PATH ${CMake_BIN_DIR}) + # configure the .h file CONFIGURE_FILE( "${CMake_SOURCE_DIR}/Source/cmConfigure.cmake.h.in" @@ -165,6 +167,8 @@ SET(SRCS cmExportFileGenerator.cxx cmExportInstallFileGenerator.h cmExportInstallFileGenerator.cxx + cmExtraCodeBlocksGenerator.cxx + cmExtraCodeBlocksGenerator.h cmExtraEclipseCDT4Generator.cxx cmExtraEclipseCDT4Generator.h cmFileTimeComparison.cxx @@ -244,6 +248,9 @@ SET(SRCS cmake.h cmakewizard.cxx cmakewizard.h + + cm_utf8.h + cm_utf8.c ) # Kdevelop only works on UNIX and not windows @@ -251,10 +258,6 @@ IF(UNIX) SET(SRCS ${SRCS} cmGlobalKdevelopGenerator.cxx) ENDIF(UNIX) -IF(NOT CYGWIN) - SET(SRCS ${SRCS} cmExtraCodeBlocksGenerator.cxx) -ENDIF(NOT CYGWIN) - # XCode only works on apple IF(APPLE) SET(SRCS ${SRCS} @@ -281,6 +284,8 @@ IF (WIN32) cmGlobalMinGWMakefileGenerator.cxx cmGlobalNMakeMakefileGenerator.cxx cmGlobalNMakeMakefileGenerator.h + cmGlobalJOMMakefileGenerator.cxx + cmGlobalJOMMakefileGenerator.h cmGlobalVisualStudio6Generator.cxx cmGlobalVisualStudio6Generator.h cmGlobalVisualStudio71Generator.cxx @@ -417,12 +422,12 @@ SET(CPACK_SRCS CPack/cmCPackZIPGenerator.cxx ) -IF(WIN32 AND UNIX) +IF(CYGWIN) SET(CPACK_SRCS ${CPACK_SRCS} CPack/cmCPackCygwinBinaryGenerator.cxx CPack/cmCPackCygwinSourceGenerator.cxx ) -ENDIF(WIN32 AND UNIX) +ENDIF(CYGWIN) IF(UNIX) SET(CPACK_SRCS ${CPACK_SRCS} @@ -456,8 +461,6 @@ ENDIF(APPLE) # Build CMake executable ADD_EXECUTABLE(cmake cmakemain.cxx) TARGET_LINK_LIBRARIES(cmake CMakeLib) -ADD_EXECUTABLE(DumpDocumentation cmDumpDocumentation) -TARGET_LINK_LIBRARIES(DumpDocumentation CMakeLib) # Build special executable for running programs on Windows 98 IF(WIN32) diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx index 3fe1c00..b984e85 100644 --- a/Source/CTest/cmCTestBuildCommand.cxx +++ b/Source/CTest/cmCTestBuildCommand.cxx @@ -23,7 +23,11 @@ cmCTestBuildCommand::cmCTestBuildCommand() { this->GlobalGenerator = 0; this->Arguments[ctb_NUMBER_ERRORS] = "NUMBER_ERRORS"; - this->Arguments[ctb_NUMBER_WARNINGS] = "NUMBER_WARNINGS"; + this->Arguments[ctb_NUMBER_WARNINGS] = "NUMBER_WARNINGS"; + this->Arguments[ctb_TARGET] = "TARGET"; + this->Arguments[ctb_CONFIGURATION] = "CONFIGURATION"; + this->Arguments[ctb_FLAGS] = "FLAGS"; + this->Arguments[ctb_PROJECT_NAME] = "PROJECT_NAME"; this->Arguments[ctb_LAST] = 0; this->Last = ctb_LAST; } @@ -49,6 +53,7 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() return 0; } this->Handler = (cmCTestBuildHandler*)handler; + const char* ctestBuildCommand = this->Makefile->GetDefinition("CTEST_BUILD_COMMAND"); if ( ctestBuildCommand && *ctestBuildCommand ) @@ -60,13 +65,33 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() const char* cmakeGeneratorName = this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR"); const char* cmakeProjectName - = this->Makefile->GetDefinition("CTEST_PROJECT_NAME"); - const char* cmakeBuildConfiguration + = (this->Values[ctb_PROJECT_NAME] && *this->Values[ctb_PROJECT_NAME]) + ? this->Values[ctb_PROJECT_NAME] + : this->Makefile->GetDefinition("CTEST_PROJECT_NAME"); + + // Build configuration is determined by: CONFIGURATION argument, + // or CTEST_BUILD_CONFIGURATION script variable, or + // CTEST_CONFIGURATION_TYPE script variable, or ctest -C command + // line argument... in that order. + // + const char* ctestBuildConfiguration = this->Makefile->GetDefinition("CTEST_BUILD_CONFIGURATION"); + const char* cmakeBuildConfiguration + = (this->Values[ctb_CONFIGURATION] && *this->Values[ctb_CONFIGURATION]) + ? this->Values[ctb_CONFIGURATION] + : ((ctestBuildConfiguration && *ctestBuildConfiguration) + ? ctestBuildConfiguration + : this->CTest->GetConfigType().c_str()); + const char* cmakeBuildAdditionalFlags - = this->Makefile->GetDefinition("CTEST_BUILD_FLAGS"); + = (this->Values[ctb_FLAGS] && *this->Values[ctb_FLAGS]) + ? this->Values[ctb_FLAGS] + : this->Makefile->GetDefinition("CTEST_BUILD_FLAGS"); const char* cmakeBuildTarget - = this->Makefile->GetDefinition("CTEST_BUILD_TARGET"); + = (this->Values[ctb_TARGET] && *this->Values[ctb_TARGET]) + ? this->Values[ctb_TARGET] + : this->Makefile->GetDefinition("CTEST_BUILD_TARGET"); + if ( cmakeGeneratorName && *cmakeGeneratorName && cmakeProjectName && *cmakeProjectName ) { @@ -104,7 +129,7 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() } cmakeBuildConfiguration = config; } - + std::string buildCommand = this->GlobalGenerator-> GenerateBuildCommand(cmakeMakeProgram, @@ -119,10 +144,17 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() else { cmOStringStream ostr; - ostr << "CTEST_BUILD_COMMAND or CTEST_CMAKE_GENERATOR not specified. " - "Please specify the CTEST_CMAKE_GENERATOR and CTEST_PROJECT_NAME if " - "this is a CMake project, or specify the CTEST_BUILD_COMMAND for " - "cmake or any other project."; + ostr << "has no project to build. If this is a " + "\"built with CMake\" project, verify that CTEST_CMAKE_GENERATOR " + "and CTEST_PROJECT_NAME are set." + "\n" + "CTEST_PROJECT_NAME is usually set in CTestConfig.cmake. Verify " + "that CTestConfig.cmake exists, or CTEST_PROJECT_NAME " + "is set in the script, or PROJECT_NAME is passed as an argument " + "to ctest_build." + "\n" + "Alternatively, set CTEST_BUILD_COMMAND to build the project " + "with a custom command line."; this->SetError(ostr.str().c_str()); return 0; } diff --git a/Source/CTest/cmCTestBuildCommand.h b/Source/CTest/cmCTestBuildCommand.h index 8122eee..228067e 100644 --- a/Source/CTest/cmCTestBuildCommand.h +++ b/Source/CTest/cmCTestBuildCommand.h @@ -82,6 +82,10 @@ protected: ctb_BUILD = ct_LAST, ctb_NUMBER_ERRORS, ctb_NUMBER_WARNINGS, + ctb_TARGET, + ctb_CONFIGURATION, + ctb_FLAGS, + ctb_PROJECT_NAME, ctb_LAST }; diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 0095bbc..a125459 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -265,6 +265,32 @@ void cmCTestBuildHandler::PopulateCustomVectors(cmMakefile *mf) } //---------------------------------------------------------------------- +std::string cmCTestBuildHandler::GetMakeCommand() +{ + std::string makeCommand + = this->CTest->GetCTestConfiguration("MakeCommand"); + cmCTestLog(this->CTest, + HANDLER_VERBOSE_OUTPUT, "MakeCommand:" << makeCommand << + "\n"); + + std::string configType = this->CTest->GetConfigType(); + if (configType == "") + { + configType + = this->CTest->GetCTestConfiguration("DefaultCTestConfigurationType"); + } + if (configType == "") + { + configType = "Release"; + } + + cmSystemTools::ReplaceString(makeCommand, + "${CTEST_CONFIGURATION_TYPE}", configType.c_str()); + + return makeCommand; +} + +//---------------------------------------------------------------------- //clearly it would be nice if this were broken up into a few smaller //functions and commented... int cmCTestBuildHandler::ProcessHandler() @@ -300,11 +326,7 @@ int cmCTestBuildHandler::ProcessHandler() } // Determine build command and build directory - const std::string &makeCommand - = this->CTest->GetCTestConfiguration("MakeCommand"); - cmCTestLog(this->CTest, - HANDLER_VERBOSE_OUTPUT, "MakeCommand:" << makeCommand << - "\n"); + std::string makeCommand = this->GetMakeCommand(); if ( makeCommand.size() == 0 ) { cmCTestLog(this->CTest, ERROR_MESSAGE, @@ -312,6 +334,7 @@ int cmCTestBuildHandler::ProcessHandler() << std::endl); return -1; } + const std::string &buildDirectory = this->CTest->GetCTestConfiguration("BuildDirectory"); if ( buildDirectory.size() == 0 ) @@ -519,8 +542,7 @@ void cmCTestBuildHandler::GenerateXMLHeader(std::ostream& os) static_cast<unsigned int>(this->StartBuildTime) << "</StartBuildTime>\n" << "<BuildCommand>" - << cmXMLSafe( - this->CTest->GetCTestConfiguration("MakeCommand")) + << cmXMLSafe(this->GetMakeCommand()) << "</BuildCommand>" << std::endl; } diff --git a/Source/CTest/cmCTestBuildHandler.h b/Source/CTest/cmCTestBuildHandler.h index 7ee50be..439efd6 100644 --- a/Source/CTest/cmCTestBuildHandler.h +++ b/Source/CTest/cmCTestBuildHandler.h @@ -46,7 +46,10 @@ public: int GetTotalErrors() { return this->TotalErrors;} int GetTotalWarnings() { return this->TotalWarnings;} + private: + std::string GetMakeCommand(); + //! Run command specialized for make and configure. Returns process status // and retVal is return value or exception. int RunMakeCommand(const char* command, diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx index 00d9ec5..147173f 100644 --- a/Source/CTest/cmCTestConfigureCommand.cxx +++ b/Source/CTest/cmCTestConfigureCommand.cxx @@ -11,6 +11,7 @@ ============================================================================*/ #include "cmCTestConfigureCommand.h" +#include "cmGlobalGenerator.h" #include "cmCTest.h" #include "cmCTestGenericHandler.h" @@ -66,6 +67,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() const char* ctestConfigureCommand = this->Makefile->GetDefinition("CTEST_CONFIGURE_COMMAND"); + if ( ctestConfigureCommand && *ctestConfigureCommand ) { this->CTest->SetCTestConfiguration("ConfigureCommand", @@ -86,6 +88,29 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() "variable"); return 0; } + + const std::string cmakelists_file = source_dir + "/CMakeLists.txt"; + if ( !cmSystemTools::FileExists(cmakelists_file.c_str()) ) + { + cmOStringStream e; + e << "CMakeLists.txt file does not exist [" + << cmakelists_file << "]"; + this->SetError(e.str().c_str()); + return 0; + } + + bool multiConfig = false; + bool cmakeBuildTypeInOptions = false; + + cmGlobalGenerator *gg = + this->Makefile->GetCMakeInstance()->CreateGlobalGenerator( + cmakeGeneratorName); + if(gg) + { + multiConfig = gg->IsMultiConfig(); + delete gg; + } + std::string cmakeConfigureCommand = "\""; cmakeConfigureCommand += this->CTest->GetCMakeExecutable(); cmakeConfigureCommand += "\""; @@ -95,9 +120,23 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() for (it= options.begin(); it!=options.end(); ++it) { option = *it; + cmakeConfigureCommand += " \""; cmakeConfigureCommand += option; cmakeConfigureCommand += "\""; + + if ((0 != strstr(option.c_str(), "CMAKE_BUILD_TYPE=")) || + (0 != strstr(option.c_str(), "CMAKE_BUILD_TYPE:STRING="))) + { + cmakeBuildTypeInOptions = true; + } + } + + if (!multiConfig && !cmakeBuildTypeInOptions) + { + cmakeConfigureCommand += " \"-DCMAKE_BUILD_TYPE:STRING="; + cmakeConfigureCommand += this->CTest->GetConfigType(); + cmakeConfigureCommand += "\""; } cmakeConfigureCommand += " \"-G"; @@ -113,9 +152,9 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() } else { - this->SetError("Configure command is not specified. If this is a CMake " - "project, specify CTEST_CMAKE_GENERATOR, or if this is not CMake " - "project, specify CTEST_CONFIGURE_COMMAND."); + this->SetError("Configure command is not specified. If this is a " + "\"built with CMake\" project, set CTEST_CMAKE_GENERATOR. If not, " + "set CTEST_CONFIGURE_COMMAND."); return 0; } } diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index 5b0e8ff..8108b19 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -19,6 +19,8 @@ #include <cmsys/ios/sstream> #include <cmsys/Process.h> +#include <sys/types.h> +#include <time.h> #include <ctype.h> //---------------------------------------------------------------------------- @@ -336,16 +338,28 @@ private: Person author; this->ParsePerson(this->Line.c_str()+7, author); this->Rev.Author = author.Name; - char buf[1024]; + + // Convert the time to a human-readable format that is also easy + // to machine-parse: "CCYY-MM-DD hh:mm:ss". + time_t seconds = static_cast<time_t>(author.Time); + struct tm* t = gmtime(&seconds); + char dt[1024]; + sprintf(dt, "%04d-%02d-%02d %02d:%02d:%02d", + t->tm_year+1900, t->tm_mon+1, t->tm_mday, + t->tm_hour, t->tm_min, t->tm_sec); + this->Rev.Date = dt; + + // Add the time-zone field "+zone" or "-zone". + char tz[32]; if(author.TimeZone >= 0) { - sprintf(buf, "%lu +%04ld", author.Time, author.TimeZone); + sprintf(tz, " +%04ld", author.TimeZone); } else { - sprintf(buf, "%lu -%04ld", author.Time, -author.TimeZone); + sprintf(tz, " -%04ld", -author.TimeZone); } - this->Rev.Date = buf; + this->Rev.Date += tz; } } diff --git a/Source/CTest/cmCTestGlobalVC.cxx b/Source/CTest/cmCTestGlobalVC.cxx index 73a36da..8c51102 100644 --- a/Source/CTest/cmCTestGlobalVC.cxx +++ b/Source/CTest/cmCTestGlobalVC.cxx @@ -107,6 +107,19 @@ void cmCTestGlobalVC::WriteXMLDirectory(std::ostream& xml, } //---------------------------------------------------------------------------- +void cmCTestGlobalVC::WriteXMLGlobal(std::ostream& xml) +{ + if(!this->NewRevision.empty()) + { + xml << "\t<Revision>" << this->NewRevision << "</Revision>\n"; + } + if(!this->OldRevision.empty() && this->OldRevision != this->NewRevision) + { + xml << "\t<PriorRevision>" << this->OldRevision << "</PriorRevision>\n"; + } +} + +//---------------------------------------------------------------------------- bool cmCTestGlobalVC::WriteXMLUpdates(std::ostream& xml) { cmCTestLog(this->CTest, HANDLER_OUTPUT, @@ -117,6 +130,8 @@ bool cmCTestGlobalVC::WriteXMLUpdates(std::ostream& xml) this->LoadModifications(); + this->WriteXMLGlobal(xml); + for(std::map<cmStdString, Directory>::const_iterator di = this->Dirs.begin(); di != this->Dirs.end(); ++di) { diff --git a/Source/CTest/cmCTestGlobalVC.h b/Source/CTest/cmCTestGlobalVC.h index d88016b..a648a59 100644 --- a/Source/CTest/cmCTestGlobalVC.h +++ b/Source/CTest/cmCTestGlobalVC.h @@ -60,6 +60,7 @@ protected: virtual void LoadModifications() = 0; virtual void LoadRevisions() = 0; + virtual void WriteXMLGlobal(std::ostream& xml); void WriteXMLDirectory(std::ostream& xml, std::string const& path, Directory const& dir); }; diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx index 1c9f080..1957e04 100644 --- a/Source/CTest/cmCTestHandlerCommand.cxx +++ b/Source/CTest/cmCTestHandlerCommand.cxx @@ -59,6 +59,17 @@ bool cmCTestHandlerCommand } } + // Set the config type of this ctest to the current value of the + // CTEST_CONFIGURATION_TYPE script variable if it is defined. + // The current script value trumps the -C argument on the command + // line. + const char* ctestConfigType = + this->Makefile->GetDefinition("CTEST_CONFIGURATION_TYPE"); + if (ctestConfigType) + { + this->CTest->SetConfigType(ctestConfigType); + } + cmCTestLog(this->CTest, DEBUG, "Initialize handler" << std::endl;); cmCTestGenericHandler* handler = this->InitializeHandler(); if ( !handler ) diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 336303a..a79f131 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -43,8 +43,11 @@ cmCTestMultiProcessHandler::SetTests(TestMap& tests, this->TestRunningMap[i->first] = false; this->TestFinishMap[i->first] = false; } - this->ReadCostData(); - this->CreateTestCostList(); + if(!this->CTest->GetShowOnly()) + { + this->ReadCostData(); + this->CreateTestCostList(); + } } // Set the max number of tests that can be run at the same time. @@ -102,6 +105,7 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test) this->RunningCount -= GetProcessorsUsed(test); testRun->EndTest(this->Completed, this->Total, false); this->Failed->push_back(this->Properties[test]->Name); + delete testRun; } cmSystemTools::ChangeDirectory(current_dir.c_str()); } @@ -412,12 +416,9 @@ void cmCTestMultiProcessHandler::CheckResume() fin.close(); } } - else + else if(cmSystemTools::FileExists(fname.c_str(), true)) { - if(cmSystemTools::FileExists(fname.c_str(), true)) - { - cmSystemTools::RemoveFile(fname.c_str()); - } + cmSystemTools::RemoveFile(fname.c_str()); } } diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index 3e4757b..24d1d9f 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -15,6 +15,9 @@ #include "cmCTest.h" #include "cmSystemTools.h" +#include <cm_zlib.h> +#include <cmsys/Base64.h> + cmCTestRunTest::cmCTestRunTest(cmCTestTestHandler* handler) { this->CTest = handler->CTest; @@ -23,9 +26,12 @@ cmCTestRunTest::cmCTestRunTest(cmCTestTestHandler* handler) this->TestProcess = 0; this->TestResult.ExecutionTime =0; this->TestResult.ReturnValue = 0; - this->TestResult.Status = 0; + this->TestResult.Status = cmCTestTestHandler::NOT_RUN; this->TestResult.TestCount = 0; this->TestResult.Properties = 0; + this->ProcessOutput = ""; + this->CompressedOutput = ""; + this->CompressionRatio = 2; } cmCTestRunTest::~cmCTestRunTest() @@ -52,7 +58,7 @@ bool cmCTestRunTest::CheckOutput() { // Store this line of output. cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, - this->GetIndex() << ": " << line << std::endl); + this->GetIndex() << ": " << line << std::endl); this->ProcessOutput += line; this->ProcessOutput += "\n"; } @@ -65,8 +71,73 @@ bool cmCTestRunTest::CheckOutput() } //--------------------------------------------------------- +// Streamed compression of test output. The compressed data +// is appended to this->CompressedOutput +void cmCTestRunTest::CompressOutput() +{ + int ret; + z_stream strm; + + unsigned char* in = + reinterpret_cast<unsigned char*>( + const_cast<char*>(this->ProcessOutput.c_str())); + //zlib makes the guarantee that this is the maximum output size + int outSize = static_cast<int>(this->ProcessOutput.size() * 1.001 + 13); + unsigned char* out = new unsigned char[outSize]; + + strm.zalloc = Z_NULL; + strm.zfree = Z_NULL; + strm.opaque = Z_NULL; + ret = deflateInit(&strm, -1); //default compression level + if (ret != Z_OK) + { + return; + } + + strm.avail_in = static_cast<uInt>(this->ProcessOutput.size()); + strm.next_in = in; + strm.avail_out = outSize; + strm.next_out = out; + ret = deflate(&strm, Z_FINISH); + + if(ret == Z_STREAM_ERROR || ret != Z_STREAM_END) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, "Error during output " + "compression. Sending uncompressed output." << std::endl); + return; + } + + (void)deflateEnd(&strm); + + unsigned char *encoded_buffer + = new unsigned char[static_cast<int>(outSize * 1.5)]; + + unsigned long rlen + = cmsysBase64_Encode(out, strm.total_out, encoded_buffer, 1); + + for(unsigned long i = 0; i < rlen; i++) + { + this->CompressedOutput += encoded_buffer[i]; + } + + if(strm.total_in) + { + this->CompressionRatio = static_cast<double>(strm.total_out) / + static_cast<double>(strm.total_in); + } + + delete [] encoded_buffer; + delete [] out; +} + +//--------------------------------------------------------- bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) { + if (this->CTest->ShouldCompressTestOutput()) + { + this->CompressOutput(); + } + //restore the old environment if (this->ModifyEnv) { @@ -146,7 +217,7 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) } else if ( res == cmsysProcess_State_Expired ) { - cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Timeout"); + cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Timeout "); this->TestResult.Status = cmCTestTestHandler::TIMEOUT; outputTestErrorsToConsole = this->CTest->OutputTestOutputOnTestFailure; } @@ -177,10 +248,9 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) this->TestResult.Status = cmCTestTestHandler::OTHER_FAULT; } } - else // if ( res == cmsysProcess_State_Error ) + else //cmsysProcess_State_Error { - cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Bad command " << res ); - this->TestResult.Status = cmCTestTestHandler::BAD_COMMAND; + cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Not Run "); } passed = this->TestResult.Status == cmCTestTestHandler::COMPLETED; @@ -202,18 +272,11 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) // Output since that is what is parsed by cmCTestMemCheckHandler if(!this->TestHandler->MemCheck && started) { - if (this->TestResult.Status == cmCTestTestHandler::COMPLETED) - { this->TestHandler->CleanTestOutput(this->ProcessOutput, static_cast<size_t> - (this->TestHandler->CustomMaximumPassedTestOutputSize)); - } - else - { - this->TestHandler->CleanTestOutput(this->ProcessOutput, - static_cast<size_t> - (this->TestHandler->CustomMaximumFailedTestOutputSize)); - } + (this->TestResult.Status == cmCTestTestHandler::COMPLETED ? + this->TestHandler->CustomMaximumPassedTestOutputSize : + this->TestHandler->CustomMaximumFailedTestOutputSize)); } this->TestResult.Reason = reason; if (this->TestHandler->LogFile) @@ -258,16 +321,23 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) << "----------------------------------------------------------" << std::endl << std::endl; } + // if the test actually started and ran + // record the results in TestResult if(started) { - this->TestResult.Output = this->ProcessOutput; + bool compress = this->CompressionRatio < 1 && + this->CTest->ShouldCompressTestOutput(); + this->TestResult.Output = compress ? this->CompressedOutput + : this->ProcessOutput; + this->TestResult.CompressOutput = compress; this->TestResult.ReturnValue = this->TestProcess->GetExitValue(); this->TestResult.CompletionStatus = "Completed"; this->TestResult.ExecutionTime = this->TestProcess->GetTotalTime(); - this->TestHandler->TestResults.push_back(this->TestResult); - this->MemCheckPostProcess(); } + // Always push the current TestResult onto the + // TestHandler vector + this->TestHandler->TestResults.push_back(this->TestResult); delete this->TestProcess; return passed; } @@ -308,16 +378,41 @@ bool cmCTestRunTest::StartTest(size_t total) std::vector<std::string>& args = this->TestProperties->Args; this->TestResult.Properties = this->TestProperties; this->TestResult.ExecutionTime = 0; + this->TestResult.CompressOutput = false; this->TestResult.ReturnValue = -1; - this->TestResult.CompletionStatus = "Not Run"; - this->TestResult.Status = cmCTestTestHandler::NOT_RUN; + this->TestResult.CompletionStatus = "Failed to start"; + this->TestResult.Status = cmCTestTestHandler::BAD_COMMAND; this->TestResult.TestCount = this->TestProperties->Index; this->TestResult.Name = this->TestProperties->Name; this->TestResult.Path = this->TestProperties->Directory.c_str(); + // Check if all required files exist + for(std::vector<std::string>::iterator i = + this->TestProperties->RequiredFiles.begin(); + i != this->TestProperties->RequiredFiles.end(); ++i) + { + std::string file = *i; + + if(!cmSystemTools::FileExists(file.c_str())) + { + //Required file was not found + this->TestProcess = new cmProcess; + *this->TestHandler->LogFile << "Unable to find required file: " + << file.c_str() << std::endl; + cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to find required file: " + << file.c_str() << std::endl); + this->TestResult.Output = "Unable to find required file: " + file; + this->TestResult.FullCommandLine = ""; + this->TestResult.CompletionStatus = "Not Run"; + this->TestResult.Status = cmCTestTestHandler::NOT_RUN; + return false; + } + } // log and return if we did not find the executable if (this->ActualCommand == "") { + // if the command was not found create a TestResult object + // that has that information this->TestProcess = new cmProcess; *this->TestHandler->LogFile << "Unable to find executable: " << args[1].c_str() << std::endl; @@ -325,7 +420,8 @@ bool cmCTestRunTest::StartTest(size_t total) << args[1].c_str() << std::endl); this->TestResult.Output = "Unable to find executable: " + args[1]; this->TestResult.FullCommandLine = ""; - this->TestHandler->TestResults.push_back(this->TestResult); + this->TestResult.CompletionStatus = "Not Run"; + this->TestResult.Status = cmCTestTestHandler::NOT_RUN; return false; } this->StartTime = this->CTest->CurrentTime(); diff --git a/Source/CTest/cmCTestRunTest.h b/Source/CTest/cmCTestRunTest.h index bfeda20..1084643 100644 --- a/Source/CTest/cmCTestRunTest.h +++ b/Source/CTest/cmCTestRunTest.h @@ -45,6 +45,9 @@ public: // Read and store output. Returns true if it must be called again. bool CheckOutput(); + // Compresses the output, writing to CompressedOutput + void CompressOutput(); + //launch the test process, return whether it started correctly bool StartTest(size_t total); //capture and report the test results @@ -53,6 +56,7 @@ public: void ComputeArguments(); private: void DartProcessing(); + void ExeNotFound(std::string exe); bool CreateProcess(double testTimeOut, std::vector<std::string>* environment); void WriteLogOutputTop(size_t completed, size_t total); @@ -71,9 +75,15 @@ private: //flag for whether the env was modified for this run bool ModifyEnv; + + bool UsePrefixCommand; + std::string PrefixCommand; + //stores the original environment if we are modifying it std::vector<std::string> OrigEnv; std::string ProcessOutput; + std::string CompressedOutput; + double CompressionRatio; //The test results cmCTestTestHandler::cmCTestTestResult TestResult; int Index; @@ -96,5 +106,6 @@ inline int getNumWidth(size_t n) } return numWidth; } + #endif diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx index 82e5845..fab9a8c 100644 --- a/Source/CTest/cmCTestSVN.cxx +++ b/Source/CTest/cmCTestSVN.cxx @@ -440,3 +440,11 @@ void cmCTestSVN::LoadModifications() OutputLogger err(this->Log, "status-err> "); this->RunChild(svn_status, &out, &err); } + +//---------------------------------------------------------------------------- +void cmCTestSVN::WriteXMLGlobal(std::ostream& xml) +{ + this->cmCTestGlobalVC::WriteXMLGlobal(xml); + + xml << "\t<SVNPath>" << this->Base << "</SVNPath>\n"; +} diff --git a/Source/CTest/cmCTestSVN.h b/Source/CTest/cmCTestSVN.h index ff9ff0f..f72c58f 100644 --- a/Source/CTest/cmCTestSVN.h +++ b/Source/CTest/cmCTestSVN.h @@ -52,6 +52,8 @@ private: void DoRevision(Revision const& revision, std::vector<Change> const& changes); + void WriteXMLGlobal(std::ostream& xml); + // Parsing helper classes. class InfoParser; class LogParser; diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 5983e68..fdf17e0 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -583,6 +583,10 @@ void cmCTestScriptHandler::SleepInSeconds(unsigned int secondsToWait) int cmCTestScriptHandler::RunConfigurationScript (const std::string& total_script_arg, bool pscope) { +#ifdef CMAKE_BUILD_WITH_CMAKE + cmSystemTools::SaveRestoreEnvironment sre; +#endif + int result; this->ScriptStartTime = diff --git a/Source/CTest/cmCTestStartCommand.cxx b/Source/CTest/cmCTestStartCommand.cxx index 779a38c..228a173 100644 --- a/Source/CTest/cmCTestStartCommand.cxx +++ b/Source/CTest/cmCTestStartCommand.cxx @@ -14,6 +14,13 @@ #include "cmCTest.h" #include "cmLocalGenerator.h" #include "cmGlobalGenerator.h" +#include "cmCTestVC.h" +#include "cmGeneratedFileStream.h" + +cmCTestStartCommand::cmCTestStartCommand() +{ + this->CreateNewTag = true; +} bool cmCTestStartCommand ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) @@ -42,6 +49,15 @@ bool cmCTestStartCommand } } + if (cnt < args.size()) + { + if (args[cnt] == "APPEND") + { + cnt ++; + this->CreateNewTag = false; + } + } + if ( cnt < args.size() ) { src_dir = args[cnt].c_str(); @@ -76,10 +92,11 @@ bool cmCTestStartCommand cmSystemTools::AddKeepPath(bld_dir); this->CTest->EmptyCTestConfiguration(); - this->CTest->SetCTestConfiguration("SourceDirectory", - cmSystemTools::CollapseFullPath(src_dir).c_str()); - this->CTest->SetCTestConfiguration("BuildDirectory", - cmSystemTools::CollapseFullPath(bld_dir).c_str()); + + std::string sourceDir = cmSystemTools::CollapseFullPath(src_dir); + std::string binaryDir = cmSystemTools::CollapseFullPath(bld_dir); + this->CTest->SetCTestConfiguration("SourceDirectory", sourceDir.c_str()); + this->CTest->SetCTestConfiguration("BuildDirectory", binaryDir.c_str()); cmCTestLog(this->CTest, HANDLER_OUTPUT, "Run dashboard with model " << smodel << std::endl @@ -92,13 +109,62 @@ bool cmCTestStartCommand " Track: " << track << std::endl); } + // Log startup actions. + std::string startLogFile = binaryDir + "/Testing/Temporary/LastStart.log"; + cmGeneratedFileStream ofs(startLogFile.c_str()); + if(!ofs) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Cannot create log file: LastStart.log" << std::endl); + return false; + } + + // Make sure the source directory exists. + if(!this->InitialCheckout(ofs, sourceDir)) + { + return false; + } + if(!cmSystemTools::FileIsDirectory(sourceDir.c_str())) + { + cmOStringStream e; + e << "given source path\n" + << " " << sourceDir << "\n" + << "which is not an existing directory. " + << "Set CTEST_CHECKOUT_COMMAND to a command line to create it."; + this->SetError(e.str().c_str()); + return false; + } + this->Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", "OFF"); this->CTest->SetSuppressUpdatingCTestConfiguration(true); int model = this->CTest->GetTestModelFromString(smodel); this->CTest->SetTestModel(model); this->CTest->SetProduceXML(true); - return this->CTest->InitializeFromCommand(this, true); + return this->CTest->InitializeFromCommand(this); } - +//---------------------------------------------------------------------------- +bool cmCTestStartCommand::InitialCheckout( + std::ostream& ofs, std::string const& sourceDir) +{ + // Use the user-provided command to create the source tree. + const char* initialCheckoutCommand + = this->Makefile->GetDefinition("CTEST_CHECKOUT_COMMAND"); + if(!initialCheckoutCommand) + { + initialCheckoutCommand = + this->Makefile->GetDefinition("CTEST_CVS_CHECKOUT"); + } + if(initialCheckoutCommand) + { + // Use a generic VC object to run and log the command. + cmCTestVC vc(this->CTest, ofs); + vc.SetSourceDirectory(sourceDir.c_str()); + if(!vc.InitialCheckout(initialCheckoutCommand)) + { + return false; + } + } + return true; +} diff --git a/Source/CTest/cmCTestStartCommand.h b/Source/CTest/cmCTestStartCommand.h index 84f7631..afbc77b 100644 --- a/Source/CTest/cmCTestStartCommand.h +++ b/Source/CTest/cmCTestStartCommand.h @@ -23,7 +23,7 @@ class cmCTestStartCommand : public cmCTestCommand { public: - cmCTestStartCommand() {} + cmCTestStartCommand(); /** * This is a virtual constructor for the command. @@ -33,6 +33,7 @@ public: cmCTestStartCommand* ni = new cmCTestStartCommand; ni->CTest = this->CTest; ni->CTestScriptHandler = this->CTestScriptHandler; + ni->CreateNewTag = this->CreateNewTag; return ni; } @@ -44,6 +45,14 @@ public: cmExecutionStatus &status); /** + * Will this invocation of ctest_start create a new TAG file? + */ + bool ShouldCreateNewTag() + { + return this->CreateNewTag; + } + + /** * The name of the command as specified in CMakeList.txt. */ virtual const char* GetName() { return "ctest_start";} @@ -62,16 +71,21 @@ public: virtual const char* GetFullDocumentation() { return - " ctest_start(Model [TRACK <track>] [source [binary]])\n" + " ctest_start(Model [TRACK <track>] [APPEND] [source [binary]])\n" "Starts the testing for a given model. The command should be called " "after the binary directory is initialized. If the 'source' and " "'binary' directory are not specified, it reads the " "CTEST_SOURCE_DIRECTORY and CTEST_BINARY_DIRECTORY. If the track is " - "specified, the submissions will go to the specified track."; + "specified, the submissions will go to the specified track. " + "If APPEND is used, the existing TAG is used rather than " + "creating a new one based on the current time stamp."; } cmTypeMacro(cmCTestStartCommand, cmCTestCommand); +private: + bool InitialCheckout(std::ostream& ofs, std::string const& sourceDir); + bool CreateNewTag; }; diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index cbef1f1..7b4f38b 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -72,6 +72,8 @@ void cmCTestSubmitHandler::Initialize() this->SubmitPart[p] = true; } this->CDash = false; + this->HasWarnings = false; + this->HasErrors = false; this->Superclass::Initialize(); this->HTTPProxy = ""; this->HTTPProxyType = 0; @@ -309,7 +311,12 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, } } } - + if(this->CTest->ShouldUseHTTP10()) + { + curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); + } + // enable HTTP ERROR parsing + curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); /* enable uploading */ curl_easy_setopt(curl, CURLOPT_UPLOAD, 1); @@ -409,6 +416,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, cmCTestLog(this->CTest, DEBUG, "CURL output: [" << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" << std::endl); + this->ParseResponse(chunk); } if ( chunkDebug.size() > 0 ) { @@ -455,6 +463,36 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, } //---------------------------------------------------------------------------- +void cmCTestSubmitHandler +::ParseResponse(cmCTestSubmitHandlerVectorOfChar chunk) +{ + std::string output = ""; + + for(cmCTestSubmitHandlerVectorOfChar::iterator i = chunk.begin(); + i != chunk.end(); ++i) + { + output += *i; + } + output = cmSystemTools::UpperCase(output); + + if(output.find("WARNING") != std::string::npos) + { + this->HasWarnings = true; + } + if(output.find("ERROR") != std::string::npos) + { + this->HasErrors = true; + } + + if(this->HasWarnings || this->HasErrors) + { + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Server Response:\n" << + cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "\n"); + } + +} + +//---------------------------------------------------------------------------- bool cmCTestSubmitHandler::TriggerUsingHTTP( const std::set<cmStdString>& files, const cmStdString& remoteprefix, @@ -1149,9 +1187,20 @@ int cmCTestSubmitHandler::ProcessHandler() return -1; } } - cmCTestLog(this->CTest, HANDLER_OUTPUT, " Submission successful" - << std::endl); - ofs << " Submission successful" << std::endl; + if(this->HasErrors) + { + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Errors occurred during " + "submission." << std::endl); + ofs << " Errors occurred during submission. " << std::endl; + } + else + { + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Submission successful" << + (this->HasWarnings ? ", with warnings." : "") << std::endl); + ofs << " Submission successful" << + (this->HasWarnings ? ", with warnings." : "") << std::endl; + } + return 0; } else if ( dropMethod == "xmlrpc" ) diff --git a/Source/CTest/cmCTestSubmitHandler.h b/Source/CTest/cmCTestSubmitHandler.h index d93f94d..8b011ea 100644 --- a/Source/CTest/cmCTestSubmitHandler.h +++ b/Source/CTest/cmCTestSubmitHandler.h @@ -75,6 +75,8 @@ private: const cmStdString& remoteprefix, const cmStdString& url); + void ParseResponse(std::vector<char>); + std::string GetSubmitResultsPrefix(); cmStdString HTTPProxy; @@ -85,6 +87,8 @@ private: std::ostream* LogFile; bool SubmitPart[cmCTest::PartCount]; bool CDash; + bool HasWarnings; + bool HasErrors; cmCTest::SetOfStrings Files; }; diff --git a/Source/CTest/cmCTestTestCommand.cxx b/Source/CTest/cmCTestTestCommand.cxx index a719b09..b0adf22 100644 --- a/Source/CTest/cmCTestTestCommand.cxx +++ b/Source/CTest/cmCTestTestCommand.cxx @@ -24,6 +24,7 @@ cmCTestTestCommand::cmCTestTestCommand() this->Arguments[ctt_EXCLUDE_LABEL] = "EXCLUDE_LABEL"; this->Arguments[ctt_INCLUDE_LABEL] = "INCLUDE_LABEL"; this->Arguments[ctt_PARALLEL_LEVEL] = "PARALLEL_LEVEL"; + this->Arguments[ctt_SCHEDULE_RANDOM] = "SCHEDULE_RANDOM"; this->Arguments[ctt_LAST] = 0; this->Last = ctt_LAST; } @@ -32,6 +33,7 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler() { const char* ctestTimeout = this->Makefile->GetDefinition("CTEST_TEST_TIMEOUT"); + double timeout = this->CTest->GetTimeOut(); if ( ctestTimeout ) { @@ -91,6 +93,11 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler() handler->SetOption("ParallelLevel", this->Values[ctt_PARALLEL_LEVEL]); } + if(this->Values[ctt_SCHEDULE_RANDOM]) + { + handler->SetOption("ScheduleRandom", + this->Values[ctt_SCHEDULE_RANDOM]); + } return handler; } @@ -98,4 +105,3 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeActualHandler() { return this->CTest->GetInitializedHandler("test"); } - diff --git a/Source/CTest/cmCTestTestCommand.h b/Source/CTest/cmCTestTestCommand.h index 73ce913..12314df 100644 --- a/Source/CTest/cmCTestTestCommand.h +++ b/Source/CTest/cmCTestTestCommand.h @@ -61,7 +61,8 @@ public: " [INCLUDE include regex] [RETURN_VALUE res] \n" " [EXCLUDE_LABEL exclude regex] \n" " [INCLUDE_LABEL label regex] \n" - " [PARALLEL_LEVEL level]) \n" + " [PARALLEL_LEVEL level] \n" + " [SCHEDULE_RANDOM on]) \n" "Tests the given build directory and stores results in Test.xml. The " "second argument is a variable that will hold value. Optionally, " "you can specify the starting test number START, the ending test number " @@ -70,7 +71,9 @@ public: "to not run EXCLUDE. EXCLUDE_LABEL and INCLUDE_LABEL are regular " "expression for test to be included or excluded by the test " "property LABEL. PARALLEL_LEVEL should be set to a positive number " - "representing the number of tests to be run in parallel." + "representing the number of tests to be run in parallel. " + "SCHEDULE_RANDOM will launch tests in a random order, and is " + "typically used to detect implicit test dependencies." "\n" CTEST_COMMAND_APPEND_OPTION_DOCS; } @@ -92,6 +95,7 @@ protected: ctt_EXCLUDE_LABEL, ctt_INCLUDE_LABEL, ctt_PARALLEL_LEVEL, + ctt_SCHEDULE_RANDOM, ctt_LAST }; }; diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 2491d19..78f2c30 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -500,11 +500,16 @@ int cmCTestTestHandler::ProcessHandler() { // Update internal data structure from generic one this->SetTestsToRunInformation(this->GetOption("TestsToRunInformation")); - this->SetUseUnion(cmSystemTools::IsOn(this->GetOption("UseUnion"))); + this->SetUseUnion(cmSystemTools::IsOn(this->GetOption("UseUnion"))); + if(cmSystemTools::IsOn(this->GetOption("ScheduleRandom"))) + { + this->CTest->SetScheduleType("Random"); + } if(this->GetOption("ParallelLevel")) { this->CTest->SetParallelLevel(atoi(this->GetOption("ParallelLevel"))); } + const char* val; val = this->GetOption("LabelRegularExpression"); if ( val ) @@ -684,13 +689,12 @@ void cmCTestTestHandler::PrintLabelSummary() } } } - it = this->TestList.begin(); ri = this->TestResults.begin(); // fill maps - for(; it != this->TestList.end(); ++it, ++ri) + for(; ri != this->TestResults.end(); ++ri) { - cmCTestTestProperties& p = *it; - cmCTestTestResult &result = *ri; + cmCTestTestResult &result = *ri; + cmCTestTestProperties& p = *result.Properties; if(p.Labels.size() != 0) { for(std::vector<std::string>::iterator l = p.Labels.begin(); @@ -1030,12 +1034,28 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed, cmCTestMultiProcessHandler::TestMap tests; cmCTestMultiProcessHandler::PropertiesMap properties; + bool randomSchedule = this->CTest->GetScheduleType() == "Random"; + if(randomSchedule) + { + srand((unsigned)time(0)); + } + for (ListOfTests::iterator it = this->TestList.begin(); it != this->TestList.end(); ++it) { cmCTestTestProperties& p = *it; cmCTestMultiProcessHandler::TestSet depends; + if(randomSchedule) + { + p.Cost = rand(); + } + + if(p.Timeout == 0 && this->CTest->GetGlobalTimeout() != 0) + { + p.Timeout = this->CTest->GetGlobalTimeout(); + } + if(p.Depends.size()) { for(std::vector<std::string>::iterator i = p.Depends.begin(); @@ -1166,12 +1186,17 @@ void cmCTestTestHandler::GenerateDartOutput(std::ostream& os) } os << "\t\t\t<Measurement>\n" - << "\t\t\t\t<Value>"; + << "\t\t\t\t<Value" + << (result->CompressOutput ? + " encoding=\"base64\" compression=\"gzip\">" + : ">"); os << cmXMLSafe(result->Output); os << "</Value>\n" << "\t\t\t</Measurement>\n" << "\t\t</Results>\n"; + + this->AttachFiles(os, result); this->WriteTestResultFooter(os, result); } @@ -1234,6 +1259,73 @@ void cmCTestTestHandler::WriteTestResultFooter(std::ostream& os, } //---------------------------------------------------------------------- +void cmCTestTestHandler::AttachFiles(std::ostream& os, + cmCTestTestResult* result) +{ + if(result->Status != cmCTestTestHandler::COMPLETED + && result->Properties->AttachOnFail.size()) + { + result->Properties->AttachedFiles.insert( + result->Properties->AttachedFiles.end(), + result->Properties->AttachOnFail.begin(), + result->Properties->AttachOnFail.end()); + } + for(std::vector<std::string>::const_iterator file = + result->Properties->AttachedFiles.begin(); + file != result->Properties->AttachedFiles.end(); ++file) + { + std::string base64 = this->EncodeFile(*file); + std::string fname = cmSystemTools::GetFilenameName(*file); + os << "\t\t<NamedMeasurement name=\"Attached File\" encoding=\"base64\" " + "compression=\"tar/gzip\" filename=\"" << fname << "\" type=\"file\">" + "\n\t\t\t<Value>\n\t\t\t" + << base64 + << "\n\t\t\t</Value>\n\t\t</NamedMeasurement>\n"; + } +} + +//---------------------------------------------------------------------- +std::string cmCTestTestHandler::EncodeFile(std::string file) +{ + std::string tarFile = file + "_temp.tar.gz"; + std::vector<cmStdString> files; + files.push_back(file); + + if(!cmSystemTools::CreateTar(tarFile.c_str(), files, true, false)) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, "Error creating tar while " + "attaching file: " << file << std::endl); + return ""; + } + long len = cmSystemTools::FileLength(tarFile.c_str()); + std::ifstream ifs(tarFile.c_str(), std::ios::in +#ifdef _WIN32 + | std::ios::binary +#endif + ); + unsigned char *file_buffer = new unsigned char [ len + 1 ]; + ifs.read(reinterpret_cast<char*>(file_buffer), len); + ifs.close(); + cmSystemTools::RemoveFile(tarFile.c_str()); + + unsigned char *encoded_buffer + = new unsigned char [ static_cast<int>(len * 1.5 + 5) ]; + + unsigned long rlen + = cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1); + + std::string base64 = ""; + for(unsigned long i = 0; i < rlen; i++) + { + base64 += encoded_buffer[i]; + } + delete [] file_buffer; + delete [] encoded_buffer; + + return base64; +} + +//---------------------------------------------------------------------- int cmCTestTestHandler::ExecuteCommands(std::vector<cmStdString>& vec) { std::vector<cmStdString>::iterator it; @@ -1274,7 +1366,7 @@ void cmCTestTestHandler std::vector<std::string> &attemptedConfigs, std::string filepath, std::string &filename) -{ +{ std::string tempPath; if (filepath.size() && @@ -1985,6 +2077,28 @@ bool cmCTestTestHandler::SetTestsProperties( { rtit->WillFail = cmSystemTools::IsOn(val.c_str()); } + if ( key == "ATTACHED_FILES" ) + { + std::vector<std::string> lval; + cmSystemTools::ExpandListArgument(val.c_str(), lval); + + for(std::vector<std::string>::iterator f = lval.begin(); + f != lval.end(); ++f) + { + rtit->AttachedFiles.push_back(*f); + } + } + if ( key == "ATTACHED_FILES_ON_FAIL" ) + { + std::vector<std::string> lval; + cmSystemTools::ExpandListArgument(val.c_str(), lval); + + for(std::vector<std::string>::iterator f = lval.begin(); + f != lval.end(); ++f) + { + rtit->AttachOnFail.push_back(*f); + } + } if ( key == "TIMEOUT" ) { rtit->Timeout = atof(val.c_str()); @@ -1993,6 +2107,17 @@ bool cmCTestTestHandler::SetTestsProperties( { rtit->Cost = static_cast<float>(atof(val.c_str())); } + if ( key == "REQUIRED_FILES" ) + { + std::vector<std::string> lval; + cmSystemTools::ExpandListArgument(val.c_str(), lval); + + for(std::vector<std::string>::iterator f = lval.begin(); + f != lval.end(); ++f) + { + rtit->RequiredFiles.push_back(*f); + } + } if ( key == "RUN_SERIAL" ) { rtit->RunSerial = cmSystemTools::IsOn(val.c_str()); @@ -2088,6 +2213,7 @@ bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args) { const std::string& testname = args[0]; cmCTestLog(this->CTest, DEBUG, "Add test: " << args[0] << std::endl); + if (this->UseExcludeRegExpFlag && this->UseExcludeRegExpFirst && this->ExcludeTestsRegularExpression.find(testname.c_str())) diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index ceb5020..1513410 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -84,7 +84,10 @@ public: cmStdString Name; cmStdString Directory; std::vector<std::string> Args; + std::vector<std::string> RequiredFiles; std::vector<std::string> Depends; + std::vector<std::string> AttachedFiles; + std::vector<std::string> AttachOnFail; std::vector<std::pair<cmsys::RegularExpression, std::string> > ErrorRegularExpressions; std::vector<std::pair<cmsys::RegularExpression, @@ -111,6 +114,7 @@ public: double ExecutionTime; int ReturnValue; int Status; + bool CompressOutput; std::string CompletionStatus; std::string Output; std::string RegressionImages; @@ -142,6 +146,10 @@ protected: void WriteTestResultHeader(std::ostream& os, cmCTestTestResult* result); void WriteTestResultFooter(std::ostream& os, cmCTestTestResult* result); + // Write attached test files into the xml + void AttachFiles(std::ostream& os, cmCTestTestResult* result); + // Helper function to encode attached test files + std::string EncodeFile(std::string file); //! Clean test output to specified length bool CleanTestOutput(std::string& output, size_t length); diff --git a/Source/CTest/cmCTestUpdateCommand.cxx b/Source/CTest/cmCTestUpdateCommand.cxx index 6dbe815..571745d 100644 --- a/Source/CTest/cmCTestUpdateCommand.cxx +++ b/Source/CTest/cmCTestUpdateCommand.cxx @@ -56,14 +56,6 @@ cmCTestGenericHandler* cmCTestUpdateCommand::InitializeHandler() this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, "HGUpdateOptions", "CTEST_HG_UPDATE_OPTIONS"); - const char* initialCheckoutCommand - = this->Makefile->GetDefinition("CTEST_CHECKOUT_COMMAND"); - if ( !initialCheckoutCommand ) - { - initialCheckoutCommand = - this->Makefile->GetDefinition("CTEST_CVS_CHECKOUT"); - } - cmCTestGenericHandler* handler = this->CTest->GetInitializedHandler("update"); if ( !handler ) @@ -78,24 +70,6 @@ cmCTestGenericHandler* cmCTestUpdateCommand::InitializeHandler() return 0; } handler->SetOption("SourceDirectory", source_dir.c_str()); - if ( initialCheckoutCommand ) - { - handler->SetOption("InitialCheckout", initialCheckoutCommand); - } - if ( (!cmSystemTools::FileExists(source_dir.c_str()) || - !cmSystemTools::FileIsDirectory(source_dir.c_str())) - && !initialCheckoutCommand ) - { - cmOStringStream str; - str << "cannot find source directory: " << source_dir.c_str() << "."; - if ( !cmSystemTools::FileExists(source_dir.c_str()) ) - { - str << " Looks like it is not checked out yet. Please specify " - "CTEST_CHECKOUT_COMMAND."; - } - this->SetError(str.str().c_str()); - return 0; - } return handler; } diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx index cd2f661..f87b37c 100644 --- a/Source/CTest/cmCTestUpdateHandler.cxx +++ b/Source/CTest/cmCTestUpdateHandler.cxx @@ -201,15 +201,6 @@ int cmCTestUpdateHandler::ProcessHandler() this->StartLogFile("Update", ofs); } - cmCTestLog(this->CTest, HANDLER_OUTPUT, - "Updating the repository" << std::endl); - - // Make sure the source directory exists. - if(!this->InitialCheckout(ofs)) - { - return -1; - } - cmCTestLog(this->CTest, HANDLER_OUTPUT, " Updating the repository: " << sourceDirectory << std::endl); @@ -267,7 +258,8 @@ int cmCTestUpdateHandler::ProcessHandler() << this->CTest->GetTestModelString() << "</BuildStamp>" << std::endl; os << "\t<StartDateTime>" << start_time << "</StartDateTime>\n" << "\t<StartTime>" << start_time_time << "</StartTime>\n" - << "\t<UpdateCommand>" << cmXMLSafe(vc->GetUpdateCommandLine()) + << "\t<UpdateCommand>" + << cmXMLSafe(vc->GetUpdateCommandLine()).Quotes(false) << "</UpdateCommand>\n" << "\t<UpdateType>" << cmXMLSafe( cmCTestUpdateHandlerUpdateToString(this->UpdateType)) @@ -323,32 +315,6 @@ int cmCTestUpdateHandler::ProcessHandler() } //---------------------------------------------------------------------- -bool cmCTestUpdateHandler::InitialCheckout(std::ostream& ofs) -{ - // Use the user-provided command to create the source tree. - if(const char* command = this->GetOption("InitialCheckout")) - { - // Use a generic VC object to run and log the command. - cmCTestVC vc(this->CTest, ofs); - vc.SetSourceDirectory(this->GetOption("SourceDirectory")); - if(!vc.InitialCheckout(command)) - { - return false; - } - - if(!this->CTest->InitializeFromCommand(this->Command)) - { - cmCTestLog(this->CTest, HANDLER_OUTPUT, - " Fatal Error in initialize: " - << std::endl); - cmSystemTools::SetFatalErrorOccured(); - return false; - } - } - return true; -} - -//---------------------------------------------------------------------- int cmCTestUpdateHandler::DetectVCS(const char* dir) { std::string sourceDirectory = dir; diff --git a/Source/CTest/cmCTestUpdateHandler.h b/Source/CTest/cmCTestUpdateHandler.h index 78426ea..55ec974 100644 --- a/Source/CTest/cmCTestUpdateHandler.h +++ b/Source/CTest/cmCTestUpdateHandler.h @@ -65,7 +65,6 @@ private: std::string UpdateCommand; int UpdateType; - bool InitialCheckout(std::ostream& ofs); int DetectVCS(const char* dir); bool SelectVCS(); }; diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx index 1895066..b028cc0 100644 --- a/Source/CTest/cmProcess.cxx +++ b/Source/CTest/cmProcess.cxx @@ -79,7 +79,10 @@ bool cmProcess::Buffer::GetLine(std::string& line) // Extract the range first..last as a line. const char* text = &*this->begin() + this->First; size_type length = this->Last - this->First; - length -= (length && text[length-1] == '\r')? 1:0; + while(length && text[length-1] == '\r') + { + length --; + } line.assign(text, length); // Start a new range for the next line. diff --git a/Source/QtDialog/CMake.desktop b/Source/QtDialog/CMake.desktop index d1d4fb2..645eb76 100644 --- a/Source/QtDialog/CMake.desktop +++ b/Source/QtDialog/CMake.desktop @@ -3,7 +3,7 @@ Version=1.0 Name=CMake Comment=Cross-platform buildsystem Exec=cmake-gui %f -Icon=CMakeSetup.png +Icon=CMakeSetup32.png Terminal=false X-MultipleArgs=false Type=Application diff --git a/Source/QtDialog/CMakeIngestOSXBundleLibraries.cmake b/Source/QtDialog/CMakeIngestOSXBundleLibraries.cmake index 37e4701..9f5cf00 100644 --- a/Source/QtDialog/CMakeIngestOSXBundleLibraries.cmake +++ b/Source/QtDialog/CMakeIngestOSXBundleLibraries.cmake @@ -210,7 +210,7 @@ macro(copy_library_into_bundle clib_bundle clib_libsrc clib_dstlibs clib_fixups) get_filename_component(fwdirname "${fw_srcdir}" NAME) string(REGEX REPLACE "^(.*)\\.framework$" "\\1" fwname "${fwdirname}") string(REGEX REPLACE "^.*/${fwname}\\.framework/(.*)$" "\\1" fwlibname "${clib_libsrc}") - set(fw_dstdir "${clib_bundle}/Contents/Frameworks/${fwdirname}") + set(fw_dstdir "${clib_bundle}/Contents/Frameworks") # message("") # message("fwdirname: '${fwdirname}'") @@ -240,17 +240,25 @@ macro(copy_library_into_bundle clib_bundle clib_libsrc clib_dstlibs clib_fixups) "${fw_src}" "${fw_dstdir}/${fwlibname}" ) + get_filename_component(fw_src_path "${fw_src}" PATH) + message("Checking ${fw_src_path}/Resources") + if(EXISTS "${fw_src_path}/Resources") + message("Copy: ${CMAKE_COMMAND} -E copy_directory \"${fw_src_path}/Resources/\" \"${fw_dstdir}/Resources/\"") + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory + "${fw_src_path}/Resources/" "${fw_dstdir}/${fwdirname}/Resources/") + endif(EXISTS "${fw_src_path}/Resources") + execute_process(COMMAND install_name_tool - -id "@executable_path/../Frameworks/${fwdirname}/${fwlibname}" - "${clib_bundle}/Contents/Frameworks/${fwdirname}/${fwlibname}" + -id "@executable_path/../Frameworks/${fwlibname}" + "${clib_bundle}/Contents/Frameworks/${fwlibname}" ) set(${clib_dstlibs} ${${clib_dstlibs}} - "${clib_bundle}/Contents/Frameworks/${fwdirname}/${fwlibname}" + "${clib_bundle}/Contents/Frameworks/${fwlibname}" ) set(${clib_fixups} ${${clib_fixups}} "-change" "${clib_libsrc}" - "@executable_path/../Frameworks/${fwdirname}/${fwlibname}" + "@executable_path/../Frameworks/${fwlibname}" ) else("${clib_libsrc}" MATCHES ".framework/.*/.*/.*") if("${clib_libsrc}" MATCHES "/") diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index 4e7e357..405c952 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -97,7 +97,7 @@ ELSE(NOT QT4_FOUND) # install a desktop file so CMake appears in the application start menu # with an icon INSTALL(FILES CMake.desktop DESTINATION share/applications ) - INSTALL(FILES CMakeSetup.png DESTINATION share/pixmaps ) + INSTALL(FILES CMakeSetup32.png DESTINATION share/pixmaps ) INSTALL(FILES cmakecache.xml DESTINATION share/mime/packages ) ENDIF(UNIX) diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index f19a36d..e613a78 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -134,7 +134,10 @@ int main(int argc, char** argv) // app setup app.setApplicationName("CMakeSetup"); app.setOrganizationName("Kitware"); - app.setWindowIcon(QIcon(":/Icons/CMakeSetup.png")); + QIcon appIcon; + appIcon.addFile(":/Icons/CMakeSetup32.png"); + appIcon.addFile(":/Icons/CMakeSetup128.png"); + app.setWindowIcon(appIcon); CMakeSetupDialog dialog; dialog.show(); diff --git a/Source/QtDialog/CMakeSetup.qrc b/Source/QtDialog/CMakeSetup.qrc index 5ceb1df..eaac192 100644 --- a/Source/QtDialog/CMakeSetup.qrc +++ b/Source/QtDialog/CMakeSetup.qrc @@ -1,6 +1,7 @@ <RCC> <qresource prefix="/Icons" > - <file>CMakeSetup.png</file> + <file>CMakeSetup128.png</file> + <file>CMakeSetup32.png</file> <file>Delete16.png</file> <file>Plus16.png</file> </qresource> diff --git a/Source/QtDialog/CMakeSetup128.png b/Source/QtDialog/CMakeSetup128.png Binary files differnew file mode 100644 index 0000000..12f1d9a --- /dev/null +++ b/Source/QtDialog/CMakeSetup128.png diff --git a/Source/QtDialog/CMakeSetup.png b/Source/QtDialog/CMakeSetup32.png Binary files differindex 7bbcee4..7bbcee4 100644 --- a/Source/QtDialog/CMakeSetup.png +++ b/Source/QtDialog/CMakeSetup32.png diff --git a/Source/QtDialog/QMacInstallDialog.cxx b/Source/QtDialog/QMacInstallDialog.cxx index fbeb10e..3aa509d 100644 --- a/Source/QtDialog/QMacInstallDialog.cxx +++ b/Source/QtDialog/QMacInstallDialog.cxx @@ -33,8 +33,8 @@ QMacInstallDialog::~QMacInstallDialog() void QMacInstallDialog::DoInstall() { QDir installDir(this->Internals->InstallPrefix->text()); - std::string installTo = installDir.path().toStdString(); - if(!cmSystemTools::FileExists(installTo.c_str())) + QString installTo = installDir.path(); + if(!cmSystemTools::FileExists(installTo.toAscii().data())) { QString message = tr("Build install does not exist, " "should I create it?") @@ -47,7 +47,7 @@ void QMacInstallDialog::DoInstall() QMessageBox::Yes | QMessageBox::No); if(btn == QMessageBox::Yes) { - cmSystemTools::MakeDirectory(installTo.c_str()); + cmSystemTools::MakeDirectory(installTo.toAscii().data()); } } QDir cmExecDir(QApplication::applicationDirPath()); @@ -56,24 +56,24 @@ void QMacInstallDialog::DoInstall() for (int i = 0; i < list.size(); ++i) { QFileInfo fileInfo = list.at(i); - std::string filename = fileInfo.fileName().toStdString(); + QString filename = fileInfo.fileName(); if(filename.size() && filename[0] == '.') { continue; } - std::string file = fileInfo.absoluteFilePath().toStdString(); - std::string newName = installTo; + QString file = fileInfo.absoluteFilePath(); + QString newName = installTo; newName += "/"; newName += filename; // Remove the old files - if(cmSystemTools::FileExists(newName.c_str())) + if(cmSystemTools::FileExists(newName.toAscii().data())) { - std::cout << "rm [" << newName << "]\n"; - if(!cmSystemTools::RemoveFile(newName.c_str())) + std::cout << "rm [" << newName.toAscii().data() << "]\n"; + if(!cmSystemTools::RemoveFile(newName.toAscii().data())) { QString message = tr("Failed to remove file " "installation may be incomplete: "); - message += newName.c_str(); + message += newName.toAscii().data(); QString title = tr("Error Removing file"); QMessageBox::StandardButton btn = QMessageBox::critical(this, title, message, @@ -84,14 +84,14 @@ void QMacInstallDialog::DoInstall() } } } - std::cout << "ln -s [" << file << "] ["; - std::cout << newName << "]\n"; - if(!cmSystemTools::CreateSymlink(file.c_str(), - newName.c_str())) + std::cout << "ln -s [" << file.toAscii().data() << "] ["; + std::cout << newName.toAscii().data() << "]\n"; + if(!cmSystemTools::CreateSymlink(file.toAscii().data(), + newName.toAscii().data())) { QString message = tr("Failed create symlink " "installation may be incomplete: "); - message += newName.c_str(); + message += newName.toAscii().data(); QString title = tr("Error Creating Symlink"); QMessageBox::StandardButton btn = QMessageBox::critical(this, title, message, diff --git a/Source/cmAddTestCommand.h b/Source/cmAddTestCommand.h index 2070fd3..79fb481 100644 --- a/Source/cmAddTestCommand.h +++ b/Source/cmAddTestCommand.h @@ -56,7 +56,7 @@ public: virtual const char* GetFullDocumentation() { return - " add_test(testname Exename arg1 arg2 ...)\n" + " add_test(testname Exename arg1 arg2 ... )\n" "If the ENABLE_TESTING command has been run, this command adds a " "test target to the current directory. If ENABLE_TESTING has not " "been run, this command does nothing. " @@ -65,7 +65,7 @@ public: "built by this project or an arbitrary executable on the " "system (like tclsh). The test will be run with the current working " "directory set to the CMakeList.txt files corresponding directory " - "in the binary tree." + "in the binary tree.\n" "\n" " add_test(NAME <name> [CONFIGURATIONS [Debug|Release|...]]\n" " COMMAND <command> [arg1 [arg2 ...]])\n" diff --git a/Source/cmBuildCommand.cxx b/Source/cmBuildCommand.cxx index b9ce561..3722ab6 100644 --- a/Source/cmBuildCommand.cxx +++ b/Source/cmBuildCommand.cxx @@ -14,25 +14,135 @@ #include "cmLocalGenerator.h" #include "cmGlobalGenerator.h" -// cmBuildCommand +//---------------------------------------------------------------------- bool cmBuildCommand ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) { + // Support the legacy signature of the command: + // + if(2 == args.size()) + { + return this->TwoArgsSignature(args); + } + + return this->MainSignature(args); +} + +//---------------------------------------------------------------------- +bool cmBuildCommand +::MainSignature(std::vector<std::string> const& args) +{ + if(args.size() < 1) + { + this->SetError("requires at least one argument naming a CMake variable"); + return false; + } + + // The cmake variable in which to store the result. + const char* variable = args[0].c_str(); + + // Parse remaining arguments. + const char* configuration = 0; + const char* project_name = 0; + const char* target = 0; + enum Doing { DoingNone, DoingConfiguration, DoingProjectName, DoingTarget }; + Doing doing = DoingNone; + for(unsigned int i=1; i < args.size(); ++i) + { + if(args[i] == "CONFIGURATION") + { + doing = DoingConfiguration; + } + else if(args[i] == "PROJECT_NAME") + { + doing = DoingProjectName; + } + else if(args[i] == "TARGET") + { + doing = DoingTarget; + } + else if(doing == DoingConfiguration) + { + doing = DoingNone; + configuration = args[i].c_str(); + } + else if(doing == DoingProjectName) + { + doing = DoingNone; + project_name = args[i].c_str(); + } + else if(doing == DoingTarget) + { + doing = DoingNone; + target = args[i].c_str(); + } + else + { + cmOStringStream e; + e << "unknown argument \"" << args[i] << "\""; + this->SetError(e.str().c_str()); + return false; + } + } + + const char* makeprogram + = this->Makefile->GetDefinition("CMAKE_MAKE_PROGRAM"); + + // If null/empty CONFIGURATION argument, GenerateBuildCommand uses 'Debug' + // in the currently implemented multi-configuration global generators... + // so we put this code here to end up with the same default configuration + // as the original 2-arg build_command signature: + // + if(!configuration || !*configuration) + { + configuration = getenv("CMAKE_CONFIG_TYPE"); + } + if(!configuration || !*configuration) + { + configuration = "Release"; + } + + // If null/empty PROJECT_NAME argument, use the Makefile's project name: + // + if(!project_name || !*project_name) + { + project_name = this->Makefile->GetProjectName(); + } + + // If null/empty TARGET argument, GenerateBuildCommand omits any mention + // of a target name on the build command line... + // + std::string makecommand = this->Makefile->GetLocalGenerator() + ->GetGlobalGenerator()->GenerateBuildCommand + (makeprogram, project_name, 0, target, configuration, true, false); + + this->Makefile->AddDefinition(variable, makecommand.c_str()); + + return true; +} + +//---------------------------------------------------------------------- +bool cmBuildCommand +::TwoArgsSignature(std::vector<std::string> const& args) +{ if(args.size() < 2 ) { - this->SetError("called with incorrect number of arguments"); + this->SetError("called with less than two arguments"); return false; } + const char* define = args[0].c_str(); const char* cacheValue = this->Makefile->GetDefinition(define); std::string makeprogram = args[1]; + std::string configType = "Release"; const char* cfg = getenv("CMAKE_CONFIG_TYPE"); if ( cfg ) { configType = cfg; } + std::string makecommand = this->Makefile->GetLocalGenerator() ->GetGlobalGenerator()->GenerateBuildCommand (makeprogram.c_str(), this->Makefile->GetProjectName(), 0, @@ -49,4 +159,3 @@ bool cmBuildCommand cmCacheManager::STRING); return true; } - diff --git a/Source/cmBuildCommand.h b/Source/cmBuildCommand.h index 9d494e7..703ff88 100644 --- a/Source/cmBuildCommand.h +++ b/Source/cmBuildCommand.h @@ -38,35 +38,60 @@ public: cmExecutionStatus &status); /** + * The primary command signature with optional, KEYWORD-based args. + */ + virtual bool MainSignature(std::vector<std::string> const& args); + + /** + * Legacy "exactly 2 args required" signature. + */ + virtual bool TwoArgsSignature(std::vector<std::string> const& args); + + /** * The name of the command as specified in CMakeList.txt. */ virtual const char* GetName() {return "build_command";} - + /** * Succinct documentation. */ virtual const char* GetTerseDocumentation() { - return "Get the command line that will build this project."; + return "Get the command line to build this project."; } - + /** * More documentation. */ virtual const char* GetFullDocumentation() { return - " build_command(<variable> <makecommand>)\n" - "Sets the given <variable> to a string containing the command that " - "will build this project from the root of the build tree using the " - "build tool given by <makecommand>. <makecommand> should be msdev, " - "nmake, make or one of the end user build tools. " - "This is useful for configuring testing systems."; + " build_command(<variable>\n" + " [CONFIGURATION <config>]\n" + " [PROJECT_NAME <projname>]\n" + " [TARGET <target>])\n" + "Sets the given <variable> to a string containing the command line " + "for building one configuration of a target in a project using the " + "build tool appropriate for the current CMAKE_GENERATOR.\n" + "If CONFIGURATION is omitted, CMake chooses a reasonable default " + "value for multi-configuration generators. CONFIGURATION is " + "ignored for single-configuration generators.\n" + "If PROJECT_NAME is omitted, the resulting command line will build " + "the top level PROJECT in the current build tree.\n" + "If TARGET is omitted, the resulting command line will build " + "everything, effectively using build target 'all' or 'ALL_BUILD'.\n" + " build_command(<cachevariable> <makecommand>)\n" + "This second signature is deprecated, but still available for " + "backwards compatibility. Use the first signature instead.\n" + "Sets the given <cachevariable> to a string containing the command " + "to build this project from the root of the build tree using " + "the build tool given by <makecommand>. <makecommand> should be " + "the full path to msdev, devenv, nmake, make or one of the end " + "user build tools." + ; } - + cmTypeMacro(cmBuildCommand, cmCommand); }; - - #endif diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 6d21ab5..1b578a9 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -23,6 +23,7 @@ #include "cmXMLSafe.h" #include "cmVersionMacros.h" #include "cmCTestCommand.h" +#include "cmCTestStartCommand.h" #include "cmCTestBuildHandler.h" #include "cmCTestBuildAndTestHandler.h" @@ -153,6 +154,78 @@ std::string cmCTest::CurrentTime() return cmXMLSafe(cmCTest::CleanString(current_time)).str(); } +#ifdef CMAKE_BUILD_WITH_CMAKE +//---------------------------------------------------------------------------- +static size_t +HTTPResponseCallback(void *ptr, size_t size, size_t nmemb, void *data) +{ + register int realsize = (int)(size * nmemb); + + std::string *response + = static_cast<std::string*>(data); + const char* chPtr = static_cast<char*>(ptr); + *response += chPtr; + + return realsize; +} + +//---------------------------------------------------------------------------- +int cmCTest::HTTPRequest(std::string url, HTTPMethod method, + std::string& response, + std::string fields, + std::string putFile, int timeout) +{ + CURL* curl; + FILE* file; + ::curl_global_init(CURL_GLOBAL_ALL); + curl = ::curl_easy_init(); + + //set request options based on method + switch(method) + { + case cmCTest::HTTP_POST: + ::curl_easy_setopt(curl, CURLOPT_POST, 1); + ::curl_easy_setopt(curl, CURLOPT_POSTFIELDS, fields.c_str()); + break; + case cmCTest::HTTP_PUT: + if(!cmSystemTools::FileExists(putFile.c_str())) + { + response = "Error: File "; + response += putFile + " does not exist.\n"; + return -1; + } + ::curl_easy_setopt(curl, CURLOPT_PUT, 1); + file = ::fopen(putFile.c_str(), "rb"); + ::curl_easy_setopt(curl, CURLOPT_INFILE, file); + //fall through to append GET fields + case cmCTest::HTTP_GET: + if(fields.size()) + { + url += "?" + fields; + } + break; + default: + break; + } + + ::curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); + ::curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout); + ::curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); + + //set response options + ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, HTTPResponseCallback); + ::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&response); + ::curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); + + CURLcode res = ::curl_easy_perform(curl); + + ::curl_easy_cleanup(curl); + ::curl_global_cleanup(); + + return static_cast<int>(res); +} +#endif + //---------------------------------------------------------------------- std::string cmCTest::MakeURLSafe(const std::string& str) { @@ -219,12 +292,17 @@ cmCTest::cmCTest() this->ProduceXML = false; this->ShowOnly = false; this->RunConfigurationScript = false; + this->UseHTTP10 = false; + this->CompressTestOutput = true; + this->ComputedCompressOutput = false; this->TestModel = cmCTest::EXPERIMENTAL; this->MaxTestNameWidth = 30; this->InteractiveDebugMode = true; this->TimeOut = 0; + this->GlobalTimeout = 0; this->CompressXMLFiles = false; this->CTestConfigFile = ""; + this->ScheduleType = ""; this->OutputLogFile = 0; this->OutputLogFileLastTag = -1; this->SuppressUpdatingCTestConfiguration = false; @@ -295,6 +373,40 @@ void cmCTest::SetParallelLevel(int level) } //---------------------------------------------------------------------------- +bool cmCTest::ShouldCompressTestOutput() +{ + if(!this->ComputedCompressOutput) + { + std::string cdashVersion = this->GetCDashVersion(); + //version >= 1.6? + bool cdashSupportsGzip = cmSystemTools::VersionCompare( + cmSystemTools::OP_GREATER, cdashVersion.c_str(), "1.6") || + cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL, + cdashVersion.c_str(), "1.6"); + this->CompressTestOutput &= cdashSupportsGzip; + this->ComputedCompressOutput = true; + } + return this->CompressTestOutput; +} + +//---------------------------------------------------------------------------- +std::string cmCTest::GetCDashVersion() +{ +#ifdef CMAKE_BUILD_WITH_CMAKE + //First query the server. If that fails, fall back to the local setting + std::string response; + std::string url = "http://"; + url += this->GetCTestConfiguration("DropSite") + "/CDash/api/getversion.php"; + + int res = cmCTest::HTTPRequest(url, cmCTest::HTTP_GET, response); + + return res ? this->GetCTestConfiguration("CDashVersion") : response; +#else + return this->GetCTestConfiguration("CDashVersion"); +#endif +} + +//---------------------------------------------------------------------------- cmCTest::Part cmCTest::GetPartFromName(const char* name) { // Look up by lower-case to make names case-insensitive. @@ -310,8 +422,7 @@ cmCTest::Part cmCTest::GetPartFromName(const char* name) } //---------------------------------------------------------------------- -int cmCTest::Initialize(const char* binary_dir, bool new_tag, - bool verbose_tag) +int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) { cmCTestLog(this, DEBUG, "Here: " << __LINE__ << std::endl); if(!this->InteractiveDebugMode) @@ -362,6 +473,8 @@ int cmCTest::Initialize(const char* binary_dir, bool new_tag, if ( this->ProduceXML ) { + // Verify "Testing" directory exists: + // std::string testingDir = this->BinaryDir + "/Testing"; if ( cmSystemTools::FileExists(testingDir.c_str()) ) { @@ -381,84 +494,114 @@ int cmCTest::Initialize(const char* binary_dir, bool new_tag, return 0; } } + + // Create new "TAG" file or read existing one: + // + bool createNewTag = true; + if (command) + { + createNewTag = command->ShouldCreateNewTag(); + } + std::string tagfile = testingDir + "/TAG"; std::ifstream tfin(tagfile.c_str()); std::string tag; - time_t tctime = time(0); - if ( this->TomorrowTag ) - { - tctime += ( 24 * 60 * 60 ); - } - struct tm *lctime = gmtime(&tctime); - if ( tfin && cmSystemTools::GetLineFromStream(tfin, tag) ) - { - int year = 0; - int mon = 0; - int day = 0; - int hour = 0; - int min = 0; - sscanf(tag.c_str(), "%04d%02d%02d-%02d%02d", - &year, &mon, &day, &hour, &min); - if ( year != lctime->tm_year + 1900 || - mon != lctime->tm_mon+1 || - day != lctime->tm_mday ) + + if (createNewTag) + { + time_t tctime = time(0); + if ( this->TomorrowTag ) { - tag = ""; + tctime += ( 24 * 60 * 60 ); } - std::string tagmode; - if ( cmSystemTools::GetLineFromStream(tfin, tagmode) ) + struct tm *lctime = gmtime(&tctime); + if ( tfin && cmSystemTools::GetLineFromStream(tfin, tag) ) { - if (tagmode.size() > 4 && !this->Parts[PartStart]) + int year = 0; + int mon = 0; + int day = 0; + int hour = 0; + int min = 0; + sscanf(tag.c_str(), "%04d%02d%02d-%02d%02d", + &year, &mon, &day, &hour, &min); + if ( year != lctime->tm_year + 1900 || + mon != lctime->tm_mon+1 || + day != lctime->tm_mday ) { - this->TestModel = cmCTest::GetTestModelFromString(tagmode.c_str()); + tag = ""; } + std::string tagmode; + if ( cmSystemTools::GetLineFromStream(tfin, tagmode) ) + { + if (tagmode.size() > 4 && !this->Parts[PartStart]) + { + this->TestModel = cmCTest::GetTestModelFromString(tagmode.c_str()); + } + } + tfin.close(); } - tfin.close(); - } - if (tag.size() == 0 || new_tag || this->Parts[PartStart]) - { - cmCTestLog(this, DEBUG, "TestModel: " << this->GetTestModelString() - << std::endl); - cmCTestLog(this, DEBUG, "TestModel: " << this->TestModel << std::endl); - if ( this->TestModel == cmCTest::NIGHTLY ) + if (tag.size() == 0 || (0 != command) || this->Parts[PartStart]) { - lctime = this->GetNightlyTime( - this->GetCTestConfiguration("NightlyStartTime"), this->TomorrowTag); + cmCTestLog(this, DEBUG, "TestModel: " << this->GetTestModelString() + << std::endl); + cmCTestLog(this, DEBUG, "TestModel: " << this->TestModel << std::endl); + if ( this->TestModel == cmCTest::NIGHTLY ) + { + lctime = this->GetNightlyTime( + this->GetCTestConfiguration("NightlyStartTime"), + this->TomorrowTag); + } + char datestring[100]; + sprintf(datestring, "%04d%02d%02d-%02d%02d", + lctime->tm_year + 1900, + lctime->tm_mon+1, + lctime->tm_mday, + lctime->tm_hour, + lctime->tm_min); + tag = datestring; + std::ofstream ofs(tagfile.c_str()); + if ( ofs ) + { + ofs << tag << std::endl; + ofs << this->GetTestModelString() << std::endl; + } + ofs.close(); + if ( 0 == command ) + { + cmCTestLog(this, OUTPUT, "Create new tag: " << tag << " - " + << this->GetTestModelString() << std::endl); + } } - char datestring[100]; - sprintf(datestring, "%04d%02d%02d-%02d%02d", - lctime->tm_year + 1900, - lctime->tm_mon+1, - lctime->tm_mday, - lctime->tm_hour, - lctime->tm_min); - tag = datestring; - std::ofstream ofs(tagfile.c_str()); - if ( ofs ) + } + else + { + if ( tfin ) { - ofs << tag << std::endl; - ofs << this->GetTestModelString() << std::endl; + cmSystemTools::GetLineFromStream(tfin, tag); + tfin.close(); } - ofs.close(); - if ( verbose_tag ) + + if ( tag.empty() ) { - cmCTestLog(this, OUTPUT, "Create new tag: " << tag << " - " - << this->GetTestModelString() << std::endl); + cmCTestLog(this, ERROR_MESSAGE, + "Cannot read existing TAG file in " << testingDir + << std::endl); + return 0; } + + cmCTestLog(this, OUTPUT, " Use existing tag: " << tag << " - " + << this->GetTestModelString() << std::endl); } + this->CurrentTag = tag; } + return 1; } //---------------------------------------------------------------------- -bool cmCTest::InitializeFromCommand(cmCTestCommand* command, bool first) +bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command) { - if ( !first && !this->CurrentTag.empty() ) - { - return true; - } - std::string src_dir = this->GetCTestConfiguration("SourceDirectory").c_str(); std::string bld_dir = this->GetCTestConfiguration("BuildDirectory").c_str(); @@ -486,17 +629,11 @@ bool cmCTest::InitializeFromCommand(cmCTestCommand* command, bool first) return false; } } - else if ( !first ) + else { cmCTestLog(this, WARNING, "Cannot locate CTest configuration: " << fname.c_str() << std::endl); } - else - { - cmCTestLog(this, HANDLER_OUTPUT, " Cannot locate CTest configuration: " - << fname.c_str() << std::endl - << " Delay the initialization of CTest" << std::endl); - } this->SetCTestConfigurationFromCMakeVariable(mf, "NightlyStartTime", "CTEST_NIGHTLY_START_TIME"); @@ -516,12 +653,8 @@ bool cmCTest::InitializeFromCommand(cmCTestCommand* command, bool first) } } - if ( !this->Initialize(bld_dir.c_str(), true, false) ) + if ( !this->Initialize(bld_dir.c_str(), command) ) { - if ( this->GetCTestConfiguration("NightlyStartTime").empty() && first) - { - return true; - } return false; } cmCTestLog(this, OUTPUT, " Use " << this->GetTestModelString() @@ -1716,6 +1849,23 @@ void cmCTest::HandleCommandLineArguments(size_t &i, int plevel = atoi(arg.substr(2).c_str()); this->SetParallelLevel(plevel); } + + if(this->CheckArgument(arg, "--no-compress-output")) + { + this->CompressTestOutput = false; + } + + if(this->CheckArgument(arg, "--http1.0")) + { + this->UseHTTP10 = true; + } + + if(this->CheckArgument(arg, "--timeout") && i < args.size() - 1) + { + i++; + double timeout = (double)atof(args[i].c_str()); + this->GlobalTimeout = timeout; + } if(this->CheckArgument(arg, "-C", "--build-config") && i < args.size() - 1) @@ -2027,6 +2177,11 @@ int cmCTest::Run(std::vector<std::string> &args, std::string* output) cmakeAndTest = true; } + if(this->CheckArgument(arg, "--schedule-random")) + { + this->ScheduleType = "Random"; + } + // pass the argument to all the handlers as well, but i may no longer be // set to what it was originally so I'm not sure this is working as // intended @@ -2107,8 +2262,8 @@ int cmCTest::Run(std::vector<std::string> &args, std::string* output) it->second->SetVerbose(this->Verbose); it->second->SetSubmitIndex(this->SubmitIndex); } - if ( !this->Initialize( - cmSystemTools::GetCurrentWorkingDirectory().c_str()) ) + std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); + if(!this->Initialize(cwd.c_str(), 0)) { res = 12; cmCTestLog(this, ERROR_MESSAGE, "Problem initializing the dashboard." @@ -2769,4 +2924,3 @@ void cmCTest::OutputTestErrors(std::vector<char> const &process_output) } cmCTestLog(this, HANDLER_OUTPUT, test_outputs << std::endl << std::flush); } - diff --git a/Source/cmCTest.h b/Source/cmCTest.h index f401c55..8621b10 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -23,6 +23,7 @@ class cmCTestGenericHandler; class cmGeneratedFileStream; class cmCTestCommand; class cmCTestScriptHandler; +class cmCTestStartCommand; #define cmCTestLog(ctSelf, logType, msg) \ do { \ @@ -79,6 +80,21 @@ public: bool Enabled; std::string Name; }; +#ifdef CMAKE_BUILD_WITH_CMAKE + enum HTTPMethod { + HTTP_GET, + HTTP_POST, + HTTP_PUT + }; + + /** + * Perform an HTTP request. + */ + static int HTTPRequest(std::string url, HTTPMethod method, + std::string& response, + std::string fields = "", + std::string putFile = "", int timeout = 0); +#endif /** Get a testing part id from its string name. Returns PartCount if the string does not name a valid part. */ @@ -93,9 +109,7 @@ public: /** * Initialize and finalize testing */ - int Initialize(const char* binary_dir, bool new_tag = false, - bool verbose_tag = true); - bool InitializeFromCommand(cmCTestCommand* command, bool first = false); + bool InitializeFromCommand(cmCTestStartCommand* command); void Finalize(); /** @@ -130,6 +144,9 @@ public: std::string const& GetConfigType(); double GetTimeOut() { return this->TimeOut; } void SetTimeOut(double t) { this->TimeOut = t; } + + double GetGlobalTimeout() { return this->GlobalTimeout; } + // how many test to run at the same time int GetParallelLevel() { return this->ParallelLevel; } void SetParallelLevel(int); @@ -191,6 +208,15 @@ public: ///! Should we only show what we would do? bool GetShowOnly(); + bool ShouldUseHTTP10() { return this->UseHTTP10; } + + bool ShouldCompressTestOutput(); + + std::string GetCDashVersion(); + + //Used for parallel ctest job scheduling + std::string GetScheduleType() { return this->ScheduleType; } + void SetScheduleType(std::string type) { this->ScheduleType = type; } ///! The max output width int GetMaxTestNameWidth() const; @@ -374,11 +400,12 @@ public: bool GetLabelSummary() { return this->LabelSummary;} private: std::string ConfigType; + std::string ScheduleType; bool Verbose; bool ExtraVerbose; bool ProduceXML; bool LabelSummary; - + bool UseHTTP10; bool Failover; bool BatchJobs; @@ -386,6 +413,9 @@ private: bool RunConfigurationScript; + //flag for lazy getter (optimization) + bool ComputedCompressOutput; + int GenerateNotesFile(const char* files); // these are helper classes @@ -416,6 +446,8 @@ private: double TimeOut; + double GlobalTimeout; + int MaxTestNameWidth; int ParallelLevel; @@ -436,12 +468,23 @@ private: bool CompressXMLFiles; + bool CompressTestOutput; + void InitStreams(); std::ostream* StreamOut; std::ostream* StreamErr; void BlockTestErrorDiagnostics(); + /** + * Initialize a dashboard run in the given build tree. The "command" + * argument is non-NULL when running from a command-driven (ctest_start) + * dashboard script, and NULL when running from the CTest command + * line. Note that a declarative dashboard script does not actually + * call this method because it sets CTEST_COMMAND to drive a build + * through the ctest command line. + */ + int Initialize(const char* binary_dir, cmCTestStartCommand* command); //! parse the option after -D and convert it into the appropriate steps bool AddTestsForDashboardType(std::string &targ); diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index e1a1076..2aa6236 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -22,10 +22,6 @@ #include <cmsys/RegularExpression.hxx> -#if defined(_WIN32) || defined(__CYGWIN__) -# include <windows.h> -#endif // _WIN32 - const char* cmCacheManagerTypes[] = { "BOOL", "PATH", diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index 961d291..9e4726c 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -442,9 +442,11 @@ cmDependsFortran for(std::set<cmStdString>::const_iterator i = info.Includes.begin(); i != info.Includes.end(); ++i) { - makeDepends << obj << ": " - << cmSystemTools::ConvertToOutputPath(i->c_str()).c_str() - << std::endl; + makeDepends << obj << ": " << + this->LocalGenerator->Convert(i->c_str(), + cmLocalGenerator::HOME_OUTPUT, + cmLocalGenerator::MAKEFILE) + << std::endl; internalDepends << " " << i->c_str() << std::endl; } makeDepends << std::endl; @@ -491,7 +493,7 @@ cmDependsFortran std::string stampFile = this->LocalGenerator->Convert(required->second.c_str(), cmLocalGenerator::HOME_OUTPUT, - cmLocalGenerator::SHELL); + cmLocalGenerator::MAKEFILE); makeDepends << obj << ": " << stampFile << "\n"; } else @@ -504,7 +506,7 @@ cmDependsFortran module = this->LocalGenerator->Convert(module.c_str(), cmLocalGenerator::HOME_OUTPUT, - cmLocalGenerator::SHELL); + cmLocalGenerator::MAKEFILE); makeDepends << obj << ": " << module << "\n"; } } diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index b42f2a9..091d688 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -201,6 +201,14 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "\"Visual Studio 6\", etc.)",false, "Variables that Provide Information"); cm->DefineProperty + ("CMAKE_EXTRA_GENERATOR", cmProperty::VARIABLE, + "The extra generator used to build the project.", + "When using the Eclipse, CodeBlocks or KDevelop generators, CMake " + "generates Makefiles (CMAKE_GENERATOR) and additionally project files " + "for the respective IDE. This IDE project file generator is stored in " + "CMAKE_EXTRA_GENERATOR (e.g. \"Eclipse CDT4\").",false, + "Variables that Provide Information"); + cm->DefineProperty ("CMAKE_HOME_DIRECTORY", cmProperty::VARIABLE, "Path to top of source tree.", "This is the path to the top level of the source tree.",false, @@ -1372,10 +1380,6 @@ void cmDocumentVariables::DefineVariables(cmake* cm) cmProperty::VARIABLE,0,0); cm->DefineProperty("CMAKE_SHARED_MODULE_SUFFIX_<LANG>", cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_SHARED_MODULE_RUNTIME_<LANG>_FLAG", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_SHARED_MODULE_RUNTIME_<LANG>_FLAG_SEP", - cmProperty::VARIABLE,0,0); cm->DefineProperty("CMAKE_STATIC_LIBRARY_PREFIX_<LANG>", cmProperty::VARIABLE,0,0); cm->DefineProperty("CMAKE_STATIC_LIBRARY_SUFFIX_<LANG>", diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index 93eb199..fc2fb14 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -267,6 +267,8 @@ cmDocumentation::cmDocumentation() this->VariableSections.push_back("Variables That Describe the System"); this->VariableSections.push_back("Variables that Control the Build"); this->VariableSections.push_back("Variables for Languages"); + + this->ShowGenerators = true; } //---------------------------------------------------------------------------- @@ -1279,7 +1281,10 @@ bool cmDocumentation::PrintDocumentationUsage(std::ostream& os) this->ClearSections(); this->AddSectionToPrint("Usage"); this->AddSectionToPrint("Options"); - this->AddSectionToPrint("Generators"); + if(this->ShowGenerators) + { + this->AddSectionToPrint("Generators"); + } this->Print(os); return true; } diff --git a/Source/cmDocumentation.h b/Source/cmDocumentation.h index 3a4a506..34b83b1 100644 --- a/Source/cmDocumentation.h +++ b/Source/cmDocumentation.h @@ -57,6 +57,8 @@ public: /** Print help of the given type. */ bool PrintDocumentation(Type ht, std::ostream& os, const char* docname=0); + + void SetShowGenerators(bool showGen) { this->ShowGenerators = showGen; } /** Set the program name for standard document generation. */ void SetName(const char* name); @@ -159,6 +161,8 @@ private: const char* GetDefaultDocName(Type ht) const; bool IsOption(const char* arg) const; + bool ShowGenerators; + std::string NameString; std::string DocName; std::map<std::string,cmDocumentationSection*> AllSections; diff --git a/Source/cmDumpDocumentation.cxx b/Source/cmDumpDocumentation.cxx deleted file mode 100644 index 877ed13..0000000 --- a/Source/cmDumpDocumentation.cxx +++ /dev/null @@ -1,150 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - - 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. -============================================================================*/ -// Program extracts documentation describing commands from -// the CMake system. -// -#include "cmake.h" - -#include "cmDocumentation.h" -#include "cmVersion.h" - -//---------------------------------------------------------------------------- -static const char *cmDocumentationName[][3] = -{ - {0, - " DumpDocumentation - Dump documentation for CMake.", 0}, - {0,0,0} -}; - -//---------------------------------------------------------------------------- -static const char *cmDocumentationUsage[][3] = -{ - {0, - " DumpDocumentation [filename]", 0}, - {0,0,0} -}; - -//---------------------------------------------------------------------------- -static const char *cmDocumentationDescription[][3] = -{ - {0, - "The \"DumpDocumentation\" executable is only available in the build " - "tree. It is used for testing, coverage, and documentation.", 0}, - CMAKE_STANDARD_INTRODUCTION, - {0,0,0} -}; - -//---------------------------------------------------------------------------- -static const char *cmDocumentationOptions[][3] = -{ - {"--all-for-coverage", - "Dump all documentation to stdout. For testing.", 0}, - {0,0,0} -}; - - -int DumpHTML(const char* outname) -{ - std::ofstream fout(outname); - if(!fout) - { - std::cerr << "failed to open output file: " << outname << "\n"; - cmSystemTools::ReportLastSystemError(""); - return -1; - } - - cmake cmi; - cmDocumentation doc; - std::vector<cmDocumentationEntry> commands; - cmi.GetCommandDocumentation(commands); - cmOStringStream str; - str << "Documentation for Commands of CMake " - << cmVersion::GetCMakeVersion(); - doc.SetSection(str.str().c_str(), commands); - doc.Print(cmDocumentation::HTMLForm, fout); - - return 0; -} - -int DumpForCoverageToStream(std::ostream& out) -{ - cmake cmi; - cmDocumentation doc; - std::vector<cmDocumentationEntry> commands; - std::vector<cmDocumentationEntry> generators; - cmi.GetCommandDocumentation(commands); - cmi.GetGeneratorDocumentation(generators); - doc.SetSection("Name",cmDocumentationName); - doc.SetSection("Usage",cmDocumentationUsage); - doc.SetSection("Description",cmDocumentationDescription); - doc.SetSection("options",cmDocumentationOptions); - doc.SetSection("Commands",commands); - doc.SetSection("Generators",generators); - doc.PrintDocumentation(cmDocumentation::Usage, out); - doc.PrintDocumentation(cmDocumentation::Full, out); - return 0; -} - -int DumpForCoverage(const char* outname) -{ - if(outname) - { - std::ofstream fout(outname); - if(!fout) - { - std::cerr << "failed to open output file: " << outname << "\n"; - cmSystemTools::ReportLastSystemError(""); - return -1; - } - return DumpForCoverageToStream(fout); - } - else - { - return DumpForCoverageToStream(std::cout); - } -} - -int main(int ac, char** av) -{ - cmSystemTools::EnableMSVCDebugHook(); - cmSystemTools::FindExecutableDirectory(av[0]); - const char* outname = "cmake.html"; - bool coverage = false; - if(ac > 1) - { - if(strcmp(av[1], "--all-for-coverage") == 0) - { - coverage = true; - if(ac > 2) - { - outname = av[2]; - } - else - { - outname = 0; - } - } - else - { - outname = av[1]; - } - } - - if(coverage) - { - return DumpForCoverage(outname); - } - else - { - return DumpHTML(outname); - } -} diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 4bedea3..5cbef8c 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -545,7 +545,6 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, { std::string makefileName = makefile->GetStartOutputDirectory(); makefileName += "/Makefile"; - makefileName = cmSystemTools::ConvertToOutputPath(makefileName.c_str()); fout<<" <Target title=\"" << targetName << "\">\n"; if (target!=0) @@ -696,22 +695,27 @@ std::string cmExtraCodeBlocksGenerator::BuildMakeCommand( std::string command = make; if (strcmp(this->GlobalGenerator->GetName(), "NMake Makefiles")==0) { + std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile); command += " /NOLOGO /f ""; - command += makefile; + command += makefileName; command += "" "; command += target; } else if (strcmp(this->GlobalGenerator->GetName(), "MinGW Makefiles")==0) { - command += " -f "; - command += makefile; - command += " "; + // no escaping of spaces in this case, see + // http://public.kitware.com/Bug/view.php?id=10014 + std::string makefileName = makefile; + command += " -f ""; + command += makefileName; + command += "" "; command += target; } else { + std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile); command += " -f ""; - command += makefile; + command += makefileName; command += "" "; command += target; } diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 0a5101f..43c8b21 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -124,10 +124,72 @@ void cmExtraEclipseCDT4Generator::CreateSourceProjectFile() const ; } + +//---------------------------------------------------------------------------- +void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout, + const char* envVar, cmMakefile* mf) +{ + // get the variables from the environment and from the cache and then + // figure out which one to use: + + const char* envVarValue = getenv(envVar); + + std::string cacheEntryName = "CMAKE_ECLIPSE_ENVVAR_"; + cacheEntryName += envVar; + const char* cacheValue = mf->GetCacheManager()->GetCacheValue( + cacheEntryName.c_str()); + + // now we have both, decide which one to use + std::string valueToUse; + if (envVarValue==0 && cacheValue==0) + { + // nothing known, do nothing + valueToUse = ""; + } + else if (envVarValue!=0 && cacheValue==0) + { + // The variable is in the env, but not in the cache. Use it and put it + // in the cache + valueToUse = envVarValue; + mf->AddCacheDefinition(cacheEntryName.c_str(), valueToUse.c_str(), + cacheEntryName.c_str(), cmCacheManager::STRING, + true); + mf->GetCacheManager()->SaveCache(mf->GetHomeOutputDirectory()); + } + else if (envVarValue==0 && cacheValue!=0) + { + // It is already in the cache, but not in the env, so use it from the cache + valueToUse = cacheValue; + } + else + { + // It is both in the cache and in the env. + // Use the version from the env. except if the value from the env is + // completely contained in the value from the cache (for the case that we + // now have a PATH without MSVC dirs in the env. but had the full PATH with + // all MSVC dirs during the cmake run which stored the var in the cache: + valueToUse = cacheValue; + if (valueToUse.find(envVarValue) == std::string::npos) + { + valueToUse = envVarValue; + mf->AddCacheDefinition(cacheEntryName.c_str(), valueToUse.c_str(), + cacheEntryName.c_str(), cmCacheManager::STRING, + true); + mf->GetCacheManager()->SaveCache(mf->GetHomeOutputDirectory()); + } + } + + if (!valueToUse.empty()) + { + fout << envVar << "=" << valueToUse << "|"; + } +} + + //---------------------------------------------------------------------------- void cmExtraEclipseCDT4Generator::CreateProjectFile() { - const cmMakefile* mf + cmMakefile* mf = this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile(); const std::string filename = this->HomeOutputDirectory + "/.project"; @@ -138,6 +200,12 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() return; } + std::string compilerId = mf->GetSafeDefinition("CMAKE_C_COMPILER_ID"); + if (compilerId.empty()) // no C compiler, try the C++ compiler: + { + compilerId = mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID"); + } + fout << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" "<projectDescription>\n" @@ -214,29 +282,24 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() fout << "\t\t\t\t<dictionary>\n" "\t\t\t\t\t<key>org.eclipse.cdt.make.core.environment</key>\n" - "\t\t\t\t\t<value>VERBOSE=1|</value>\n" // enforce VERBOSE Makefile output - "\t\t\t\t\t<value>" + "\t\t\t\t\t<value>VERBOSE=1|CMAKE_NO_VERBOSE=1|" //verbose Makefile output ; // set vsvars32.bat environment available at CMake time, // but not necessarily when eclipse is open - if (make.find("nmake") != std::string::npos) + if (compilerId == "MSVC") { - if (getenv("PATH")) - { - fout << "PATH=" << getenv("PATH") << "|"; - } - if (getenv("INCLUDE")) - { - fout << "INCLUDE=" << getenv("INCLUDE") << "|"; - } - if (getenv("LIB")) - { - fout << "LIB=" << getenv("LIB") << "|"; - } - if (getenv("LIBPATH")) - { - fout << "LIBPATH=" << getenv("LIBPATH") << "|"; - } + AddEnvVar(fout, "PATH", mf); + AddEnvVar(fout, "INCLUDE", mf); + AddEnvVar(fout, "LIB", mf); + AddEnvVar(fout, "LIBPATH", mf); + AddEnvVar(fout, "INCLUDE", mf); + } + else if (compilerId == "Intel") + { + // if the env.var is set, use this one and put it in the cache + // if the env.var is not set, but the value is in the cache, + // use it from the cache: + AddEnvVar(fout, "INTEL_LICENSE_FILE", mf); } fout << "</value>\n" @@ -285,10 +348,14 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() "\t\t\t\t\t<key>org.eclipse.cdt.core.errorOutputParser</key>\n" "\t\t\t\t\t<value>" ; - if (this->GetToolChainType(*mf) == EclipseToolchainOther) + if (compilerId == "MSVC") { fout << "org.eclipse.cdt.core.VCErrorParser;"; } + else if (compilerId == "Intel") + { + fout << "org.eclipse.cdt.core.ICCErrorParser;"; + } fout << "org.eclipse.cdt.core.MakeErrorParser;" "org.eclipse.cdt.core.GCCErrorParser;" @@ -418,20 +485,25 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const "<extensions>\n" ; // TODO: refactor this out... - switch (this->GetToolChainType(*mf)) - { - case EclipseToolchainLinux : - fout << "<extension id=\"org.eclipse.cdt.core.ELF\"" - " point=\"org.eclipse.cdt.core.BinaryParser\"/>\n" - ; - fout << "<extension id=\"org.eclipse.cdt.core.GNU_ELF\"" - " point=\"org.eclipse.cdt.core.BinaryParser\">\n" - "<attribute key=\"addr2line\" value=\"addr2line\"/>\n" - "<attribute key=\"c++filt\" value=\"c++filt\"/>\n" - "</extension>\n" - ; - break; - case EclipseToolchainCygwin : + std::string executableFormat = mf->GetSafeDefinition( + "CMAKE_EXECUTABLE_FORMAT"); + if (executableFormat == "ELF") + { + fout << "<extension id=\"org.eclipse.cdt.core.ELF\"" + " point=\"org.eclipse.cdt.core.BinaryParser\"/>\n" + ; + fout << "<extension id=\"org.eclipse.cdt.core.GNU_ELF\"" + " point=\"org.eclipse.cdt.core.BinaryParser\">\n" + "<attribute key=\"addr2line\" value=\"addr2line\"/>\n" + "<attribute key=\"c++filt\" value=\"c++filt\"/>\n" + "</extension>\n" + ; + } + else + { + std::string systemName = mf->GetSafeDefinition("CMAKE_SYSTEM_NAME"); + if (systemName == "CYGWIN") + { fout << "<extension id=\"org.eclipse.cdt.core.Cygwin_PE\"" " point=\"org.eclipse.cdt.core.BinaryParser\">\n" "<attribute key=\"addr2line\" value=\"addr2line\"/>\n" @@ -440,36 +512,28 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const "<attribute key=\"nm\" value=\"nm\"/>\n" "</extension>\n" ; - break; - case EclipseToolchainMinGW : + } + else if (systemName == "Windows") + { fout << "<extension id=\"org.eclipse.cdt.core.PE\"" " point=\"org.eclipse.cdt.core.BinaryParser\"/>\n" ; - break; - case EclipseToolchainSolaris : - fout << "<extension id=\"org.eclipse.cdt.core.ELF\"" - " point=\"org.eclipse.cdt.core.BinaryParser\"/>\n" - ; - break; - case EclipseToolchainMacOSX : + } + else if (systemName == "Darwin") + { fout << "<extension id=\"org.eclipse.cdt.core.MachO\"" " point=\"org.eclipse.cdt.core.BinaryParser\">\n" "<attribute key=\"c++filt\" value=\"c++filt\"/>\n" "</extension>\n" ; - break; - case EclipseToolchainOther : - fout << "<extension id=\"org.eclipse.cdt.core.PE\"" - " point=\"org.eclipse.cdt.core.BinaryParser\"/>\n" - ; - fout << "<extension id=\"org.eclipse.cdt.core.ELF\"" - " point=\"org.eclipse.cdt.core.BinaryParser\"/>\n" - ; - break; - default : + } + else + { // *** Should never get here *** fout << "<error_toolchain_type/>\n"; - } + } + } + fout << "</extensions>\n" "</storageModule>\n" ; @@ -828,40 +892,6 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const } //---------------------------------------------------------------------------- -cmExtraEclipseCDT4Generator::EclipseToolchainType -cmExtraEclipseCDT4Generator::GetToolChainType(const cmMakefile& makefile) -{ - if (makefile.IsSet("UNIX")) - { - if (makefile.IsSet("CYGWIN")) - { - return EclipseToolchainCygwin; - } - if (makefile.IsSet("APPLE" )) - { - return EclipseToolchainMacOSX; - } - // *** how do I determine if it is Solaris ??? - return EclipseToolchainLinux; - } - else if (makefile.IsSet("WIN32")) - { - if (makefile.IsSet("MINGW")) - { - return EclipseToolchainMinGW; - } - if (makefile.IsSet("MSYS" )) - { - return EclipseToolchainMinGW; - } - return EclipseToolchainOther; - } - else - { - return EclipseToolchainOther; - } -} - std::string cmExtraEclipseCDT4Generator::GetEclipsePath(const std::string& path) { diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h index 08adc07..143b7fa 100644 --- a/Source/cmExtraEclipseCDT4Generator.h +++ b/Source/cmExtraEclipseCDT4Generator.h @@ -56,18 +56,6 @@ private: // create .cproject file void CreateCProjectFile() const; - // Eclipse supported toolchain types - enum EclipseToolchainType - { - EclipseToolchainOther, - EclipseToolchainLinux, - EclipseToolchainCygwin, - EclipseToolchainMinGW, - EclipseToolchainSolaris, - EclipseToolchainMacOSX - }; - static EclipseToolchainType GetToolChainType(const cmMakefile& makefile); - // If built with cygwin cmake, convert posix to windows path. static std::string GetEclipsePath(const std::string& path); @@ -112,6 +100,9 @@ private: const std::vector<std::string>& includeDirs, std::set<std::string>& emittedDirs); + static void AddEnvVar(cmGeneratedFileStream& fout, const char* envVar, + cmMakefile* mf); + std::vector<std::string> SrcLinkedResources; std::vector<std::string> OutLinkedResources; std::string HomeDirectory; diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index bce4137..c2e90b6 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -189,9 +189,7 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args, #elif defined( __BORLANDC__ ) S_IRUSR | S_IWUSR #else - S_IRUSR | S_IWUSR | - S_IRGRP | - S_IROTH + 0666 #endif ; @@ -202,7 +200,7 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args, #if defined( _MSC_VER ) || defined( __MINGW32__ ) S_IREAD | S_IWRITE #else - S_IRUSR | S_IWUSR + 0666 #endif ); } diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 7dbbf6d..bd58f56 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -268,6 +268,7 @@ cmFindPackageCommand::cmFindPackageCommand() "2. Search paths specified in cmake-specific environment variables. " "These are intended to be set in the user's shell configuration. " "This can be skipped if NO_CMAKE_ENVIRONMENT_PATH is passed.\n" + " <package>_DIR\n" " CMAKE_PREFIX_PATH\n" " CMAKE_FRAMEWORK_PATH\n" " CMAKE_APPBUNDLE_PATH\n" diff --git a/Source/cmGetFilenameComponentCommand.cxx b/Source/cmGetFilenameComponentCommand.cxx index 31b8336..1a31d54 100644 --- a/Source/cmGetFilenameComponentCommand.cxx +++ b/Source/cmGetFilenameComponentCommand.cxx @@ -101,7 +101,7 @@ bool cmGetFilenameComponentCommand if(args[2] == "REALPATH") { // Resolve symlinks if possible - result = cmSystemTools::GetRealPath(filename.c_str()); + result = cmSystemTools::GetRealPath(result.c_str()); } } else diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 4734c50..1cbd423 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1761,7 +1761,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) ostr.str().c_str(), &cpackCommandLines, depends, 0); } - std::string cmd; + std::string cmd = cmakeCommand; cpackCommandLines.erase(cpackCommandLines.begin(), cpackCommandLines.end()); singleLine.erase(singleLine.begin(), singleLine.end()); @@ -1782,18 +1782,9 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) if(mf->GetDefinition("CMake_BINARY_DIR")) { // We are building CMake itself. We cannot use the original - // executable to install over itself. - cmd = mf->GetDefinition("EXECUTABLE_OUTPUT_PATH"); - if(cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.') - { - cmd += "/"; - cmd += cmakeCfgIntDir; - } - cmd += "/cmake"; - } - else - { - cmd = cmakeCommand; + // executable to install over itself. The generator will + // automatically convert this name to the build-time location. + cmd = "cmake"; } singleLine.push_back(cmd.c_str()); if ( cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.' ) diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index c9d0790..b7b4324 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -258,6 +258,10 @@ public: /** Supported systems creates a GUID for the given name */ virtual void CreateGUID(const char*) {} + /** Return true if the generated build tree may contain multiple builds. + i.e. "Can I build Debug and Release in the same tree?" */ + virtual bool IsMultiConfig() { return false; } + protected: typedef std::vector<cmLocalGenerator*> GeneratorVector; // for a project collect all its targets by following depend diff --git a/Source/cmGlobalJOMMakefileGenerator.cxx b/Source/cmGlobalJOMMakefileGenerator.cxx new file mode 100644 index 0000000..411e28b --- /dev/null +++ b/Source/cmGlobalJOMMakefileGenerator.cxx @@ -0,0 +1,69 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + 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. +============================================================================*/ +#include "cmGlobalJOMMakefileGenerator.h" +#include "cmLocalUnixMakefileGenerator3.h" +#include "cmMakefile.h" + +cmGlobalJOMMakefileGenerator::cmGlobalJOMMakefileGenerator() +{ + this->FindMakeProgramFile = "CMakeJOMFindMake.cmake"; + this->ForceUnixPaths = false; + this->ToolSupportsColor = true; + this->UseLinkScript = false; +} + +void cmGlobalJOMMakefileGenerator +::EnableLanguage(std::vector<std::string>const& l, + cmMakefile *mf, + bool optional) +{ + // pick a default + mf->AddDefinition("CMAKE_GENERATOR_CC", "cl"); + mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl"); + if(!(cmSystemTools::GetEnv("INCLUDE") && + cmSystemTools::GetEnv("LIB")) + ) + { + std::string message = "To use the JOM generator, cmake must be run " + "from a shell that can use the compiler cl from the command line. " + "This environment does not contain INCLUDE, LIB, or LIBPATH, and " + "these must be set for the cl compiler to work. "; + mf->IssueMessage(cmake::WARNING, + message); + } + + this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional); +} + +///! Create a local generator appropriate to this Global Generator +cmLocalGenerator *cmGlobalJOMMakefileGenerator::CreateLocalGenerator() +{ + cmLocalUnixMakefileGenerator3* lg = new cmLocalUnixMakefileGenerator3; + lg->SetDefineWindowsNULL(true); + lg->SetWindowsShell(true); + lg->SetMakeSilentFlag("/nologo"); + lg->SetGlobalGenerator(this); + lg->SetIgnoreLibPrefix(true); + lg->SetPassMakeflags(true); + lg->SetNMake(true); + lg->SetUnixCD(false); + return lg; +} + +//---------------------------------------------------------------------------- +void cmGlobalJOMMakefileGenerator +::GetDocumentation(cmDocumentationEntry& entry) const +{ + entry.Name = this->GetName(); + entry.Brief = "Generates JOM makefiles."; + entry.Full = ""; +} diff --git a/Source/cmGlobalJOMMakefileGenerator.h b/Source/cmGlobalJOMMakefileGenerator.h new file mode 100644 index 0000000..08be4b4 --- /dev/null +++ b/Source/cmGlobalJOMMakefileGenerator.h @@ -0,0 +1,49 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + 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. +============================================================================*/ +#ifndef cmGlobalJOMMakefileGenerator_h +#define cmGlobalJOMMakefileGenerator_h + +#include "cmGlobalUnixMakefileGenerator3.h" + +/** \class cmGlobalJOMMakefileGenerator + * \brief Write a JOM makefiles. + * + * cmGlobalJOMMakefileGenerator manages nmake build process for a tree + */ +class cmGlobalJOMMakefileGenerator : public cmGlobalUnixMakefileGenerator3 +{ +public: + cmGlobalJOMMakefileGenerator(); + static cmGlobalGenerator* New() { + return new cmGlobalJOMMakefileGenerator; } + ///! Get the name for the generator. + virtual const char* GetName() const { + return cmGlobalJOMMakefileGenerator::GetActualName();} + // use NMake Makefiles in the name so that scripts/tests that depend on the + // name NMake Makefiles will work + static const char* GetActualName() {return "NMake Makefiles JOM";} + + /** Get the documentation entry for this generator. */ + virtual void GetDocumentation(cmDocumentationEntry& entry) const; + + ///! Create a local generator appropriate to this Global Generator + virtual cmLocalGenerator *CreateLocalGenerator(); + + /** + * Try to determine system infomation such as shared library + * extension, pthreads, byte order etc. + */ + virtual void EnableLanguage(std::vector<std::string>const& languages, + cmMakefile *, bool optional); +}; + +#endif diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index 6ceec48..56b9e9c 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -475,6 +475,7 @@ void cmGlobalKdevelopGenerator " <environments>\n" " <default>\n" " <envvar value=\"1\" name=\"VERBOSE\" />\n" + " <envvar value=\"1\" name=\"CMAKE_NO_VERBOSE\" />\n" " </default>\n" " </environments>\n" " </make>\n"; diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index abe66a8..691502f 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -25,6 +25,8 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator() void cmGlobalVisualStudio10Generator::AddPlatformDefinitions(cmMakefile* mf) { mf->AddDefinition("MSVC10", "1"); + mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "X86"); + mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "X86"); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 9e4e474..219c36e 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -67,7 +67,7 @@ public: */ virtual std::string GetUserMacrosRegKeyBase(); virtual const char* GetCMakeCFGInitDirectory() - { return "$(ConfigurationName)";} + { return "$(Configuration)";} protected: virtual const char* GetIDEVersion() { return "10.0"; } }; diff --git a/Source/cmGlobalVisualStudio10Win64Generator.cxx b/Source/cmGlobalVisualStudio10Win64Generator.cxx index 0e821c7..1004fa9 100644 --- a/Source/cmGlobalVisualStudio10Win64Generator.cxx +++ b/Source/cmGlobalVisualStudio10Win64Generator.cxx @@ -29,9 +29,11 @@ void cmGlobalVisualStudio10Win64Generator } //---------------------------------------------------------------------------- -void cmGlobalVisualStudio10Win64Generator::EnableLanguage( - std::vector<std::string> const& lang, cmMakefile *mf, bool optional) +void cmGlobalVisualStudio10Win64Generator +::AddPlatformDefinitions(cmMakefile* mf) { + this->cmGlobalVisualStudio10Generator::AddPlatformDefinitions(mf); mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE"); - cmGlobalVisualStudio10Generator::EnableLanguage(lang, mf, optional); + mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "x64"); + mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "x64"); } diff --git a/Source/cmGlobalVisualStudio10Win64Generator.h b/Source/cmGlobalVisualStudio10Win64Generator.h index 51b68c0..98ba03c 100644 --- a/Source/cmGlobalVisualStudio10Win64Generator.h +++ b/Source/cmGlobalVisualStudio10Win64Generator.h @@ -30,7 +30,7 @@ public: /** Get the documentation entry for this generator. */ virtual void GetDocumentation(cmDocumentationEntry& entry) const; - virtual void EnableLanguage(std::vector<std::string>const& languages, - cmMakefile *, bool optional); + virtual void AddPlatformDefinitions(cmMakefile* mf); + }; #endif diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index 783db21..d053ca2 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -44,6 +44,8 @@ void cmGlobalVisualStudio6Generator mf->AddDefinition("CMAKE_GENERATOR_RC", "rc"); mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1"); mf->AddDefinition("CMAKE_GENERATOR_Fortran", "ifort"); + mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "X86"); + mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "X86"); mf->AddDefinition("MSVC60", "1"); this->GenerateConfigurations(mf); this->cmGlobalGenerator::EnableLanguage(lang, mf, optional); diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index c7014aa..d608aac 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -36,6 +36,7 @@ cmLocalGenerator *cmGlobalVisualStudio71Generator::CreateLocalGenerator() //---------------------------------------------------------------------------- void cmGlobalVisualStudio71Generator::AddPlatformDefinitions(cmMakefile* mf) { + this->cmGlobalVisualStudio7Generator::AddPlatformDefinitions(mf); mf->AddDefinition("MSVC71", "1"); } diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index ea9065e..9631e9a 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -31,7 +31,6 @@ void cmGlobalVisualStudio7Generator mf->AddDefinition("CMAKE_GENERATOR_RC", "rc"); mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1"); mf->AddDefinition("CMAKE_GENERATOR_FC", "ifort"); - this->AddPlatformDefinitions(mf); // Create list of configurations requested by user's cache, if any. @@ -59,6 +58,8 @@ void cmGlobalVisualStudio7Generator void cmGlobalVisualStudio7Generator::AddPlatformDefinitions(cmMakefile* mf) { mf->AddDefinition("MSVC70", "1"); + mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "X86"); + mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "X86"); } std::string cmGlobalVisualStudio7Generator diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 8aec865..e423174 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -55,6 +55,8 @@ void cmGlobalVisualStudio8Generator //---------------------------------------------------------------------------- void cmGlobalVisualStudio8Generator::AddPlatformDefinitions(cmMakefile* mf) { + mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "X86"); + mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "X86"); mf->AddDefinition("MSVC80", "1"); } diff --git a/Source/cmGlobalVisualStudio8Win64Generator.cxx b/Source/cmGlobalVisualStudio8Win64Generator.cxx index aa756d8..d5558bb 100644 --- a/Source/cmGlobalVisualStudio8Win64Generator.cxx +++ b/Source/cmGlobalVisualStudio8Win64Generator.cxx @@ -42,10 +42,12 @@ void cmGlobalVisualStudio8Win64Generator entry.Full = ""; } +//---------------------------------------------------------------------------- void cmGlobalVisualStudio8Win64Generator -::EnableLanguage(std::vector<std::string>const & lang, - cmMakefile *mf, bool optional) +::AddPlatformDefinitions(cmMakefile* mf) { + this->cmGlobalVisualStudio8Generator::AddPlatformDefinitions(mf); mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE"); - cmGlobalVisualStudio8Generator::EnableLanguage(lang, mf, optional); + mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "x64"); + mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "x64"); } diff --git a/Source/cmGlobalVisualStudio8Win64Generator.h b/Source/cmGlobalVisualStudio8Win64Generator.h index 2d41a36..44c237c 100644 --- a/Source/cmGlobalVisualStudio8Win64Generator.h +++ b/Source/cmGlobalVisualStudio8Win64Generator.h @@ -43,7 +43,6 @@ public: * Try to determine system infomation such as shared library * extension, pthreads, byte order etc. */ - virtual void EnableLanguage(std::vector<std::string>const& languages, - cmMakefile *, bool optional); + virtual void AddPlatformDefinitions(cmMakefile *); }; #endif diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx index 75fe900..f6ae705 100644 --- a/Source/cmGlobalVisualStudio9Generator.cxx +++ b/Source/cmGlobalVisualStudio9Generator.cxx @@ -25,6 +25,8 @@ cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator() //---------------------------------------------------------------------------- void cmGlobalVisualStudio9Generator::AddPlatformDefinitions(cmMakefile* mf) { + mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "X86"); + mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "X86"); mf->AddDefinition("MSVC90", "1"); } diff --git a/Source/cmGlobalVisualStudio9Win64Generator.cxx b/Source/cmGlobalVisualStudio9Win64Generator.cxx index 288480f..c5b9bab 100644 --- a/Source/cmGlobalVisualStudio9Win64Generator.cxx +++ b/Source/cmGlobalVisualStudio9Win64Generator.cxx @@ -39,10 +39,12 @@ void cmGlobalVisualStudio9Win64Generator entry.Full = ""; } +//---------------------------------------------------------------------------- void cmGlobalVisualStudio9Win64Generator -::EnableLanguage(std::vector<std::string>const & lang, - cmMakefile *mf, bool optional) +::AddPlatformDefinitions(cmMakefile* mf) { + cmGlobalVisualStudio9Generator::AddPlatformDefinitions(mf); mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE"); - cmGlobalVisualStudio9Generator::EnableLanguage(lang, mf, optional); + mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "x64"); + mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "x64"); } diff --git a/Source/cmGlobalVisualStudio9Win64Generator.h b/Source/cmGlobalVisualStudio9Win64Generator.h index 698d20e..55abcfc 100644 --- a/Source/cmGlobalVisualStudio9Win64Generator.h +++ b/Source/cmGlobalVisualStudio9Win64Generator.h @@ -43,7 +43,6 @@ public: * Try to determine system infomation such as shared library * extension, pthreads, byte order etc. */ - virtual void EnableLanguage(std::vector<std::string>const& languages, - cmMakefile *, bool optional); + virtual void AddPlatformDefinitions(cmMakefile *); }; #endif diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index 0c7cf7f..b0be087 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -65,6 +65,11 @@ public: /** Get the top-level registry key for this VS version. */ std::string GetRegistryBase(); + + /** Return true if the generated build tree may contain multiple builds. + i.e. "Can I build Debug and Release in the same tree?" */ + virtual bool IsMultiConfig() { return true; } + protected: void FixUtilityDepends(); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index e548230..05c6848 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1532,6 +1532,34 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, } } + // Set target-specific architectures. + std::vector<std::string> archs; + target.GetAppleArchs(configName, archs); + if(!archs.empty()) + { + // Enable ARCHS attribute. + buildSettings->AddAttribute("ONLY_ACTIVE_ARCH", + this->CreateString("NO")); + + // Store ARCHS value. + if(archs.size() == 1) + { + buildSettings->AddAttribute("ARCHS", + this->CreateString(archs[0].c_str())); + } + else + { + cmXCodeObject* archObjects = + this->CreateObject(cmXCodeObject::OBJECT_LIST); + for(std::vector<std::string>::iterator i = archs.begin(); + i != archs.end(); i++) + { + archObjects->AddObject(this->CreateString((*i).c_str())); + } + buildSettings->AddAttribute("ARCHS", archObjects); + } + } + // Get the product name components. std::string pnprefix; std::string pnbase; @@ -1549,7 +1577,18 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, target.GetType() == cmTarget::MODULE_LIBRARY || target.GetType() == cmTarget::EXECUTABLE) { - pndir = target.GetDirectory(); + if(this->XcodeVersion >= 21) + { + std::string pncdir = target.GetDirectory(configName); + buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR", + this->CreateString(pncdir.c_str())); + } + else + { + buildSettings->AddAttribute("OBJROOT", + this->CreateString(pndir.c_str())); + pndir = target.GetDirectory(configName); + } buildSettings->AddAttribute("EXECUTABLE_PREFIX", this->CreateString(pnprefix.c_str())); buildSettings->AddAttribute("EXECUTABLE_SUFFIX", @@ -2895,7 +2934,8 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( // then remove those exectuables as well if(this->Architectures.size() > 1) { - std::string universal = t->GetDirectory(); + std::string universal = + t->GetMakefile()->GetCurrentOutputDirectory(); universal += "/"; universal += this->CurrentProject; universal += ".build/"; @@ -3262,3 +3302,18 @@ cmGlobalXCodeGenerator::ComputeInfoPListLocation(cmTarget& target) plist += ".dir/Info.plist"; return plist; } + +//---------------------------------------------------------------------------- +// Return true if the generated build tree may contain multiple builds. +// i.e. "Can I build Debug and Release in the same tree?" +bool cmGlobalXCodeGenerator::IsMultiConfig() +{ + // Old Xcode 1.5 is single config: + if(this->XcodeVersion == 15) + { + return false; + } + + // Newer Xcode versions are multi config: + return true; +} diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 02ac1b5..b4de805 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -80,6 +80,11 @@ public: std::vector<std::string>& dirs); void SetCurrentLocalGenerator(cmLocalGenerator*); + + /** Return true if the generated build tree may contain multiple builds. + i.e. "Can I build Debug and Release in the same tree?" */ + virtual bool IsMultiConfig(); + private: cmXCodeObject* CreateOrGetPBXGroup(cmTarget& cmtarget, cmSourceGroup* sg); diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index 76bbd0c..22ba28f 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -525,6 +525,13 @@ namespace cmSystemTools::FileIsDirectory((argP1)->c_str()), reducible, arg, newArgs, argP1, argP2); } + // does a symlink with this name exist + if (*arg == "IS_SYMLINK" && argP1 != newArgs.end()) + { + HandlePredicate( + cmSystemTools::FileIsSymlink((argP1)->c_str()), + reducible, arg, newArgs, argP1, argP2); + } // is the given path an absolute path ? if (*arg == "IS_ABSOLUTE" && argP1 != newArgs.end()) { diff --git a/Source/cmIfCommand.h b/Source/cmIfCommand.h index 74692b7..107a892 100644 --- a/Source/cmIfCommand.h +++ b/Source/cmIfCommand.h @@ -158,6 +158,9 @@ public: " if(IS_DIRECTORY directory-name)\n" "True if the given name is a directory. " "Behavior is well-defined only for full paths.\n" + " if(IS_SYMLINK file-name)\n" + "True if the given name is a symbolic link. " + "Behavior is well-defined only for full paths.\n" " if(IS_ABSOLUTE path)\n" "True if the given path is an absolute path.\n" " if(variable MATCHES regex)\n" diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index e4bd7a4..33ffbfb 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -75,19 +75,12 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, fromDirConfig = this->Target->GetDirectory(config, this->ImportLibrary); fromDirConfig += "/"; } - - // Compute the full path to the main installed file for this target. - NameType nameType = this->ImportLibrary? NameImplib : NameNormal; - std::string toInstallPath = this->GetInstallDestination(); - toInstallPath += "/"; - toInstallPath += this->GetInstallFilename(this->Target, config, nameType); - - // Track whether post-install operations should be added to the - // script. - bool tweakInstalledFile = true; + std::string toDir = this->GetInstallDestination(); + toDir += "/"; // Compute the list of files to install for this target. - std::vector<std::string> files; + std::vector<std::string> filesFrom; + std::vector<std::string> filesTo; std::string literal_args; cmTarget::TargetType type = this->Target->GetType(); if(type == cmTarget::EXECUTABLE) @@ -104,49 +97,45 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, config); if(this->ImportLibrary) { - std::string from1 = fromDirConfig; - from1 += targetNameImport; - files.push_back(from1); + std::string from1 = fromDirConfig + targetNameImport; + std::string to1 = toDir + targetNameImport; + filesFrom.push_back(from1); + filesTo.push_back(to1); // An import library looks like a static library. type = cmTarget::STATIC_LIBRARY; } else { - std::string from1 = fromDirConfig; - from1 += targetName; + std::string from1 = fromDirConfig + targetName; + std::string to1 = toDir + targetName; // Handle OSX Bundles. if(this->Target->IsAppBundleOnApple()) { - // Compute the source locations of the bundle executable and - // Info.plist file. - from1 += ".app"; - files.push_back(from1); + // Install the whole app bundle directory. type = cmTarget::INSTALL_DIRECTORY; - // Need to apply install_name_tool and stripping to binary - // inside bundle. - toInstallPath += ".app/Contents/MacOS/"; - toInstallPath += - this->GetInstallFilename(this->Target, config, nameType); literal_args += " USE_SOURCE_PERMISSIONS"; + from1 += ".app"; + + // Tweaks apply to the binary inside the bundle. + to1 += ".app/Contents/MacOS/"; + to1 += targetName; } else { - // Operations done at install time on the installed file should - // be done on the real file and not any of the symlinks. - toInstallPath = this->GetInstallDestination(); - toInstallPath += "/"; - toInstallPath += targetNameReal; - - files.push_back(from1); + // Tweaks apply to the real file, so list it first. if(targetNameReal != targetName) { - std::string from2 = fromDirConfig; - from2 += targetNameReal; - files.push_back(from2); + std::string from2 = fromDirConfig + targetNameReal; + std::string to2 = toDir += targetNameReal; + filesFrom.push_back(from2); + filesTo.push_back(to2); } } + + filesFrom.push_back(from1); + filesTo.push_back(to1); } } else @@ -164,9 +153,10 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, // There is a bug in cmInstallCommand if this fails. assert(this->NamelinkMode == NamelinkModeNone); - std::string from1 = fromDirConfig; - from1 += targetNameImport; - files.push_back(from1); + std::string from1 = fromDirConfig + targetNameImport; + std::string to1 = toDir + targetNameImport; + filesFrom.push_back(from1); + filesTo.push_back(to1); // An import library looks like a static library. type = cmTarget::STATIC_LIBRARY; @@ -176,51 +166,48 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, // There is a bug in cmInstallCommand if this fails. assert(this->NamelinkMode == NamelinkModeNone); - // Compute the build tree location of the framework directory - std::string from1 = fromDirConfig; - from1 += targetName; - from1 += ".framework"; - files.push_back(from1); - + // Install the whole framework directory. type = cmTarget::INSTALL_DIRECTORY; + literal_args += " USE_SOURCE_PERMISSIONS"; + std::string from1 = fromDirConfig + targetName + ".framework"; - // Need to apply install_name_tool and stripping to binary - // inside framework. - toInstallPath += ".framework/Versions/"; - toInstallPath += this->Target->GetFrameworkVersion(); - toInstallPath += "/"; - toInstallPath += this->GetInstallFilename(this->Target, config, - NameNormal); + // Tweaks apply to the binary inside the bundle. + std::string to1 = toDir + targetName; + to1 += ".framework/Versions/"; + to1 += this->Target->GetFrameworkVersion(); + to1 += "/"; + to1 += targetName; - literal_args += " USE_SOURCE_PERMISSIONS"; + filesFrom.push_back(from1); + filesTo.push_back(to1); } else { - // Operations done at install time on the installed file should - // be done on the real file and not any of the symlinks. - toInstallPath = this->GetInstallDestination(); - toInstallPath += "/"; - toInstallPath += targetNameReal; - - // Construct the list of file names to install for this library. bool haveNamelink = false; - std::string fromName; + + // Library link name. + std::string fromName = fromDirConfig + targetName; + std::string toName = toDir + targetName; + + // Library interface name. std::string fromSOName; - std::string fromRealName; - fromName = fromDirConfig; - fromName += targetName; + std::string toSOName; if(targetNameSO != targetName) { haveNamelink = true; - fromSOName = fromDirConfig; - fromSOName += targetNameSO; + fromSOName = fromDirConfig + targetNameSO; + toSOName = toDir + targetNameSO; } + + // Library implementation name. + std::string fromRealName; + std::string toRealName; if(targetNameReal != targetName && targetNameReal != targetNameSO) { haveNamelink = true; - fromRealName = fromDirConfig; - fromRealName += targetNameReal; + fromRealName = fromDirConfig + targetNameReal; + toRealName = toDir + targetNameReal; } // Add the names based on the current namelink mode. @@ -230,27 +217,30 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, if(this->NamelinkMode == NamelinkModeOnly) { // Install the namelink only. - files.push_back(fromName); - tweakInstalledFile = false; + filesFrom.push_back(fromName); + filesTo.push_back(toName); } else { // Install the real file if it has its own name. if(!fromRealName.empty()) { - files.push_back(fromRealName); + filesFrom.push_back(fromRealName); + filesTo.push_back(toRealName); } // Install the soname link if it has its own name. if(!fromSOName.empty()) { - files.push_back(fromSOName); + filesFrom.push_back(fromSOName); + filesTo.push_back(toSOName); } // Install the namelink if it is not to be skipped. if(this->NamelinkMode != NamelinkModeSkip) { - files.push_back(fromName); + filesFrom.push_back(fromName); + filesTo.push_back(toName); } } } @@ -260,73 +250,39 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, // if this is not a namelink-only rule. if(this->NamelinkMode != NamelinkModeOnly) { - files.push_back(fromName); + filesFrom.push_back(fromName); + filesTo.push_back(toName); } } } } + // If this fails the above code is buggy. + assert(filesFrom.size() == filesTo.size()); + // Skip this rule if no files are to be installed for the target. - if(files.empty()) + if(filesFrom.empty()) { return; } - // Construct the path of the file on disk after installation on - // which tweaks may be performed. - std::string toDestDirPath = "$ENV{DESTDIR}"; - if(toInstallPath[0] != '/' && toInstallPath[0] != '$') - { - toDestDirPath += "/"; - } - toDestDirPath += toInstallPath; - // Add pre-installation tweaks. - if(tweakInstalledFile) - { - // Collect tweaking rules. - cmOStringStream tw; - this->AddRPathCheckRule(tw, indent.Next(), config, toDestDirPath); - std::string tws = tw.str(); - - // Add the rules, if any. - if(!tws.empty()) - { - os << indent << "IF(EXISTS \"" << toDestDirPath << "\")\n"; - os << tws; - os << indent << "ENDIF(EXISTS \"" << toDestDirPath << "\")\n"; - } - } + this->AddTweak(os, indent, config, filesTo, + &cmInstallTargetGenerator::PreReplacementTweaks); // Write code to install the target file. const char* no_dir_permissions = 0; const char* no_rename = 0; bool optional = this->Optional || this->ImportLibrary; - this->AddInstallRule(os, type, files, + this->AddInstallRule(os, type, filesFrom, optional, this->FilePermissions.c_str(), no_dir_permissions, no_rename, literal_args.c_str(), indent); // Add post-installation tweaks. - if(tweakInstalledFile) - { - // Collect tweaking rules. - cmOStringStream tw; - this->AddInstallNamePatchRule(tw, indent.Next(), config, toDestDirPath); - this->AddChrpathPatchRule(tw, indent.Next(), config, toDestDirPath); - this->AddRanlibRule(tw, indent.Next(), type, toDestDirPath); - this->AddStripRule(tw, indent.Next(), type, toDestDirPath); - std::string tws = tw.str(); - - // Add the rules, if any. - if(!tws.empty()) - { - os << indent << "IF(EXISTS \"" << toDestDirPath << "\")\n"; - os << tws; - os << indent << "ENDIF(EXISTS \"" << toDestDirPath << "\")\n"; - } - } + this->AddTweak(os, indent, config, filesTo, + &cmInstallTargetGenerator::PostReplacementTweaks); } //---------------------------------------------------------------------------- @@ -408,6 +364,92 @@ std::string cmInstallTargetGenerator::GetInstallFilename(cmTarget* target, //---------------------------------------------------------------------------- void cmInstallTargetGenerator +::AddTweak(std::ostream& os, Indent const& indent, const char* config, + std::string const& file, TweakMethod tweak) +{ + cmOStringStream tw; + (this->*tweak)(tw, indent.Next(), config, file); + std::string tws = tw.str(); + if(!tws.empty()) + { + os << indent << "IF(EXISTS \"" << file << "\" AND\n" + << indent << " NOT IS_SYMLINK \"" << file << "\")\n"; + os << tws; + os << indent << "ENDIF()\n"; + } +} + +//---------------------------------------------------------------------------- +void +cmInstallTargetGenerator +::AddTweak(std::ostream& os, Indent const& indent, const char* config, + std::vector<std::string> const& files, TweakMethod tweak) +{ + if(files.size() == 1) + { + // Tweak a single file. + this->AddTweak(os, indent, config, this->GetDestDirPath(files[0]), tweak); + } + else + { + // Generate a foreach loop to tweak multiple files. + cmOStringStream tw; + this->AddTweak(tw, indent.Next(), config, "${file}", tweak); + std::string tws = tw.str(); + if(!tws.empty()) + { + Indent indent2 = indent.Next().Next(); + os << indent << "FOREACH(file\n"; + for(std::vector<std::string>::const_iterator i = files.begin(); + i != files.end(); ++i) + { + os << indent2 << "\"" << this->GetDestDirPath(*i) << "\"\n"; + } + os << indent2 << ")\n"; + os << tws; + os << indent << "ENDFOREACH()\n"; + } + } +} + +//---------------------------------------------------------------------------- +std::string cmInstallTargetGenerator::GetDestDirPath(std::string const& file) +{ + // Construct the path of the file on disk after installation on + // which tweaks may be performed. + std::string toDestDirPath = "$ENV{DESTDIR}"; + if(file[0] != '/' && file[0] != '$') + { + toDestDirPath += "/"; + } + toDestDirPath += file; + return toDestDirPath; +} + +//---------------------------------------------------------------------------- +void cmInstallTargetGenerator::PreReplacementTweaks(std::ostream& os, + Indent const& indent, + const char* config, + std::string const& file) +{ + this->AddRPathCheckRule(os, indent, config, file); +} + +//---------------------------------------------------------------------------- +void cmInstallTargetGenerator::PostReplacementTweaks(std::ostream& os, + Indent const& indent, + const char* config, + std::string const& file) +{ + this->AddInstallNamePatchRule(os, indent, config, file); + this->AddChrpathPatchRule(os, indent, config, file); + this->AddRanlibRule(os, indent, file); + this->AddStripRule(os, indent, file); +} + +//---------------------------------------------------------------------------- +void +cmInstallTargetGenerator ::AddInstallNamePatchRule(std::ostream& os, Indent const& indent, const char* config, std::string const& toDestDirPath) { @@ -599,13 +641,12 @@ cmInstallTargetGenerator void cmInstallTargetGenerator::AddStripRule(std::ostream& os, Indent const& indent, - cmTarget::TargetType type, const std::string& toDestDirPath) { // don't strip static libraries, because it removes the only symbol table // they have so you can't link to them anymore - if(type == cmTarget::STATIC_LIBRARY) + if(this->Target->GetType() == cmTarget::STATIC_LIBRARY) { return; } @@ -633,11 +674,10 @@ cmInstallTargetGenerator::AddStripRule(std::ostream& os, void cmInstallTargetGenerator::AddRanlibRule(std::ostream& os, Indent const& indent, - cmTarget::TargetType type, const std::string& toDestDirPath) { // Static libraries need ranlib on this platform. - if(type != cmTarget::STATIC_LIBRARY) + if(this->Target->GetType() != cmTarget::STATIC_LIBRARY) { return; } diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index 978c302..b48d456 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -63,6 +63,20 @@ protected: virtual void GenerateScriptForConfig(std::ostream& os, const char* config, Indent const& indent); + typedef void (cmInstallTargetGenerator::*TweakMethod)( + std::ostream&, Indent const&, const char*, std::string const& + ); + void AddTweak(std::ostream& os, Indent const& indent, + const char* config, std::string const& file, + TweakMethod tweak); + void AddTweak(std::ostream& os, Indent const& indent, + const char* config, std::vector<std::string> const& files, + TweakMethod tweak); + std::string GetDestDirPath(std::string const& file); + void PreReplacementTweaks(std::ostream& os, Indent const& indent, + const char* config, std::string const& file); + void PostReplacementTweaks(std::ostream& os, Indent const& indent, + const char* config, std::string const& file); void AddInstallNamePatchRule(std::ostream& os, Indent const& indent, const char* config, const std::string& toDestDirPath); @@ -74,10 +88,8 @@ protected: std::string const& toDestDirPath); void AddStripRule(std::ostream& os, Indent const& indent, - cmTarget::TargetType type, const std::string& toDestDirPath); void AddRanlibRule(std::ostream& os, Indent const& indent, - cmTarget::TargetType type, const std::string& toDestDirPath); cmTarget* Target; diff --git a/Source/cmLinkDirectoriesCommand.cxx b/Source/cmLinkDirectoriesCommand.cxx index 697376f..4412414 100644 --- a/Source/cmLinkDirectoriesCommand.cxx +++ b/Source/cmLinkDirectoriesCommand.cxx @@ -23,10 +23,48 @@ bool cmLinkDirectoriesCommand for(std::vector<std::string>::const_iterator i = args.begin(); i != args.end(); ++i) { - std::string unixPath = *i; - cmSystemTools::ConvertToUnixSlashes(unixPath); - this->Makefile->AddLinkDirectory(unixPath.c_str()); + this->AddLinkDir(*i); } return true; } +//---------------------------------------------------------------------------- +void cmLinkDirectoriesCommand::AddLinkDir(std::string const& dir) +{ + std::string unixPath = dir; + cmSystemTools::ConvertToUnixSlashes(unixPath); + if(!cmSystemTools::FileIsFullPath(unixPath.c_str())) + { + bool convertToAbsolute = false; + cmOStringStream e; + e << "This command specifies the relative path\n" + << " " << unixPath << "\n" + << "as a link directory.\n"; + cmPolicies* policies = this->Makefile->GetPolicies(); + switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0015)) + { + case cmPolicies::WARN: + e << policies->GetPolicyWarning(cmPolicies::CMP0015); + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, e.str()); + case cmPolicies::OLD: + // OLD behavior does not convert + break; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + e << policies->GetRequiredPolicyError(cmPolicies::CMP0015); + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + case cmPolicies::NEW: + // NEW behavior converts + convertToAbsolute = true; + break; + } + if (convertToAbsolute) + { + std::string tmp = this->Makefile->GetStartDirectory(); + tmp += "/"; + tmp += unixPath; + unixPath = tmp; + } + } + this->Makefile->AddLinkDirectory(unixPath.c_str()); +} diff --git a/Source/cmLinkDirectoriesCommand.h b/Source/cmLinkDirectoriesCommand.h index 73673c4..e5ff4f0 100644 --- a/Source/cmLinkDirectoriesCommand.h +++ b/Source/cmLinkDirectoriesCommand.h @@ -70,6 +70,8 @@ public: } cmTypeMacro(cmLinkDirectoriesCommand, cmCommand); +private: + void AddLinkDir(std::string const& dir); }; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index c4ee5c7..3339ee4 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -712,6 +712,9 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target) std::string langFlags; this->AddLanguageFlags(langFlags, llang, 0); +#ifdef __APPLE__ + this->AddArchitectureFlags(langFlags, &target, llang, 0); +#endif /* __APPLE__ */ vars.LanguageCompileFlags = langFlags.c_str(); cmCustomCommandLines commandLines; @@ -908,6 +911,16 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, } return targetQuoted; } + if(variable == "TARGET_UNQUOTED") + { + std::string unquoted = replaceValues.Target; + std::string::size_type sz = unquoted.size(); + if(sz > 2 && unquoted[0] == '\"' && unquoted[sz-1] == '\"') + { + unquoted = unquoted.substr(1, sz-2); + } + return unquoted; + } if(replaceValues.LanguageCompileFlags) { if(variable == "LANGUAGE_COMPILE_FLAGS") @@ -1751,21 +1764,18 @@ void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout, } } + //---------------------------------------------------------------------------- -void cmLocalGenerator::AddLanguageFlags(std::string& flags, - const char* lang, - const char* config) -{ - // Add language-specific flags. - std::string flagsVar = "CMAKE_"; - flagsVar += lang; - flagsVar += "_FLAGS"; - // Add special OSX flags #ifdef __APPLE__ +void cmLocalGenerator::AddArchitectureFlags(std::string& flags, + cmTarget* target, + const char *lang, + const char* config) +{ if(this->EmitUniversalBinaryFlags) { - const char* osxArch = - this->Makefile->GetDefinition("CMAKE_OSX_ARCHITECTURES"); + std::vector<std::string> archs; + target->GetAppleArchs(config, archs); const char* sysroot = this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT"); const char* sysrootDefault = @@ -1775,24 +1785,13 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, std::string isysrootVar = std::string("CMAKE_") + lang + "_HAS_ISYSROOT"; bool hasIsysroot = this->Makefile->IsOn(isysrootVar.c_str()); bool flagsUsed = false; - if(osxArch && sysroot && lang && (lang[0] =='C' || lang[0] == 'F')) + if(!archs.empty() && sysroot && lang && (lang[0] =='C' || lang[0] == 'F')) { - std::vector<std::string> archs; - cmSystemTools::ExpandListArgument(std::string(osxArch), - archs); - bool addArchFlag = false; - if(archs.size() >= 1) - { - if(archs[0] != "") - { - addArchFlag = true; - } - } // if there is more than one arch add the -arch and // -isysroot flags, or if there is one arch flag, but // it is not the default -arch flag for the system, then // add it. Otherwize do not add -arch and -isysroot - if(addArchFlag) + if(archs[0] != "") { for( std::vector<std::string>::iterator i = archs.begin(); i != archs.end(); ++i) @@ -1823,7 +1822,19 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, flags += deploymentTarget; } } -#endif +} +#endif /* __APPLE__ */ + + +//---------------------------------------------------------------------------- +void cmLocalGenerator::AddLanguageFlags(std::string& flags, + const char* lang, + const char* config) +{ + // Add language-specific flags. + std::string flagsVar = "CMAKE_"; + flagsVar += lang; + flagsVar += "_FLAGS"; this->AddConfigVariableFlags(flags, flagsVar.c_str(), config); } diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index d2082e4..becdfff 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -133,6 +133,11 @@ public: std::vector<cmLocalGenerator*>& GetChildren() { return this->Children; }; +#ifdef __APPLE__ + void AddArchitectureFlags(std::string& flags, cmTarget* target, + const char *lang, const char* config); +#endif /* __APPLE__ */ + void AddLanguageFlags(std::string& flags, const char* lang, const char* config); void AddSharedFlags(std::string& flags, const char* lang, bool shared); diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 3719b5f..2cf840d 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -825,6 +825,34 @@ void cmLocalVisualStudio6Generator::SetBuildType(BuildType b, } } +//---------------------------------------------------------------------------- +cmsys::auto_ptr<cmCustomCommand> +cmLocalVisualStudio6Generator::MaybeCreateOutputDir(cmTarget& target, + const char* config) +{ + cmsys::auto_ptr<cmCustomCommand> pcc; + + // VS6 forgets to create the output directory for archives if it + // differs from the intermediate directory. + if(target.GetType() != cmTarget::STATIC_LIBRARY) { return pcc; } + std::string outDir = target.GetDirectory(config, false); + + // Add a pre-link event to create the directory. + cmCustomCommandLine command; + command.push_back(this->Makefile->GetRequiredDefinition("CMAKE_COMMAND")); + command.push_back("-E"); + command.push_back("make_directory"); + command.push_back(outDir); + std::vector<std::string> no_output; + std::vector<std::string> no_depends; + cmCustomCommandLines commands; + commands.push_back(command); + pcc.reset(new cmCustomCommand(no_output, no_depends, commands, 0, 0)); + pcc->SetEscapeOldStyle(false); + pcc->SetEscapeAllowMakeVars(true); + return pcc; +} + // look for custom rules on a target and collect them together std::string cmLocalVisualStudio6Generator::CreateTargetRules(cmTarget &target, @@ -849,6 +877,11 @@ cmLocalVisualStudio6Generator::CreateTargetRules(cmTarget &target, { event.Write(*pcc); } + pcc = this->MaybeCreateOutputDir(target, configName); + if(pcc.get()) + { + event.Write(*pcc); + } event.Finish(); // Write the post-build rules. @@ -1193,6 +1226,30 @@ void cmLocalVisualStudio6Generator outputNameRelWithDebInfo = target.GetFullName("RelWithDebInfo"); } + // Compute the output directory for the target. + std::string outputDirDebug; + std::string outputDirRelease; + std::string outputDirMinSizeRel; + std::string outputDirRelWithDebInfo; + if(target.GetType() == cmTarget::EXECUTABLE || + target.GetType() == cmTarget::STATIC_LIBRARY || + target.GetType() == cmTarget::SHARED_LIBRARY || + target.GetType() == cmTarget::MODULE_LIBRARY) + { + outputDirDebug = + removeQuotes(this->ConvertToOptionallyRelativeOutputPath( + target.GetDirectory("Debug").c_str())); + outputDirRelease = + removeQuotes(this->ConvertToOptionallyRelativeOutputPath( + target.GetDirectory("Release").c_str())); + outputDirMinSizeRel = + removeQuotes(this->ConvertToOptionallyRelativeOutputPath( + target.GetDirectory("MinSizeRel").c_str())); + outputDirRelWithDebInfo = + removeQuotes(this->ConvertToOptionallyRelativeOutputPath( + target.GetDirectory("RelWithDebInfo").c_str())); + } + // Compute the proper link information for the target. std::string optionsDebug; std::string optionsRelease; @@ -1412,11 +1469,21 @@ void cmLocalVisualStudio6Generator if(targetBuilds) { + cmSystemTools::ReplaceString(line, "OUTPUT_DIRECTORY_DEBUG", + outputDirDebug.c_str()); + cmSystemTools::ReplaceString(line, "OUTPUT_DIRECTORY_RELEASE", + outputDirRelease.c_str()); + cmSystemTools::ReplaceString(line, "OUTPUT_DIRECTORY_MINSIZEREL", + outputDirMinSizeRel.c_str()); + cmSystemTools::ReplaceString(line, "OUTPUT_DIRECTORY_RELWITHDEBINFO", + outputDirRelWithDebInfo.c_str()); +#ifdef CM_USE_OLD_VS6 std::string outPath = target.GetDirectory(); cmSystemTools::ReplaceString (line, "OUTPUT_DIRECTORY", removeQuotes(this->ConvertToOptionallyRelativeOutputPath (outPath.c_str())).c_str()); +#endif } cmSystemTools::ReplaceString(line, diff --git a/Source/cmLocalVisualStudio6Generator.h b/Source/cmLocalVisualStudio6Generator.h index 7279869..195d654 100644 --- a/Source/cmLocalVisualStudio6Generator.h +++ b/Source/cmLocalVisualStudio6Generator.h @@ -81,6 +81,8 @@ private: std::ostream &fout, const char *libName); class EventWriter; friend class EventWriter; + cmsys::auto_ptr<cmCustomCommand> + MaybeCreateOutputDir(cmTarget& target, const char* config); std::string CreateTargetRules(cmTarget &target, const char* configName, const char *libName); diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 2084808..1af0d1d 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -744,7 +744,9 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, // We need to specify a program database file name even for // non-debug configurations because VS still creates .idb files. fout << "\t\t\t\tProgramDataBaseFileName=\"" - << target.GetDirectory(configName) << "/" + << this->ConvertToXMLOutputPathSingle( + target.GetDirectory(configName).c_str()) + << "/" << target.GetPDBName(configName) << "\"\n"; } fout << "/>\n"; // end of <Tool Name=VCCLCompilerTool @@ -1049,8 +1051,10 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, fout << "\t\t\t\tAdditionalLibraryDirectories=\""; this->OutputLibraryDirectories(fout, cli.GetDirectories()); fout << "\"\n"; + std::string path = this->ConvertToXMLOutputPathSingle( + target.GetDirectory(configName).c_str()); fout << "\t\t\t\tProgramDataBaseFile=\"" - << target.GetDirectory(configName) << "/" << targetNamePDB + << path << "/" << targetNamePDB << "\"\n"; if(isDebug) { @@ -1420,6 +1424,10 @@ void cmLocalVisualStudio7Generator else if(!fcinfo.FileConfigMap.empty()) { const char* aCompilerTool = "VCCLCompilerTool"; + if(this->FortranProject) + { + aCompilerTool = "VFFortranCompilerTool"; + } std::string ext = (*sf)->GetExtension(); ext = cmSystemTools::LowerCase(ext); if(ext == "idl") diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index a20c917..e7c4a7d 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -229,6 +229,11 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Add language feature flags. this->AddFeatureFlags(flags, linkLanguage); +#ifdef __APPLE__ + this->LocalGenerator->AddArchitectureFlags(flags, this->Target, + linkLanguage, this->ConfigName); +#endif /* __APPLE__ */ + // Add target-specific linker flags. this->LocalGenerator->AppendFlags (linkFlags, this->Target->GetProperty("LINK_FLAGS")); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 4070a3b..f351174 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -682,6 +682,11 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules std::string langFlags; this->AddFeatureFlags(langFlags, linkLanguage); +#ifdef __APPLE__ + this->LocalGenerator->AddArchitectureFlags(langFlags, this->Target, + linkLanguage, this->ConfigName); +#endif /* __APPLE__ */ + // remove any language flags that might not work with the // particular os if(forbiddenFlagVar) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index c4f1d32..dd45950 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -294,6 +294,11 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags() // Add language feature flags. this->AddFeatureFlags(flags, lang); +#ifdef __APPLE__ + this->LocalGenerator->AddArchitectureFlags(flags, this->Target, + lang, this->ConfigName); +#endif /* __APPLE__ */ + // Fortran-specific flags computed for this target. if(*l == "Fortran") { diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 6b35b5b..2d41d40 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -406,6 +406,21 @@ cmPolicies::cmPolicies() "The OLD behavior for this policy is to silently ignore the problem. " "The NEW behavior for this policy is to report an error.", 2,8,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0015, "CMP0015", + "link_directories() treats paths relative to the source dir.", + "In CMake 2.6.4 and lower the link_directories() command passed relative " + "paths unchanged to the linker. " + "In CMake 2.8.1 and above the link_directories() command prefers to " + "interpret relative paths with respect to CMAKE_CURRENT_SOURCE_DIR, " + "which is consistent with include_directories() and other commands. " + "The OLD behavior for this policy is to use relative paths verbatim in " + "the linker command. " + "The NEW behavior for this policy is to convert relative paths to " + "absolute paths by appending the relative path to " + "CMAKE_CURRENT_SOURCE_DIR.", + 2,8,1, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 4d1c3fc..aaa3ac0 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -50,6 +50,7 @@ public: CMP0012, // Recognize numbers and boolean constants in if() CMP0013, // Duplicate binary directories not allowed CMP0014, // Input directories must have CMakeLists.txt + CMP0015, // link_directories() treats paths relative to source dir // Always the last entry. Useful mostly to avoid adding a comma // the last policy when adding a new one. diff --git a/Source/cmSetTestsPropertiesCommand.h b/Source/cmSetTestsPropertiesCommand.h index 20646d0..fbc8ac1 100644 --- a/Source/cmSetTestsPropertiesCommand.h +++ b/Source/cmSetTestsPropertiesCommand.h @@ -64,14 +64,8 @@ public: " Example: PASS_REGULAR_EXPRESSION \"[^a-z]Error;ERROR;Failed\"\n" "Both PASS_REGULAR_EXPRESSION and FAIL_REGULAR_EXPRESSION expect a " "list of regular expressions.\n" - "PROCESSORS: Denotes the number of processors that this test will " - "require. This is typically used for MPI tests, and should be used in " - "conjunction with the ctest_test PARALLEL_LEVEL option.\n" - "COST: Set this to a floating point value. Tests in a test set will be " - "run in descending order of cost.\n" - "RUN_SERIAL: If set to true, this test will not run in parallel with " - "any other tests. This should be used in conjunction with " - "the ctest_test PARALLEL_LEVEL option.\n"; + "TIMEOUT: Setting this will limit the test runtime to the number of " + "seconds specified.\n"; } cmTypeMacro(cmSetTestsPropertiesCommand, cmCommand); diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h index 38347a92..5db0200 100644 --- a/Source/cmStandardIncludes.h +++ b/Source/cmStandardIncludes.h @@ -37,6 +37,7 @@ #ifdef __ICL #pragma warning ( disable : 985 ) +#pragma warning ( disable : 1572 ) /* floating-point equality test */ #endif #include <stdarg.h> // Work-around for SGI MIPSpro 7.4.2m header bug diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 031bfc3..33e8fb0 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1672,6 +1672,18 @@ void cmSystemTools::RestoreEnv(const std::vector<std::string>& env) PutEnv(eit->c_str()); } } + +//---------------------------------------------------------------------- +cmSystemTools::SaveRestoreEnvironment::SaveRestoreEnvironment() +{ + this->Env = cmSystemTools::GetEnvironmentVariables(); +} + +//---------------------------------------------------------------------- +cmSystemTools::SaveRestoreEnvironment::~SaveRestoreEnvironment() +{ + cmSystemTools::RestoreEnv(this->Env); +} #endif void cmSystemTools::EnableVSConsoleOutput() @@ -2591,6 +2603,33 @@ bool cmSystemTools::ChangeRPath(std::string const& file, } //---------------------------------------------------------------------------- +bool cmSystemTools::VersionCompare(cmSystemTools::CompareOp op, + const char* lhss, const char* rhss) +{ + unsigned int lhs[4] = {0,0,0,0}; + unsigned int rhs[4] = {0,0,0,0}; + sscanf(lhss, "%u.%u.%u.%u", &lhs[0], &lhs[1], &lhs[2], &lhs[3]); + sscanf(rhss, "%u.%u.%u.%u", &rhs[0], &rhs[1], &rhs[2], &rhs[3]); + + // Do component-wise comparison. + for(unsigned int i=0; i < 4; ++i) + { + if(lhs[i] < rhs[i]) + { + // lhs < rhs, so true if operation is LESS + return op == cmSystemTools::OP_LESS; + } + else if(lhs[i] > rhs[i]) + { + // lhs > rhs, so true if operation is GREATER + return op == cmSystemTools::OP_GREATER; + } + } + // lhs == rhs, so true if operation is EQUAL + return op == cmSystemTools::OP_EQUAL; +} + +//---------------------------------------------------------------------------- bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg, bool* removed) { diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 679884e..70d1462 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -268,6 +268,17 @@ public: UNKNOWN_FILE_FORMAT }; + enum CompareOp { + OP_LESS, + OP_GREATER, + OP_EQUAL + }; + + /** + * Compare versions + */ + static bool VersionCompare(CompareOp op, const char* lhs, const char* rhs); + /** * Determine the file type based on the extension */ @@ -347,6 +358,20 @@ public: AppendEnv to put the environment back to the way it was. */ static void RestoreEnv(const std::vector<std::string>& env); + + /** Helper class to save and restore the environment. + Instantiate this class as an automatic variable on + the stack. Its constructor saves a copy of the current + environment and then its destructor restores the + original environment. */ + class SaveRestoreEnvironment + { + public: + SaveRestoreEnvironment(); + virtual ~SaveRestoreEnvironment(); + private: + std::vector<std::string> Env; + }; #endif /** Setup the environment to enable VS 8 IDE output. */ diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index f44fb6b..0436bd0 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -573,6 +573,23 @@ void cmTarget::DefineProperties(cmake *cm) false /* TODO: make this chained */ ); cm->DefineProperty + ("OSX_ARCHITECTURES", cmProperty::TARGET, + "Target specific architectures for OS X.", + "The OSX_ARCHITECTURES property sets the target binary architecture " + "for targets on OS X. " + "This property is initialized by the value of the variable " + "CMAKE_OSX_ARCHITECTURES if it is set when a target is created. " + "Use OSX_ARCHITECTURES_<CONFIG> to set the binary architectures on a " + "per-configuration basis. " + "<CONFIG> is an upper-case name (ex: \"OSX_ARCHITECTURES_DEBUG\")."); + + cm->DefineProperty + ("OSX_ARCHITECTURES_<CONFIG>", cmProperty::TARGET, + "Per-configuration OS X binary architectures for a target.", + "This property is the configuration-specific version of " + "OSX_ARCHITECTURES."); + + cm->DefineProperty ("OUTPUT_NAME", cmProperty::TARGET, "Output name for target files.", "This sets the base name for output files created for an executable or " @@ -884,22 +901,44 @@ void cmTarget::DefineProperties(cmake *cm) #define CM_TARGET_OUTDIR_DOC(TYPE, type) \ "This property specifies the directory into which " #type " target " \ "files should be built. " \ + "Multi-configuration generators (VS, Xcode) append " \ + "a per-configuration subdirectory to the specified directory. " \ CM_TARGET_FILE_TYPES_DOC " " \ "This property is initialized by the value of the variable " \ "CMAKE_" #TYPE "_OUTPUT_DIRECTORY if it is set when a target is created." +#define CM_TARGET_OUTDIR_CONFIG_DOC(TYPE) \ + "This is a per-configuration version of " #TYPE "_OUTPUT_DIRECTORY, " \ + "but multi-configuration generators (VS, Xcode) do NOT append " \ + "a per-configuration subdirectory to the specified directory. " \ + "This property is initialized by the value of the variable " \ + "CMAKE_" #TYPE "_OUTPUT_DIRECTORY_<CONFIG> " \ + "if it is set when a target is created." + cm->DefineProperty ("ARCHIVE_OUTPUT_DIRECTORY", cmProperty::TARGET, "Output directory in which to build ARCHIVE target files.", CM_TARGET_OUTDIR_DOC(ARCHIVE, archive)); cm->DefineProperty + ("ARCHIVE_OUTPUT_DIRECTORY_<CONFIG>", cmProperty::TARGET, + "Per-configuration output directory for ARCHIVE target files.", + CM_TARGET_OUTDIR_CONFIG_DOC(ARCHIVE)); + cm->DefineProperty ("LIBRARY_OUTPUT_DIRECTORY", cmProperty::TARGET, "Output directory in which to build LIBRARY target files.", CM_TARGET_OUTDIR_DOC(LIBRARY, library)); cm->DefineProperty + ("LIBRARY_OUTPUT_DIRECTORY_<CONFIG>", cmProperty::TARGET, + "Per-configuration output directory for LIBRARY target files.", + CM_TARGET_OUTDIR_CONFIG_DOC(LIBRARY)); + cm->DefineProperty ("RUNTIME_OUTPUT_DIRECTORY", cmProperty::TARGET, "Output directory in which to build RUNTIME target files.", CM_TARGET_OUTDIR_DOC(RUNTIME, runtime)); + cm->DefineProperty + ("RUNTIME_OUTPUT_DIRECTORY_<CONFIG>", cmProperty::TARGET, + "Per-configuration output directory for RUNTIME target files.", + CM_TARGET_OUTDIR_CONFIG_DOC(RUNTIME)); cm->DefineProperty ("ARCHIVE_OUTPUT_NAME", cmProperty::TARGET, @@ -983,6 +1022,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SetPropertyDefault("LIBRARY_OUTPUT_DIRECTORY", 0); this->SetPropertyDefault("RUNTIME_OUTPUT_DIRECTORY", 0); this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", 0); + this->SetPropertyDefault("OSX_ARCHITECTURES", 0); // Collect the set of configuration types. std::vector<std::string> configNames; @@ -1000,9 +1040,22 @@ void cmTarget::SetMakefile(cmMakefile* mf) } // Setup per-configuration property default values. + const char* configProps[] = { + "ARCHIVE_OUTPUT_DIRECTORY_", + "LIBRARY_OUTPUT_DIRECTORY_", + "RUNTIME_OUTPUT_DIRECTORY_", + 0}; for(std::vector<std::string>::iterator ci = configNames.begin(); ci != configNames.end(); ++ci) { + std::string configUpper = cmSystemTools::UpperCase(*ci); + for(const char** p = configProps; *p; ++p) + { + std::string property = *p; + property += configUpper; + this->SetPropertyDefault(property.c_str(), 0); + } + // Initialize per-configuration name postfix property from the // variable only for non-executable targets. This preserves // compatibility with previous CMake versions in which executables @@ -3036,13 +3089,13 @@ void cmTarget::GetFullNameInternal(const char* config, outBase += configPostfix?configPostfix:""; // Name shared libraries with their version number on some platforms. - if(const char* version = this->GetProperty("VERSION")) + if(const char* soversion = this->GetProperty("SOVERSION")) { if(this->GetType() == cmTarget::SHARED_LIBRARY && !implib && this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) { outBase += "-"; - outBase += version; + outBase += soversion; } } @@ -3423,14 +3476,20 @@ std::string cmTarget::GetInstallNameDirForBuildTree(const char* config, std::string cmTarget::GetInstallNameDirForInstallTree(const char* config, bool for_xcode) { - // Lookup the target property. - const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR"); - if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME") && - !this->Makefile->IsOn("CMAKE_SKIP_RPATH") && - install_name_dir && *install_name_dir) + if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { - std::string dir = install_name_dir; - dir += "/"; + std::string dir; + + if(!this->Makefile->IsOn("CMAKE_SKIP_RPATH")) + { + const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR"); + if(install_name_dir && *install_name_dir) + { + dir = install_name_dir; + dir += "/"; + } + } + if(this->IsFrameworkOnApple() && !for_xcode) { dir += this->GetFullName(config, false); @@ -3438,6 +3497,7 @@ std::string cmTarget::GetInstallNameDirForInstallTree(const char* config, dir += this->GetFrameworkVersion(); dir += "/"; } + return dir; } else @@ -3508,16 +3568,36 @@ void cmTarget::ComputeOutputDir(const char* config, { // Look for a target property defining the target output directory // based on the target type. + std::string targetTypeName = this->GetOutputTargetType(implib); const char* propertyName = 0; - std::string propertyNameStr = this->GetOutputTargetType(implib); + std::string propertyNameStr = targetTypeName; if(!propertyNameStr.empty()) { propertyNameStr += "_OUTPUT_DIRECTORY"; propertyName = propertyNameStr.c_str(); } + // Check for a per-configuration output directory target property. + std::string configUpper = cmSystemTools::UpperCase(config? config : ""); + const char* configProp = 0; + std::string configPropStr = targetTypeName; + if(!configPropStr.empty()) + { + configPropStr += "_OUTPUT_DIRECTORY_"; + configPropStr += configUpper; + configProp = configPropStr.c_str(); + } + // Select an output directory. - if(const char* outdir = this->GetProperty(propertyName)) + if(const char* config_outdir = this->GetProperty(configProp)) + { + // Use the user-specified per-configuration output directory. + out = config_outdir; + + // Skip per-configuration subdirectory. + config = 0; + } + else if(const char* outdir = this->GetProperty(propertyName)) { // Use the user-specified output directory. out = outdir; @@ -3648,6 +3728,27 @@ void cmTarget::GetLanguages(std::set<cmStdString>& languages) const } //---------------------------------------------------------------------------- +void cmTarget::GetAppleArchs(const char* config, + std::vector<std::string>& archVec) +{ + const char* archs = 0; + if(config && *config) + { + std::string defVarName = "OSX_ARCHITECTURES_"; + defVarName += cmSystemTools::UpperCase(config); + archs = this->GetProperty(defVarName.c_str()); + } + if(!archs) + { + archs = this->GetProperty("OSX_ARCHITECTURES"); + } + if(archs) + { + cmSystemTools::ExpandListArgument(std::string(archs), archVec); + } +} + +//---------------------------------------------------------------------------- bool cmTarget::IsChrpathUsed(const char* config) { #if defined(CMAKE_USE_ELF_PARSER) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 66e3f3df..f2b7d61 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -410,6 +410,9 @@ public: // until we have per-target object file properties. void GetLanguages(std::set<cmStdString>& languages) const; + /** Get the list of OS X target architectures to be built. */ + void GetAppleArchs(const char* config, std::vector<std::string>& archVec); + /** Return whether this target is an executable with symbol exports enabled. */ bool IsExecutableWithExports(); diff --git a/Source/cmTest.cxx b/Source/cmTest.cxx index 88b0eae..b52bc19 100644 --- a/Source/cmTest.cxx +++ b/Source/cmTest.cxx @@ -97,6 +97,31 @@ void cmTest::AppendProperty(const char* prop, const char* value) void cmTest::DefineProperties(cmake *cm) { cm->DefineProperty + ("ATTACHED_FILES", cmProperty::TEST, + "Attach a list of files to a dashboard submission.", + "Set this property to a list of files that will be encoded and " + "submitted to the dashboard as an addition to the test result."); + + cm->DefineProperty + ("ATTACHED_FILES_ON_FAIL", cmProperty::TEST, + "Attach a list of files to a dashboard submission if the test fails.", + "Same as ATTACHED_FILES, but these files will only be included if the " + "test does not pass."); + + cm->DefineProperty + ("COST", cmProperty::TEST, + "Set this to a floating point value. Tests in a test set will be " + "run in descending order of cost.", "This property describes the cost " + "of a test. You can explicitly set this value; tests with higher COST " + "values will run first."); + + cm->DefineProperty + ("DEPENDS", cmProperty::TEST, + "Specifies that this test should only be run after the specified " + "list of tests.", + "Set this to a list of tests that must finish before this test is run."); + + cm->DefineProperty ("ENVIRONMENT", cmProperty::TEST, "Specify environment variables that should be defined for running " "a test.", @@ -132,6 +157,26 @@ void cmTest::DefineProperties(cmake *cm) " regular expressions has to match, otherwise the test will fail."); cm->DefineProperty + ("PROCESSORS", cmProperty::TEST, + "How many process slots this test requires", + "Denotes the number of processors that this test will require. This is " + "typically used for MPI tests, and should be used in conjunction with " + "the ctest_test PARALLEL_LEVEL option."); + + cm->DefineProperty + ("REQUIRED_FILES", cmProperty::TEST, + "List of files required to run the test.", + "If set to a list of files, the test will not be run unless all of the " + "files exist."); + + cm->DefineProperty + ("RUN_SERIAL", cmProperty::TEST, + "Do not run this test in parallel with any other test.", + "Use this option in conjunction with the ctest_test PARALLEL_LEVEL " + "option to specify that this test should not be run in parallel with " + "any other tests."); + + cm->DefineProperty ("TIMEOUT", cmProperty::TEST, "How many seconds to allow for this test.", "This property if set will limit a test to not take more than " diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 32fcead..4a8e161 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -396,6 +396,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() std::vector<cmSourceFile*> customBuild; std::vector<cmSourceFile*> none; std::vector<cmSourceFile*> headers; + std::vector<cmSourceFile*> resource; for(std::vector<cmSourceFile*>::const_iterator s = classes.begin(); s != classes.end(); s++) @@ -417,6 +418,10 @@ void cmVisualStudio10TargetGenerator::WriteGroups() { clCompile.push_back(sf); } + if(strcmp(lang, "RC") == 0) + { + resource.push_back(sf); + } else if(sf->GetCustomCommand()) { customBuild.push_back(sf); @@ -448,6 +453,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() 0); this->WriteGroupSources("ClCompile", clCompile, sourceGroups); this->WriteGroupSources("ClInclude", headers, sourceGroups); + this->WriteGroupSources("ResourceCompile", resource, sourceGroups); this->WriteGroupSources("CustomBuild", customBuild, sourceGroups); this->WriteString("<ItemGroup>\n", 1); @@ -568,37 +574,40 @@ void cmVisualStudio10TargetGenerator::WriteCLSources() ((*source)->GetExtension().c_str()); const char* lang = (*source)->GetLanguage(); bool cl = lang && (strcmp(lang, "C") == 0 || strcmp(lang, "CXX") ==0); + bool rc = lang && (strcmp(lang, "RC") == 0); + std::string sourceFile = (*source)->GetFullPath(); + sourceFile = cmSystemTools::RelativePath( + this->Makefile->GetCurrentOutputDirectory(), + sourceFile.c_str()); + this->ConvertToWindowsSlash(sourceFile); + // output the source file + if(header) + { + this->WriteString("<ClInclude Include=\"", 2); + } + else if(cl) + { + this->WriteString("<ClCompile Include=\"", 2); + } + else if(rc) + { + this->WriteString("<ResourceCompile Include=\"", 2); + } + else + { + this->WriteString("<None Include=\"", 2); + } + (*this->BuildFileStream ) << sourceFile << "\""; + // ouput any flags specific to this source file + if(cl && this->OutputSourceSpecificFlags(*source)) + { + // if the source file has specific flags the tag + // is ended on a new line + this->WriteString("</ClCompile>\n", 2); + } + else { - std::string sourceFile = (*source)->GetFullPath(); - sourceFile = cmSystemTools::RelativePath( - this->Makefile->GetCurrentOutputDirectory(), - sourceFile.c_str()); - this->ConvertToWindowsSlash(sourceFile); - // output the source file - if(header) - { - this->WriteString("<ClInclude Include=\"", 2); - } - else if(cl) - { - this->WriteString("<ClCompile Include=\"", 2); - } - else - { - this->WriteString("<None Include=\"", 2); - } - (*this->BuildFileStream ) << sourceFile << "\""; - // ouput any flags specific to this source file - if(cl && this->OutputSourceSpecificFlags(*source)) - { - // if the source file has specific flags the tag - // is ended on a new line - this->WriteString("</ClCompile>\n", 2); - } - else - { - (*this->BuildFileStream ) << " />\n"; - } + (*this->BuildFileStream ) << " />\n"; } } } @@ -1222,6 +1231,7 @@ void cmVisualStudio10TargetGenerator::AddLibraries( Convert(l->Value.c_str(), cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED); + this->ConvertToWindowsSlash(path); libstring += sep; libstring += path; } diff --git a/Source/cmWriteFileCommand.cxx b/Source/cmWriteFileCommand.cxx index 5c5ad2e..f46b87f 100644 --- a/Source/cmWriteFileCommand.cxx +++ b/Source/cmWriteFileCommand.cxx @@ -60,9 +60,7 @@ bool cmWriteFileCommand #elif defined( __BORLANDC__ ) S_IRUSR | S_IWUSR #else - S_IRUSR | S_IWUSR | - S_IRGRP | - S_IROTH + 0666 #endif ; @@ -73,7 +71,7 @@ bool cmWriteFileCommand #if defined( _MSC_VER ) || defined( __MINGW32__ ) S_IREAD | S_IWRITE #else - S_IRUSR | S_IWUSR + 0666 #endif ); } diff --git a/Source/cmXMLSafe.cxx b/Source/cmXMLSafe.cxx index ea55ed1..72fdc34 100644 --- a/Source/cmXMLSafe.cxx +++ b/Source/cmXMLSafe.cxx @@ -11,6 +11,8 @@ ============================================================================*/ #include "cmXMLSafe.h" +#include "cm_utf8.h" + #include <cmsys/ios/iostream> #include <cmsys/ios/sstream> @@ -53,44 +55,47 @@ cmsys_ios::ostream& operator<<(cmsys_ios::ostream& os, cmXMLSafe const& self) { char const* first = self.Data; char const* last = self.Data + self.Size; - for(char const* ci = first; ci != last; ++ci) + while(first != last) { - unsigned char c = static_cast<unsigned char>(*ci); - switch(c) + unsigned int ch; + if(const char* next = cm_utf8_decode_character(first, last, &ch)) { - case '&': os << "&"; break; - case '<': os << "<"; break; - case '>': os << ">"; break; - case '"': os << (self.DoQuotes? """ : "\""); break; - case '\'': os << (self.DoQuotes? "'" : "'"); break; - case '\t': os << "\t"; break; - case '\n': os << "\n"; break; - case '\r': break; // Ignore CR - default: - if(c >= 0x20 && c <= 0x7f) - { - os.put(static_cast<char>(c)); - } - else + // http://www.w3.org/TR/REC-xml/#NT-Char + if((ch >= 0x20 && ch <= 0xD7FF) || + (ch >= 0xE000 && ch <= 0xFFFD) || + (ch >= 0x10000 && ch <= 0x10FFFF) || + ch == 0x9 || ch == 0xA || ch == 0xD) + { + switch(ch) { - // TODO: More complete treatment of program output character - // encoding. Instead of escaping these bytes, we should - // handle the current locale and its encoding. - char buf[16]; - // http://www.w3.org/TR/REC-xml/#NT-Char - if(c >= 0x80) - { - sprintf(buf, "&#x%hx;", static_cast<unsigned short>(c)); - } - else - { - // We cannot use "&#x%hx;" here because this value is not - // valid in XML. Instead use a human-readable hex value. - sprintf(buf, "<0x%hx>", static_cast<unsigned short>(c)); - } - os << buf; + // Escape XML control characters. + case '&': os << "&"; break; + case '<': os << "<"; break; + case '>': os << ">"; break; + case '"': os << (self.DoQuotes? """ : "\""); break; + case '\'': os << (self.DoQuotes? "'" : "'"); break; + case '\r': break; // Ignore CR + // Print the UTF-8 character. + default: os.write(first, next-first); break; } - break; + } + else + { + // Use a human-readable hex value for this invalid character. + char buf[16]; + sprintf(buf, "%X", ch); + os << "[NON-XML-CHAR-0x" << buf << "]"; + } + + first = next; + } + else + { + ch = static_cast<unsigned char>(*first++); + // Use a human-readable hex value for this invalid byte. + char buf[16]; + sprintf(buf, "%X", ch); + os << "[NON-UTF-8-BYTE-0x" << buf << "]"; } } return os; diff --git a/Source/cm_utf8.c b/Source/cm_utf8.c new file mode 100644 index 0000000..3d4ca16 --- /dev/null +++ b/Source/cm_utf8.c @@ -0,0 +1,84 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + 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. +============================================================================*/ +#include "cm_utf8.h" + +/* + RFC 3629 + 07-bit: 0xxxxxxx + 11-bit: 110xxxxx 10xxxxxx + 16-bit: 1110xxxx 10xxxxxx 10xxxxxx + 21-bit: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx + + Pre-RFC Compatibility + 26-bit: 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx + 31-bit: 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx +*/ + +/* Number of leading ones before a zero in the byte. */ +static unsigned char const cm_utf8_ones[256] = { + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, + 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,7,8 +}; + +/* Mask away control bits from bytes with n leading ones. */ +static unsigned char const cm_utf8_mask[7] = { + 0xEF, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01 +}; + +/* Minimum allowed value when first byte has n leading ones. */ +static unsigned int const cm_utf8_min[7] = { + 0, 0, 1u<<7, 1u<<11, 1u<<16, 1u<<21, 1u<<26 /*, 1u<<31 */ +}; + +/*--------------------------------------------------------------------------*/ +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 const ones = cm_utf8_ones[c]; + switch(ones) + { + case 0: *pc = c; return first; /* One-byte character. */ + case 1: case 7: case 8: return 0; /* Invalid leading byte. */ + default: break; + } + + /* Extract bits from this multi-byte character. */ + { + unsigned int uc = c & cm_utf8_mask[ones]; + unsigned char left; + for(left = ones-1; left && first != last; --left) + { + c = *first++; + if(cm_utf8_ones[c] != 1) + { + return 0; + } + uc = (uc << 6) | (c & cm_utf8_mask[1]); + } + + if(left > 0 || uc < cm_utf8_min[ones]) + { + return 0; + } + + *pc = uc; + return first; + } +} diff --git a/Source/cm_utf8.h b/Source/cm_utf8.h new file mode 100644 index 0000000..06e2868 --- /dev/null +++ b/Source/cm_utf8.h @@ -0,0 +1,29 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + 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. +============================================================================*/ +#ifndef cm_utf8_h +#define cm_utf8_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** Decode one UTF-8 character from the input byte range. On success, + stores the unicode character number in *pc and returns the first + position not extracted. On failure, returns 0. */ +const char* cm_utf8_decode_character(const char* first, const char* last, + unsigned int* pc); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 1a85a02..ef1febb 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -67,6 +67,7 @@ # include "cmGlobalVisualStudio8Win64Generator.h" # include "cmGlobalBorlandMakefileGenerator.h" # include "cmGlobalNMakeMakefileGenerator.h" +# include "cmGlobalJOMMakefileGenerator.h" # include "cmGlobalWatcomWMakeGenerator.h" # define CMAKE_HAVE_VS_GENERATORS # endif @@ -81,7 +82,7 @@ #include "cmCallVisualStudioMacro.h" #endif -#if !defined(__CYGWIN__) && !defined(CMAKE_BOOT_MINGW) +#if !defined(CMAKE_BOOT_MINGW) # include "cmExtraCodeBlocksGenerator.h" #endif @@ -1378,61 +1379,12 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args) // Internal CMake shared library support. else if (args[1] == "cmake_symlink_library" && args.size() == 5) { - int result = 0; - std::string realName = args[2]; - std::string soName = args[3]; - std::string name = args[4]; - if(soName != realName) - { - std::string fname = cmSystemTools::GetFilenameName(realName); - if(cmSystemTools::FileExists(soName.c_str()) || - cmSystemTools::FileIsSymlink(soName.c_str())) - { - cmSystemTools::RemoveFile(soName.c_str()); - } - if(!cmSystemTools::CreateSymlink(fname.c_str(), soName.c_str())) - { - cmSystemTools::ReportLastSystemError("cmake_symlink_library"); - result = 1; - } - } - if(name != soName) - { - std::string fname = cmSystemTools::GetFilenameName(soName); - if(cmSystemTools::FileExists(name.c_str()) || - cmSystemTools::FileIsSymlink(name.c_str())) - { - cmSystemTools::RemoveFile(name.c_str()); - } - if(!cmSystemTools::CreateSymlink(fname.c_str(), name.c_str())) - { - cmSystemTools::ReportLastSystemError("cmake_symlink_library"); - result = 1; - } - } - return result; + return cmake::SymlinkLibrary(args); } // Internal CMake versioned executable support. else if (args[1] == "cmake_symlink_executable" && args.size() == 4) { - int result = 0; - std::string realName = args[2]; - std::string name = args[3]; - if(name != realName) - { - std::string fname = cmSystemTools::GetFilenameName(realName); - if(cmSystemTools::FileExists(name.c_str()) || - cmSystemTools::FileIsSymlink(name.c_str())) - { - cmSystemTools::RemoveFile(name.c_str()); - } - if(!cmSystemTools::CreateSymlink(fname.c_str(), name.c_str())) - { - cmSystemTools::ReportLastSystemError("cmake_symlink_executable"); - result = 1; - } - } - return result; + return cmake::SymlinkExecutable(args); } #if defined(CMAKE_HAVE_VS_GENERATORS) @@ -1465,8 +1417,10 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args) else if (args[1] == "cmake_depends" && args.size() >= 6) { // Use the make system's VERBOSE environment variable to enable - // verbose output. - bool verbose = cmSystemTools::GetEnv("VERBOSE") != 0; + // verbose output. This can be skipped by also setting CMAKE_NO_VERBOSE + // (which is set by the Eclipse and KDevelop generators). + bool verbose = ((cmSystemTools::GetEnv("VERBOSE") != 0) + && (cmSystemTools::GetEnv("CMAKE_NO_VERBOSE") == 0)); // Create a cmake object instance to process dependencies. cmake cm; @@ -1693,10 +1647,8 @@ void cmake::AddDefaultExtraGenerators() // e.g. kdevelop4 ? #endif -#if !defined(__CYGWIN__) this->AddExtraGenerator(cmExtraCodeBlocksGenerator::GetActualName(), &cmExtraCodeBlocksGenerator::New); -#endif #ifdef CMAKE_USE_ECLIPSE this->AddExtraGenerator(cmExtraEclipseCDT4Generator::GetActualName(), @@ -2364,34 +2316,6 @@ const char* cmake::GetCacheDefinition(const char* name) const return this->CacheManager->GetCacheValue(name); } -int cmake::DumpDocumentationToFile(std::ostream& f) -{ -#ifdef CMAKE_BUILD_WITH_CMAKE - // Loop over all registered commands and print out documentation - const char *name; - const char *terse; - const char *full; - char tmp[1024]; - sprintf(tmp,"Version %s", cmVersion::GetCMakeVersion()); - f << "<html>\n"; - f << "<h1>Documentation for commands of CMake " << tmp << "</h1>\n"; - f << "<ul>\n"; - for(RegisteredCommandsMap::iterator j = this->Commands.begin(); - j != this->Commands.end(); ++j) - { - name = (*j).second->GetName(); - terse = (*j).second->GetTerseDocumentation(); - full = (*j).second->GetFullDocumentation(); - f << "<li><b>" << name << "</b> - " << terse << std::endl - << "<br><i>Usage:</i> " << full << "</li>" << std::endl << std::endl; - } - f << "</ul></html>\n"; -#else - (void)f; -#endif - return 1; -} - void cmake::AddDefaultCommands() { std::list<cmCommand*> commands; @@ -2430,6 +2354,8 @@ void cmake::AddDefaultGenerators() &cmGlobalBorlandMakefileGenerator::New; this->Generators[cmGlobalNMakeMakefileGenerator::GetActualName()] = &cmGlobalNMakeMakefileGenerator::New; + this->Generators[cmGlobalJOMMakefileGenerator::GetActualName()] = + &cmGlobalJOMMakefileGenerator::New; this->Generators[cmGlobalWatcomWMakeGenerator::GetActualName()] = &cmGlobalWatcomWMakeGenerator::New; # endif @@ -2588,9 +2514,11 @@ int cmake::CheckBuildSystem() { // We do not need to rerun CMake. Check dependency integrity. Use // the make system's VERBOSE environment variable to enable verbose - // output. - bool verbose = cmSystemTools::GetEnv("VERBOSE") != 0; - + // output. This can be skipped by setting CMAKE_NO_VERBOSE (which is set + // by the Eclipse and KDevelop generators). + bool verbose = ((cmSystemTools::GetEnv("VERBOSE") != 0) + && (cmSystemTools::GetEnv("CMAKE_NO_VERBOSE") == 0)); + // This method will check the integrity of the build system if the // option was given on the command line. It reads the given file to // determine whether CMake should rerun. @@ -3131,6 +3059,65 @@ void cmake::GenerateGraphViz(const char* fileName) const } //---------------------------------------------------------------------------- +int cmake::SymlinkLibrary(std::vector<std::string>& args) +{ + int result = 0; + std::string realName = args[2]; + std::string soName = args[3]; + std::string name = args[4]; + if(soName != realName) + { + if(!cmake::SymlinkInternal(realName, soName)) + { + cmSystemTools::ReportLastSystemError("cmake_symlink_library"); + result = 1; + } + } + if(name != soName) + { + if(!cmake::SymlinkInternal(soName, name)) + { + cmSystemTools::ReportLastSystemError("cmake_symlink_library"); + result = 1; + } + } + return result; +} + +//---------------------------------------------------------------------------- +int cmake::SymlinkExecutable(std::vector<std::string>& args) +{ + int result = 0; + std::string realName = args[2]; + std::string name = args[3]; + if(name != realName) + { + if(!cmake::SymlinkInternal(realName, name)) + { + cmSystemTools::ReportLastSystemError("cmake_symlink_executable"); + result = 1; + } + } + return result; +} + +//---------------------------------------------------------------------------- +bool cmake::SymlinkInternal(std::string const& file, std::string const& link) +{ + if(cmSystemTools::FileExists(link.c_str()) || + cmSystemTools::FileIsSymlink(link.c_str())) + { + cmSystemTools::RemoveFile(link.c_str()); + } +#if defined(_WIN32) && !defined(__CYGWIN__) + return cmSystemTools::CopyFileAlways(file.c_str(), link.c_str()); +#else + std::string linktext = cmSystemTools::GetFilenameName(file); + return cmSystemTools::CreateSymlink(linktext.c_str(), link.c_str()); +#endif +} + +//---------------------------------------------------------------------------- #ifdef CMAKE_BUILD_WITH_CMAKE int cmake::ExecuteEchoColor(std::vector<std::string>& args) { @@ -4402,7 +4389,7 @@ int cmake::Build(const std::string& dir, const std::string& config, const std::vector<std::string>& nativeOptions, bool clean) -{ +{ if(!cmSystemTools::FileIsDirectory(dir.c_str())) { std::cerr << "Error: " << dir << " is not a directory\n"; @@ -4422,8 +4409,8 @@ int cmake::Build(const std::string& dir, std::cerr << "Error: could find generator in Cache\n"; return 1; } - cmGlobalGenerator* gen = - this->CreateGlobalGenerator(it.GetValue()); + std::auto_ptr<cmGlobalGenerator> gen( + this->CreateGlobalGenerator(it.GetValue())); std::string output; std::string projName; std::string makeProgram; diff --git a/Source/cmake.h b/Source/cmake.h index f983dc2..8312795 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -123,12 +123,6 @@ class cmake //@} /** - * Dump documentation to a file. If 0 is returned, the - * operation failed. - */ - int DumpDocumentationToFile(std::ostream&); - - /** * Handle a command line invocation of cmake. */ int Run(const std::vector<std::string>&args) @@ -414,6 +408,10 @@ protected: void GenerateGraphViz(const char* fileName) const; + static int SymlinkLibrary(std::vector<std::string>& args); + static int SymlinkExecutable(std::vector<std::string>& args); + static bool SymlinkInternal(std::string const& file, + std::string const& link); static int ExecuteEchoColor(std::vector<std::string>& args); static int ExecuteLinkScript(std::vector<std::string>& args); static int VisualStudioLink(std::vector<std::string>& args, int type); diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 766eead..ddff71d 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -423,7 +423,7 @@ int do_cmake(int ac, char** av) std::vector<std::string> args; for(int i =0; i < ac; ++i) { - if(strcmp(av[i], "-i") == 0) + if(!command && strcmp(av[i], "-i") == 0) { wiz = true; } diff --git a/Source/ctest.cxx b/Source/ctest.cxx index eec5c03..c9b875d 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -123,8 +123,8 @@ static const char * cmDocumentationOptions[][3] = {"-SP <script>, --script-new-process <script>", "Execute a dashboard for a " "configuration", "This option does the same operations as -S but it will do them in a " - "seperate process. This is primarily useful in cases where the script " - "may modify the environment and you do not want the modified enviroment " + "separate process. This is primarily useful in cases where the script " + "may modify the environment and you do not want the modified environment " "to impact other -S scripts."}, {"-A <file>, --add-notes <file>", "Add a notes file with submission", "This option tells ctest to include a notes file when submitting " @@ -141,7 +141,7 @@ static const char * cmDocumentationOptions[][3] = "tests are run. By specifying -U the union of tests is run instead."}, {"--max-width <width>", "Set the max width for a test name to output", "Set the maximum width for each test name to show in the output. This " - "allows the user to widen the output to avoid cliping the test name which " + "allows the user to widen the output to avoid clipping the test name which " "can be very annoying."}, {"--interactive-debug-mode [0|1]", "Set the interactive mode to 0 or 1.", "This option causes ctest to run tests in either an interactive mode or " @@ -181,8 +181,8 @@ static const char * cmDocumentationOptions[][3] = {"--build-makeprogram", "Specify the make program to use.", "" }, {"--build-noclean", "Skip the make clean step.", "" }, {"--build-config-sample", - "A sample executable to use to determine the configuraiton", - "A sample executable to use to determine the configuraiton that " + "A sample executable to use to determine the configuration", + "A sample executable to use to determine the configuration that " "should be used. e.g. Debug/Release/etc" }, {"--build-options", "Add extra options to the build step.", "This option must be the last option with the exception of --test-command" @@ -208,10 +208,23 @@ static const char * cmDocumentationOptions[][3] = "By default CTest will run child CTest instances within the same process. " "If this behavior is not desired, this argument will enforce new " "processes for child CTest processes." }, + {"--schedule-random", "Use a random order for scheduling tests", + "This option will run the tests in a random order. It is commonly used to " + "detect implicit dependencies in a test suite." }, {"--submit-index", "Submit individual dashboard tests with specific index", "This option allows performing the same CTest action (such as test) " "multiple times and submit all stages to the same dashboard (Dart2 " "required). Each execution requires different index." }, + {"--timeout <seconds>", "Set a global timeout on all tests.", + "This option will set a global timeout on all tests that do not already " + "have a timeout set on them."}, + {"--http1.0", "Submit using HTTP 1.0.", + "This option will force CTest to use HTTP 1.0 to submit files to the " + "dashboard, instead of HTTP 1.1."}, + {"--no-compress-output", "Do not compress test output when submitting.", + "This flag will turn off automatic compression of test output. Use this " + "to maintain compatibility with an older version of CDash which doesn't " + "support compressed test output."}, {"--help-command <cmd> [<file>]", "Show help for a single command and exit.", "Prints the help for the command to stdout or to the specified file." }, {"--help-command-list [<file>]", "List available commands and exit.", @@ -276,6 +289,7 @@ int main (int argc, char *argv[]) ch->CreateCMake(); ch->GetCommandDocumentation(commands); + doc.SetShowGenerators(false); doc.SetName("ctest"); doc.SetSection("Name",cmDocumentationName); doc.SetSection("Usage",cmDocumentationUsage); diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index c142bcb..62042e8 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt @@ -103,6 +103,14 @@ # any outside mailing list and no documentation of the change will be # written. +CMAKE_MINIMUM_REQUIRED(VERSION 2.4.5 FATAL_ERROR) +IF(COMMAND CMAKE_POLICY) + CMAKE_POLICY(SET CMP0003 NEW) +ENDIF(COMMAND CMAKE_POLICY) + +# Allow empty endif() and such with CMake 2.4. +SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS 1) + #----------------------------------------------------------------------------- # If a namespace is not specified, use "kwsys" and enable testing. # This should be the case only when kwsys is not included inside @@ -111,12 +119,6 @@ IF(NOT KWSYS_NAMESPACE) SET(KWSYS_NAMESPACE "kwsys") SET(KWSYS_STANDALONE 1) ENDIF(NOT KWSYS_NAMESPACE) -IF(KWSYS_STANDALONE) - CMAKE_MINIMUM_REQUIRED(VERSION 2.4) - IF(COMMAND CMAKE_POLICY) - CMAKE_POLICY(SET CMP0003 NEW) - ENDIF(COMMAND CMAKE_POLICY) -ENDIF(KWSYS_STANDALONE) #----------------------------------------------------------------------------- # The project name is that of the specified namespace. @@ -299,13 +301,6 @@ ELSE(COMMAND INSTALL) SET(KWSYS_INSTALL_LIB_DIR) ENDIF(COMMAND INSTALL) -# Work-around for CMake 1.6.7 bug in custom command dependencies when -# there is no executable output path. -IF(NOT EXECUTABLE_OUTPUT_PATH) - SET(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}" CACHE PATH - "Output directory for executables.") -ENDIF(NOT EXECUTABLE_OUTPUT_PATH) - # Generated source files will need this header. STRING(COMPARE EQUAL "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}" KWSYS_IN_SOURCE_BUILD) @@ -474,19 +469,54 @@ IF(UNIX) ENDIF(UNIX) IF(KWSYS_USE_FundamentalType) - # Determine type sizes. - CHECK_TYPE_SIZE("char" KWSYS_SIZEOF_CHAR) - CHECK_TYPE_SIZE("short" KWSYS_SIZEOF_SHORT) - CHECK_TYPE_SIZE("int" KWSYS_SIZEOF_INT) - CHECK_TYPE_SIZE("long" KWSYS_SIZEOF_LONG) - CHECK_TYPE_SIZE("long long" KWSYS_SIZEOF_LONG_LONG) - CHECK_TYPE_SIZE("__int64" KWSYS_SIZEOF___INT64) - IF(NOT KWSYS_SIZEOF_LONG_LONG) - SET(KWSYS_SIZEOF_LONG_LONG 0) - ENDIF(NOT KWSYS_SIZEOF_LONG_LONG) - IF(NOT KWSYS_SIZEOF___INT64) - SET(KWSYS_SIZEOF___INT64 0) - ENDIF(NOT KWSYS_SIZEOF___INT64) + # Look for type size helper macros. + KWSYS_PLATFORM_INFO_TEST(C KWSYS_C_TYPE_MACROS + "Checking for C type size macros") + SET(macro_regex ".*INFO:macro\\[([^]]*)\\].*") + FOREACH(info ${KWSYS_C_TYPE_MACROS}) + IF("${info}" MATCHES "${macro_regex}") + STRING(REGEX REPLACE "${macro_regex}" "\\1" macro "${info}") + SET(KWSYS_C_HAS_MACRO_${macro} 1) + ENDIF() + ENDFOREACH() + + # Determine type sizes at preprocessing time if possible, and + # otherwise fall back to a try-compile. + SET(KWSYS_C_TYPE_NAME_CHAR "char") + SET(KWSYS_C_TYPE_NAME_SHORT "short") + SET(KWSYS_C_TYPE_NAME_INT "int") + SET(KWSYS_C_TYPE_NAME_LONG "long") + SET(KWSYS_C_TYPE_NAME_LONG_LONG "long long") + SET(KWSYS_C_TYPE_NAME___INT64 "__int64") + FOREACH(type CHAR SHORT INT LONG LONG_LONG __INT64) + IF(KWSYS_C_HAS_MACRO___SIZEOF_${type}__) + # Use __SIZEOF_${type}__ macro. + SET(KWSYS_SIZEOF_${type} TRUE) + SET(KWSYS_C_CODE_SIZEOF_${type} "#define ${KWSYS_NAMESPACE}_SIZEOF_${type} __SIZEOF_${type}__") + ELSEIF(KWSYS_C_HAS_MACRO___${type}_MAX__) + # Use __${type}_MAX__ macro. + SET(KWSYS_SIZEOF_${type} TRUE) + SET(KWSYS_C_CODE_SIZEOF_${type} "#if __${type}_MAX__ == 0x7f +# define ${KWSYS_NAMESPACE}_SIZEOF_${type} 1 +#elif __${type}_MAX__ == 0x7fff +# define ${KWSYS_NAMESPACE}_SIZEOF_${type} 2 +#elif __${type}_MAX__ == 0x7fffffff +# define ${KWSYS_NAMESPACE}_SIZEOF_${type} 4 +#elif __${type}_MAX__>>32 == 0x7fffffff +# define ${KWSYS_NAMESPACE}_SIZEOF_${type} 8 +#else +# error \"Cannot determine sizeof(${KWSYS_C_TYPE_NAME_${type}}).\" +#endif") + ELSE() + # Configure a hard-coded type size. + CHECK_TYPE_SIZE("${KWSYS_C_TYPE_NAME_${type}}" KWSYS_SIZEOF_${type}) + IF(NOT KWSYS_SIZEOF_${type}) + SET(KWSYS_SIZEOF_${type} 0) + ENDIF() + SET(KWSYS_C_CODE_SIZEOF_${type} + "#define ${KWSYS_NAMESPACE}_SIZEOF_${type} ${KWSYS_SIZEOF_${type}}") + ENDIF() + ENDFOREACH() # Check uniqueness of types. IF(KWSYS_SIZEOF___INT64) @@ -530,8 +560,9 @@ ENDIF(KWSYS_USE_FundamentalType) IF(KWSYS_USE_IOStream) # Determine whether iostreams support long long. - CHECK_TYPE_SIZE("long long" KWSYS_SIZEOF_LONG_LONG) - IF(KWSYS_SIZEOF_LONG_LONG) + KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_LONG_LONG + "Checking whether C++ compiler has 'long long'" DIRECT) + IF(KWSYS_CXX_HAS_LONG_LONG) SET(KWSYS_PLATFORM_CXX_TEST_DEFINES -DKWSYS_IOS_USE_ANSI=${KWSYS_IOS_USE_ANSI} -DKWSYS_IOS_HAVE_STD=${KWSYS_IOS_HAVE_STD}) @@ -540,10 +571,10 @@ IF(KWSYS_USE_IOStream) KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_HAS_OSTREAM_LONG_LONG "Checking if ostream supports long long" DIRECT) SET(KWSYS_PLATFORM_CXX_TEST_DEFINES) - ELSE(KWSYS_SIZEOF_LONG_LONG) + ELSE() SET(KWSYS_IOS_HAS_ISTREAM_LONG_LONG 0) SET(KWSYS_IOS_HAS_OSTREAM_LONG_LONG 0) - ENDIF(KWSYS_SIZEOF_LONG_LONG) + ENDIF() ENDIF(KWSYS_USE_IOStream) IF(KWSYS_NAMESPACE MATCHES "^kwsys$") @@ -989,6 +1020,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) # If kwsys contains the DynamicLoader, need extra library ADD_LIBRARY(${KWSYS_NAMESPACE}TestDynload MODULE testDynload.c) KWSYS_SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestDynload PROPERTY LABELS ${KWSYS_LABELS_LIB}) + ADD_DEPENDENCIES(${KWSYS_NAMESPACE}TestDynload ${KWSYS_NAMESPACE}) ENDIF(KWSYS_USE_DynamicLoader) CREATE_TEST_SOURCELIST( KWSYS_CXX_TEST_SRCS ${KWSYS_NAMESPACE}TestsCxx.cxx @@ -1057,12 +1089,18 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) KWSYS_SET_PROPERTY(TEST kwsys.testProcess-${n} PROPERTY LABELS ${KWSYS_LABELS_TEST}) ENDFOREACH(n) + # Some Apple compilers produce bad optimizations in this source. + IF(APPLE AND "${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU|LLVM)$") + SET_SOURCE_FILES_PROPERTIES(testProcess.c PROPERTIES COMPILE_FLAGS -O0) + ENDIF() + # Test SharedForward CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/testSharedForward.c.in ${PROJECT_BINARY_DIR}/testSharedForward.c @ONLY IMMEDIATE) ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestSharedForward ${PROJECT_BINARY_DIR}/testSharedForward.c) KWSYS_SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestSharedForward PROPERTY LABELS ${KWSYS_LABELS_EXE}) + ADD_DEPENDENCIES(${KWSYS_NAMESPACE}TestSharedForward ${KWSYS_NAMESPACE}_c) ADD_TEST(kwsys.testSharedForward ${EXEC_DIR}/${KWSYS_NAMESPACE}TestSharedForward 1) KWSYS_SET_PROPERTY(TEST kwsys.testSharedForward PROPERTY LABELS ${KWSYS_LABELS_TEST}) diff --git a/Source/kwsys/Configure.h.in b/Source/kwsys/Configure.h.in index d3b6906..97b2c5d 100644 --- a/Source/kwsys/Configure.h.in +++ b/Source/kwsys/Configure.h.in @@ -25,6 +25,9 @@ # if defined(__BORLANDC__) # pragma warn -8027 /* function not inlined. */ # endif +# if defined(__INTEL_COMPILER) +# pragma warning (disable: 1572) /* floating-point equality test */ +# endif #endif /* Whether kwsys namespace is "kwsys". */ @@ -85,11 +88,17 @@ #endif /* Setup the export macro. */ -#if defined(_WIN32) && @KWSYS_BUILD_SHARED@ -# if defined(@KWSYS_NAMESPACE@_EXPORTS) -# define @KWSYS_NAMESPACE@_EXPORT __declspec(dllexport) +#if @KWSYS_BUILD_SHARED@ +# if defined(_WIN32) || defined(__CYGWIN__) +# if defined(@KWSYS_NAMESPACE@_EXPORTS) +# define @KWSYS_NAMESPACE@_EXPORT __declspec(dllexport) +# else +# define @KWSYS_NAMESPACE@_EXPORT __declspec(dllimport) +# endif +# elif __GNUC__ >= 4 +# define @KWSYS_NAMESPACE@_EXPORT __attribute__ ((visibility("default"))) # else -# define @KWSYS_NAMESPACE@_EXPORT __declspec(dllimport) +# define @KWSYS_NAMESPACE@_EXPORT # endif #else # define @KWSYS_NAMESPACE@_EXPORT diff --git a/Source/kwsys/FundamentalType.h.in b/Source/kwsys/FundamentalType.h.in index aabe822..ff20063 100644 --- a/Source/kwsys/FundamentalType.h.in +++ b/Source/kwsys/FundamentalType.h.in @@ -36,12 +36,12 @@ #endif /* The size of fundamental types. Types that do not exist have size 0. */ -#define @KWSYS_NAMESPACE@_SIZEOF_CHAR @KWSYS_SIZEOF_CHAR@ -#define @KWSYS_NAMESPACE@_SIZEOF_SHORT @KWSYS_SIZEOF_SHORT@ -#define @KWSYS_NAMESPACE@_SIZEOF_INT @KWSYS_SIZEOF_INT@ -#define @KWSYS_NAMESPACE@_SIZEOF_LONG @KWSYS_SIZEOF_LONG@ -#define @KWSYS_NAMESPACE@_SIZEOF_LONG_LONG @KWSYS_SIZEOF_LONG_LONG@ -#define @KWSYS_NAMESPACE@_SIZEOF___INT64 @KWSYS_SIZEOF___INT64@ +@KWSYS_C_CODE_SIZEOF_CHAR@ +@KWSYS_C_CODE_SIZEOF_SHORT@ +@KWSYS_C_CODE_SIZEOF_INT@ +@KWSYS_C_CODE_SIZEOF_LONG@ +@KWSYS_C_CODE_SIZEOF_LONG_LONG@ +@KWSYS_C_CODE_SIZEOF___INT64@ /* Whether types "long long" and "__int64" are enabled. If a type is enabled then it is a unique fundamental type. */ diff --git a/Source/kwsys/MD5.c b/Source/kwsys/MD5.c index f2e2019..1ea0a66 100644 --- a/Source/kwsys/MD5.c +++ b/Source/kwsys/MD5.c @@ -52,7 +52,6 @@ ghost@aladdin.com */ -/* $Id$ */ /* Independent implementation of MD5 (RFC 1321). diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c index e2935eb..373e906 100644 --- a/Source/kwsys/ProcessUNIX.c +++ b/Source/kwsys/ProcessUNIX.c @@ -1875,9 +1875,8 @@ static int kwsysProcessSetupOutputPipeFile(int* p, const char* name) /* Close the existing descriptor. */ kwsysProcessCleanupDescriptor(p); - /* Open a file for the pipe to write (permissions 644). */ - if((fout = open(name, O_WRONLY | O_CREAT | O_TRUNC, - S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) < 0) + /* Open a file for the pipe to write. */ + if((fout = open(name, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) { return 0; } @@ -2377,9 +2376,13 @@ static pid_t kwsysProcessFork(kwsysProcess* cp, #if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) # define KWSYSPE_PS_COMMAND "ps axo pid,ppid" # define KWSYSPE_PS_FORMAT "%d %d\n" -#elif defined(__hpux) || defined(__sparc) || defined(__sgi) || defined(_AIX) +#elif defined(__hpux) || defined(__sun__) || defined(__sgi) || defined(_AIX) \ + || defined(__sparc) # define KWSYSPE_PS_COMMAND "ps -ef" # define KWSYSPE_PS_FORMAT "%*s %d %d %*[^\n]\n" +#elif defined(__QNX__) +# define KWSYSPE_PS_COMMAND "ps -Af" +# define KWSYSPE_PS_FORMAT "%*d %d %d %*[^\n]\n" #elif defined(__CYGWIN__) # define KWSYSPE_PS_COMMAND "ps aux" # define KWSYSPE_PS_FORMAT "%d %d %*[^\n]\n" @@ -2392,13 +2395,8 @@ static void kwsysProcessKill(pid_t process_id) DIR* procdir; #endif - /* Kill the process now to make sure it does not create more - children. Do not reap it yet so we can identify its existing - children. There is a small race condition here. If the child - forks after we begin looking for children below but before it - receives this kill signal we might miss a child. Also we might - not be able to catch up to a fork bomb. */ - kill(process_id, SIGKILL); + /* Suspend the process to be sure it will not create more children. */ + kill(process_id, SIGSTOP); /* Kill all children if we can find them. */ #if defined(__linux__) || defined(__CYGWIN__) @@ -2486,6 +2484,19 @@ static void kwsysProcessKill(pid_t process_id) } #endif } + + /* Kill the process. */ + kill(process_id, SIGKILL); + +#if defined(__APPLE__) + /* On OS X 10.3 the above SIGSTOP occasionally prevents the SIGKILL + from working. Just in case, we resume the child and kill it + again. There is a small race condition in this obscure case. If + the child manages to fork again between these two signals, we + will not catch its children. */ + kill(process_id, SIGCONT); + kill(process_id, SIGKILL); +#endif } /*--------------------------------------------------------------------------*/ diff --git a/Source/kwsys/ProcessWin32.c b/Source/kwsys/ProcessWin32.c index ae3bde1..c5ea6db 100644 --- a/Source/kwsys/ProcessWin32.c +++ b/Source/kwsys/ProcessWin32.c @@ -2516,6 +2516,11 @@ struct _SYSTEM_PROCESS_INFORMATION /*--------------------------------------------------------------------------*/ /* Toolhelp32 API definitions. */ #define TH32CS_SNAPPROCESS 0x00000002 +#if defined(_WIN64) +typedef unsigned __int64 ProcessULONG_PTR; +#else +typedef unsigned long ProcessULONG_PTR; +#endif typedef struct tagPROCESSENTRY32 PROCESSENTRY32; typedef PROCESSENTRY32* LPPROCESSENTRY32; struct tagPROCESSENTRY32 @@ -2523,7 +2528,7 @@ struct tagPROCESSENTRY32 DWORD dwSize; DWORD cntUsage; DWORD th32ProcessID; - DWORD th32DefaultHeapID; + ProcessULONG_PTR th32DefaultHeapID; DWORD th32ModuleID; DWORD cntThreads; DWORD th32ParentProcessID; diff --git a/Source/kwsys/SharedForward.h.in b/Source/kwsys/SharedForward.h.in index 53b74c6..da62d84 100644 --- a/Source/kwsys/SharedForward.h.in +++ b/Source/kwsys/SharedForward.h.in @@ -194,31 +194,27 @@ static const char kwsys_shared_forward_path_slash[2] = {KWSYS_SHARED_FORWARD_PAT # define KWSYS_SHARED_FORWARD_LDD "ldd" # define KWSYS_SHARED_FORWARD_LDD_N 1 # define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH" -#endif /* FreeBSD */ -#if defined(__FreeBSD__) +#elif defined(__FreeBSD__) # define KWSYS_SHARED_FORWARD_LDD "ldd" # define KWSYS_SHARED_FORWARD_LDD_N 1 # define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH" -#endif /* OSX */ -#if defined(__APPLE__) +#elif defined(__APPLE__) # define KWSYS_SHARED_FORWARD_LDD "otool", "-L" # define KWSYS_SHARED_FORWARD_LDD_N 2 # define KWSYS_SHARED_FORWARD_LDPATH "DYLD_LIBRARY_PATH" -#endif /* AIX */ -#if defined(_AIX) +#elif defined(_AIX) # define KWSYS_SHARED_FORWARD_LDD "dump", "-H" # define KWSYS_SHARED_FORWARD_LDD_N 2 # define KWSYS_SHARED_FORWARD_LDPATH "LIBPATH" -#endif /* SUN */ -#if defined(__sparc) && !defined(__linux) +#elif defined(__sun) # define KWSYS_SHARED_FORWARD_LDD "ldd" # define KWSYS_SHARED_FORWARD_LDD_N 1 # include <sys/isa_defs.h> @@ -227,10 +223,9 @@ static const char kwsys_shared_forward_path_slash[2] = {KWSYS_SHARED_FORWARD_PAT # elif defined(_LP64) # define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH_64" # endif -#endif /* HP-UX */ -#if defined(__hpux) +#elif defined(__hpux) # define KWSYS_SHARED_FORWARD_LDD "chatr" # define KWSYS_SHARED_FORWARD_LDD_N 1 # if defined(__LP64__) @@ -238,10 +233,9 @@ static const char kwsys_shared_forward_path_slash[2] = {KWSYS_SHARED_FORWARD_PAT # else # define KWSYS_SHARED_FORWARD_LDPATH "SHLIB_PATH" # endif -#endif /* SGI MIPS */ -#if defined(__sgi) && defined(_MIPS_SIM) +#elif defined(__sgi) && defined(_MIPS_SIM) # define KWSYS_SHARED_FORWARD_LDD "ldd" # define KWSYS_SHARED_FORWARD_LDD_N 1 # if _MIPS_SIM == _ABIO32 @@ -251,19 +245,19 @@ static const char kwsys_shared_forward_path_slash[2] = {KWSYS_SHARED_FORWARD_PAT # elif _MIPS_SIM == _ABI64 # define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY64_PATH" # endif -#endif + +/* Cygwin */ +#elif defined(__CYGWIN__) +# define KWSYS_SHARED_FORWARD_LDD "cygcheck" /* TODO: cygwin 1.7 has ldd */ +# define KWSYS_SHARED_FORWARD_LDD_N 1 +# define KWSYS_SHARED_FORWARD_LDPATH "PATH" /* Windows */ -#if defined(_WIN32) -# if defined(__CYGWIN__) -# define KWSYS_SHARED_FORWARD_LDD "cygcheck" -# define KWSYS_SHARED_FORWARD_LDD_N 1 -# endif +#elif defined(_WIN32) # define KWSYS_SHARED_FORWARD_LDPATH "PATH" -#endif /* Guess on this unknown system. */ -#if !defined(KWSYS_SHARED_FORWARD_LDPATH) +#else # define KWSYS_SHARED_FORWARD_LDD "ldd" # define KWSYS_SHARED_FORWARD_LDD_N 1 # define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH" diff --git a/Source/kwsys/String.hxx.in b/Source/kwsys/String.hxx.in index 424f61d..4386c9e 100644 --- a/Source/kwsys/String.hxx.in +++ b/Source/kwsys/String.hxx.in @@ -25,7 +25,7 @@ namespace @KWSYS_NAMESPACE@ * simply a subclass of this type with the same interface so that the * name is shorter in debugging symbols and error messages. */ -class @KWSYS_NAMESPACE@_EXPORT String: public @KWSYS_NAMESPACE@_stl::string +class String: public @KWSYS_NAMESPACE@_stl::string { /** The original string type. */ typedef @KWSYS_NAMESPACE@_stl::string stl_string; diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index 23d396f..7041d38 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -13,6 +13,18 @@ # include <winsock.h> // WSADATA, include before sys/types.h #endif +// TODO: +// We need an alternative implementation for many functions in this file +// when USE_ASM_INSTRUCTIONS gets defined as 0. +// +// Consider using these on Win32/Win64 for some of them: +// +// IsProcessorFeaturePresent +// http://msdn.microsoft.com/en-us/library/ms724482(VS.85).aspx +// +// GetProcessMemoryInfo +// http://msdn.microsoft.com/en-us/library/ms683219(VS.85).aspx + #include "kwsysPrivate.h" #include KWSYS_HEADER(FundamentalType.h) #include KWSYS_HEADER(stl/string) @@ -22,6 +34,7 @@ #include KWSYS_HEADER(Process.h) #include KWSYS_HEADER(ios/iostream) #include KWSYS_HEADER(ios/sstream) + // Work-around CMake dependency scanning limitation. This must // duplicate the above list of headers. #if 0 @@ -36,7 +49,6 @@ # include "kwsys_ios_iostream.h.in" #endif - #ifndef WIN32 # include <sys/utsname.h> // int uname(struct utsname *buf); #endif @@ -76,7 +88,6 @@ #include <string.h> - namespace KWSYS_NAMESPACE { @@ -89,12 +100,13 @@ namespace KWSYS_NAMESPACE # error "No Long Long" #endif + // Define SystemInformationImplementation class typedef void (*DELAY_FUNC)(unsigned int uiMS); - -class SystemInformationImplementation -{ + +class SystemInformationImplementation +{ public: SystemInformationImplementation (); ~SystemInformationImplementation (); @@ -128,21 +140,22 @@ public: bool DoesCPUSupportCPUID(); // Retrieve memory information in megabyte. - unsigned long GetTotalVirtualMemory(); - unsigned long GetAvailableVirtualMemory(); - unsigned long GetTotalPhysicalMemory(); - unsigned long GetAvailablePhysicalMemory(); + size_t GetTotalVirtualMemory(); + size_t GetAvailableVirtualMemory(); + size_t GetTotalPhysicalMemory(); + size_t GetAvailablePhysicalMemory(); /** Run the different checks */ void RunCPUCheck(); void RunOSCheck(); void RunMemoryCheck(); + public: #define VENDOR_STRING_LENGTH (12 + 1) #define CHIPNAME_STRING_LENGTH (48 + 1) #define SERIALNUMBER_STRING_LENGTH (29 + 1) - typedef struct tagID + typedef struct tagID { int Type; int Family; @@ -155,14 +168,14 @@ public: char SerialNumber[SERIALNUMBER_STRING_LENGTH]; } ID; - typedef struct tagCPUPowerManagement + typedef struct tagCPUPowerManagement { bool HasVoltageID; bool HasFrequencyID; bool HasTempSenseDiode; } CPUPowerManagement; - typedef struct tagCPUExtendedFeatures + typedef struct tagCPUExtendedFeatures { bool Has3DNow; bool Has3DNowPlus; @@ -173,9 +186,9 @@ public: unsigned int LogicalProcessorsPerPhysical; int APIC_ID; CPUPowerManagement PowerManagement; - } CPUExtendedFeatures; - - typedef struct CPUtagFeatures + } CPUExtendedFeatures; + + typedef struct CPUtagFeatures { bool HasFPU; bool HasTSC; @@ -196,13 +209,14 @@ public: int L3CacheSize; CPUExtendedFeatures ExtendedFeatures; } CPUFeatures; - - enum Manufacturer + + enum Manufacturer { - AMD, Intel, NSC, UMC, Cyrix, NexGen, IDT, Rise, Transmeta, Sun, IBM, Motorola, UnknownManufacturer + AMD, Intel, NSC, UMC, Cyrix, NexGen, IDT, Rise, Transmeta, Sun, IBM, + Motorola, UnknownManufacturer }; -protected: +protected: // Functions. bool RetrieveCPUFeatures(); bool RetrieveCPUIdentity(); @@ -216,7 +230,7 @@ protected: bool RetrieveCPUPowerManagement(); bool RetrieveClassicalCPUIdentity(); bool RetrieveExtendedCPUIdentity(); - + Manufacturer ChipManufacturer; CPUFeatures Features; ID ChipID; @@ -257,10 +271,10 @@ protected: // Evaluate the memory information. int QueryMemory(); - unsigned long TotalVirtualMemory; - unsigned long AvailableVirtualMemory; - unsigned long TotalPhysicalMemory; - unsigned long AvailablePhysicalMemory; + size_t TotalVirtualMemory; + size_t AvailableVirtualMemory; + size_t TotalPhysicalMemory; + size_t AvailablePhysicalMemory; size_t CurrentPositionInFile; @@ -272,17 +286,14 @@ protected: kwsys_stl::string OSVersion; kwsys_stl::string OSPlatform; }; - - - - + SystemInformation::SystemInformation() { this->Implementation = new SystemInformationImplementation; } -SystemInformation::~SystemInformation () +SystemInformation::~SystemInformation() { delete this->Implementation; } @@ -291,54 +302,67 @@ const char * SystemInformation::GetVendorString() { return this->Implementation->GetVendorString(); } + const char * SystemInformation::GetVendorID() { return this->Implementation->GetVendorID(); } + kwsys_stl::string SystemInformation::GetTypeID() { return this->Implementation->GetTypeID(); } + kwsys_stl::string SystemInformation::GetFamilyID() { return this->Implementation->GetFamilyID(); } + kwsys_stl::string SystemInformation::GetModelID() { return this->Implementation->GetModelID(); } + kwsys_stl::string SystemInformation::GetSteppingCode() { return this->Implementation->GetSteppingCode(); } + const char * SystemInformation::GetExtendedProcessorName() { return this->Implementation->GetExtendedProcessorName(); } + const char * SystemInformation::GetProcessorSerialNumber() { return this->Implementation->GetProcessorSerialNumber(); } + int SystemInformation::GetProcessorCacheSize() { return this->Implementation->GetProcessorCacheSize(); } + unsigned int SystemInformation::GetLogicalProcessorsPerPhysical() { return this->Implementation->GetLogicalProcessorsPerPhysical(); } + float SystemInformation::GetProcessorClockFrequency() { return this->Implementation->GetProcessorClockFrequency(); } + int SystemInformation::GetProcessorAPICID() { return this->Implementation->GetProcessorAPICID(); } + int SystemInformation::GetProcessorCacheXSize(long int l) { return this->Implementation->GetProcessorCacheXSize(l); } + bool SystemInformation::DoesCPUSupportFeature(long int i) { return this->Implementation->DoesCPUSupportFeature(i); @@ -348,18 +372,22 @@ const char * SystemInformation::GetOSName() { return this->Implementation->GetOSName(); } + const char * SystemInformation::GetHostname() { return this->Implementation->GetHostname(); } + const char * SystemInformation::GetOSRelease() { return this->Implementation->GetOSRelease(); } + const char * SystemInformation::GetOSVersion() { return this->Implementation->GetOSVersion(); } + const char * SystemInformation::GetOSPlatform() { return this->Implementation->GetOSPlatform(); @@ -374,6 +402,7 @@ unsigned int SystemInformation::GetNumberOfLogicalCPU() // per physical cpu { return this->Implementation->GetNumberOfLogicalCPU(); } + unsigned int SystemInformation::GetNumberOfPhysicalCPU() { return this->Implementation->GetNumberOfPhysicalCPU(); @@ -385,20 +414,22 @@ bool SystemInformation::DoesCPUSupportCPUID() } // Retrieve memory information in megabyte. -unsigned long SystemInformation::GetTotalVirtualMemory() +size_t SystemInformation::GetTotalVirtualMemory() { return this->Implementation->GetTotalVirtualMemory(); } -unsigned long SystemInformation::GetAvailableVirtualMemory() + +size_t SystemInformation::GetAvailableVirtualMemory() { return this->Implementation->GetAvailableVirtualMemory(); } -unsigned long SystemInformation::GetTotalPhysicalMemory() + +size_t SystemInformation::GetTotalPhysicalMemory() { return this->Implementation->GetTotalPhysicalMemory(); } -unsigned long SystemInformation::GetAvailablePhysicalMemory() +size_t SystemInformation::GetAvailablePhysicalMemory() { return this->Implementation->GetAvailablePhysicalMemory(); } @@ -408,17 +439,18 @@ void SystemInformation::RunCPUCheck() { this->Implementation->RunCPUCheck(); } + void SystemInformation::RunOSCheck() { this->Implementation->RunOSCheck(); } + void SystemInformation::RunMemoryCheck() { this->Implementation->RunMemoryCheck(); } - // -------------------------------------------------------------- // SystemInformationImplementation starts here @@ -440,29 +472,29 @@ void SystemInformation::RunMemoryCheck() #define CPUID_INSTRUCTION _asm _emit 0x0f _asm _emit 0xa2 #endif -#define MMX_FEATURE 0x00000001 -#define MMX_PLUS_FEATURE 0x00000002 -#define SSE_FEATURE 0x00000004 -#define SSE2_FEATURE 0x00000008 +#define MMX_FEATURE 0x00000001 +#define MMX_PLUS_FEATURE 0x00000002 +#define SSE_FEATURE 0x00000004 +#define SSE2_FEATURE 0x00000008 #define AMD_3DNOW_FEATURE 0x00000010 -#define AMD_3DNOW_PLUS_FEATURE 0x00000020 -#define IA64_FEATURE 0x00000040 -#define MP_CAPABLE 0x00000080 -#define HYPERTHREAD_FEATURE 0x00000100 -#define SERIALNUMBER_FEATURE 0x00000200 -#define APIC_FEATURE 0x00000400 -#define SSE_FP_FEATURE 0x00000800 +#define AMD_3DNOW_PLUS_FEATURE 0x00000020 +#define IA64_FEATURE 0x00000040 +#define MP_CAPABLE 0x00000080 +#define HYPERTHREAD_FEATURE 0x00000100 +#define SERIALNUMBER_FEATURE 0x00000200 +#define APIC_FEATURE 0x00000400 +#define SSE_FP_FEATURE 0x00000800 #define SSE_MMX_FEATURE 0x00001000 -#define CMOV_FEATURE 0x00002000 -#define MTRR_FEATURE 0x00004000 +#define CMOV_FEATURE 0x00002000 +#define MTRR_FEATURE 0x00004000 #define L1CACHE_FEATURE 0x00008000 #define L2CACHE_FEATURE 0x00010000 #define L3CACHE_FEATURE 0x00020000 -#define ACPI_FEATURE 0x00040000 -#define THERMALMONITOR_FEATURE 0x00080000 -#define TEMPSENSEDIODE_FEATURE 0x00100000 -#define FREQUENCYID_FEATURE 0x00200000 -#define VOLTAGEID_FREQUENCY 0x00400000 +#define ACPI_FEATURE 0x00040000 +#define THERMALMONITOR_FEATURE 0x00080000 +#define TEMPSENSEDIODE_FEATURE 0x00100000 +#define FREQUENCYID_FEATURE 0x00200000 +#define VOLTAGEID_FREQUENCY 0x00400000 // Status Flag #define HT_NOT_CAPABLE 0 @@ -489,7 +521,6 @@ void SystemInformation::RunMemoryCheck() // Default value = 0xff if HT is not supported - SystemInformationImplementation::SystemInformationImplementation() { this->TotalVirtualMemory = 0; @@ -518,32 +549,48 @@ void SystemInformationImplementation::RunCPUCheck() { #ifdef WIN32 // Check to see if this processor supports CPUID. - if (DoesCPUSupportCPUID()) + bool supportsCPUID = DoesCPUSupportCPUID(); + + if (supportsCPUID) { // Retrieve the CPU details. RetrieveCPUIdentity(); RetrieveCPUFeatures(); - if (!RetrieveCPUClockSpeed()) - { - RetrieveClassicalCPUClockSpeed(); - } + } - // Attempt to retrieve cache information. + // These two may be called without support for the CPUID instruction. + // (But if the instruction is there, they should be called *after* + // the above call to RetrieveCPUIdentity... that's why the two if + // blocks exist with the same "if (supportsCPUID)" logic... + // + if (!RetrieveCPUClockSpeed()) + { + RetrieveClassicalCPUClockSpeed(); + } + + if (supportsCPUID) + { + // Retrieve cache information. if (!RetrieveCPUCacheDetails()) { RetrieveClassicalCPUCacheDetails(); } + // Retrieve the extended CPU details. if (!RetrieveExtendedCPUIdentity()) { RetrieveClassicalCPUIdentity(); } + RetrieveExtendedCPUFeatures(); + RetrieveCPUPowerManagement(); // Now attempt to retrieve the serial number (if possible). RetrieveProcessorSerialNumber(); } + this->CPUCount(); + #elif defined(__APPLE__) this->ParseSysCtl(); #elif defined (__SVR4) && defined (__sun) @@ -559,7 +606,7 @@ void SystemInformationImplementation::RunOSCheck() { this->QueryOSInformation(); } - + void SystemInformationImplementation::RunMemoryCheck() { #if defined(__APPLE__) @@ -613,7 +660,7 @@ const char* SystemInformationImplementation::GetOSPlatform() const char * SystemInformationImplementation::GetVendorID() { // Return the vendor ID. - switch (this->ChipManufacturer) + switch (this->ChipManufacturer) { case Intel: return "Intel Corporation"; @@ -716,7 +763,7 @@ int SystemInformationImplementation::GetProcessorCacheSize() /** Return the chosen cache size. */ int SystemInformationImplementation::GetProcessorCacheXSize(long int dwCacheID) { - switch (dwCacheID) + switch (dwCacheID) { case L1CACHE_FEATURE: return this->Features.L1CacheSize; @@ -728,6 +775,7 @@ int SystemInformationImplementation::GetProcessorCacheXSize(long int dwCacheID) return -1; } + bool SystemInformationImplementation::DoesCPUSupportFeature(long int dwFeature) { bool bHasFeature = false; @@ -801,6 +849,7 @@ bool SystemInformationImplementation::DoesCPUSupportFeature(long int dwFeature) return bHasFeature; } + void SystemInformationImplementation::Delay(unsigned int uiMS) { #ifdef WIN32 @@ -822,6 +871,7 @@ void SystemInformationImplementation::Delay(unsigned int uiMS) (void)uiMS; } + bool SystemInformationImplementation::DoesCPUSupportCPUID() { #if USE_ASM_INSTRUCTIONS @@ -857,19 +907,20 @@ bool SystemInformationImplementation::DoesCPUSupportCPUID() // The cpuid instruction succeeded. return true; + #else // Assume no cpuid instruction. return false; #endif } + bool SystemInformationImplementation::RetrieveCPUFeatures() { #if USE_ASM_INSTRUCTIONS int localCPUFeatures = 0; int localCPUAdvanced = 0; - // Use assembly to detect CPUID information... __try { _asm { @@ -905,17 +956,17 @@ bool SystemInformationImplementation::RetrieveCPUFeatures() } // Retrieve the features of CPU present. - this->Features.HasFPU = ((localCPUFeatures & 0x00000001) != 0); // FPU Present --> Bit 0 - this->Features.HasTSC = ((localCPUFeatures & 0x00000010) != 0); // TSC Present --> Bit 4 + this->Features.HasFPU = ((localCPUFeatures & 0x00000001) != 0); // FPU Present --> Bit 0 + this->Features.HasTSC = ((localCPUFeatures & 0x00000010) != 0); // TSC Present --> Bit 4 this->Features.HasAPIC = ((localCPUFeatures & 0x00000200) != 0); // APIC Present --> Bit 9 this->Features.HasMTRR = ((localCPUFeatures & 0x00001000) != 0); // MTRR Present --> Bit 12 this->Features.HasCMOV = ((localCPUFeatures & 0x00008000) != 0); // CMOV Present --> Bit 15 this->Features.HasSerial = ((localCPUFeatures & 0x00040000) != 0); // Serial Present --> Bit 18 this->Features.HasACPI = ((localCPUFeatures & 0x00400000) != 0); // ACPI Capable --> Bit 22 - this->Features.HasMMX = ((localCPUFeatures & 0x00800000) != 0); // MMX Present --> Bit 23 - this->Features.HasSSE = ((localCPUFeatures & 0x02000000) != 0); // SSE Present --> Bit 25 + this->Features.HasMMX = ((localCPUFeatures & 0x00800000) != 0); // MMX Present --> Bit 23 + this->Features.HasSSE = ((localCPUFeatures & 0x02000000) != 0); // SSE Present --> Bit 25 this->Features.HasSSE2 = ((localCPUFeatures & 0x04000000) != 0); // SSE2 Present --> Bit 26 - this->Features.HasThermal = ((localCPUFeatures & 0x20000000) != 0); // Thermal Monitor Present --> Bit 29 + this->Features.HasThermal = ((localCPUFeatures & 0x20000000) != 0); // Thermal Monitor Present --> Bit 29 this->Features.HasIA64 = ((localCPUFeatures & 0x40000000) != 0); // IA64 Present --> Bit 30 // Retrieve extended SSE capabilities if SSE is available. @@ -959,15 +1010,19 @@ bool SystemInformationImplementation::RetrieveCPUFeatures() this->Features.ExtendedFeatures.APIC_ID = ((localCPUAdvanced & 0xFF000000) >> 24); } } -#endif + return true; + +#else + return false; +#endif } /** Find the manufacturer given the vendor id */ void SystemInformationImplementation::FindManufacturer() { - if (strcmp (this->ChipID.Vendor, "GenuineIntel") == 0) this->ChipManufacturer = Intel; // Intel Corp. + if (strcmp (this->ChipID.Vendor, "GenuineIntel") == 0) this->ChipManufacturer = Intel; // Intel Corp. else if (strcmp (this->ChipID.Vendor, "UMC UMC UMC ") == 0) this->ChipManufacturer = UMC; // United Microelectronics Corp. else if (strcmp (this->ChipID.Vendor, "AuthenticAMD") == 0) this->ChipManufacturer = AMD; // Advanced Micro Devices else if (strcmp (this->ChipID.Vendor, "AMD ISBETTER") == 0) this->ChipManufacturer = AMD; // Advanced Micro Devices (1994) @@ -981,9 +1036,10 @@ void SystemInformationImplementation::FindManufacturer() else if (strcmp (this->ChipID.Vendor, "Sun") == 0) this->ChipManufacturer = Sun; // Sun Microelectronics else if (strcmp (this->ChipID.Vendor, "IBM") == 0) this->ChipManufacturer = IBM; // IBM Microelectronics else if (strcmp (this->ChipID.Vendor, "Motorola") == 0) this->ChipManufacturer = Motorola; // Motorola Microelectronics - else this->ChipManufacturer = UnknownManufacturer; // Unknown manufacturer + else this->ChipManufacturer = UnknownManufacturer; // Unknown manufacturer } + /** */ bool SystemInformationImplementation::RetrieveCPUIdentity() { @@ -1052,11 +1108,15 @@ bool SystemInformationImplementation::RetrieveCPUIdentity() this->ChipID.Family = ((localCPUSignature & 0x00000F00) >> 8); // Bits 11..8 Used this->ChipID.Model = ((localCPUSignature & 0x000000F0) >> 4); // Bits 7..4 Used this->ChipID.Revision = ((localCPUSignature & 0x0000000F) >> 0); // Bits 3..0 Used -#endif return true; + +#else + return false; +#endif } + /** */ bool SystemInformationImplementation::RetrieveCPUCacheDetails() { @@ -1174,6 +1234,7 @@ bool SystemInformationImplementation::RetrieveCPUCacheDetails() return ((this->Features.L1CacheSize == -1) && (this->Features.L2CacheSize == -1)) ? false : true; } + /** */ bool SystemInformationImplementation::RetrieveClassicalCPUCacheDetails() { @@ -1370,18 +1431,51 @@ bool SystemInformationImplementation::RetrieveClassicalCPUCacheDetails() this->Features.L3CacheSize = L3Unified; } -#endif return true; + +#else + return false; +#endif } + /** */ bool SystemInformationImplementation::RetrieveCPUClockSpeed() { + bool retrieved = false; + #if _WIN32 - // First of all we check to see if the RDTSC (0x0F, 0x31) instruction is supported. - if (!this->Features.HasTSC) + // First of all we check to see if the RDTSC (0x0F, 0x31) instruction is + // supported. If not, we fallback to trying to read this value from the + // registry: + // + if (!this->Features.HasTSC) { - return false; + HKEY hKey = NULL; + LONG err = RegOpenKeyEx(HKEY_LOCAL_MACHINE, + "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", 0, + KEY_READ, &hKey); + + if (ERROR_SUCCESS == err) + { + DWORD dwType = 0; + DWORD data = 0; + DWORD dwSize = sizeof(DWORD); + + err = RegQueryValueEx(hKey, "~MHz", 0, + &dwType, (LPBYTE) &data, &dwSize); + + if (ERROR_SUCCESS == err) + { + this->CPUSpeedInMHz = (float) data; + retrieved = true; + } + + RegCloseKey(hKey); + hKey = NULL; + } + + return retrieved; } unsigned int uiRepetitions = 1; @@ -1389,7 +1483,7 @@ bool SystemInformationImplementation::RetrieveCPUClockSpeed() __int64 i64Total = 0; __int64 i64Overhead = 0; - for (unsigned int nCounter = 0; nCounter < uiRepetitions; nCounter ++) + for (unsigned int nCounter = 0; nCounter < uiRepetitions; nCounter ++) { i64Total += GetCyclesDifference (SystemInformationImplementation::Delay, uiMSecPerRepetition); @@ -1407,12 +1501,13 @@ bool SystemInformationImplementation::RetrieveCPUClockSpeed() // Save the CPU speed. this->CPUSpeedInMHz = (float) i64Total; - return true; -#else - return false; + retrieved = true; #endif + + return retrieved; } + /** */ bool SystemInformationImplementation::RetrieveClassicalCPUClockSpeed() { @@ -1466,11 +1561,15 @@ bool SystemInformationImplementation::RetrieveClassicalCPUClockSpeed() // Save the clock speed. this->Features.CPUSpeed = (int) dFrequency; -#else + return true; + +#else + return false; #endif } + /** */ bool SystemInformationImplementation::RetrieveCPUExtendedLevelSupport(int CPULevelToCheck) { @@ -1516,7 +1615,7 @@ bool SystemInformationImplementation::RetrieveCPUExtendedLevelSupport(int CPULev return false; } } - + #if USE_ASM_INSTRUCTIONS // Use assembly to detect CPUID information... @@ -1564,6 +1663,7 @@ bool SystemInformationImplementation::RetrieveCPUExtendedLevelSupport(int CPULev return true; } + /** */ bool SystemInformationImplementation::RetrieveExtendedCPUFeatures() { @@ -1579,6 +1679,7 @@ bool SystemInformationImplementation::RetrieveExtendedCPUFeatures() { return false; } + #if USE_ASM_INSTRUCTIONS int localCPUExtendedFeatures = 0; @@ -1634,11 +1735,15 @@ bool SystemInformationImplementation::RetrieveExtendedCPUFeatures() { this->Features.ExtendedFeatures.HasMMXPlus = ((localCPUExtendedFeatures & 0x01000000) != 0); // Cyrix specific: Extended MMX --> Bit 24 } -#endif return true; + +#else + return false; +#endif } + /** */ bool SystemInformationImplementation::RetrieveProcessorSerialNumber() { @@ -1651,7 +1756,6 @@ bool SystemInformationImplementation::RetrieveProcessorSerialNumber() #if USE_ASM_INSTRUCTIONS int SerialNumber[3]; - // Use assembly to detect CPUID information... __try { _asm { @@ -1701,14 +1805,18 @@ bool SystemInformationImplementation::RetrieveProcessorSerialNumber() ((SerialNumber[2] & 0x00ff0000) >> 16), ((SerialNumber[2] & 0x0000ff00) >> 8), ((SerialNumber[2] & 0x000000ff) >> 0)); -#endif return true; + +#else + return false; +#endif } + /** */ bool SystemInformationImplementation::RetrieveCPUPowerManagement() -{ +{ // Check to see if what we are about to do is supported... if (!RetrieveCPUExtendedLevelSupport(static_cast<int>(0x80000007))) { @@ -1758,11 +1866,14 @@ bool SystemInformationImplementation::RetrieveCPUPowerManagement() this->Features.ExtendedFeatures.PowerManagement.HasFrequencyID = ((localCPUPowerManagement & 0x00000002) != 0); this->Features.ExtendedFeatures.PowerManagement.HasVoltageID = ((localCPUPowerManagement & 0x00000004) != 0); -#endif - return true; + +#else + return false; +#endif } + /** */ bool SystemInformationImplementation::RetrieveExtendedCPUIdentity() { @@ -1773,7 +1884,7 @@ bool SystemInformationImplementation::RetrieveExtendedCPUIdentity() return false; if (!RetrieveCPUExtendedLevelSupport(static_cast<int>(0x80000004))) return false; - + #if USE_ASM_INSTRUCTIONS int ProcessorNameStartPos = 0; int CPUExtendedIdentity[12]; @@ -1869,11 +1980,15 @@ bool SystemInformationImplementation::RetrieveExtendedCPUIdentity() // Now move the name forward so that there is no white space. memmove(this->ChipID.ProcessorName, &(this->ChipID.ProcessorName[ProcessorNameStartPos]), (CHIPNAME_STRING_LENGTH - ProcessorNameStartPos)); } -#endif return true; + +#else + return false; +#endif } + /** */ bool SystemInformationImplementation::RetrieveClassicalCPUIdentity() { @@ -2150,6 +2265,7 @@ bool SystemInformationImplementation::RetrieveClassicalCPUIdentity() return true; } + /** Extract a value from the CPUInfo file */ kwsys_stl::string SystemInformationImplementation::ExtractValueFromCpuInfoFile(kwsys_stl::string buffer,const char* word,size_t init) { @@ -2279,11 +2395,16 @@ int SystemInformationImplementation::QueryMemory() #elif _WIN32 #if _MSC_VER < 1300 MEMORYSTATUS ms; + ms.dwLength = sizeof(ms); GlobalMemoryStatus(&ms); #define MEM_VAL(value) dw##value #else MEMORYSTATUSEX ms; - GlobalMemoryStatusEx(&ms); + ms.dwLength = sizeof(ms); + if (0 == GlobalMemoryStatusEx(&ms)) + { + return 0; + } #define MEM_VAL(value) ull##value #endif unsigned long tv = ms.MEM_VAL(TotalVirtual); @@ -2446,24 +2567,24 @@ int SystemInformationImplementation::QueryMemory() } /** */ -unsigned long SystemInformationImplementation::GetTotalVirtualMemory() +size_t SystemInformationImplementation::GetTotalVirtualMemory() { return this->TotalVirtualMemory; } /** */ -unsigned long SystemInformationImplementation::GetAvailableVirtualMemory() +size_t SystemInformationImplementation::GetAvailableVirtualMemory() { return this->AvailableVirtualMemory; } -unsigned long SystemInformationImplementation::GetTotalPhysicalMemory() +size_t SystemInformationImplementation::GetTotalPhysicalMemory() { return this->TotalPhysicalMemory; } /** */ -unsigned long SystemInformationImplementation::GetAvailablePhysicalMemory() +size_t SystemInformationImplementation::GetAvailablePhysicalMemory() { return this->AvailablePhysicalMemory; } @@ -2515,6 +2636,7 @@ LongLong SystemInformationImplementation::GetCyclesDifference (DELAY_FUNC DelayF #endif } + /** Compute the delay overhead */ void SystemInformationImplementation::DelayOverhead(unsigned int uiMS) { @@ -2544,6 +2666,7 @@ void SystemInformationImplementation::DelayOverhead(unsigned int uiMS) unsigned char SystemInformationImplementation::LogicalCPUPerPhysicalCPU(void) { unsigned int Regebx = 0; + #if USE_ASM_INSTRUCTIONS if (!this->IsHyperThreadingSupported()) { @@ -2570,9 +2693,11 @@ unsigned char SystemInformationImplementation::LogicalCPUPerPhysicalCPU(void) return static_cast<unsigned char>(cores_per_package); } #endif + return static_cast<unsigned char> ((Regebx & NUM_LOGICAL_BITS) >> 16); } + /** Works only for windows */ unsigned int SystemInformationImplementation::IsHyperThreadingSupported() { @@ -2619,10 +2744,12 @@ unsigned int SystemInformationImplementation::IsHyperThreadingSupported() return 0; // Not genuine Intel processor } + /** Return the APIC Id. Works only for windows. */ unsigned char SystemInformationImplementation::GetAPICId() { unsigned int Regebx = 0; + #if USE_ASM_INSTRUCTIONS if (!this->IsHyperThreadingSupported()) { @@ -2635,9 +2762,11 @@ unsigned char SystemInformationImplementation::GetAPICId() mov Regebx, ebx } #endif + return static_cast<unsigned char>((Regebx & INITIAL_APIC_ID_BITS) >> 24); } + /** Count the number of CPUs. Works only on windows. */ int SystemInformationImplementation::CPUCount() { @@ -2751,18 +2880,21 @@ int SystemInformationImplementation::CPUCount() #endif } + /** Return the number of logical CPUs on the system */ unsigned int SystemInformationImplementation::GetNumberOfLogicalCPU() { return this->NumberOfLogicalCPU; } + /** Return the number of physical CPUs on the system */ unsigned int SystemInformationImplementation::GetNumberOfPhysicalCPU() { return this->NumberOfPhysicalCPU; } + /** For Mac use sysctlbyname calls to find system info */ bool SystemInformationImplementation::ParseSysCtl() { @@ -2771,7 +2903,7 @@ bool SystemInformationImplementation::ParseSysCtl() uint64_t value = 0; size_t len = sizeof(value); sysctlbyname("hw.memsize", &value, &len, NULL, 0); - this->TotalPhysicalMemory = value/1048576; + this->TotalPhysicalMemory = static_cast< size_t >( value/1048576 ); // Parse values for Mac this->AvailablePhysicalMemory = 0; @@ -2782,7 +2914,7 @@ bool SystemInformationImplementation::ParseSysCtl() { err = sysctlbyname("hw.pagesize", &value, &len, NULL, 0); int64_t available_memory = vmstat.free_count * value; - this->AvailablePhysicalMemory = available_memory / 1048576; + this->AvailablePhysicalMemory = static_cast< size_t >( available_memory / 1048576 ); } #ifdef VM_SWAPUSAGE @@ -2794,8 +2926,8 @@ bool SystemInformationImplementation::ParseSysCtl() err = sysctl(mib, miblen, &swap, &len, NULL, 0); if (err == 0) { - this->AvailableVirtualMemory = swap.xsu_avail/1048576; - this->TotalVirtualMemory = swap.xsu_total/1048576; + this->AvailableVirtualMemory = static_cast< size_t >( swap.xsu_avail/1048576 ); + this->TotalVirtualMemory = static_cast< size_t >( swap.xsu_total/1048576 ); } #else this->AvailableVirtualMemory = 0; @@ -2811,7 +2943,7 @@ bool SystemInformationImplementation::ParseSysCtl() len = sizeof(value); sysctlbyname("hw.cpufrequency", &value, &len, NULL, 0); - this->CPUSpeedInMHz = value / 1048576; + this->CPUSpeedInMHz = static_cast< float >( value )/ 1048576; // Chip family @@ -2859,14 +2991,14 @@ bool SystemInformationImplementation::ParseSysCtl() // Chip Model len = sizeof(value); err = sysctlbyname("machdep.cpu.model", &value, &len, NULL, 0); - this->ChipID.Model = value; + this->ChipID.Model = static_cast< int >( value ); } // Cache size len = sizeof(value); err = sysctlbyname("hw.l1icachesize", &value, &len, NULL, 0); - this->Features.L1CacheSize = value; + this->Features.L1CacheSize = static_cast< int >( value ); err = sysctlbyname("hw.l2cachesize", &value, &len, NULL, 0); - this->Features.L2CacheSize = value; + this->Features.L2CacheSize = static_cast< int >( value ); return true; #else @@ -2874,6 +3006,7 @@ bool SystemInformationImplementation::ParseSysCtl() #endif } + /** Extract a value from sysctl command */ kwsys_stl::string SystemInformationImplementation::ExtractValueFromSysCtl(const char* word) { @@ -2890,6 +3023,7 @@ kwsys_stl::string SystemInformationImplementation::ExtractValueFromSysCtl(const return ""; } + /** Run a given process */ kwsys_stl::string SystemInformationImplementation::RunProcess(kwsys_stl::vector<const char*> args) { @@ -2950,7 +3084,7 @@ kwsys_stl::string SystemInformationImplementation::RunProcess(kwsys_stl::vector< } return buffer; } - + kwsys_stl::string SystemInformationImplementation::ParseValueFromKStat(const char* arguments) { @@ -3019,6 +3153,7 @@ kwsys_stl::string SystemInformationImplementation::ParseValueFromKStat(const cha return value; } + /** Querying for system information from Solaris */ bool SystemInformationImplementation::QuerySolarisInfo() { @@ -3064,6 +3199,7 @@ bool SystemInformationImplementation::QuerySolarisInfo() return true; } + /** Querying for system information from Haiku OS */ bool SystemInformationImplementation::QueryHaikuInfo() { @@ -3129,10 +3265,14 @@ bool SystemInformationImplementation::QueryHaikuInfo() this->Features.L1CacheSize = 0; this->Features.L2CacheSize = 0; -#endif return true; + +#else + return false; +#endif } + /** Query the operating system information */ bool SystemInformationImplementation::QueryOSInformation() { @@ -3377,15 +3517,18 @@ bool SystemInformationImplementation::QueryOSInformation() this->OSVersion = unameInfo.version; this->OSPlatform = unameInfo.machine; } + #ifdef __APPLE__ this->CallSwVers(); #endif + #endif return true; } + void SystemInformationImplementation::CallSwVers() { #ifdef __APPLE__ @@ -3418,6 +3561,7 @@ void SystemInformationImplementation::CallSwVers() #endif } + void SystemInformationImplementation::TrimNewline(kwsys_stl::string& output) { // remove \r @@ -3435,10 +3579,12 @@ void SystemInformationImplementation::TrimNewline(kwsys_stl::string& output) } } + /** Return true if the machine is 64 bits */ bool SystemInformationImplementation::Is64Bits() { return (sizeof(void*) == 8); } + } // namespace @KWSYS_NAMESPACE@ diff --git a/Source/kwsys/SystemInformation.hxx.in b/Source/kwsys/SystemInformation.hxx.in index 9d073c4c..b6ebe6a 100644 --- a/Source/kwsys/SystemInformation.hxx.in +++ b/Source/kwsys/SystemInformation.hxx.in @@ -19,6 +19,7 @@ # define kwsys_ios @KWSYS_NAMESPACE@_ios #endif #include <@KWSYS_NAMESPACE@/stl/string> +#include <stddef.h> /* size_t */ namespace @KWSYS_NAMESPACE@ { @@ -63,10 +64,10 @@ public: bool DoesCPUSupportCPUID(); // Retrieve memory information in megabyte. - unsigned long GetTotalVirtualMemory(); - unsigned long GetAvailableVirtualMemory(); - unsigned long GetTotalPhysicalMemory(); - unsigned long GetAvailablePhysicalMemory(); + size_t GetTotalVirtualMemory(); + size_t GetAvailableVirtualMemory(); + size_t GetTotalPhysicalMemory(); + size_t GetAvailablePhysicalMemory(); /** Run the different checks */ void RunCPUCheck(); diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index a6dee1b..1c00621 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -287,7 +287,7 @@ extern int putenv (char *__string) __THROW; # define FTIME _ftime # define TIMEB _timeb # endif -#elif defined( __CYGWIN__ ) || defined( __linux__ ) +#elif defined( __CYGWIN__ ) || defined( __linux__ ) || defined(__APPLE__) # include <sys/time.h> # include <time.h> # define HAVE_GETTIMEOFDAY diff --git a/Source/kwsys/kwsysPlatformTests.cmake b/Source/kwsys/kwsysPlatformTests.cmake index efff762..994b7e7 100644 --- a/Source/kwsys/kwsysPlatformTests.cmake +++ b/Source/kwsys/kwsysPlatformTests.cmake @@ -162,3 +162,55 @@ MACRO(KWSYS_PLATFORM_CXX_TEST_RUN var description invert) SET(KWSYS_PLATFORM_TEST_DEFINES) SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS) ENDMACRO(KWSYS_PLATFORM_CXX_TEST_RUN) + +#----------------------------------------------------------------------------- +# KWSYS_PLATFORM_INFO_TEST(lang var description) +# +# Compile test named by ${var} and store INFO strings extracted from binary. +MACRO(KWSYS_PLATFORM_INFO_TEST lang var description) + # We can implement this macro on CMake 2.6 and above. + IF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.6) + SET(${var} "") + ELSE() + # Choose a location for the result binary. + SET(KWSYS_PLATFORM_INFO_FILE + ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${var}.bin) + + # Compile the test binary. + IF(NOT DEFINED ${var}_COMPILED) + MESSAGE(STATUS "${description}") + TRY_COMPILE(${var}_COMPILED + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/${KWSYS_PLATFORM_TEST_FILE_${lang}} + COMPILE_DEFINITIONS -DTEST_${var} + ${KWSYS_PLATFORM_${lang}_TEST_DEFINES} + ${KWSYS_PLATFORM_${lang}_TEST_EXTRA_FLAGS} + OUTPUT_VARIABLE OUTPUT + COPY_FILE ${KWSYS_PLATFORM_INFO_FILE} + ) + IF(${var}_COMPILED) + FILE(APPEND + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "${description} compiled with the following output:\n${OUTPUT}\n\n") + ELSE() + FILE(APPEND + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "${description} failed to compile with the following output:\n${OUTPUT}\n\n") + ENDIF() + IF(${var}_COMPILED) + MESSAGE(STATUS "${description} - compiled") + ELSE() + MESSAGE(STATUS "${description} - failed") + ENDIF() + ENDIF() + + # Parse info strings out of the compiled binary. + IF(${var}_COMPILED) + FILE(STRINGS ${KWSYS_PLATFORM_INFO_FILE} ${var} REGEX "INFO:[A-Za-z0-9]+\\[[^]]*\\]") + ELSE() + SET(${var} "") + ENDIF() + + SET(KWSYS_PLATFORM_INFO_FILE) + ENDIF() +ENDMACRO() diff --git a/Source/kwsys/kwsysPlatformTestsC.c b/Source/kwsys/kwsysPlatformTestsC.c index 0d26347..e602964 100644 --- a/Source/kwsys/kwsysPlatformTestsC.c +++ b/Source/kwsys/kwsysPlatformTestsC.c @@ -60,3 +60,41 @@ int KWSYS_PLATFORM_TEST_C_MAIN() return f(n); } #endif + +/*--------------------------------------------------------------------------*/ +#ifdef TEST_KWSYS_C_TYPE_MACROS +char* info_macros = +#if defined(__SIZEOF_SHORT__) +"INFO:macro[__SIZEOF_SHORT__]\n" +#endif +#if defined(__SIZEOF_INT__) +"INFO:macro[__SIZEOF_INT__]\n" +#endif +#if defined(__SIZEOF_LONG__) +"INFO:macro[__SIZEOF_LONG__]\n" +#endif +#if defined(__SIZEOF_LONG_LONG__) +"INFO:macro[__SIZEOF_LONG_LONG__]\n" +#endif +#if defined(__SHORT_MAX__) +"INFO:macro[__SHORT_MAX__]\n" +#endif +#if defined(__INT_MAX__) +"INFO:macro[__INT_MAX__]\n" +#endif +#if defined(__LONG_MAX__) +"INFO:macro[__LONG_MAX__]\n" +#endif +#if defined(__LONG_LONG_MAX__) +"INFO:macro[__LONG_LONG_MAX__]\n" +#endif + ""; + +int KWSYS_PLATFORM_TEST_C_MAIN_ARGS(argc, argv) +{ + int require = 0; + require += info_macros[argc]; + (void)argv; + return require; +} +#endif diff --git a/Source/kwsys/kwsysPlatformTestsCXX.cxx b/Source/kwsys/kwsysPlatformTestsCXX.cxx index 4a19ef8..903be9b 100644 --- a/Source/kwsys/kwsysPlatformTestsCXX.cxx +++ b/Source/kwsys/kwsysPlatformTestsCXX.cxx @@ -113,6 +113,15 @@ void f(size_t) {} int main() { return 0; } #endif +#ifdef TEST_KWSYS_CXX_HAS_LONG_LONG +long long f(long long n) { return n; } +int main() +{ + long long n = 0; + return static_cast<int>(f(n)); +} +#endif + #ifdef TEST_KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS template <class T> class A; template <class T> int f(A<T>&); diff --git a/Templates/DLLHeader.dsptemplate b/Templates/DLLHeader.dsptemplate index eb703b2..c752fdb 100644 --- a/Templates/DLLHeader.dsptemplate +++ b/Templates/DLLHeader.dsptemplate @@ -53,7 +53,7 @@ RSC=rc.exe # PROP BASE Target_Dir ""
# PROP Use_MFC CMAKE_MFC_FLAG
# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "OUTPUT_DIRECTORY\Release"
+# PROP Output_Dir "OUTPUT_DIRECTORY_RELEASE"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
@@ -73,7 +73,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /dll /machine:I386
-# ADD LINK32 /nologo /dll TARGET_VERSION_FLAG /machine:I386 /out:"OUTPUT_DIRECTORY\Release/OUTPUT_NAME_RELEASE" TARGET_IMPLIB_FLAG_RELEASE
+# ADD LINK32 /nologo /dll TARGET_VERSION_FLAG /machine:I386 /out:"OUTPUT_DIRECTORY_RELEASE/OUTPUT_NAME_RELEASE" TARGET_IMPLIB_FLAG_RELEASE
CM_MULTILINE_OPTIONS_RELEASE
CMAKE_CUSTOM_RULE_CODE_RELEASE
@@ -87,7 +87,7 @@ CMAKE_CUSTOM_RULE_CODE_RELEASE # PROP BASE Target_Dir ""
# PROP Use_MFC CMAKE_MFC_FLAG
# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "OUTPUT_DIRECTORY\Debug"
+# PROP Output_Dir "OUTPUT_DIRECTORY_DEBUG"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
@@ -107,7 +107,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 /nologo /dll TARGET_VERSION_FLAG /debug /machine:I386 /out:"OUTPUT_DIRECTORY\Debug/OUTPUT_NAME_DEBUG" /pdbtype:sept TARGET_IMPLIB_FLAG_DEBUG
+# ADD LINK32 /nologo /dll TARGET_VERSION_FLAG /debug /machine:I386 /out:"OUTPUT_DIRECTORY_DEBUG/OUTPUT_NAME_DEBUG" /pdbtype:sept TARGET_IMPLIB_FLAG_DEBUG
CM_MULTILINE_OPTIONS_DEBUG
CMAKE_CUSTOM_RULE_CODE_DEBUG
@@ -122,7 +122,7 @@ CMAKE_CUSTOM_RULE_CODE_DEBUG # PROP BASE Target_Dir ""
# PROP Use_MFC CMAKE_MFC_FLAG
# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "OUTPUT_DIRECTORY\MinSizeRel"
+# PROP Output_Dir "OUTPUT_DIRECTORY_MINSIZEREL"
# PROP Intermediate_Dir "MinSizeRel"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
@@ -143,7 +143,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /dll /machine:I386
-# ADD LINK32 /nologo /dll TARGET_VERSION_FLAG /machine:I386 /out:"OUTPUT_DIRECTORY\MinSizeRel/OUTPUT_NAME_MINSIZEREL" TARGET_IMPLIB_FLAG_MINSIZEREL
+# ADD LINK32 /nologo /dll TARGET_VERSION_FLAG /machine:I386 /out:"OUTPUT_DIRECTORY_MINSIZEREL/OUTPUT_NAME_MINSIZEREL" TARGET_IMPLIB_FLAG_MINSIZEREL
CM_MULTILINE_OPTIONS_MINSIZEREL
CMAKE_CUSTOM_RULE_CODE_MINSIZEREL
@@ -157,7 +157,7 @@ CMAKE_CUSTOM_RULE_CODE_MINSIZEREL # PROP BASE Target_Dir ""
# PROP Use_MFC CMAKE_MFC_FLAG
# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "OUTPUT_DIRECTORY\RelWithDebInfo"
+# PROP Output_Dir "OUTPUT_DIRECTORY_RELWITHDEBINFO"
# PROP Intermediate_Dir "RelWithDebInfo"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
@@ -177,7 +177,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /dll /machine:I386 /pdbtype:sept
-# ADD LINK32 /nologo /dll TARGET_VERSION_FLAG /debug /machine:I386 /pdbtype:sept /out:"OUTPUT_DIRECTORY\RelWithDebInfo/OUTPUT_NAME_RELWITHDEBINFO" TARGET_IMPLIB_FLAG_RELWITHDEBINFO
+# ADD LINK32 /nologo /dll TARGET_VERSION_FLAG /debug /machine:I386 /pdbtype:sept /out:"OUTPUT_DIRECTORY_RELWITHDEBINFO/OUTPUT_NAME_RELWITHDEBINFO" TARGET_IMPLIB_FLAG_RELWITHDEBINFO
CM_MULTILINE_OPTIONS_RELWITHDEBINFO
CMAKE_CUSTOM_RULE_CODE_RELWITHDEBINFO
diff --git a/Templates/EXEHeader.dsptemplate b/Templates/EXEHeader.dsptemplate index a4c03dd..f48eacc 100644 --- a/Templates/EXEHeader.dsptemplate +++ b/Templates/EXEHeader.dsptemplate @@ -53,7 +53,7 @@ RSC=rc.exe # PROP BASE Target_Dir ""
# PROP Use_MFC CMAKE_MFC_FLAG
# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "OUTPUT_DIRECTORY\Release"
+# PROP Output_Dir "OUTPUT_DIRECTORY_RELEASE"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /FD /c
@@ -71,7 +71,7 @@ BSC32=bscmake.exe LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:console /machine:I386 /IGNORE:4089
# ADD LINK32 /nologo /subsystem:console /machine:I386 /IGNORE:4089 TARGET_VERSION_FLAG
-# ADD LINK32 /out:"OUTPUT_DIRECTORY\Release\OUTPUT_NAME_RELEASE" TARGET_IMPLIB_FLAG_RELEASE
+# ADD LINK32 /out:"OUTPUT_DIRECTORY_RELEASE\OUTPUT_NAME_RELEASE" TARGET_IMPLIB_FLAG_RELEASE
CM_MULTILINE_OPTIONS_RELEASE
CMAKE_CUSTOM_RULE_CODE_RELEASE
@@ -85,7 +85,7 @@ CMAKE_CUSTOM_RULE_CODE_RELEASE # PROP BASE Target_Dir ""
# PROP Use_MFC CMAKE_MFC_FLAG
# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "OUTPUT_DIRECTORY\Debug"
+# PROP Output_Dir "OUTPUT_DIRECTORY_DEBUG"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /FD /GZ /c
@@ -105,7 +105,7 @@ BSC32=bscmake.exe LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /IGNORE:4089
# ADD LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /IGNORE:4089 TARGET_VERSION_FLAG
-# ADD LINK32 /out:"OUTPUT_DIRECTORY\Debug\OUTPUT_NAME_DEBUG" TARGET_IMPLIB_FLAG_DEBUG
+# ADD LINK32 /out:"OUTPUT_DIRECTORY_DEBUG\OUTPUT_NAME_DEBUG" TARGET_IMPLIB_FLAG_DEBUG
CM_MULTILINE_OPTIONS_DEBUG
CMAKE_CUSTOM_RULE_CODE_DEBUG
@@ -118,7 +118,7 @@ CMAKE_CUSTOM_RULE_CODE_DEBUG # PROP BASE Target_Dir ""
# PROP Use_MFC CMAKE_MFC_FLAG
# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "OUTPUT_DIRECTORY\MinSizeRel"
+# PROP Output_Dir "OUTPUT_DIRECTORY_MINSIZEREL"
# PROP Intermediate_Dir "MinSizeRel"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /FD /c
@@ -136,7 +136,7 @@ BSC32=bscmake.exe LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:console /machine:I386 /IGNORE:4089
# ADD LINK32 /nologo /subsystem:console /machine:I386 /IGNORE:4089 TARGET_VERSION_FLAG
-# ADD LINK32 /out:"OUTPUT_DIRECTORY\MinSizeRel\OUTPUT_NAME_MINSIZEREL" TARGET_IMPLIB_FLAG_MINSIZEREL
+# ADD LINK32 /out:"OUTPUT_DIRECTORY_MINSIZEREL\OUTPUT_NAME_MINSIZEREL" TARGET_IMPLIB_FLAG_MINSIZEREL
CM_MULTILINE_OPTIONS_MINSIZEREL
CMAKE_CUSTOM_RULE_CODE_MINSIZEREL
@@ -150,7 +150,7 @@ CMAKE_CUSTOM_RULE_CODE_MINSIZEREL # PROP BASE Target_Dir ""
# PROP Use_MFC CMAKE_MFC_FLAG
# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "OUTPUT_DIRECTORY\RelWithDebInfo"
+# PROP Output_Dir "OUTPUT_DIRECTORY_RELWITHDEBINFO"
# PROP Intermediate_Dir "RelWithDebInfo"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /FD /c
@@ -168,7 +168,7 @@ BSC32=bscmake.exe LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /IGNORE:4089
# ADD LINK32 /nologo /subsystem:console /debug /machine:I386 /IGNORE:4089 TARGET_VERSION_FLAG
-# ADD LINK32 /out:"OUTPUT_DIRECTORY\RelWithDebInfo\OUTPUT_NAME_RELWITHDEBINFO" TARGET_IMPLIB_FLAG_RELWITHDEBINFO
+# ADD LINK32 /out:"OUTPUT_DIRECTORY_RELWITHDEBINFO\OUTPUT_NAME_RELWITHDEBINFO" TARGET_IMPLIB_FLAG_RELWITHDEBINFO
CM_MULTILINE_OPTIONS_RELWITHDEBINFO
CMAKE_CUSTOM_RULE_CODE_RELWITHDEBINFO
diff --git a/Templates/EXEWinHeader.dsptemplate b/Templates/EXEWinHeader.dsptemplate index c0c4971..e0d2264 100644 --- a/Templates/EXEWinHeader.dsptemplate +++ b/Templates/EXEWinHeader.dsptemplate @@ -53,7 +53,7 @@ RSC=rc.exe # PROP BASE Target_Dir ""
# PROP Use_MFC CMAKE_MFC_FLAG
# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "OUTPUT_DIRECTORY\Release"
+# PROP Output_Dir "OUTPUT_DIRECTORY_RELEASE"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
@@ -73,7 +73,7 @@ BSC32=bscmake.exe LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386 /IGNORE:4089
# ADD LINK32 /nologo /subsystem:windows /machine:I386 /IGNORE:4089 TARGET_VERSION_FLAG
-# ADD LINK32 /out:"OUTPUT_DIRECTORY\Release\OUTPUT_NAME_RELEASE" TARGET_IMPLIB_FLAG_RELEASE
+# ADD LINK32 /out:"OUTPUT_DIRECTORY_RELEASE\OUTPUT_NAME_RELEASE" TARGET_IMPLIB_FLAG_RELEASE
CM_MULTILINE_OPTIONS_RELEASE
CMAKE_CUSTOM_RULE_CODE_RELEASE
@@ -87,7 +87,7 @@ CMAKE_CUSTOM_RULE_CODE_RELEASE # PROP BASE Target_Dir ""
# PROP Use_MFC CMAKE_MFC_FLAG
# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "OUTPUT_DIRECTORY\Debug"
+# PROP Output_Dir "OUTPUT_DIRECTORY_DEBUG"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c
@@ -107,7 +107,7 @@ BSC32=bscmake.exe LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /IGNORE:4089
# ADD LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /IGNORE:4089 TARGET_VERSION_FLAG
-# ADD LINK32 /out:"OUTPUT_DIRECTORY\Debug\OUTPUT_NAME_DEBUG" TARGET_IMPLIB_FLAG_DEBUG
+# ADD LINK32 /out:"OUTPUT_DIRECTORY_DEBUG\OUTPUT_NAME_DEBUG" TARGET_IMPLIB_FLAG_DEBUG
CM_MULTILINE_OPTIONS_DEBUG
CMAKE_CUSTOM_RULE_CODE_DEBUG
@@ -120,7 +120,7 @@ CMAKE_CUSTOM_RULE_CODE_DEBUG # PROP BASE Target_Dir ""
# PROP Use_MFC CMAKE_MFC_FLAG
# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "OUTPUT_DIRECTORY\MinSizeRel"
+# PROP Output_Dir "OUTPUT_DIRECTORY_MINSIZEREL"
# PROP Intermediate_Dir "MinSizeRel"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
@@ -138,7 +138,7 @@ BSC32=bscmake.exe LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386 /pdbtype:sept /IGNORE:4089
# ADD LINK32 /nologo /subsystem:windows /machine:I386 /pdbtype:sept /IGNORE:4089 TARGET_VERSION_FLAG
-# ADD LINK32 /out:"OUTPUT_DIRECTORY\MinSizeRel\OUTPUT_NAME_MINSIZEREL" TARGET_IMPLIB_FLAG_MINSIZEREL
+# ADD LINK32 /out:"OUTPUT_DIRECTORY_MINSIZEREL\OUTPUT_NAME_MINSIZEREL" TARGET_IMPLIB_FLAG_MINSIZEREL
CM_MULTILINE_OPTIONS_MINSIZEREL
CMAKE_CUSTOM_RULE_CODE_MINSIZEREL
@@ -152,7 +152,7 @@ CMAKE_CUSTOM_RULE_CODE_MINSIZEREL # PROP BASE Target_Dir ""
# PROP Use_MFC CMAKE_MFC_FLAG
# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "OUTPUT_DIRECTORY\RelWithDebInfo"
+# PROP Output_Dir "OUTPUT_DIRECTORY_RELWITHDEBINFO"
# PROP Intermediate_Dir "RelWithDebInfo"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
@@ -172,7 +172,7 @@ BSC32=bscmake.exe LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386 /IGNORE:4089
# ADD LINK32 /nologo /subsystem:windows /debug /machine:I386 /IGNORE:4089 TARGET_VERSION_FLAG
-# ADD LINK32 /out:"OUTPUT_DIRECTORY\RelWithDebInfo\OUTPUT_NAME_RELWITHDEBINFO" TARGET_IMPLIB_FLAG_RELWITHDEBINFO
+# ADD LINK32 /out:"OUTPUT_DIRECTORY_RELWITHDEBINFO\OUTPUT_NAME_RELWITHDEBINFO" TARGET_IMPLIB_FLAG_RELWITHDEBINFO
CM_MULTILINE_OPTIONS_RELWITHDEBINFO
CMAKE_CUSTOM_RULE_CODE_RELWITHDEBINFO
diff --git a/Templates/staticLibHeader.dsptemplate b/Templates/staticLibHeader.dsptemplate index 57fad98..1b5c8bc 100644 --- a/Templates/staticLibHeader.dsptemplate +++ b/Templates/staticLibHeader.dsptemplate @@ -50,7 +50,7 @@ RSC=rc.exe # PROP BASE Target_Dir ""
# PROP Use_MFC CMAKE_MFC_FLAG
# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "OUTPUT_DIRECTORY\Release"
+# PROP Output_Dir "OUTPUT_DIRECTORY_RELEASE"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /D "WIN32" /D "NDEBUG" /D "_LIB" /FD /c
@@ -67,7 +67,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"OUTPUT_DIRECTORY\Release/OUTPUT_NAME_RELEASE" CM_STATIC_LIB_ARGS
+# ADD LIB32 /nologo /out:"OUTPUT_DIRECTORY_RELEASE/OUTPUT_NAME_RELEASE" CM_STATIC_LIB_ARGS
CMAKE_CUSTOM_RULE_CODE_RELEASE
@@ -80,7 +80,7 @@ CMAKE_CUSTOM_RULE_CODE_RELEASE # PROP BASE Target_Dir ""
# PROP Use_MFC CMAKE_MFC_FLAG
# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "OUTPUT_DIRECTORY\Debug"
+# PROP Output_Dir "OUTPUT_DIRECTORY_DEBUG"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /D "WIN32" /D "_DEBUG" /D "_LIB" /FD /c
@@ -97,7 +97,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"OUTPUT_DIRECTORY\Debug/OUTPUT_NAME_DEBUG" CM_STATIC_LIB_ARGS
+# ADD LIB32 /nologo /out:"OUTPUT_DIRECTORY_DEBUG/OUTPUT_NAME_DEBUG" CM_STATIC_LIB_ARGS
CMAKE_CUSTOM_RULE_CODE_DEBUG
@@ -110,7 +110,7 @@ CMAKE_CUSTOM_RULE_CODE_DEBUG # PROP BASE Target_Dir ""
# PROP Use_MFC CMAKE_MFC_FLAG
# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "OUTPUT_DIRECTORY\MinSizeRel"
+# PROP Output_Dir "OUTPUT_DIRECTORY_MINSIZEREL"
# PROP Intermediate_Dir "MinSizeRel"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
@@ -128,7 +128,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"OUTPUT_DIRECTORY\MinSizeRel/OUTPUT_NAME_MINSIZEREL" CM_STATIC_LIB_ARGS
+# ADD LIB32 /nologo /out:"OUTPUT_DIRECTORY_MINSIZEREL/OUTPUT_NAME_MINSIZEREL" CM_STATIC_LIB_ARGS
CMAKE_CUSTOM_RULE_CODE_MINSIZEREL
@@ -141,7 +141,7 @@ CMAKE_CUSTOM_RULE_CODE_MINSIZEREL # PROP BASE Target_Dir ""
# PROP Use_MFC CMAKE_MFC_FLAG
# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "OUTPUT_DIRECTORY\RelWithDebInfo"
+# PROP Output_Dir "OUTPUT_DIRECTORY_RELWITHDEBINFO"
# PROP Intermediate_Dir "RelWithDebInfo"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /D "WIN32" /D "NDEBUG" /D "_LIB" /FD /c
@@ -158,7 +158,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"OUTPUT_DIRECTORY\RelWithDebInfo/OUTPUT_NAME_RELWITHDEBINFO" CM_STATIC_LIB_ARGS
+# ADD LIB32 /nologo /out:"OUTPUT_DIRECTORY_RELWITHDEBINFO/OUTPUT_NAME_RELWITHDEBINFO" CM_STATIC_LIB_ARGS
CMAKE_CUSTOM_RULE_CODE_RELWITHDEBINFO
diff --git a/Tests/Architecture/CMakeLists.txt b/Tests/Architecture/CMakeLists.txt new file mode 100644 index 0000000..bc767fe --- /dev/null +++ b/Tests/Architecture/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 2.8) +project(Architecture C) + +add_library(foo foo.c) +if(CMAKE_OSX_ARCHITECTURES) + get_property(archs TARGET foo PROPERTY OSX_ARCHITECTURES) + if(NOT "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "${archs}") + message(FATAL_ERROR + "OSX_ARCHITECTURES property not initialized by CMAKE_OSX_ARCHITECTURES.\n" + "Expected [${CMAKE_OSX_ARCHITECTURES}], got [${archs}]." + ) + endif() +endif() +set_property(TARGET foo PROPERTY OSX_ARCHITECTURES i386) +set_property(TARGET foo PROPERTY OSX_ARCHITECTURES_DEBUG ppc) + +add_executable(bar bar.c) +target_link_libraries(bar foo) +set_property(TARGET bar PROPERTY OUTPUT_NAME Architecture) +set_property(TARGET bar PROPERTY OSX_ARCHITECTURES ppc) +set_property(TARGET bar PROPERTY OSX_ARCHITECTURES_DEBUG i386) diff --git a/Tests/Architecture/bar.c b/Tests/Architecture/bar.c new file mode 100644 index 0000000..923c89c --- /dev/null +++ b/Tests/Architecture/bar.c @@ -0,0 +1,2 @@ +extern int foo(void); +int main() { return foo(); } diff --git a/Tests/Architecture/foo.c b/Tests/Architecture/foo.c new file mode 100644 index 0000000..e35694b --- /dev/null +++ b/Tests/Architecture/foo.c @@ -0,0 +1 @@ +int foo(void) { return 0; } diff --git a/Tests/CMakeCommands/build_command/CMakeLists.txt b/Tests/CMakeCommands/build_command/CMakeLists.txt new file mode 100644 index 0000000..990ac90 --- /dev/null +++ b/Tests/CMakeCommands/build_command/CMakeLists.txt @@ -0,0 +1,58 @@ +# This CMakeLists file is *sometimes expected* to result in a configure error. +# +# expect this to succeed: +# ../bin/Release/cmake -G Xcode +# ../../CMake/Tests/CMakeCommands/build_command +# +# expect this to fail: +# ../bin/Release/cmake -DTEST_ERROR_CONDITIONS:BOOL=ON -G Xcode +# ../../CMake/Tests/CMakeCommands/build_command +# +# This project exists merely to test the CMake command 'build_command'... +# ...even purposefully calling it with known-bad argument lists to cover +# error handling code. +# +cmake_minimum_required(VERSION 2.8) +project(test_build_command) + +set(cmd "initial") + +message("CTEST_FULL_OUTPUT") +message("0. begin") + +if(TEST_ERROR_CONDITIONS) + # Test with no arguments (an error): + build_command() + message("1. cmd='${cmd}'") + + # Test with unknown arguments (also an error): + build_command(cmd BOGUS STUFF) + message("2. cmd='${cmd}'") + + build_command(cmd STUFF BOGUS) + message("3. cmd='${cmd}'") +else() + message("(skipping cases 1, 2 and 3 because TEST_ERROR_CONDITIONS is OFF)") +endif() + +# Test the one arg signature with none of the optional KEYWORD arguments: +build_command(cmd) +message("4. cmd='${cmd}'") + +# Test the two-arg legacy signature: +build_command(legacy_cmd ${CMAKE_BUILD_TOOL}) +message("5. legacy_cmd='${legacy_cmd}'") +message(" CMAKE_BUILD_TOOL='${CMAKE_BUILD_TOOL}'") + +# Test the optional KEYWORDs: +build_command(cmd CONFIGURATION hoohaaConfig) +message("6. cmd='${cmd}'") + +build_command(cmd PROJECT_NAME hoohaaProject) +message("7. cmd='${cmd}'") + +build_command(cmd TARGET hoohaaTarget) +message("8. cmd='${cmd}'") + +set(cmd "final") +message("9. cmd='${cmd}'") diff --git a/Tests/CMakeCommands/build_command/RunCMake.cmake b/Tests/CMakeCommands/build_command/RunCMake.cmake new file mode 100644 index 0000000..55d9359 --- /dev/null +++ b/Tests/CMakeCommands/build_command/RunCMake.cmake @@ -0,0 +1,86 @@ +if(NOT DEFINED CMake_SOURCE_DIR) + message(FATAL_ERROR "CMake_SOURCE_DIR not defined") +endif() + +if(NOT DEFINED dir) + message(FATAL_ERROR "dir not defined") +endif() + +if(NOT DEFINED gen) + message(FATAL_ERROR "gen not defined") +endif() + +message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") + +# Run cmake: +# +function(run_cmake build_dir extra_args expected_result expected_output expected_error) + message(STATUS "run_cmake build_dir='${build_dir}' extra_args='${extra_args}'") + + # Ensure build_dir exists: + # + execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${build_dir}) + + # Run cmake: + # + execute_process(COMMAND ${CMAKE_COMMAND} + ${extra_args} + -G ${gen} ${CMake_SOURCE_DIR}/Tests/CMakeCommands/build_command + RESULT_VARIABLE result + OUTPUT_VARIABLE stdout + ERROR_VARIABLE stderr + WORKING_DIRECTORY ${build_dir} + ) + + message(STATUS "result='${result}'") + message(STATUS "stdout='${stdout}'") + message(STATUS "stderr='${stderr}'") + message(STATUS "") + + # Verify result and output match expectations: + # + if("0" STREQUAL "${expected_result}") + if(NOT "${result}" STREQUAL "0") + message(FATAL_ERROR + "error: result='${result}' is non-zero and different than expected_result='${expected_result}'") + endif() + else() + if("${result}" STREQUAL "0") + message(FATAL_ERROR + "error: result='${result}' is zero and different than expected_result='${expected_result}'") + endif() + endif() + + foreach(e ${expected_output}) + if(NOT stdout MATCHES "${e}") + message(FATAL_ERROR + "error: stdout does not match expected_output item e='${e}'") + else() + message(STATUS "info: stdout matches '${e}'") + endif() + endforeach() + + foreach(e ${expected_error}) + if(NOT stderr MATCHES "${e}") + message(FATAL_ERROR + "error: stderr does not match expected_error item e='${e}'") + else() + message(STATUS "info: stderr matches '${e}'") + endif() + endforeach() + + message(STATUS "result, stdout and stderr match all expectations: test passes") + message(STATUS "") +endfunction() + + +# Expect this case to succeed: +run_cmake("${dir}/b1" "" 0 + "Build files have been written to:" + "skipping cases 1, 2 and 3 because TEST_ERROR_CONDITIONS is OFF") + + +# Expect this one to fail: +run_cmake("${dir}/b2" "-DTEST_ERROR_CONDITIONS:BOOL=ON" 1 + "Configuring incomplete, errors occurred!" + "build_command requires at least one argument naming a CMake variable;build_command unknown argument ") diff --git a/Tests/CMakeInstall.cmake b/Tests/CMakeInstall.cmake new file mode 100644 index 0000000..f141b53 --- /dev/null +++ b/Tests/CMakeInstall.cmake @@ -0,0 +1,48 @@ +# Define option CMake_TEST_INSTALL, and enable by default for dashboards. +set(_default 0) +if(DEFINED ENV{DASHBOARD_TEST_FROM_CTEST}) + set(_default 1) +endif() +option(CMake_TEST_INSTALL "Test CMake Installation" ${_default}) +mark_as_advanced(CMake_TEST_INSTALL) + +if(CMake_TEST_INSTALL) + # Do not build during the test. + set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY 1) + + # Install to a test directory. + set(CMake_TEST_INSTALL_PREFIX ${CMake_BINARY_DIR}/Tests/CMakeInstall) + set(CMAKE_INSTALL_PREFIX "${CMake_TEST_INSTALL_PREFIX}") + + if(CMAKE_CONFIGURATION_TYPES) + # There are multiple configurations. Make sure the tested + # configuration is the one that is installed. + set(CMake_TEST_INSTALL_CONFIG -C "\${CTEST_CONFIGURATION_TYPE}") + else() + set(CMake_TEST_INSTALL_CONFIG) + endif() + + # The CTest of the CMake used to build this CMake. + if(CMAKE_CTEST_COMMAND) + set(CMake_TEST_INSTALL_CTest ${CMAKE_CTEST_COMMAND}) + else() + set(CMake_TEST_INSTALL_CTest ${CMake_BIN_DIR}/ctest) + endif() + + # Add a test to install CMake through the build system install target. + add_test(CMake.Install + ${CMake_TEST_INSTALL_CTest} + ${CMake_TEST_INSTALL_CONFIG} + --build-and-test ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} + --build-generator ${CMAKE_GENERATOR} # Not CMAKE_TEST_GENERATOR + --build-project CMake + --build-makeprogram ${CMAKE_MAKE_PROGRAM} # Not CMAKE_TEST_MAKEPROGRAM + --build-nocmake + --build-noclean + --build-target install) + + # TODO: Make all other tests depend on this one, and then drive them + # with the installed CTest. +else() + set(CMake_TEST_INSTALL_PREFIX) +endif() diff --git a/Tests/CMakeLib/CMakeLists.txt b/Tests/CMakeLib/CMakeLists.txt new file mode 100644 index 0000000..bda2fa5 --- /dev/null +++ b/Tests/CMakeLib/CMakeLists.txt @@ -0,0 +1,32 @@ +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMake_BINARY_DIR}/Source + ${CMake_SOURCE_DIR}/Source + ) + +set(CMakeLib_TESTS + testUTF8 + testXMLParser + testXMLSafe + ) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/testXMLParser.h.in + ${CMAKE_CURRENT_BINARY_DIR}/testXMLParser.h @ONLY) + +create_test_sourcelist(CMakeLib_TEST_SRCS CMakeLibTests.cxx ${CMakeLib_TESTS}) +add_executable(CMakeLibTests ${CMakeLib_TEST_SRCS}) +target_link_libraries(CMakeLibTests CMakeLib) + +# Xcode 2.x forgets to create the output directory before linking +# the individual architectures. +if(CMAKE_OSX_ARCHITECTURES AND XCODE + AND NOT "${XCODE_VERSION}" MATCHES "^[^12]") + add_custom_command( + TARGET CMakeLibTests + PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CFG_INTDIR}" + ) +endif() + +foreach(test ${CMakeLib_TESTS}) + add_test(CMakeLib.${test} CMakeLibTests ${test}) +endforeach() diff --git a/Tests/CMakeLib/testUTF8.cxx b/Tests/CMakeLib/testUTF8.cxx new file mode 100644 index 0000000..4ab96cf --- /dev/null +++ b/Tests/CMakeLib/testUTF8.cxx @@ -0,0 +1,125 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + 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. +============================================================================*/ +#include <cm_utf8.h> + +#include <string.h> +#include <stdio.h> + +typedef char test_utf8_char[5]; + +static void test_utf8_char_print(test_utf8_char const c) +{ + unsigned char const* d = reinterpret_cast<unsigned char const*>(c); + printf("[0x%02X,0x%02X,0x%02X,0x%02X]", + (int)d[0], (int)d[1], (int)d[2], (int)d[3]); +} + +struct test_utf8_entry +{ + int n; + test_utf8_char str; + unsigned int chr; +}; + +static test_utf8_entry const good_entry[] = { + {1, "\x20\x00\x00\x00", 0x0020}, /* Space. */ + {2, "\xC2\xA9\x00\x00", 0x00A9}, /* Copyright. */ + {3, "\xE2\x80\x98\x00", 0x2018}, /* Open-single-quote. */ + {3, "\xE2\x80\x99\x00", 0x2019}, /* Close-single-quote. */ + {4, "\xF0\xA3\x8E\xB4", 0x233B4}, /* Example from RFC 3629. */ + {0, {0,0,0,0,0}, 0} +}; + +static test_utf8_char const bad_chars[] = { + "\x80\x00\x00\x00", + "\xC0\x00\x00\x00", + "\xE0\x00\x00\x00", + "\xE0\x80\x80\x00", + "\xF0\x80\x80\x80", + {0,0,0,0,0} +}; + +static void report_good(bool passed, test_utf8_char const c) +{ + printf("%s: decoding good ", passed?"pass":"FAIL"); + test_utf8_char_print(c); + printf(" (%s) ", c); +} + +static void report_bad(bool passed, test_utf8_char const c) +{ + printf("%s: decoding bad ", passed?"pass":"FAIL"); + test_utf8_char_print(c); + printf(" "); +} + +static bool decode_good(test_utf8_entry const entry) +{ + unsigned int uc; + if(const char* e = cm_utf8_decode_character(entry.str, entry.str+4, &uc)) + { + int used = static_cast<int>(e-entry.str); + if(uc != entry.chr) + { + report_good(false, entry.str); + printf("expected 0x%04X, got 0x%04X\n", entry.chr, uc); + return false; + } + if(used != entry.n) + { + report_good(false, entry.str); + printf("had %d bytes, used %d\n", entry.n, used); + return false; + } + report_good(true, entry.str); + printf("got 0x%04X\n", uc); + return true; + } + report_good(false, entry.str); + printf("failed\n"); + return false; +} + +static bool decode_bad(test_utf8_char const s) +{ + unsigned int uc = 0xFFFFu; + const char* e = cm_utf8_decode_character(s, s+4, &uc); + if(e) + { + report_bad(false, s); + printf("expected failure, got 0x%04X\n", uc); + return false; + } + report_bad(true, s); + printf("failed as expected\n"); + return true; +} + +int testUTF8(int, char*[]) +{ + int result = 0; + for(test_utf8_entry const* e = good_entry; e->n; ++e) + { + if(!decode_good(*e)) + { + result = 1; + } + } + for(test_utf8_char const* c = bad_chars; (*c)[0]; ++c) + { + if(!decode_bad(*c)) + { + result = 1; + } + } + return result; +} diff --git a/Tests/CMakeLib/testXMLParser.cxx b/Tests/CMakeLib/testXMLParser.cxx new file mode 100644 index 0000000..54ed5dc --- /dev/null +++ b/Tests/CMakeLib/testXMLParser.cxx @@ -0,0 +1,17 @@ +#include "testXMLParser.h" + +#include "cmXMLParser.h" + +#include <cmsys/ios/iostream> + +int testXMLParser(int, char*[]) +{ + // TODO: Derive from parser and check attributes. + cmXMLParser parser; + if(!parser.ParseFile(SOURCE_DIR "/testXMLParser.xml")) + { + cmsys_ios::cerr << "cmXMLParser failed!" << cmsys_ios::endl; + return 1; + } + return 0; +} diff --git a/Tests/CMakeLib/testXMLParser.h.in b/Tests/CMakeLib/testXMLParser.h.in new file mode 100644 index 0000000..da0b275 --- /dev/null +++ b/Tests/CMakeLib/testXMLParser.h.in @@ -0,0 +1,6 @@ +#ifndef testXMLParser_h +#define testXMLParser_h + +#define SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@" + +#endif diff --git a/Tests/CMakeLib/testXMLParser.xml b/Tests/CMakeLib/testXMLParser.xml new file mode 100644 index 0000000..5a13f07 --- /dev/null +++ b/Tests/CMakeLib/testXMLParser.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Document> + <Element attr="1"/> +</Document> diff --git a/Tests/CMakeLib/testXMLSafe.cxx b/Tests/CMakeLib/testXMLSafe.cxx new file mode 100644 index 0000000..60442fa --- /dev/null +++ b/Tests/CMakeLib/testXMLSafe.cxx @@ -0,0 +1,47 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + 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. +============================================================================*/ +#include <cmXMLSafe.h> + +#include "cmStandardIncludes.h" + +struct test_pair +{ + const char* in; + const char* out; +}; + +static test_pair const pairs[] = { + {"copyright \xC2\xA9", "copyright \xC2\xA9"}, + {"form-feed \f", "form-feed [NON-XML-CHAR-0xC]"}, + {"angles <>", "angles <>"}, + {"ampersand &", "ampersand &"}, + {"bad-byte \x80", "bad-byte [NON-UTF-8-BYTE-0x80]"}, + {0,0} +}; + +int testXMLSafe(int, char*[]) +{ + int result = 0; + for(test_pair const* p = pairs; p->in; ++p) + { + cmXMLSafe xs(p->in); + cmOStringStream oss; + oss << xs; + std::string out = oss.str(); + if(out != p->out) + { + printf("expected [%s], got [%s]\n", p->out, out.c_str()); + result = 1; + } + } + return result; +} diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 6fbe57d..7defb28 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1,27 +1,42 @@ # a macro for tests that have a simple format where the name matches the # directory and project MACRO(ADD_TEST_MACRO NAME COMMAND) + STRING(REPLACE "." "/" dir "${NAME}") + STRING(REGEX REPLACE "[^.]*\\." "" proj "${NAME}") ADD_TEST(${NAME} ${CMAKE_CTEST_COMMAND} --build-and-test - "${CMake_SOURCE_DIR}/Tests/${NAME}" - "${CMake_BINARY_DIR}/Tests/${NAME}" + "${CMake_SOURCE_DIR}/Tests/${dir}" + "${CMake_BINARY_DIR}/Tests/${dir}" --build-two-config --build-generator ${CMAKE_TEST_GENERATOR} --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} - --build-project ${NAME} + --build-project ${proj} --test-command ${COMMAND}) - LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${NAME}") + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${dir}") ENDMACRO(ADD_TEST_MACRO) -# Make sure the 'testing' test gets a proper configuration. +# Fake a user home directory to avoid polluting the real one. +IF(DEFINED ENV{HOME} AND NOT CTEST_NO_TEST_HOME) + SET(TEST_HOME "${CMake_BINARY_DIR}/Tests/CMakeFiles/TestHome") + FILE(MAKE_DIRECTORY "${TEST_HOME}") + FILE(WRITE "${TEST_HOME}/.cvspass" ":pserver:anoncvs@www.cmake.org:/cvsroot/KWSys A\n") + SET(TEST_HOME_ENV_CODE "# Fake a user home directory to avoid polluting the real one. +SET(ENV{HOME} \"${TEST_HOME}\")") +ENDIF() + +# Choose a default configuration for CTest tests. +SET(CTestTest_CONFIG Debug) +IF(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) + SET(CTestTest_CONFIG ${CMAKE_BUILD_TYPE}) +ENDIF() + CONFIGURE_FILE(${CMake_SOURCE_DIR}/Tests/EnforceConfig.cmake.in ${CMake_BINARY_DIR}/Tests/EnforceConfig.cmake @ONLY) -SET_DIRECTORY_PROPERTIES(PROPERTIES - TEST_INCLUDE_FILE "${CMake_BINARY_DIR}/Tests/EnforceConfig.cmake" - ) # Testing IF(BUILD_TESTING) + ADD_SUBDIRECTORY(CMakeLib) + # Collect a list of all test build directories. SET(TEST_BUILD_DIRS) @@ -77,7 +92,8 @@ IF(BUILD_TESTING) "Should the tests that use '--build-target package' be run?" ON) MARK_AS_ADVANCED(CTEST_TEST_CPACK) - IF(APPLE AND CTEST_TEST_CPACK) + SET(CTEST_TEST_OSX_ARCH 0) + IF(APPLE) EXECUTE_PROCESS( COMMAND sw_vers -productVersion OUTPUT_VARIABLE OSX_VERSION @@ -87,8 +103,10 @@ IF(BUILD_TESTING) MESSAGE(STATUS "Forcing CTEST_TEST_CPACK=OFF on OSX < 10.4") MESSAGE(STATUS "OSX_VERSION='${OSX_VERSION}'") SET(CTEST_TEST_CPACK OFF) + ELSE(OSX_VERSION MATCHES "^10\\.[0123]" OR OSX_VERSION MATCHES "ProductVersion:\t10\\.[0123]") + SET(CTEST_TEST_OSX_ARCH 1) ENDIF(OSX_VERSION MATCHES "^10\\.[0123]" OR OSX_VERSION MATCHES "ProductVersion:\t10\\.[0123]") - ENDIF(APPLE AND CTEST_TEST_CPACK) + ENDIF(APPLE) # Use 1500 or CTEST_TEST_TIMEOUT for long test timeout value, # whichever is greater. @@ -114,10 +132,12 @@ IF(BUILD_TESTING) ADD_TEST_MACRO(COnly COnly) ADD_TEST_MACRO(CxxOnly CxxOnly) ADD_TEST_MACRO(IPO COnly/COnly) + ADD_TEST_MACRO(OutDir runtime/OutDir) ADD_TEST_MACRO(NewlineArgs NewlineArgs) ADD_TEST_MACRO(SetLang SetLang) ADD_TEST_MACRO(ExternalOBJ ExternalOBJ) ADD_TEST_MACRO(LoadCommand LoadedCommand) + ADD_TEST_MACRO(LinkDirectory bin/LinkDirectory) ADD_TEST_MACRO(LinkLanguage LinkLanguage) ADD_TEST_MACRO(LinkLine LinkLine) ADD_TEST_MACRO(MacroTest miniMacroTest) @@ -130,9 +150,19 @@ IF(BUILD_TESTING) ADD_TEST_MACRO(ExportImport ExportImport) ADD_TEST_MACRO(Unset Unset) ADD_TEST_MACRO(PolicyScope PolicyScope) + ADD_TEST_MACRO(CrossCompile CrossCompile) + SET_TESTS_PROPERTIES(CrossCompile PROPERTIES + PASS_REGULAR_EXPRESSION "TRY_RUN.. invoked in cross-compiling mode") IF("${CMAKE_TEST_GENERATOR}" MATCHES "Make") ADD_TEST_MACRO(Policy0002 Policy0002) ENDIF("${CMAKE_TEST_GENERATOR}" MATCHES "Make") + IF(CTEST_TEST_OSX_ARCH) + ADD_TEST_MACRO(Architecture Architecture) + SET_TESTS_PROPERTIES(Architecture PROPERTIES + PASS_REGULAR_EXPRESSION "(file is not of required architecture|does not match cputype)") + ENDIF(CTEST_TEST_OSX_ARCH) + + LIST(APPEND TEST_BUILD_DIRS ${CMake_TEST_INSTALL_PREFIX}) SET(CMAKE_BUILD_TEST_SOURCE_DIR "${CMake_SOURCE_DIR}/Tests/COnly") SET(CMAKE_BUILD_TEST_BINARY_DIR "${CMake_BINARY_DIR}/Tests/CMakeBuildCOnly") @@ -140,6 +170,9 @@ IF(BUILD_TESTING) "${CMake_BINARY_DIR}/Tests/CMakeBuildTest.cmake" @ONLY) ADD_TEST(CMakeBuildTest ${CMAKE_CMAKE_COMMAND} -P "${CMake_BINARY_DIR}/Tests/CMakeBuildTest.cmake") + LIST(APPEND TEST_BUILD_DIRS ${CMAKE_BUILD_TEST_BINARY_DIR}) + + ADD_TEST_MACRO(Module.CheckTypeSize CheckTypeSize) # If we are running right now with a UnixMakefiles based generator, # build the "Simple" test with the ExtraGenerators, if available @@ -393,6 +426,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=CVS -P ${CMake_SOURCE_DIR}/Utilities/Rel --build-two-config --build-options "-DCMAKE_INSTALL_PREFIX:PATH=${SimpleInstallInstallDir}" + "-DCTEST_TEST_CPACK:BOOL=${CTEST_TEST_CPACK}" --test-command ${SimpleInstallInstallDir}/MyTest/bin/SimpleInstExe) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SimpleInstall") ADD_TEST(SimpleInstall-Stage2 ${CMAKE_CTEST_COMMAND} @@ -1151,7 +1185,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=CVS -P ${CMake_SOURCE_DIR}/Utilities/Rel ) SET_TESTS_PROPERTIES(CTestTestNoBuild PROPERTIES FAIL_REGULAR_EXPRESSION "Error" WILL_FAIL true) - + CONFIGURE_FILE( "${CMake_SOURCE_DIR}/Tests/CTestTestFailure/testNoExe.cmake.in" "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testNoExe.cmake" @@ -1164,6 +1198,50 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=CVS -P ${CMake_SOURCE_DIR}/Utilities/Rel PASS_REGULAR_EXPRESSION "Could not find executable" FAIL_REGULAR_EXPRESSION "SegFault") + + # Use macro, not function so that build can still be driven by CMake 2.4. + # After 2.6 is required, this could be a function without the extra 'set' + # calls. + # + macro(add_config_tests cfg) + set(cfg "${cfg}") + set(base "${CMake_BINARY_DIR}/Tests/CTestConfig") + + # Test -S script with a -C config arg to ctest: + configure_file( + "${CMake_SOURCE_DIR}/Tests/CTestConfig/script.cmake.in" + "${base}/${cfg}-script.cmake" + @ONLY ESCAPE_QUOTES) + add_test(CTestConfig.Script.${cfg} ${CMAKE_CTEST_COMMAND} + -C ${cfg} + -S "${base}/${cfg}-script.cmake" -VV + --output-log "${base}/${cfg}-script.log" + ) + + # Test -D dashboard with a -C config arg to ctest. + # (Actual commands inside a cmake -P script because we need to be able to set + # the working directory reliably...) + configure_file( + "${CMake_SOURCE_DIR}/Tests/CTestConfig/dashboard.cmake.in" + "${base}/${cfg}-dashboard.cmake" + @ONLY ESCAPE_QUOTES) + add_test(CTestConfig.Dashboard.${cfg} ${CMAKE_CMAKE_COMMAND} + -P "${base}/${cfg}-dashboard.cmake" -VV + ) + endmacro() + + add_config_tests(Debug) + add_config_tests(MinSizeRel) + add_config_tests(Release) + add_config_tests(RelWithDebInfo) + + add_test(CMakeCommands.build_command ${CMAKE_CMAKE_COMMAND} + -DCMake_SOURCE_DIR=${CMake_SOURCE_DIR} + -Ddir=${CMake_BINARY_DIR}/Tests/CMakeCommands/build_command + -Dgen=${CMAKE_TEST_GENERATOR} + -P "${CMake_SOURCE_DIR}/Tests/CMakeCommands/build_command/RunCMake.cmake" + ) + CONFIGURE_FILE( "${CMake_SOURCE_DIR}/Tests/CTestTestCrash/test.cmake.in" "${CMake_BINARY_DIR}/Tests/CTestTestCrash/test.cmake" @@ -1182,6 +1260,23 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=CVS -P ${CMake_SOURCE_DIR}/Utilities/Rel ENDIF(CMAKE_TEST_GENERATOR MATCHES "Watcom WMake") CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestBadExe/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestBadExe/test.cmake" + @ONLY ESCAPE_QUOTES) + ADD_TEST(CTestTestBadExe ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTestBadExe/test.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestBadExe/testOutput.log" + ) + SET(CTestTestBadExe_REGEX "BAD_COMMAND") + # cygwin can not be made to produce a BAD_COMMAND error + # the best we can get from it is a failed test + IF(CYGWIN) + SET(CTestTestBadExe_REGEX "\\*\\*\\*Failed") + ENDIF() + SET_TESTS_PROPERTIES(CTestTestBadExe PROPERTIES + PASS_REGULAR_EXPRESSION "${CTestTestBadExe_REGEX}") + + CONFIGURE_FILE( "${CMake_SOURCE_DIR}/Tests/CTestTestParallel/test.cmake.in" "${CMake_BINARY_DIR}/Tests/CTestTestParallel/test.cmake" @ONLY ESCAPE_QUOTES) @@ -1207,11 +1302,12 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=CVS -P ${CMake_SOURCE_DIR}/Utilities/Rel "${CMake_BINARY_DIR}/Tests/CTestTestTimeout/test.cmake" @ONLY ESCAPE_QUOTES) ADD_TEST(CTestTestTimeout ${CMAKE_CTEST_COMMAND} + -C "\${CTestTest_CONFIG}" -S "${CMake_BINARY_DIR}/Tests/CTestTestTimeout/test.cmake" -V --output-log "${CMake_BINARY_DIR}/Tests/CTestTestTimeout/testOutput.log" ) SET_TESTS_PROPERTIES(CTestTestTimeout PROPERTIES - PASS_REGULAR_EXPRESSION "\\*\\*\\*Timeout") + PASS_REGULAR_EXPRESSION "TestTimeout *\\.+ *\\*\\*\\*Timeout.*CheckChild *\\.+ *Passed") CONFIGURE_FILE( "${CMake_SOURCE_DIR}/Tests/CTestTestRunScript/test.cmake.in" @@ -1225,11 +1321,11 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=CVS -P ${CMake_SOURCE_DIR}/Utilities/Rel -S "${CMake_BINARY_DIR}/Tests/CTestTestRunScript/test.cmake" -V --output-log "${CMake_BINARY_DIR}/Tests/CTestTestRunScript/testOutput.log" ) - + ADD_TEST(CTestTestShowOnly ${CMAKE_CTEST_COMMAND} -N) - + ADD_TEST(CTestBatchTest ${CMAKE_CTEST_COMMAND} -B) - + # Use macro, not function so that build can still be driven by CMake 2.4. # After 2.6 is required, this could be a function without the extra 'set' # calls. @@ -1249,6 +1345,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=CVS -P ${CMake_SOURCE_DIR}/Utilities/Rel 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}|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") set(regex "${regex}|Submission successful)") @@ -1380,23 +1477,15 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=CVS -P ${CMake_SOURCE_DIR}/Utilities/Rel GET_TEST_PROPERTY(BootstrapTest TIMEOUT PREVIOUS_TIMEOUT) IF ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) SET_TESTS_PROPERTIES ( BootstrapTest - PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) + PROPERTIES TIMEOUT 5400) ENDIF ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) ENDIF(UNIX AND CMAKE_RUN_LONG_TESTS AND NOT CMAKE_SKIP_BOOTSTRAP_TEST) # fortran does not work for IDE builds because # CMAKE_STANDARD_LIBRARIES needs to be per language - IF(CMAKE_TEST_GENERATOR MATCHES "Makefiles" - OR CMAKE_TEST_GENERATOR MATCHES "KDevelop") - # see if we can find a fortran compiler on the machine - # if so, add the fortran test and see if it works. - SET(CMAKE_Fortran_COMPILER_LIST ifort ifc efc f95 pgf95 - lf95 xlf95 fort gfortran gfortran-4 f90 pgf90 xlf90 - epcf90 f77 fort77 frt pgf77 xlf fl32 af77 g77 ) - FIND_PROGRAM(CMAKE_Fortran_COMPILER_FULLPATH NAMES - ${CMAKE_Fortran_COMPILER_LIST} ) - MARK_AS_ADVANCED(CMAKE_Fortran_COMPILER_FULLPATH) - IF(CMAKE_Fortran_COMPILER_FULLPATH) + IF(CMAKE_TEST_GENERATOR MATCHES "Make|KDevelop") + INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CheckFortran.cmake) + IF(CMAKE_Fortran_COMPILER) ADD_TEST(Fortran ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/Fortran" @@ -1407,9 +1496,17 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=CVS -P ${CMake_SOURCE_DIR}/Utilities/Rel --build-two-config --test-command testf) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Fortran") - ENDIF(CMAKE_Fortran_COMPILER_FULLPATH) - ENDIF(CMAKE_TEST_GENERATOR MATCHES "Makefiles" - OR CMAKE_TEST_GENERATOR MATCHES "KDevelop") + + # FortranCInterface tests. + IF(UNIX) + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/FortranC/Flags.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/FortranC/Flags.cmake @ONLY) + ADD_TEST(FortranC.Flags ${CMAKE_CMAKE_COMMAND} -P + ${CMAKE_CURRENT_BINARY_DIR}/FortranC/Flags.cmake) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranC/Flags") + ENDIF() + ENDIF() + ENDIF() IF(NOT CMAKE_TEST_GENERATOR MATCHES "Xcode") INCLUDE(FindJava) @@ -1492,6 +1589,19 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=CVS -P ${CMake_SOURCE_DIR}/Utilities/Rel ENDIF(PREFIX_IS_FOR_TEST) ENDIF(UNIX) + IF(CMAKE_TEST_PROJECT_CSE_DIR) + SET(script "${CMAKE_TEST_PROJECT_CSE_DIR}/BuildProjectCSE.cmake") + IF(NOT EXISTS "${script}") + SET(script "${CMAKE_TEST_PROJECT_CSE_DIR}/cse_build.cmake") + ENDIF(NOT EXISTS "${script}") + IF(NOT EXISTS "${script}") + MESSAGE("warning: CMAKE_TEST_PROJECT_CSE_DIR set, but no build script found...") + ENDIF(NOT EXISTS "${script}") + + ADD_TEST(BuildCSE ${CMAKE_CTEST_COMMAND} -V -S "${script}") + SET_TESTS_PROPERTIES(BuildCSE PROPERTIES TIMEOUT 5400) + ENDIF(CMAKE_TEST_PROJECT_CSE_DIR) + IF(CMAKE_TEST_PLPLOT_DIR) ADD_TEST(plplot ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_PLPLOT_DIR}/../../EasyDashboardScripts/plplot.cmake ) SET_TESTS_PROPERTIES ( plplot PROPERTIES TIMEOUT 5400) diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt index adaf247..161ca44 100644 --- a/Tests/CMakeTests/CMakeLists.txt +++ b/Tests/CMakeTests/CMakeLists.txt @@ -1,4 +1,4 @@ -SET(CMAKE_EXECUTABLE "${EXECUTABLE_OUTPUT_PATH}/cmake") +SET(CMAKE_EXECUTABLE "${CMake_BIN_DIR}/cmake") MACRO(AddCMakeTest TestName PreArgs) @@ -50,6 +50,7 @@ if(do_cvs_tests) "-DCMake_BINARY_DIR:PATH=${CMake_BINARY_DIR}" "-DCMake_SOURCE_DIR:PATH=${CMake_SOURCE_DIR}" "-DCVS_EXECUTABLE:STRING=${CVS_EXECUTABLE}" + "-DHOME:STRING=$ENV{HOME}" ) AddCMakeTest(CheckSourceTree "${CheckSourceTree_PreArgs}") endif(do_cvs_tests) diff --git a/Tests/CMakeTests/CheckSourceTreeTest.cmake.in b/Tests/CMakeTests/CheckSourceTreeTest.cmake.in index fab5662..1cfadcb 100644 --- a/Tests/CMakeTests/CheckSourceTreeTest.cmake.in +++ b/Tests/CMakeTests/CheckSourceTreeTest.cmake.in @@ -6,8 +6,10 @@ message("") message("CMake_BINARY_DIR='${CMake_BINARY_DIR}'") message("CMake_SOURCE_DIR='${CMake_SOURCE_DIR}'") message("CVS_EXECUTABLE='${CVS_EXECUTABLE}'") +message("HOME='${HOME}'") message("ENV{DASHBOARD_TEST_FROM_CTEST}='$ENV{DASHBOARD_TEST_FROM_CTEST}'") message("") +string(REPLACE "\\" "\\\\" HOME "${HOME}") # Is the build directory the same as or underneath the source directory? @@ -40,6 +42,16 @@ message("in_source_build='${in_source_build}'") message("") +# If this does not appear to be a CVS checkout, just pass the test here and now. +# (Do not let the test fail if it is run in a tree *exported* from CVS or +# unpacked from a .zip file source installer...) +# +if(NOT EXISTS "${CMake_SOURCE_DIR}/CVS/Root") + message("source tree is not a CVS checkout... test passes by early return...") + return() +endif() + + # Check with "cvs -q -n up -dP" if there are any local modifications to the # CMake source tree: # @@ -47,18 +59,31 @@ message("======================================================================= message("Copy/paste this command to reproduce:") message("cd \"${CMake_SOURCE_DIR}\" && \"${CVS_EXECUTABLE}\" -q -n up -dP") message("") + +# Use the HOME value passed in to the script for calling cvs so it can find +# its .cvspass and other file(s) +# +set(original_ENV_HOME "$ENV{HOME}") +set(ENV{HOME} "${HOME}") + execute_process(COMMAND ${CVS_EXECUTABLE} -q -n up -dP WORKING_DIRECTORY ${CMake_SOURCE_DIR} OUTPUT_VARIABLE ov ERROR_VARIABLE ev RESULT_VARIABLE rv) +set(ENV{HOME} "${original_ENV_HOME}") + message("Results of running '${CVS_EXECUTABLE} -q -n up -dP'") message("rv='${rv}'") message("ov='${ov}'") message("ev='${ev}'") message("") +if(NOT rv STREQUAL 0) + message(FATAL_ERROR "error: 'cvs -q -n up -dP' attempt failed... (see output above)") +endif() + # Analyze cvs output: # set(additions 0) diff --git a/Tests/CMakeTests/GetFilenameComponentRealpathTest.cmake.in b/Tests/CMakeTests/GetFilenameComponentRealpathTest.cmake.in index c795512..7adc240 100644 --- a/Tests/CMakeTests/GetFilenameComponentRealpathTest.cmake.in +++ b/Tests/CMakeTests/GetFilenameComponentRealpathTest.cmake.in @@ -13,6 +13,21 @@ if(NOT nonexistent2 STREQUAL "${bindir}/THIS_IS_A_NONEXISTENT_FILE") endif() # +# Test treatment of relative paths +# +foreach(c REALPATH ABSOLUTE) + get_filename_component(dir "subdir/THIS_IS_A_NONEXISTENT_FILE" ${c}) + if(NOT "${dir}" STREQUAL "${bindir}/subdir/THIS_IS_A_NONEXISTENT_FILE") + message(FATAL_ERROR + "${c} does not handle relative paths. Expected:\n" + " ${bindir}/subdir/THIS_IS_A_NONEXISTENT_FILE\n" + "but got:\n" + " ${nonexistent1}\n" + ) + endif() +endforeach() + +# # Test symbolic link resolution # if(UNIX) diff --git a/Tests/CTestConfig/CMakeLists.txt b/Tests/CTestConfig/CMakeLists.txt new file mode 100644 index 0000000..f46d89a --- /dev/null +++ b/Tests/CTestConfig/CMakeLists.txt @@ -0,0 +1,47 @@ +cmake_minimum_required(VERSION 2.8) +project(CTestConfig) + +include(CTest) + + +# We expect this configure to occur through a 'ctest -D Experimental' or a +# 'ctest -S script.cmake' call. +# +# In either case, we expect CMAKE_BUILD_TYPE to be defined for single-configuration +# build trees and not defined for multi-configuration build trees. +# +if(CMAKE_CONFIGURATION_TYPES) + # multi-configuration: expect not defined, error if defined + if(DEFINED CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE STREQUAL "") + message(FATAL_ERROR "CMAKE_CONFIGURATION_TYPES='${CMAKE_CONFIGURATION_TYPES}' CMAKE_BUILD_TYPE='${CMAKE_BUILD_TYPE}' is defined and non-empty (but should not be for a multi-configuration generator)") + endif() +else() + # single-configuration: expect defined, error if not defined + if(NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "") + message(FATAL_ERROR "CMAKE_BUILD_TYPE is not defined or is empty (but should be defined and non-empty for a single-configuration generator)") + endif() +endif() + + +if(DEFINED CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE STREQUAL "") + add_definitions(-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}") +endif() + +add_executable(ctc CTestConfig.cxx) + + +foreach(cfg ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE}) + add_test(NAME ctc-${cfg} CONFIGURATIONS ${cfg} COMMAND ctc --config $<CONFIGURATION>) + + if(CMAKE_CONFIGURATION_TYPES) + set_property(TEST ctc-${cfg} + PROPERTY PASS_REGULAR_EXPRESSION "CMAKE_INTDIR is ${cfg}") + set_property(TEST ctc-${cfg} + PROPERTY FAIL_REGULAR_EXPRESSION "CMAKE_BUILD_TYPE is") + else() + set_property(TEST ctc-${cfg} + PROPERTY PASS_REGULAR_EXPRESSION "CMAKE_BUILD_TYPE is ${cfg}") + set_property(TEST ctc-${cfg} + PROPERTY FAIL_REGULAR_EXPRESSION "CMAKE_INTDIR is") + endif() +endforeach() diff --git a/Tests/CTestConfig/CTestConfig.cxx b/Tests/CTestConfig/CTestConfig.cxx new file mode 100644 index 0000000..49c5324 --- /dev/null +++ b/Tests/CTestConfig/CTestConfig.cxx @@ -0,0 +1,20 @@ +#include <stdio.h> + +int main(int argc, const char* argv[]) +{ + int i = 0; + for (; i<argc; ++i) + { + fprintf(stdout, "%s\n", argv[i]); + } + +#ifdef CMAKE_BUILD_TYPE + fprintf(stdout, "CMAKE_BUILD_TYPE is %s\n", CMAKE_BUILD_TYPE); +#endif + +#ifdef CMAKE_INTDIR + fprintf(stdout, "CMAKE_INTDIR is %s\n", CMAKE_INTDIR); +#endif + + return 0; +} diff --git a/Tests/CTestConfig/dashboard.cmake.in b/Tests/CTestConfig/dashboard.cmake.in new file mode 100644 index 0000000..c7ac210 --- /dev/null +++ b/Tests/CTestConfig/dashboard.cmake.in @@ -0,0 +1,43 @@ +set(CMAKE_CONFIGURATION_TYPES "@CMAKE_CONFIGURATION_TYPES@") +set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestConfig") +set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestConfig/@cfg@-dashboard") + +file(MAKE_DIRECTORY "${CTEST_BINARY_DIRECTORY}") + +get_filename_component(dir "${CMAKE_COMMAND}" PATH) +set(CMAKE_CTEST_COMMAND "${dir}/ctest") + +message("CMAKE_COMMAND='${CMAKE_COMMAND}'") +message("CMAKE_CTEST_COMMAND='${CMAKE_CTEST_COMMAND}'") + +set(arg "") +if(NOT CMAKE_CONFIGURATION_TYPES) + set(arg "-DCMAKE_BUILD_TYPE:STRING=@cfg@") +endif() + +message("cmake initial configure") +execute_process(COMMAND ${CMAKE_COMMAND} + ${arg} -G "@CMAKE_TEST_GENERATOR@" ${CTEST_SOURCE_DIRECTORY} + WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY} + RESULT_VARIABLE rv) +if(NOT rv STREQUAL 0) + message(FATAL_ERROR "error calling cmake: rv='${rv}'") +endif() + + +function(call_ctest arg) + message("call_ctest ${arg}") + execute_process(COMMAND ${CMAKE_CTEST_COMMAND} + -C "@cfg@" -D ${arg} -VV + WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY} + RESULT_VARIABLE rv) + if(NOT rv STREQUAL 0) + message(FATAL_ERROR "error calling ctest: rv='${rv}'") + endif() +endfunction() + + +call_ctest(ExperimentalStart) +call_ctest(ExperimentalConfigure) +call_ctest(ExperimentalBuild) +call_ctest(ExperimentalTest) diff --git a/Tests/CTestConfig/script.cmake.in b/Tests/CTestConfig/script.cmake.in new file mode 100644 index 0000000..5ceb7c3 --- /dev/null +++ b/Tests/CTestConfig/script.cmake.in @@ -0,0 +1,21 @@ +set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +set(CTEST_PROJECT_NAME "CTestConfig") +set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestConfig") +set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestConfig/@cfg@-script") + +ctest_start(Experimental) + +ctest_configure(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE rv) +if(NOT rv STREQUAL 0) + message(FATAL_ERROR "*** error in ctest_configure ***") +endif() + +ctest_build(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE rv) +if(NOT rv STREQUAL 0) + message(FATAL_ERROR "*** error in ctest_build ***") +endif() + +ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE rv) +if(NOT rv STREQUAL 0) + message(FATAL_ERROR "*** error in ctest_test ***") +endif() diff --git a/Tests/CTestTest/CMakeLists.txt b/Tests/CTestTest/CMakeLists.txt deleted file mode 100644 index 7d87612..0000000 --- a/Tests/CTestTest/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -cmake_minimum_required (VERSION 2.6) -PROJECT(CTestTest) - -SET(DART_ROOT "" CACHE STRING "" FORCE) -ENABLE_TESTING() -INCLUDE (${CMAKE_ROOT}/Modules/Dart.cmake) - -GET_FILENAME_COMPONENT(CTEST_COMMAND "${CMAKE_COMMAND}" PATH) -SET(CTEST_COMMAND "${CTEST_COMMAND}/ctest") - -CONFIGURE_FILE(${CTestTest_SOURCE_DIR}/test.cmake.in - ${CTestTest_BINARY_DIR}/test.cmake @ONLY) diff --git a/Tests/CTestTest2/CMakeLists.txt b/Tests/CTestTest2/CMakeLists.txt deleted file mode 100644 index ec793c4..0000000 --- a/Tests/CTestTest2/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required (VERSION 2.6) -PROJECT(CTestTest2) - -SET(DART_ROOT "" CACHE STRING "" FORCE) -ENABLE_TESTING() -INCLUDE (${CMAKE_ROOT}/Modules/Dart.cmake) - -GET_FILENAME_COMPONENT(CTEST_COMMAND "${CMAKE_COMMAND}" PATH) -SET(CTEST_COMMAND "${CTEST_COMMAND}/ctest") - - -CONFIGURE_FILE(${CTestTest2_SOURCE_DIR}/test.cmake.in - ${CTestTest2_BINARY_DIR}/test.cmake @ONLY) diff --git a/Tests/CTestTest3/test.cmake.in b/Tests/CTestTest3/test.cmake.in index 734bdf4..d0a1f88 100644 --- a/Tests/CTestTest3/test.cmake.in +++ b/Tests/CTestTest3/test.cmake.in @@ -50,7 +50,7 @@ CTEST_UPDATE(SOURCE "${CTEST_SOURCE_DIRECTORY}" RETURN_VALUE res) CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) CTEST_READ_CUSTOM_FILES("${CTEST_BINARY_DIRECTORY}") CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) -CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res PARALLEL_LEVEL 5 SCHEDULE_RANDOM ON) CTEST_MEMCHECK(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) CTEST_COVERAGE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) CTEST_SUBMIT(RETURN_VALUE res) @@ -97,7 +97,7 @@ IF(svncommand) CTEST_UPDATE(SOURCE "${CTEST_SOURCE_DIRECTORY}" RETURN_VALUE res) 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 5) + CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res PARALLEL_LEVEL 5 SCHEDULE_RANDOM ON) CTEST_MEMCHECK(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res PARALLEL_LEVEL 5) CTEST_COVERAGE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) CTEST_SUBMIT(RETURN_VALUE res) diff --git a/Tests/CTestTestBadExe/CMakeLists.txt b/Tests/CTestTestBadExe/CMakeLists.txt new file mode 100644 index 0000000..8a925b6 --- /dev/null +++ b/Tests/CTestTestBadExe/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(CTestTestBadExe) +INCLUDE(CTest) + +CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/notAnExe.txt" "${CMAKE_CURRENT_BINARY_DIR}/notAnExe.txt" COPYONLY) + +ADD_TEST (TestBadExe "${CMAKE_CURRENT_BINARY_DIR}/notAnExe.txt") diff --git a/Tests/CTestTestBadExe/CTestConfig.cmake b/Tests/CTestTestBadExe/CTestConfig.cmake new file mode 100644 index 0000000..1d46ea3 --- /dev/null +++ b/Tests/CTestTestBadExe/CTestConfig.cmake @@ -0,0 +1,7 @@ +set (CTEST_PROJECT_NAME "CTestTestBadExe") +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/CTestTestBadExe/notAnExe.txt b/Tests/CTestTestBadExe/notAnExe.txt new file mode 100644 index 0000000..f2a0aa4 --- /dev/null +++ b/Tests/CTestTestBadExe/notAnExe.txt @@ -0,0 +1 @@ +This is not an executable file. diff --git a/Tests/CTestTestBadExe/test.cmake.in b/Tests/CTestTestBadExe/test.cmake.in new file mode 100644 index 0000000..743e835 --- /dev/null +++ b/Tests/CTestTestBadExe/test.cmake.in @@ -0,0 +1,24 @@ +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@-BadExe") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestBadExe") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestBadExe") +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_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) + +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/CTestTestCrash/CMakeLists.txt b/Tests/CTestTestCrash/CMakeLists.txt index 5c8cc0b..0ac6ba0 100644 --- a/Tests/CTestTestCrash/CMakeLists.txt +++ b/Tests/CTestTestCrash/CMakeLists.txt @@ -1,19 +1,7 @@ cmake_minimum_required (VERSION 2.6) PROJECT(CTestTestCrash) - -SET(DART_ROOT "" CACHE STRING "" FORCE) -ENABLE_TESTING() -INCLUDE (${CMAKE_ROOT}/Modules/Dart.cmake) - -GET_FILENAME_COMPONENT(CTEST_COMMAND "${CMAKE_COMMAND}" PATH) -SET(CTEST_COMMAND "${CTEST_COMMAND}/ctest") +INCLUDE(CTest) ADD_EXECUTABLE (Crash crash.cxx) -TARGET_LINK_LIBRARIES (NoBuild ${EXTRA_LIBS}) - -ENABLE_TESTING () ADD_TEST (TestCrash Crash) - -INCLUDE (CTest) - diff --git a/Tests/CTestTestCrash/test.cmake.in b/Tests/CTestTestCrash/test.cmake.in index 794b8ff..259c8659 100644 --- a/Tests/CTestTestCrash/test.cmake.in +++ b/Tests/CTestTestCrash/test.cmake.in @@ -8,8 +8,6 @@ SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Crash") SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestCrash") SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestCrash") SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") -SET(CMAKE_TEST_MAKEPROGRAM "@CMAKE_TEST_MAKEPROGRAM@") -SET(MAKECOMMAND "@MAKECOMMAND@") SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") @@ -20,13 +18,6 @@ SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIP #CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) - -FILE(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" " -CMAKE_TEST_GENERATOR:STRING=@CMAKE_TEST_GENERATOR@ -CMAKE_TEST_MAKEPROGRAM:FILEPATH=@CMAKE_TEST_MAKEPROGRAM@ -MAKECOMMAND:STRING=@MAKECOMMAND@ -") - CTEST_START(Experimental) CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestFailedSubmits/test.cmake.in b/Tests/CTestTestFailedSubmits/test.cmake.in index 42bc79c..9b581eb 100644 --- a/Tests/CTestTestFailedSubmits/test.cmake.in +++ b/Tests/CTestTestFailedSubmits/test.cmake.in @@ -45,3 +45,7 @@ CTEST_COVERAGE(BUILD "${CTEST_BINARY_DIRECTORY}" @ctest_coverage_labels_args@ RE # ok to call ctest_submit - still avoids network activity because there is # not a valid drop location given above... CTEST_SUBMIT(RETURN_VALUE res) + +# Add coverage for the new APPEND arg to ctest_start: +# +CTEST_START(Experimental APPEND) diff --git a/Tests/CTestTestFailure/CMakeLists.txt b/Tests/CTestTestFailure/CMakeLists.txt index 62ce7c5..690fbfc 100644 --- a/Tests/CTestTestFailure/CMakeLists.txt +++ b/Tests/CTestTestFailure/CMakeLists.txt @@ -1,19 +1,8 @@ cmake_minimum_required (VERSION 2.6) PROJECT(CTestTestFailure) - -SET(DART_ROOT "" CACHE STRING "" FORCE) -ENABLE_TESTING() -INCLUDE (${CMAKE_ROOT}/Modules/Dart.cmake) - -GET_FILENAME_COMPONENT(CTEST_COMMAND "${CMAKE_COMMAND}" PATH) -SET(CTEST_COMMAND "${CTEST_COMMAND}/ctest") +INCLUDE(CTest) ADD_EXECUTABLE (NoBuild badCode.cxx) TARGET_LINK_LIBRARIES (NoBuild ${EXTRA_LIBS}) -ENABLE_TESTING () - ADD_TEST (TestNoExe NoBuild) - -INCLUDE (CTest) - diff --git a/Tests/CTestTestFailure/testNoBuild.cmake.in b/Tests/CTestTestFailure/testNoBuild.cmake.in index 7870723..b0bb039 100644 --- a/Tests/CTestTestFailure/testNoBuild.cmake.in +++ b/Tests/CTestTestFailure/testNoBuild.cmake.in @@ -8,8 +8,6 @@ SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-NoBuild") SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestFailure") SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestFailure") SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") -SET(CMAKE_TEST_MAKEPROGRAM "@CMAKE_TEST_MAKEPROGRAM@") -SET(MAKECOMMAND "@MAKECOMMAND@") SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") @@ -20,13 +18,6 @@ SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIP #CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) - -FILE(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" " -CMAKE_TEST_GENERATOR:STRING=@CMAKE_TEST_GENERATOR@ -CMAKE_TEST_MAKEPROGRAM:FILEPATH=@CMAKE_TEST_MAKEPROGRAM@ -MAKECOMMAND:STRING=@MAKECOMMAND@ -") - CTEST_START(Experimental) #CTEST_UPDATE(SOURCE "${CTEST_SOURCE_DIRECTORY}" RETURN_VALUE res) CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestFailure/testNoExe.cmake.in b/Tests/CTestTestFailure/testNoExe.cmake.in index 7c40f48..69d4f84 100644 --- a/Tests/CTestTestFailure/testNoExe.cmake.in +++ b/Tests/CTestTestFailure/testNoExe.cmake.in @@ -8,8 +8,6 @@ SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-NoExe") SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestFailure") SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestFailure") SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") -SET(CMAKE_TEST_MAKEPROGRAM "@CMAKE_TEST_MAKEPROGRAM@") -SET(MAKECOMMAND "@MAKECOMMAND@") SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") @@ -20,12 +18,5 @@ SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIP #CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) - -FILE(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" " -CMAKE_TEST_GENERATOR:STRING=@CMAKE_TEST_GENERATOR@ -CMAKE_TEST_MAKEPROGRAM:FILEPATH=@CMAKE_TEST_MAKEPROGRAM@ -MAKECOMMAND:STRING=@MAKECOMMAND@ -") - CTEST_START(Experimental) CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestParallel/CMakeLists.txt b/Tests/CTestTestParallel/CMakeLists.txt index 1e57074..8fab44b 100644 --- a/Tests/CTestTestParallel/CMakeLists.txt +++ b/Tests/CTestTestParallel/CMakeLists.txt @@ -1,17 +1,9 @@ cmake_minimum_required (VERSION 2.6) PROJECT(CTestTestParallel) - -SET(DART_ROOT "" CACHE STRING "" FORCE) -ENABLE_TESTING() -INCLUDE (${CMAKE_ROOT}/Modules/Dart.cmake) - -GET_FILENAME_COMPONENT(CTEST_COMMAND "${CMAKE_COMMAND}" PATH) -SET(CTEST_COMMAND "${CTEST_COMMAND}/ctest") +INCLUDE(CTest) ADD_EXECUTABLE (LockFile lockFile.c) -ENABLE_TESTING () - ADD_TEST (TestRunSerial1 LockFile) ADD_TEST (TestRunSerial2 LockFile) SET_TESTS_PROPERTIES(TestRunSerial1 TestRunSerial2 PROPERTIES RUN_SERIAL true) @@ -19,5 +11,3 @@ SET_TESTS_PROPERTIES(TestRunSerial1 TestRunSerial2 PROPERTIES RUN_SERIAL true) ADD_TEST (TestProcessorsGreaterThanMPL1 LockFile) ADD_TEST (TestProcessorsGreaterThanMPL2 LockFile) SET_TESTS_PROPERTIES(TestProcessorsGreaterThanMPL1 PROPERTIES PROCESSORS 10) - -INCLUDE (CTest) diff --git a/Tests/CTestTestParallel/test.cmake.in b/Tests/CTestTestParallel/test.cmake.in index aaa93fc..6ca15f6 100644 --- a/Tests/CTestTestParallel/test.cmake.in +++ b/Tests/CTestTestParallel/test.cmake.in @@ -8,8 +8,6 @@ SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Parallel") SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestParallel") SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestParallel") SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") -SET(CMAKE_TEST_MAKEPROGRAM "@CMAKE_TEST_MAKEPROGRAM@") -SET(MAKECOMMAND "@MAKECOMMAND@") SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") @@ -20,12 +18,6 @@ SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIP #CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) -FILE(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" " -CMAKE_TEST_GENERATOR:STRING=@CMAKE_TEST_GENERATOR@ -CMAKE_TEST_MAKEPROGRAM:FILEPATH=@CMAKE_TEST_MAKEPROGRAM@ -MAKECOMMAND:STRING=@MAKECOMMAND@ -") - CTEST_START(Experimental) CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestSubdir/CMakeLists.txt b/Tests/CTestTestSubdir/CMakeLists.txt index 5daa543..5400ee8 100644 --- a/Tests/CTestTestSubdir/CMakeLists.txt +++ b/Tests/CTestTestSubdir/CMakeLists.txt @@ -1,12 +1,6 @@ cmake_minimum_required (VERSION 2.6) PROJECT(CTestTestSubdir) - -SET(DART_ROOT "" CACHE STRING "" FORCE) -ENABLE_TESTING() -INCLUDE (${CMAKE_ROOT}/Modules/Dart.cmake) - -GET_FILENAME_COMPONENT(CTEST_COMMAND "${CMAKE_COMMAND}" PATH) -SET(CTEST_COMMAND "${CTEST_COMMAND}/ctest") +INCLUDE(CTest) ADD_SUBDIRECTORY(subdir) SUBDIRS(subdir2) diff --git a/Tests/CTestTestSubdir/test.cmake.in b/Tests/CTestTestSubdir/test.cmake.in index 299f86d..c8d4fda 100644 --- a/Tests/CTestTestSubdir/test.cmake.in +++ b/Tests/CTestTestSubdir/test.cmake.in @@ -8,8 +8,6 @@ SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Subdir") SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestSubdir") SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestSubdir") SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") -SET(CMAKE_TEST_MAKEPROGRAM "@CMAKE_TEST_MAKEPROGRAM@") -SET(MAKECOMMAND "@MAKECOMMAND@") SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") @@ -20,12 +18,6 @@ SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIP #CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) -FILE(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" " -CMAKE_TEST_GENERATOR:STRING=@CMAKE_TEST_GENERATOR@ -CMAKE_TEST_MAKEPROGRAM:FILEPATH=@CMAKE_TEST_MAKEPROGRAM@ -MAKECOMMAND:STRING=@MAKECOMMAND@ -") - CTEST_START(Experimental) CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestTimeout/CMakeLists.txt b/Tests/CTestTestTimeout/CMakeLists.txt index 15942c8..0fd1ceb 100644 --- a/Tests/CTestTestTimeout/CMakeLists.txt +++ b/Tests/CTestTestTimeout/CMakeLists.txt @@ -1,18 +1,28 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8) PROJECT(CTestTestTimeout) +INCLUDE(CTest) -SET(DART_ROOT "" CACHE STRING "" FORCE) -ENABLE_TESTING() -INCLUDE (${CMAKE_ROOT}/Modules/Dart.cmake) - -GET_FILENAME_COMPONENT(CTEST_COMMAND "${CMAKE_COMMAND}" PATH) -SET(CTEST_COMMAND "${CTEST_COMMAND}/ctest") +IF(NOT TIMEOUT) + IF(CYGWIN) + SET(TIMEOUT 4) # Cygwin CMake sometimes takes > 1 second to load! + ELSE() + SET(TIMEOUT 1) + ENDIF() +ENDIF() +ADD_DEFINITIONS(-DTIMEOUT=${TIMEOUT}) ADD_EXECUTABLE (Timeout timeout.c) -ENABLE_TESTING () - -ADD_TEST (TestTimeout Timeout) -SET_TESTS_PROPERTIES(TestTimeout PROPERTIES TIMEOUT 1) +ADD_TEST(NAME TestTimeout + COMMAND ${CMAKE_COMMAND} -D Timeout=$<TARGET_FILE:Timeout> + -D Log=${CMAKE_CURRENT_BINARY_DIR}/timeout.log + -P ${CMAKE_CURRENT_SOURCE_DIR}/timeout.cmake + ) +SET_TESTS_PROPERTIES(TestTimeout PROPERTIES TIMEOUT ${TIMEOUT}) -INCLUDE (CTest) +ADD_TEST(NAME CheckChild + COMMAND ${CMAKE_COMMAND} -D Timeout=$<TARGET_FILE:Timeout> + -D Log=${CMAKE_CURRENT_BINARY_DIR}/timeout.log + -P ${CMAKE_CURRENT_SOURCE_DIR}/check.cmake + ) +SET_TESTS_PROPERTIES(CheckChild PROPERTIES DEPENDS TestTimeout) diff --git a/Tests/CTestTestTimeout/check.cmake b/Tests/CTestTestTimeout/check.cmake new file mode 100644 index 0000000..b16f2aa --- /dev/null +++ b/Tests/CTestTestTimeout/check.cmake @@ -0,0 +1,9 @@ +# Block just as long as timeout.cmake would if it were not killed. +execute_process(COMMAND ${Timeout}) + +# Verify that the log is empty, which indicates that the grandchild +# was killed before it finished sleeping. +file(READ "${Log}" LOG) +if(NOT "${LOG}" STREQUAL "") + message(FATAL_ERROR "${LOG}") +endif() diff --git a/Tests/CTestTestTimeout/test.cmake.in b/Tests/CTestTestTimeout/test.cmake.in index 4582801..6ed11a4 100644 --- a/Tests/CTestTestTimeout/test.cmake.in +++ b/Tests/CTestTestTimeout/test.cmake.in @@ -8,8 +8,6 @@ SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Timeout") SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestTimeout") SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestTimeout") SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") -SET(CMAKE_TEST_MAKEPROGRAM "@CMAKE_TEST_MAKEPROGRAM@") -SET(MAKECOMMAND "@MAKECOMMAND@") SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") @@ -21,9 +19,7 @@ SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIP #CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) FILE(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" " -CMAKE_TEST_GENERATOR:STRING=@CMAKE_TEST_GENERATOR@ -CMAKE_TEST_MAKEPROGRAM:FILEPATH=@CMAKE_TEST_MAKEPROGRAM@ -MAKECOMMAND:STRING=@MAKECOMMAND@ +TIMEOUT:STRING=@CTestTestTimeout_TIME@ ") CTEST_START(Experimental) diff --git a/Tests/CTestTestTimeout/timeout.c b/Tests/CTestTestTimeout/timeout.c index 559b6a5..370ab22 100644 --- a/Tests/CTestTestTimeout/timeout.c +++ b/Tests/CTestTestTimeout/timeout.c @@ -4,12 +4,15 @@ # include <unistd.h> #endif +#include <stdio.h> + int main(void) { #if defined(_WIN32) - Sleep(5000); + Sleep((TIMEOUT+4)*1000); #else - sleep(5); + sleep((TIMEOUT+4)); #endif + printf("timeout process finished sleeping!\n"); return -1; } diff --git a/Tests/CTestTestTimeout/timeout.cmake b/Tests/CTestTestTimeout/timeout.cmake new file mode 100644 index 0000000..198cc97 --- /dev/null +++ b/Tests/CTestTestTimeout/timeout.cmake @@ -0,0 +1,6 @@ +# Remove the log file. +file(REMOVE ${Log}) + +# Run a child that sleeps longer than the timout of this test. +# Log its output so check.cmake can verify it dies. +execute_process(COMMAND ${Timeout} OUTPUT_FILE ${Log}) diff --git a/Tests/CTestUpdateCVS.cmake.in b/Tests/CTestUpdateCVS.cmake.in index 8ac0fa1..1509adf 100644 --- a/Tests/CTestUpdateCVS.cmake.in +++ b/Tests/CTestUpdateCVS.cmake.in @@ -5,6 +5,7 @@ # Test in a directory next to this script. get_filename_component(TOP "${CMAKE_CURRENT_LIST_FILE}" PATH) set(TOP "${TOP}/@CTestUpdateCVS_DIR@") +set(UPDATE_NOT_GLOBAL 1) # Include code common to all update tests. include("@CMAKE_CURRENT_SOURCE_DIR@/CTestUpdateCommon.cmake") diff --git a/Tests/CTestUpdateCommon.cmake b/Tests/CTestUpdateCommon.cmake index b680b8e..1f5941d 100644 --- a/Tests/CTestUpdateCommon.cmake +++ b/Tests/CTestUpdateCommon.cmake @@ -45,6 +45,25 @@ function(check_updates build) endif() endforeach(f) + if(NOT UPDATE_NOT_GLOBAL) + set(rev_elements Revision PriorRevision ${UPDATE_GLOBAL_ELEMENTS}) + string(REPLACE ";" "|" rev_regex "${rev_elements}") + set(rev_regex "^\t<(${rev_regex})>[^<\n]+</(${rev_regex})>$") + file(STRINGS ${TOP}/${UPDATE_XML_FILE} UPDATE_XML_REVISIONS + REGEX "${rev_regex}" + LIMIT_INPUT 4096 + ) + foreach(r IN LISTS UPDATE_XML_REVISIONS) + string(REGEX REPLACE "${rev_regex}" "\\1" element "${r}") + set(element_${element} 1) + endforeach() + foreach(element ${rev_elements}) + if(NOT element_${element}) + list(APPEND MISSING "global <${element}> element") + endif() + endforeach() + endif() + # Report the result if(MISSING) # List the missing entries diff --git a/Tests/CTestUpdateSVN.cmake.in b/Tests/CTestUpdateSVN.cmake.in index 57d72fd..509597b 100644 --- a/Tests/CTestUpdateSVN.cmake.in +++ b/Tests/CTestUpdateSVN.cmake.in @@ -5,6 +5,7 @@ # Test in a directory next to this script. get_filename_component(TOP "${CMAKE_CURRENT_LIST_FILE}" PATH) set(TOP "${TOP}/@CTestUpdateSVN_DIR@") +set(UPDATE_GLOBAL_ELEMENTS SVNPath) # Include code common to all update tests. include("@CMAKE_CURRENT_SOURCE_DIR@/CTestUpdateCommon.cmake") diff --git a/Tests/CheckFortran.cmake b/Tests/CheckFortran.cmake new file mode 100644 index 0000000..8adcafc --- /dev/null +++ b/Tests/CheckFortran.cmake @@ -0,0 +1,50 @@ + +#============================================================================= +# Copyright 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.) + +if(NOT DEFINED CMAKE_Fortran_COMPILER) + set(_desc "Looking for a Fortran compiler") + message(STATUS ${_desc}) + file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CheckFortran) + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CheckFortran/CMakeLists.txt" + "cmake_minimum_required(VERSION 2.4) +project(CheckFortran Fortran) +file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\" + \"set(CMAKE_Fortran_COMPILER \\\"\${CMAKE_Fortran_COMPILER}\\\")\\n\" + \"set(CMAKE_Fortran_FLAGS \\\"\${CMAKE_Fortran_FLAGS}\\\")\\n\" + ) +") + execute_process( + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CheckFortran + COMMAND ${CMAKE_COMMAND} . -G ${CMAKE_GENERATOR} + OUTPUT_VARIABLE output + ERROR_VARIABLE output + RESULT_VARIABLE result + ) + include(${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CheckFortran/result.cmake OPTIONAL) + if(CMAKE_Fortran_COMPILER AND "${result}" STREQUAL "0") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "${_desc} passed with the following output:\n" + "${output}\n") + else() + set(CMAKE_Fortran_COMPILER NOTFOUND) + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "${_desc} failed with the following output:\n" + "${output}\n") + endif() + message(STATUS "${_desc} - ${CMAKE_Fortran_COMPILER}") + set(CMAKE_Fortran_COMPILER "${CMAKE_Fortran_COMPILER}" CACHE FILEPATH "Fortran compiler") + mark_as_advanced(CMAKE_Fortran_COMPILER) + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}" CACHE STRING "Fortran flags") + mark_as_advanced(CMAKE_Fortran_FLAGS) +endif() diff --git a/Tests/CommandLineTest/CMakeLists.txt b/Tests/CommandLineTest/CMakeLists.txt index e01a4c7..0493a0c 100644 --- a/Tests/CommandLineTest/CMakeLists.txt +++ b/Tests/CommandLineTest/CMakeLists.txt @@ -2,7 +2,6 @@ cmake_minimum_required (VERSION 2.6) PROJECT(CommandLineTest) GET_FILENAME_COMPONENT(CMAKE_BIN_DIR ${CMAKE_COMMAND} PATH) -FIND_PROGRAM(DUMP_DOC_EXE NAMES DumpDocumentation PATHS ${CMAKE_BIN_DIR}) MACRO(EXEC_CMAKE_COMMAND CMAKE_ARGS) EXEC_PROGRAM("${CMAKE_COMMAND}" ARGS "${CMAKE_ARGS}" RETURN_VALUE RET) IF(${RET}) @@ -25,15 +24,6 @@ EXEC_CMAKE_COMMAND("--help-html \"${CMAKE_CURRENT_BINARY_DIR}/cmake.html\"") EXEC_CMAKE_COMMAND("--copyright \"${CMAKE_CURRENT_BINARY_DIR}/Copyright.txt\"") EXEC_CMAKE_COMMAND("--version \"${CMAKE_CURRENT_BINARY_DIR}/version.txt\"") -IF(DUMP_DOC_EXE) - EXEC_PROGRAM(${DUMP_DOC_EXE} ARGS "--all-for-coverage \"${CMAKE_CURRENT_BINARY_DIR}/all_for_coverage.txt\"" RETURN_VALUE RET) - IF(${RET}) - MESSAGE(SEND_ERROR "DumpDoc command failed ") - ENDIF(${RET}) -ELSE(DUMP_DOC_EXE) - MESSAGE(SEND_ERROR "Cannot find DumpDocumentation executable.") -ENDIF(DUMP_DOC_EXE) - ADD_EXECUTABLE(CommandLineTest CommandLineTest.cxx) GET_FILENAME_COMPONENT(CMAKE_COMMAND_PATH "${CMAKE_COMMAND}" PATH) diff --git a/Tests/CrossCompile/CMakeLists.txt b/Tests/CrossCompile/CMakeLists.txt new file mode 100644 index 0000000..96a57a0 --- /dev/null +++ b/Tests/CrossCompile/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(CrossCompile) + +UNSET(run_result CACHE) + +#Simulate the cross compile condition +SET(CMAKE_CROSSCOMPILING ON) + +ADD_EXECUTABLE(CrossCompile main.c) + +TRY_RUN(run_result compile_result + ${CrossCompile_BINARY_DIR} + ${CrossCompile_SOURCE_DIR}/main.c) diff --git a/Tests/CrossCompile/main.c b/Tests/CrossCompile/main.c new file mode 100644 index 0000000..8488f4e --- /dev/null +++ b/Tests/CrossCompile/main.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff --git a/Tests/EnforceConfig.cmake.in b/Tests/EnforceConfig.cmake.in index c10d2a3..c9028a3 100644 --- a/Tests/EnforceConfig.cmake.in +++ b/Tests/EnforceConfig.cmake.in @@ -1,17 +1,12 @@ -# Older versions of CMake do not support an empty configuration name in -# CTEST_CONFIGURATION_TYPE for the 'testing' test. -SET(CONFIG_REQUIRED) -IF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.6) - SET(CONFIG_REQUIRED 1) -ELSE("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.6) - IF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" STREQUAL 2.6) - IF("${CMAKE_PATCH_VERSION}" LESS 3) - SET(CONFIG_REQUIRED 1) - ENDIF("${CMAKE_PATCH_VERSION}" LESS 3) - ENDIF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" STREQUAL 2.6) -ENDIF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.6) +# Choose a configuration with which to drive CTest tests. +IF(CTEST_CONFIGURATION_TYPE) + SET(CTestTest_CONFIG "${CTEST_CONFIGURATION_TYPE}") +ELSE(CTEST_CONFIGURATION_TYPE) + SET(CTestTest_CONFIG "@CTestTest_CONFIG@") +ENDIF(CTEST_CONFIGURATION_TYPE) -IF(NOT CTEST_CONFIGURATION_TYPE AND CONFIG_REQUIRED) +# Choose a configuration that was built if none is given. +IF(NOT CTEST_CONFIGURATION_TYPE) SET(CTEST_CMD "@CMAKE_CTEST_COMMAND@@CMAKE_EXECUTABLE_SUFFIX@") GET_FILENAME_COMPONENT(CTEST_DIR "${CTEST_CMD}" PATH) GET_FILENAME_COMPONENT(CTEST_EXE "${CTEST_CMD}" NAME) @@ -26,4 +21,6 @@ IF(NOT CTEST_CONFIGURATION_TYPE AND CONFIG_REQUIRED) SET(CTEST_CONFIGURATION_TYPE NoConfig) ENDIF(NOT CTEST_CONFIGURATION_TYPE) MESSAGE("Guessing configuration ${CTEST_CONFIGURATION_TYPE}") -ENDIF(NOT CTEST_CONFIGURATION_TYPE AND CONFIG_REQUIRED) +ENDIF(NOT CTEST_CONFIGURATION_TYPE) + +@TEST_HOME_ENV_CODE@ diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt index 48ca548..31cf0fc 100644 --- a/Tests/FindPackageTest/CMakeLists.txt +++ b/Tests/FindPackageTest/CMakeLists.txt @@ -40,6 +40,7 @@ SET(PACKAGES WrongA WrongB WrongC WrongD wibbleA wibbleB RecursiveA RecursiveB RecursiveC + EnvA EnvB ) FOREACH(p ${PACKAGES}) SET(${p}_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE) @@ -96,6 +97,13 @@ FIND_PACKAGE(RecursiveA) FIND_PACKAGE(RecursiveB 2) FIND_PACKAGE(RecursiveC 3.1 EXACT) +# Test <Package>_DIR environment variable. +# We erase the main prefix path to ensure the env var is used. +SET(CMAKE_PREFIX_PATH) +SET(ENV{EnvA_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/lib/zot-3.1") +FIND_PACKAGE(EnvA 3.1 EXACT QUIET NAMES zot) # Should Work +FIND_PACKAGE(EnvB 3.1 EXACT QUIET NAMES zot) # Should Fail + # Expected locations at which packages should be found. SET(foo_EXPECTED "lib/foo-1.2/foo-config.cmake") SET(Foo_EXPECTED "lib/foo-1.2/CMake/FooConfig.cmake") @@ -123,6 +131,8 @@ SET(wibbleB_EXPECTED "B/wibble-config.cmake") SET(RecursiveA_EXPECTED "lib/RecursiveA/recursivea-config.cmake") SET(RecursiveB_EXPECTED "lib/zot-2.0/zot-config.cmake") SET(RecursiveC_EXPECTED "lib/zot-3.1/zot-config.cmake") +SET(EnvA_EXPECTED "lib/zot-3.1/zot-config.cmake") +SET(EnvB_MISSING "EnvB_DIR-NOTFOUND") # Check the results. FOREACH(p ${PACKAGES}) diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt index 709ea5f..04563ef 100644 --- a/Tests/Fortran/CMakeLists.txt +++ b/Tests/Fortran/CMakeLists.txt @@ -34,7 +34,7 @@ function(test_fortran_c_interface_module) FortranCInterface_VERIFY() FortranCInterface_VERIFY(CXX) if(CMAKE_Fortran_COMPILER_SUPPORTS_F90) - if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "SunPro|MIPSpro") + if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "SunPro|MIPSpro|PathScale") set(module_expected 1) endif() if(FortranCInterface_MODULE_FOUND OR module_expected) @@ -171,13 +171,20 @@ if(TEST_MODULE_DEPENDS) set(External_CONFIG_TYPE) set(External_BUILD_TYPE -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}) endif(CMAKE_CONFIGURATION_TYPES) + set(External_SOURCE_DIR "${testf_SOURCE_DIR}/External") + set(External_BINARY_DIR "${testf_BINARY_DIR}/External") + if("${testf_BINARY_DIR}" MATCHES " ") + # Our build tree has a space, so the build tool supports spaces. + # Test using modules from a path with spaces. + set(External_BINARY_DIR "${External_BINARY_DIR} Build") + endif() add_custom_command( OUTPUT ${testf_BINARY_DIR}/ExternalProject COMMAND ${CMAKE_CTEST_COMMAND} ARGS ${External_CONFIG_TYPE} --build-and-test - ${testf_SOURCE_DIR}/External - ${testf_BINARY_DIR}/External + ${External_SOURCE_DIR} + ${External_BINARY_DIR} --build-noclean --build-two-config --build-project ExtFort diff --git a/Tests/Fortran/Executable/CMakeLists.txt b/Tests/Fortran/Executable/CMakeLists.txt index 40114e4..55f21ad 100644 --- a/Tests/Fortran/Executable/CMakeLists.txt +++ b/Tests/Fortran/Executable/CMakeLists.txt @@ -1,6 +1,6 @@ include_directories(${Library_MODDIR}) -include_directories(${testf_BINARY_DIR}/External) -link_directories(${testf_BINARY_DIR}/External) +include_directories(${External_BINARY_DIR}) +link_directories(${External_BINARY_DIR}) add_executable(subdir_exe2 main.f90) target_link_libraries(subdir_exe2 subdir_mods) diff --git a/Tests/FortranC/CMakeLists.txt b/Tests/FortranC/CMakeLists.txt new file mode 100644 index 0000000..f335583 --- /dev/null +++ b/Tests/FortranC/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required(VERSION 2.8) +project(FortranC C Fortran) + +# Skip this test for compilers not known to be compatible. +if(NOT ("${CMAKE_C_COMPILER_ID}" STREQUAL "${CMAKE_Fortran_COMPILER_ID}" OR + "${CMAKE_C_COMPILER_ID}-${CMAKE_Fortran_COMPILER_ID}" MATCHES "^(MSVC-Intel)$")) + message(STATUS "${CMAKE_C_COMPILER_ID} C and ${CMAKE_Fortran_COMPILER_ID} Fortran not known to be compatible!") + return() +endif() + +# Wipe out all FortranCInterface information to ensure it re-runs. +file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/CMakeFiles/FortranCInterface) + +if(FortranC_TEST_FLAGS) + # Test whether FortranCInterface checks see C flags. + set(ENV{TEST_OPT_CC} "--test-opt-cc=1") + set(CMAKE_C_FLAGS "$ENV{TEST_OPT_CC} ${CMAKE_C_FLAGS}") + + # Test whether FortranCInterface checks see Fortran flags. + set(ENV{TEST_OPT_FC} "--test-opt-fc=1") + set(CMAKE_Fortran_FLAGS "$ENV{TEST_OPT_FC} ${CMAKE_Fortran_FLAGS}") +endif() + +include(FortranCInterface) +FortranCInterface_VERIFY() diff --git a/Tests/FortranC/Flags.cmake.in b/Tests/FortranC/Flags.cmake.in new file mode 100644 index 0000000..0b82f0e --- /dev/null +++ b/Tests/FortranC/Flags.cmake.in @@ -0,0 +1,28 @@ +set(src "@CMAKE_CURRENT_SOURCE_DIR@/FortranC") +set(bld "@CMAKE_CURRENT_BINARY_DIR@/FortranC/Flags") + +# Create wrapper scripts for the compilers that check for expected +# flags, remove them, and invoke the real compiler. +set(ID "CC") +set(COMMAND "@CMAKE_C_COMPILER@") +configure_file("${src}/test_opt.sh.in" "${bld}/cc.sh" @ONLY) +set(ID "FC") +set(COMMAND "@CMAKE_Fortran_COMPILER@") +configure_file("${src}/test_opt.sh.in" "${bld}/fc.sh" @ONLY) +set(ID) +set(COMMAND) + +execute_process( + WORKING_DIRECTORY "${bld}" + COMMAND ${CMAKE_COMMAND} "${src}" -G "@CMAKE_TEST_GENERATOR@" + "-DFortranC_TEST_FLAGS=1" + "-DCMAKE_C_COMPILER=${bld}/cc.sh" + "-DCMAKE_C_FLAGS:STRING=@CMAKE_C_FLAGS@" + "-DCMAKE_Fortran_COMPILER=${bld}/fc.sh" + "-DCMAKE_Fortran_FLAGS:STRING=@CMAKE_Fortran_FLAGS@" + RESULT_VARIABLE result + ) + +if(NOT "${result}" STREQUAL "0") + message(FATAL_ERROR "Configuration failed: ${result}") +endif() diff --git a/Tests/FortranC/test_opt.sh.in b/Tests/FortranC/test_opt.sh.in new file mode 100755 index 0000000..f3d93dc --- /dev/null +++ b/Tests/FortranC/test_opt.sh.in @@ -0,0 +1,18 @@ +#!/bin/sh + +TEST_OPT_@ID@_FOUND=0 +ARGS="" +for a in "$@"; do + if [ "x${TEST_OPT_@ID@}" != "x" -a "x${TEST_OPT_@ID@}" = "x$a" ]; then + TEST_OPT_@ID@_FOUND=1 + else + ARGS="$ARGS \"$a\"" + fi +done + +if [ "x${TEST_OPT_@ID@}" != "x" -a "x${TEST_OPT_@ID@_FOUND}" != "x1" ]; then + echo "Not given option '${TEST_OPT_@ID@}' as expected!" + exit 1 +fi + +eval "\"@COMMAND@\"" "$ARGS" diff --git a/Tests/LinkDirectory/CMakeLists.txt b/Tests/LinkDirectory/CMakeLists.txt new file mode 100644 index 0000000..7356b27 --- /dev/null +++ b/Tests/LinkDirectory/CMakeLists.txt @@ -0,0 +1,47 @@ +cmake_minimum_required(VERSION 2.8) +project(LinkDirectory C) + +# Put the subproject source tree in our build tree so it can refer to +# link directories relative to its source. +if(NOT "${LinkDirectory_SOURCE_DIR}" STREQUAL "${LinkDirectory_BINARY_DIR}") + file(COPY External/ DESTINATION External PATTERN CVS EXCLUDE) +endif() + +# Build a library into the subproject source tree. +add_library(mylibA STATIC mylibA.c) +set_property(TARGET mylibA PROPERTY + ARCHIVE_OUTPUT_DIRECTORY "${LinkDirectory_BINARY_DIR}/External/lib") +get_property(mylibA TARGET mylibA PROPERTY LOCATION) + +# Build a library into our build tree relative to the subproject build tree. +add_library(mylibB STATIC mylibB.c) +set_property(TARGET mylibB PROPERTY + ARCHIVE_OUTPUT_DIRECTORY "${LinkDirectory_BINARY_DIR}/lib") +get_property(mylibB TARGET mylibB PROPERTY LOCATION) + +# Create a custom target to drive the subproject build. +include(ExternalProject) +ExternalProject_Add(ExternalTarget + SOURCE_DIR "${LinkDirectory_BINARY_DIR}/External" + BINARY_DIR "${LinkDirectory_BINARY_DIR}/External-build" + CMAKE_ARGS "-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${LinkDirectory_BINARY_DIR}/bin" + PREFIX "${LinkDirectory_BINARY_DIR}/External-build/root" + DOWNLOAD_COMMAND "" + INSTALL_COMMAND "" + ) + +# Add a step to wipe out the subproject executable after our libraries +# change. This is needed because the subproject cannot depend on them +# directly because it does not know the full paths to the libraries. +# (The purpose of this test is to check that link_directories works.) +ExternalProject_Add_Step(ExternalTarget cleanup + COMMAND ${CMAKE_COMMAND} -E remove_directory ${LinkDirectory_BINARY_DIR}/bin + DEPENDEES download + DEPENDERS configure + DEPENDS ${mylibA} ${mylibB} + "${LinkDirectory_BINARY_DIR}/External/CMakeLists.txt" + "${LinkDirectory_BINARY_DIR}/External/myexe.c" + ) + +# Make the subproject build after our targets. +add_dependencies(ExternalTarget mylibA mylibB) diff --git a/Tests/LinkDirectory/External/CMakeLists.txt b/Tests/LinkDirectory/External/CMakeLists.txt new file mode 100644 index 0000000..f7c840f --- /dev/null +++ b/Tests/LinkDirectory/External/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 2.8) +project(LinkDirectoryExternal C) + +# Test CMP0015 OLD behavior: -L../lib +cmake_policy(SET CMP0015 OLD) +link_directories(../lib) + +# Test CMP0015 NEW behavior: -L${CMAKE_CURRENT_SOURCE_DIR}/lib +cmake_policy(SET CMP0015 NEW) +link_directories(lib) + +add_executable(myexe myexe.c) +set_property(TARGET myexe PROPERTY OUTPUT_NAME LinkDirectory) +target_link_libraries(myexe mylibA mylibB) diff --git a/Tests/LinkDirectory/External/myexe.c b/Tests/LinkDirectory/External/myexe.c new file mode 100644 index 0000000..6ef1ebe --- /dev/null +++ b/Tests/LinkDirectory/External/myexe.c @@ -0,0 +1,3 @@ +extern int mylibA(void); +extern int mylibB(void); +int main(void) { return mylibA() + mylibB(); } diff --git a/Tests/LinkDirectory/mylibA.c b/Tests/LinkDirectory/mylibA.c new file mode 100644 index 0000000..890a089 --- /dev/null +++ b/Tests/LinkDirectory/mylibA.c @@ -0,0 +1 @@ +int mylibA(void) { return 0; } diff --git a/Tests/LinkDirectory/mylibB.c b/Tests/LinkDirectory/mylibB.c new file mode 100644 index 0000000..090cc6c --- /dev/null +++ b/Tests/LinkDirectory/mylibB.c @@ -0,0 +1 @@ +int mylibB(void) { return 0; } diff --git a/Tests/Module/CheckTypeSize/CMakeLists.txt b/Tests/Module/CheckTypeSize/CMakeLists.txt new file mode 100644 index 0000000..45e9f67 --- /dev/null +++ b/Tests/Module/CheckTypeSize/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 2.8.1 FATAL_ERROR) +project(CheckTypeSize C) + +include(CheckTypeSize) +check_type_size("void*" SIZEOF_DATA_PTR) +check_type_size(char SIZEOF_CHAR) +check_type_size(short SIZEOF_SHORT) +check_type_size(int SIZEOF_INT) +check_type_size(long SIZEOF_LONG) +check_type_size("long long" SIZEOF_LONG_LONG) +check_type_size(__int64 SIZEOF___INT64) +check_type_size(size_t SIZEOF_SIZE_T) +check_type_size(ssize_t SIZEOF_SSIZE_T) + +configure_file(config.h.in config.h) +include_directories(${CheckTypeSize_BINARY_DIR}) + +add_executable(CheckTypeSize CheckTypeSize.c) diff --git a/Tests/Module/CheckTypeSize/CheckTypeSize.c b/Tests/Module/CheckTypeSize/CheckTypeSize.c new file mode 100644 index 0000000..602c834 --- /dev/null +++ b/Tests/Module/CheckTypeSize/CheckTypeSize.c @@ -0,0 +1,122 @@ +#include "config.h" + +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif +#ifdef HAVE_STDINT_H +# include <stdint.h> +#endif +#ifdef HAVE_STDDEF_H +# include <stddef.h> +#endif + +#include <stdio.h> + +#define CHECK(t,m) do { \ + if(sizeof(t) != m) \ + { \ + printf(#m ": expected %d, got %d (line %d)\n", \ + (int)sizeof(t), (int)m, __LINE__); \ + result = 1; \ + } \ + } while(0) + +#define NODEF(m) do { \ + printf(#m": not defined (line %d)\n", __LINE__); \ + result = 1; \ + } while(0) + +int main() +{ + int result = 0; + + /* void* */ +#if !defined(HAVE_SIZEOF_DATA_PTR) + NODEF(HAVE_SIZEOF_DATA_PTR); +#endif +#if defined(SIZEOF_DATA_PTR) + CHECK(void*, SIZEOF_DATA_PTR); +#else + NODEF(SIZEOF_DATA_PTR); +#endif + + /* char */ +#if !defined(HAVE_SIZEOF_CHAR) + NODEF(HAVE_SIZEOF_CHAR); +#endif +#if defined(SIZEOF_CHAR) + CHECK(char, SIZEOF_CHAR); +#else + NODEF(SIZEOF_CHAR); +#endif + + /* short */ +#if !defined(HAVE_SIZEOF_SHORT) + NODEF(HAVE_SIZEOF_SHORT); +#endif +#if defined(SIZEOF_SHORT) + CHECK(short, SIZEOF_SHORT); +#else + NODEF(SIZEOF_SHORT); +#endif + + /* int */ +#if !defined(HAVE_SIZEOF_INT) + NODEF(HAVE_SIZEOF_INT); +#endif +#if defined(SIZEOF_INT) + CHECK(int, SIZEOF_INT); +#else + NODEF(SIZEOF_INT); +#endif + + /* long */ +#if !defined(HAVE_SIZEOF_LONG) + NODEF(HAVE_SIZEOF_LONG); +#endif +#if defined(SIZEOF_LONG) + CHECK(long, SIZEOF_LONG); +#else + NODEF(SIZEOF_LONG); +#endif + + /* long long */ +#if defined(SIZEOF_LONG_LONG) + CHECK(long long, SIZEOF_LONG_LONG); +# if !defined(HAVE_SIZEOF_LONG_LONG) + NODEF(HAVE_SIZEOF_LONG_LONG); +# endif +#endif + + /* __int64 */ +#if defined(SIZEOF___INT64) + CHECK(__int64, SIZEOF___INT64); +# if !defined(HAVE_SIZEOF___INT64) + NODEF(HAVE_SIZEOF___INT64); +# endif +#elif defined(HAVE_SIZEOF___INT64) + NODEF(SIZEOF___INT64); +#endif + + /* size_t */ +#if !defined(HAVE_SIZEOF_SIZE_T) + NODEF(HAVE_SIZEOF_SIZE_T); +#endif +#if defined(SIZEOF_SIZE_T) + CHECK(size_t, SIZEOF_SIZE_T); +#else + NODEF(SIZEOF_SIZE_T); +#endif + + /* ssize_t */ +#if defined(SIZEOF_SSIZE_T) + CHECK(ssize_t, SIZEOF_SSIZE_T); +# if !defined(HAVE_SIZEOF_SSIZE_T) + NODEF(HAVE_SIZEOF_SSIZE_T); +# endif +#elif defined(HAVE_SIZEOF_SSIZE_T) + NODEF(SIZEOF_SSIZE_T); +#endif + + return result; +} diff --git a/Tests/Module/CheckTypeSize/config.h.in b/Tests/Module/CheckTypeSize/config.h.in new file mode 100644 index 0000000..b5bfbf6 --- /dev/null +++ b/Tests/Module/CheckTypeSize/config.h.in @@ -0,0 +1,39 @@ +#cmakedefine HAVE_SYS_TYPES_H +#cmakedefine HAVE_STDINT_H +#cmakedefine HAVE_STDDEF_H + +/* void* */ +#cmakedefine HAVE_SIZEOF_DATA_PTR +@SIZEOF_DATA_PTR_CODE@ + +/* char */ +#cmakedefine HAVE_SIZEOF_CHAR +@SIZEOF_CHAR_CODE@ + +/* short */ +#cmakedefine HAVE_SIZEOF_SHORT +@SIZEOF_SHORT_CODE@ + +/* int */ +#cmakedefine HAVE_SIZEOF_INT +@SIZEOF_INT_CODE@ + +/* long */ +#cmakedefine HAVE_SIZEOF_LONG +@SIZEOF_LONG_CODE@ + +/* long long */ +#cmakedefine HAVE_SIZEOF_LONG_LONG +@SIZEOF_LONG_LONG_CODE@ + +/* __int64 */ +#cmakedefine HAVE_SIZEOF___INT64 +@SIZEOF___INT64_CODE@ + +/* size_t */ +#cmakedefine HAVE_SIZEOF_SIZE_T +@SIZEOF_SIZE_T_CODE@ + +/* ssize_t */ +#cmakedefine HAVE_SIZEOF_SSIZE_T +@SIZEOF_SSIZE_T_CODE@ diff --git a/Tests/OutDir/CMakeLists.txt b/Tests/OutDir/CMakeLists.txt new file mode 100644 index 0000000..88468c3 --- /dev/null +++ b/Tests/OutDir/CMakeLists.txt @@ -0,0 +1,35 @@ +cmake_minimum_required(VERSION 2.8) +project(OutDir C) + +if(CMAKE_CONFIGURATION_TYPES) + foreach(config ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER "${config}" CONFIG) + list(APPEND configs "${CONFIG}") + endforeach() + set(CMAKE_BUILD_TYPE) +elseif(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug) +endif() + +if(CMAKE_BUILD_TYPE) + string(TOUPPER "${CMAKE_BUILD_TYPE}" configs) +endif() + +set(top "${OutDir_BINARY_DIR}") +foreach(config ${configs}) + foreach(type archive runtime library) + string(TOUPPER "${type}" TYPE) + set(CMAKE_${TYPE}_OUTPUT_DIRECTORY_${config} "${top}/${type}") + file(REMOVE_RECURSE "${top}/${type}") + endforeach() +endforeach() + +add_subdirectory(../COnly COnly) + +add_custom_command( + OUTPUT OutDir.h + COMMAND ${CMAKE_COMMAND} -Dtop=${top} -P ${OutDir_SOURCE_DIR}/OutDir.cmake + DEPENDS COnly ${OutDir_SOURCE_DIR}/OutDir.cmake + ) +include_directories(${top}) +add_executable(OutDir OutDir.c OutDir.h) diff --git a/Tests/OutDir/OutDir.c b/Tests/OutDir/OutDir.c new file mode 100644 index 0000000..53f9259 --- /dev/null +++ b/Tests/OutDir/OutDir.c @@ -0,0 +1,24 @@ +#include <OutDir.h> +#include <stdio.h> + +int main(void) +{ + const char* files[] = {TESTC1_LIB, TESTC2_LIB, CONLY_EXE, 0}; + int result = 0; + const char** fname = files; + for(;*fname;++fname) + { + FILE* f = fopen(*fname, "rb"); + if(f) + { + printf("found: [%s]\n", *fname); + fclose(f); + } + else + { + printf("error: [%s]\n", *fname); + result = 1; + } + } + return result; +} diff --git a/Tests/OutDir/OutDir.cmake b/Tests/OutDir/OutDir.cmake new file mode 100644 index 0000000..e1e6b7f --- /dev/null +++ b/Tests/OutDir/OutDir.cmake @@ -0,0 +1,28 @@ +set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "") +set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".a" ".so" ".sl" ".dylib" ".dll.a") + +find_library(TESTC1_LIB + NAMES testc1 testc1_test_debug_postfix + PATHS ${top}/archive + NO_DEFAULT_PATH) + +find_library(TESTC2_LIB + NAMES testc2 testc2_test_debug_postfix + PATHS ${top}/archive ${top}/library + NO_DEFAULT_PATH) + +find_program(CONLY_EXE + NAMES COnly + PATHS ${top}/runtime + NO_DEFAULT_PATH) + +file(WRITE ${top}/OutDir.h "/* Generated by ${CMAKE_CURRENT_LIST_FILE} */ +#ifndef OutDir_h +#define OutDir_h + +#define TESTC1_LIB \"${TESTC1_LIB}\" +#define TESTC2_LIB \"${TESTC2_LIB}\" +#define CONLY_EXE \"${CONLY_EXE}\" + +#endif +") diff --git a/Tests/SimpleInstall/CMakeLists.txt b/Tests/SimpleInstall/CMakeLists.txt index 7a249d8..5fc6550 100644 --- a/Tests/SimpleInstall/CMakeLists.txt +++ b/Tests/SimpleInstall/CMakeLists.txt @@ -364,14 +364,21 @@ SET(CPACK_PACKAGE_EXECUTABLES "SimpleInstall" "Simple Install") SET(CMAKE_INSTALL_MFC_LIBRARIES 1) SET(CMAKE_INSTALL_DEBUG_LIBRARIES 1) INCLUDE(InstallRequiredSystemLibraries) -INCLUDE(CPack) IF(CTEST_TEST_CPACK) SET(PACKAGE_TARGET --build-target package) + + # Avoid settings that require the .zip file command line tools... + # (just build an NSIS installer without component support) + # + SET(CPACK_BINARY_ZIP OFF) + SET(CPACK_MONOLITHIC_INSTALL ON) ELSE(CTEST_TEST_CPACK) SET(PACKAGE_TARGET) ENDIF(CTEST_TEST_CPACK) +INCLUDE(CPack) + ADD_CUSTOM_COMMAND( TARGET ${install_target} POST_BUILD diff --git a/Tests/SimpleInstallS2/CMakeLists.txt b/Tests/SimpleInstallS2/CMakeLists.txt index 7a249d8..5fc6550 100644 --- a/Tests/SimpleInstallS2/CMakeLists.txt +++ b/Tests/SimpleInstallS2/CMakeLists.txt @@ -364,14 +364,21 @@ SET(CPACK_PACKAGE_EXECUTABLES "SimpleInstall" "Simple Install") SET(CMAKE_INSTALL_MFC_LIBRARIES 1) SET(CMAKE_INSTALL_DEBUG_LIBRARIES 1) INCLUDE(InstallRequiredSystemLibraries) -INCLUDE(CPack) IF(CTEST_TEST_CPACK) SET(PACKAGE_TARGET --build-target package) + + # Avoid settings that require the .zip file command line tools... + # (just build an NSIS installer without component support) + # + SET(CPACK_BINARY_ZIP OFF) + SET(CPACK_MONOLITHIC_INSTALL ON) ELSE(CTEST_TEST_CPACK) SET(PACKAGE_TARGET) ENDIF(CTEST_TEST_CPACK) +INCLUDE(CPack) + ADD_CUSTOM_COMMAND( TARGET ${install_target} POST_BUILD diff --git a/Tests/SystemInformation/SystemInformation.in b/Tests/SystemInformation/SystemInformation.in index d2e4de4..1055d07 100644 --- a/Tests/SystemInformation/SystemInformation.in +++ b/Tests/SystemInformation/SystemInformation.in @@ -30,8 +30,6 @@ CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_C_FLAGS == "${CMAKE_SHARED_LIBRARY_LINK_DYNAMI // C shared module flags CMAKE_SHARED_MODULE_C_FLAGS == "${CMAKE_SHARED_MODULE_C_FLAGS}" CMAKE_SHARED_MODULE_CREATE_C_FLAGS == "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS}" -CMAKE_SHARED_MODULE_RUNTIME_FLAG == "${CMAKE_SHARED_MODULE_RUNTIME_FLAG}" -CMAKE_SHARED_MODULE_RUNTIME_FLAG_SEP == "${CMAKE_SHARED_MODULE_RUNTIME_FLAG_SEP}" CMAKE_SHARED_MODULE_LINK_STATIC_C_FLAGS == "${CMAKE_SHARED_MODULE_LINK_STATIC_C_FLAGS}" CMAKE_SHARED_MODULE_LINK_DYNAMIC_C_FLAGS == "${CMAKE_SHARED_MODULE_LINK_DYNAMIC_C_FLAGS}" @@ -51,8 +49,6 @@ CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_CXX_FLAGS == "${CMAKE_SHARED_LIBRARY_LINK_DYNA // CXX shared module flags CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS == "${CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS}" CMAKE_SHARED_MODULE_CXX_FLAGS == "${CMAKE_SHARED_MODULE_CXX_FLAGS}" -CMAKE_SHARED_MODULE_RUNTIME_CXX_FLAG == "${CMAKE_SHARED_MODULE_RUNTIME_CXX_FLAG}" -CMAKE_SHARED_MODULE_RUNTIME_CXX_FLAG_SEP == "${CMAKE_SHARED_MODULE_RUNTIME_CXX_FLAG_SEP}" CMAKE_SHARED_MODULE_LINK_STATIC_CXX_FLAGS == "${CMAKE_SHARED_MODULE_LINK_STATIC_CXX_FLAGS}" CMAKE_SHARED_MODULE_LINK_DYNAMIC_CXX_FLAGS == "${CMAKE_SHARED_MODULE_LINK_DYNAMIC_CXX_FLAGS}" diff --git a/Tests/TarTest/CMakeLists.txt b/Tests/TarTest/CMakeLists.txt index 548712d..a3c5b31 100644 --- a/Tests/TarTest/CMakeLists.txt +++ b/Tests/TarTest/CMakeLists.txt @@ -28,9 +28,19 @@ IF(UNIX) SET(CHECK_FILES ${CHECK_FILES} "d1/f2.txt") ENDIF(UNIX) +# cleanup first in case there are files left from previous runs +# if the umask is odd on the machine it might create files that +# are not automatically over written. These tests are run +# each time the configure step is run. +FILE(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/test_tar.tar") +FILE(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/test_tgz.tgz") +FILE(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/test_output_tar") +FILE(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/test_output_tgz") + MAKE_DIRECTORY("${CMAKE_CURRENT_BINARY_DIR}/test_output_tar") MAKE_DIRECTORY("${CMAKE_CURRENT_BINARY_DIR}/test_output_tgz") + # Run tests EXEC_TAR_COMMAND("${CMAKE_CURRENT_BINARY_DIR}" "cvf \"${CMAKE_CURRENT_BINARY_DIR}/test_tar.tar\" tar_dir") EXEC_TAR_COMMAND("${CMAKE_CURRENT_BINARY_DIR}" "cvfz \"${CMAKE_CURRENT_BINARY_DIR}/test_tgz.tgz\" tar_dir") diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt index 62bed87..a57498f 100644 --- a/Tests/TryCompile/CMakeLists.txt +++ b/Tests/TryCompile/CMakeLists.txt @@ -211,12 +211,18 @@ TEST_ASSERT(CXX_BUILD_SHOULD_WORK "CHECK_CXX_SOURCE_COMPILES() failed") TEST_FAIL(CXX_RUN_SHOULD_FAIL "CHECK_CXX_SOURCE_RUNS() succeeded, but should have failed") TEST_ASSERT(CXX_RUN_SHOULD_WORK "CHECK_CXX_SOURCE_RUNS() failed") +FOREACH(lang C CXX) + IF(NOT "${CMAKE_${lang}_COMPILER_ID}" MATCHES "^(PathScale)$") + SET(${lang}_DD --) + ENDIF() +ENDFOREACH() + UNSET(C_BOGUS_FLAG CACHE) INCLUDE(CheckCCompilerFlag) -CHECK_C_COMPILER_FLAG(---_this_is_not_a_flag_ C_BOGUS_FLAG) +CHECK_C_COMPILER_FLAG(${C_DD}-_this_is_not_a_flag_ C_BOGUS_FLAG) TEST_FAIL(C_BOGUS_FLAG "CHECK_C_COMPILER_FLAG() succeeded, but should have failed") UNSET(CXX_BOGUS_FLAG CACHE) INCLUDE(CheckCXXCompilerFlag) -CHECK_CXX_COMPILER_FLAG(---_this_is_not_a_flag_ CXX_BOGUS_FLAG) +CHECK_CXX_COMPILER_FLAG(${CXX_DD}-_this_is_not_a_flag_ CXX_BOGUS_FLAG) TEST_FAIL(CXX_BOGUS_FLAG "CHECK_CXX_COMPILER_FLAG() succeeded, but should have failed") diff --git a/Utilities/Release/create-cmake-release.cmake b/Utilities/Release/create-cmake-release.cmake index 93c7e44..4a88c82 100644 --- a/Utilities/Release/create-cmake-release.cmake +++ b/Utilities/Release/create-cmake-release.cmake @@ -7,18 +7,16 @@ set(RELEASE_SCRIPTS dashsun1_release.cmake # SunOS destiny_release.cmake # HPUX magrathea_release.cmake # Linux - vogon_release.cmake # Windows + dash2win64_release.cmake # Windows v20n17_aix_release.cmake # AIX 5.3 - vogon_cygwin.cmake # Cygwin +# vogon_cygwin.cmake # Cygwin ferrari_sgi64_release.cmake # IRIX 64 ferrari_sgi_release.cmake # IRIX 64 -# dashsgi1_release.cmake # IRIX -# dashsgi1_release64.cmake # IRIX 64 # r36n11_aix_release.cmake # AIX 5.3 # r15n65_aix_release.cmake # AIX 5.2 ) -file(WRITE create-${CMAKE_CREATE_VERSION}.sh "#!/bin/sh") +file(WRITE create-${CMAKE_CREATE_VERSION}.sh "#!/bin/bash") make_directory(${CMAKE_CURRENT_SOURCE_DIR}/logs) foreach(f ${RELEASE_SCRIPTS}) diff --git a/Utilities/Release/dash2win64_release.cmake b/Utilities/Release/dash2win64_release.cmake index 19fec14..b1fd388 100644 --- a/Utilities/Release/dash2win64_release.cmake +++ b/Utilities/Release/dash2win64_release.cmake @@ -9,6 +9,7 @@ set(MAKE_PROGRAM "make") set(MAKE "${MAKE_PROGRAM} -j8") set(INITIAL_CACHE "CMAKE_BUILD_TYPE:STRING=Release CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE +CMAKE_Fortran_COMPILER:FILEPATH=FALSE CMAKE_GENERATOR:INTERNAL=Unix Makefiles BUILD_QtDialog:BOOL:=TRUE QT_QMAKE_EXECUTABLE:FILEPATH=c:/Dashboards/Support/qt-4.5.3-static/bin/qmake.exe diff --git a/Utilities/Release/destiny_release.cmake b/Utilities/Release/destiny_release.cmake index 886909f..06cc601 100644 --- a/Utilities/Release/destiny_release.cmake +++ b/Utilities/Release/destiny_release.cmake @@ -1,4 +1,5 @@ set(PROCESSORS 1) +set(CVSROOT ":pserver:anonymous@www.cmake.org:/cvsroot/CMake") set(RUN_SHELL "/usr/local/bin/zsh -l -c /bin/sh") set(CVS_COMMAND "/usr/local/bin/cvs") set(HOST destiny) diff --git a/Utilities/Release/upload_release.cmake b/Utilities/Release/upload_release.cmake index c7f99c0..211bc3e 100644 --- a/Utilities/Release/upload_release.cmake +++ b/Utilities/Release/upload_release.cmake @@ -1,6 +1,6 @@ set(PROJECT_PREFIX cmake-) if(NOT VERSION) - set(VERSION 2.6) + set(VERSION 2.8) endif(NOT VERSION) file(GLOB FILES ${CMAKE_CURRENT_SOURCE_DIR} "${PROJECT_PREFIX}*") message("${FILES}") diff --git a/Utilities/Release/v20n17_aix_release.cmake b/Utilities/Release/v20n17_aix_release.cmake index b7494bb..a169817 100644 --- a/Utilities/Release/v20n17_aix_release.cmake +++ b/Utilities/Release/v20n17_aix_release.cmake @@ -1,4 +1,5 @@ set(CMAKE_RELEASE_DIRECTORY "/bench1/noibm34/CMakeReleaseDirectory" ) +set(CVSROOT ":pserver:anonymous@www.cmake.org:/cvsroot/CMake") set(FINAL_PATH /u/noibm34/cmake-release) set(PROCESSORS 2) set(CVS_COMMAND /vol/local/bin/cvs) diff --git a/Utilities/cmcurl/CMake/CheckTypeSize.c.in b/Utilities/cmcurl/CMake/CheckTypeSize.c.in deleted file mode 100644 index 8c9a016..0000000 --- a/Utilities/cmcurl/CMake/CheckTypeSize.c.in +++ /dev/null @@ -1,34 +0,0 @@ -#cmakedefine CHECK_TYPE_SIZE_TYPE @CHECK_TYPE_SIZE_TYPE@ -#ifdef CHECK_TYPE_SIZE_TYPE - -@CHECK_TYPE_SIZE_PREINCLUDE@ -#ifdef HAVE_SYS_TYPES_H -# include <sys/types.h> -#endif /* HAVE_SYS_TYPES_H */ - -#ifdef HAVE_STDINT_H -# include <stdint.h> -#endif /* HAVE_STDINT_H */ - -#ifdef HAVE_STDDEF_H -# include <stddef.h> -#endif /* HAVE_STDDEF_H */ - -@CHECK_TYPE_SIZE_PREMAIN@ - -#ifdef __CLASSIC_C__ -int main(){ - int ac; - char*av[]; -#else -int main(int ac, char*av[]){ -#endif - if(ac > 1000){return *av[0];} - return sizeof(CHECK_TYPE_SIZE_TYPE); -} - -#else /* CHECK_TYPE_SIZE_TYPE */ - -# error "CHECK_TYPE_SIZE_TYPE has to specify the type" - -#endif /* CHECK_TYPE_SIZE_TYPE */ diff --git a/Utilities/cmcurl/CMake/CheckTypeSize.cmake b/Utilities/cmcurl/CMake/CheckTypeSize.cmake deleted file mode 100644 index e16c64d..0000000 --- a/Utilities/cmcurl/CMake/CheckTypeSize.cmake +++ /dev/null @@ -1,56 +0,0 @@ -# - Check sizeof a type -# CHECK_TYPE_SIZE(TYPE VARIABLE) -# Check if the type exists and determine size of type. if the type -# exists, the size will be stored to the variable. -# -# VARIABLE - variable to store size if the type exists. -# HAVE_${VARIABLE} - does the variable exists or not - -MACRO(CHECK_TYPE_SIZE TYPE VARIABLE) - SET(CMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS 1) - IF(NOT DEFINED ${VARIABLE}) - IF("HAVE_${VARIABLE}" MATCHES "^HAVE_${VARIABLE}$") - SET(CHECK_TYPE_SIZE_TYPE "${TYPE}") - SET(MACRO_CHECK_TYPE_SIZE_FLAGS - "${CMAKE_REQUIRED_FLAGS}") - FOREACH(def HAVE_SYS_TYPES_H HAVE_STDINT_H HAVE_STDDEF_H) - IF("${def}") - SET(MACRO_CHECK_TYPE_SIZE_FLAGS - "${MACRO_CHECK_TYPE_SIZE_FLAGS} -D${def}") - ENDIF("${def}") - ENDFOREACH(def) - SET(CHECK_TYPE_SIZE_PREMAIN) - FOREACH(def ${CMAKE_EXTRA_INCLUDE_FILES}) - SET(CHECK_TYPE_SIZE_PREMAIN "${CHECK_TYPE_SIZE_PREMAIN}#include \"${def}\"\n") - ENDFOREACH(def) - CONFIGURE_FILE( - "${CMAKE_CURRENT_SOURCE_DIR}/CMake/CheckTypeSize.c.in" - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckTypeSize.c" - IMMEDIATE @ONLY) - FILE(READ - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckTypeSize.c" - CHECK_TYPE_SIZE_FILE_CONTENT) - MESSAGE(STATUS "Check size of ${TYPE}") - IF(CMAKE_REQUIRED_LIBRARIES) - SET(CHECK_TYPE_SIZE_ADD_LIBRARIES - "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") - ENDIF(CMAKE_REQUIRED_LIBRARIES) - TRY_RUN(${VARIABLE} HAVE_${VARIABLE} - ${CMAKE_BINARY_DIR} - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckTypeSize.c" - CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_TYPE_SIZE_FLAGS} - "${CHECK_TYPE_SIZE_ADD_LIBRARIES}" - OUTPUT_VARIABLE OUTPUT) - IF(HAVE_${VARIABLE}) - MESSAGE(STATUS "Check size of ${TYPE} - done") - FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining size of ${TYPE} passed with the following output:\n${OUTPUT}\n\n") - ELSE(HAVE_${VARIABLE}) - MESSAGE(STATUS "Check size of ${TYPE} - failed") - FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining size of ${TYPE} failed with the following output:\n${OUTPUT}\nCheckTypeSize.c:\n${CHECK_TYPE_SIZE_FILE_CONTENT}\n\n") - ENDIF(HAVE_${VARIABLE}) - ENDIF("HAVE_${VARIABLE}" MATCHES "^HAVE_${VARIABLE}$") - ENDIF(NOT DEFINED ${VARIABLE}) - SET(CMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS ) -ENDMACRO(CHECK_TYPE_SIZE) diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt index e2c64db..d7ff9aa 100644 --- a/Utilities/cmcurl/CMakeLists.txt +++ b/Utilities/cmcurl/CMakeLists.txt @@ -2,10 +2,11 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.4) IF(COMMAND CMAKE_POLICY) CMAKE_POLICY(SET CMP0003 NEW) ENDIF(COMMAND CMAKE_POLICY) +IF(CMAKE_OSX_ARCHITECTURES) + CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3 FATAL_ERROR) +ENDIF(CMAKE_OSX_ARCHITECTURES) PROJECT(LIBCURL C) -INCLUDE_REGULAR_EXPRESSION("^.*$") - # Setup package meta-data SET(PACKAGE "curl") SET(VERSION "7.16.1") @@ -38,13 +39,12 @@ INCLUDE (CheckIncludeFile) INCLUDE (CheckIncludeFiles) INCLUDE (CheckLibraryExists) INCLUDE (CheckSymbolExists) -# if crosscompiling is on, the CHECK_TYPE_SIZE macro coming with cmake uses -# TRY_COMPILE instead of TRY_RUN which makes crosscompiling easier, Alex -IF(CMAKE_CROSSCOMPILING) - INCLUDE ("${CMAKE_ROOT}/Modules/CheckTypeSize.cmake") -ELSE(CMAKE_CROSSCOMPILING) +IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.4 + AND CMake_SOURCE_DIR) + INCLUDE (${CMake_SOURCE_DIR}/Modules/CheckTypeSize.cmake) +ELSE() INCLUDE (CheckTypeSize) -ENDIF(CMAKE_CROSSCOMPILING) +ENDIF() SET(libCurl_SRCS # amigaos.c - does not build on AmigaOS @@ -246,6 +246,12 @@ MACRO(CHECK_INCLUDE_FILE_CONCAT FILE VARIABLE) ENDMACRO(CHECK_INCLUDE_FILE_CONCAT) # Check for header files +IF(UNIX) + SET(HAVE_WINDOWS_H 0) + SET(HAVE_WINSOCK_H 0) + SET(HAVE_WS2TCPIP_H 0) + SET(HAVE_WINSOCK2_H 0) +ENDIF(UNIX) IF(NOT UNIX) CHECK_INCLUDE_FILE_CONCAT("ws2tcpip.h" HAVE_WS2TCPIP_H) CHECK_INCLUDE_FILE_CONCAT("winsock2.h" HAVE_WINSOCK2_H) @@ -330,16 +336,7 @@ CHECK_TYPE_SIZE(ssize_t SIZEOF_SSIZE_T) CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG) CHECK_TYPE_SIZE("long" SIZEOF_LONG) CHECK_TYPE_SIZE("__int64" SIZEOF___INT64) -CHECK_TYPE_SIZE("long double" SIZEOF_LONG_DOUBLE) CHECK_TYPE_SIZE("time_t" SIZEOF_TIME_T) -IF(NOT HAVE_SIZEOF_SSIZE_T) - IF(SIZEOF_LONG EQUAL SIZEOF_SIZE_T) - SET(ssize_t long) - ENDIF(SIZEOF_LONG EQUAL SIZEOF_SIZE_T) - IF(NOT ssize_t AND SIZEOF___INT64 EQUAL SIZEOF_SIZE_T) - SET(ssize_t __int64) - ENDIF(NOT ssize_t AND SIZEOF___INT64 EQUAL SIZEOF_SIZE_T) -ENDIF(NOT HAVE_SIZEOF_SSIZE_T) IF(HAVE_SIZEOF_LONG_LONG) SET(HAVE_LONGLONG 1) @@ -726,6 +723,26 @@ ELSE(CMAKE_BUILD_CURL_SHARED) -DCURL_STATICLIB) ENDIF(CMAKE_BUILD_CURL_SHARED) SET(CURL_STATICLIB) + +# Support CheckTypeSize module from CMake 2.8.0 and lower. +FOREACH(var + SIZEOF_CURL_OFF_T + SIZEOF_LONG + SIZEOF_LONG_LONG + SIZEOF___INT64 + SIZEOF_SIZE_T + SIZEOF_TIME_T + ) + IF(NOT ${var}_CODE) + MESSAGE("creating ${var}_CODE") + IF(${var}) + SET(${var}_CODE "#define ${var} ${${var}}") + ELSE() + SET(${var}_CODE "/* #undef ${var} */") + ENDIF() + ENDIF() +ENDFOREACH() + CONFIGURE_FILE(${LIBCURL_SOURCE_DIR}/config.h.in ${LIBCURL_BINARY_DIR}/config.h) @@ -734,7 +751,7 @@ ADD_LIBRARY(cmcurl ${LIBRARY_TYPE} ${libCurl_SRCS}) TARGET_LINK_LIBRARIES(cmcurl ${CURL_LIBS}) IF(CMAKE_BUILD_CURL_SHARED) SET_TARGET_PROPERTIES(cmcurl PROPERTIES DEFINE_SYMBOL BUILDING_LIBCURL - RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) + RUNTIME_OUTPUT_DIRECTORY ${CMake_BIN_DIR}) INSTALL_TARGETS(/bin cmcurl) ENDIF(CMAKE_BUILD_CURL_SHARED) @@ -745,5 +762,5 @@ ENDIF(CURL_TESTING) ADD_EXECUTABLE(LIBCURL Testing/curltest.c) TARGET_LINK_LIBRARIES(LIBCURL cmcurl ${CMAKE_DL_LIBS}) -ADD_TEST(curl "${EXECUTABLE_OUTPUT_PATH}/LIBCURL") +ADD_TEST(curl LIBCURL) INSTALL(FILES COPYING DESTINATION ${CMake_DOC_DEST}/cmcurl) diff --git a/Utilities/cmcurl/config.h.in b/Utilities/cmcurl/config.h.in index 6f2e5db..e3efdc1 100644 --- a/Utilities/cmcurl/config.h.in +++ b/Utilities/cmcurl/config.h.in @@ -640,16 +640,25 @@ #cmakedefine SEND_TYPE_RETV ${SEND_TYPE_RETV} /* The size of `curl_off_t', as computed by sizeof. */ -#cmakedefine SIZEOF_CURL_OFF_T ${SIZEOF_CURL_OFF_T} +@SIZEOF_CURL_OFF_T_CODE@ /* The size of `long', as computed by sizeof. */ -#cmakedefine SIZEOF_LONG ${SIZEOF_LONG} +@SIZEOF_LONG_CODE@ + +/* The size of `long long', as computed by sizeof. */ +@SIZEOF_LONG_LONG_CODE@ + +/* The size of `__int64', as computed by sizeof. */ +@SIZEOF___INT64_CODE@ /* The size of `size_t', as computed by sizeof. */ -#cmakedefine SIZEOF_SIZE_T ${SIZEOF_SIZE_T} +@SIZEOF_SIZE_T_CODE@ + +/* The size of `ssize_t', as computed by sizeof. */ +@SIZEOF_SSIZE_T_CODE@ /* The size of `time_t', as computed by sizeof. */ -#cmakedefine SIZEOF_TIME_T ${SIZEOF_TIME_T} +@SIZEOF_TIME_T_CODE@ /* Define to 1 if you have the ANSI C header files. */ #cmakedefine STDC_HEADERS ${STDC_HEADERS} @@ -713,7 +722,17 @@ #cmakedefine socklen_t ${socklen_t} /* the signed version of size_t */ -#cmakedefine ssize_t ${ssize_t} +#ifndef SIZEOF_SSIZE_T +# if SIZEOF_LONG == SIZEOF_SIZE_T + typedef long ssize_t; +# elif SIZEOF_LONG_LONG == SIZEOF_SIZE_T + typedef long long ssize_t; +# elif SIZEOF___INT64 == SIZEOF_SIZE_T + typedef __int64 ssize_t; +# else + typedef int ssize_t; +# endif +#endif /* Special handling of zlib library */ #cmakedefine CURL_SPECIAL_ZLIB_H "${CURL_SPECIAL_ZLIB_H}" diff --git a/Utilities/cmcurl/mprintf.c b/Utilities/cmcurl/mprintf.c index 6103953..8b2f3d0 100644 --- a/Utilities/cmcurl/mprintf.c +++ b/Utilities/cmcurl/mprintf.c @@ -44,10 +44,6 @@ #include <curl/mprintf.h> -#ifndef SIZEOF_LONG_DOUBLE -#define SIZEOF_LONG_DOUBLE 0 -#endif - #ifndef SIZEOF_SIZE_T /* default to 4 bytes for size_t unless defined in the config.h */ #define SIZEOF_SIZE_T 4 diff --git a/Utilities/cmexpat/CMakeLists.txt b/Utilities/cmexpat/CMakeLists.txt index 7dd8329..b75c112 100644 --- a/Utilities/cmexpat/CMakeLists.txt +++ b/Utilities/cmexpat/CMakeLists.txt @@ -1,5 +1,4 @@ PROJECT(CMEXPAT) -INCLUDE_REGULAR_EXPRESSION("^.*$") SET(expat_SRCS xmlparse.c diff --git a/Utilities/cmzlib/CMakeLists.txt b/Utilities/cmzlib/CMakeLists.txt index 5ee43e3..c42a434 100644 --- a/Utilities/cmzlib/CMakeLists.txt +++ b/Utilities/cmzlib/CMakeLists.txt @@ -6,9 +6,6 @@ INCLUDE_DIRECTORIES( "${CMZLIB_BINARY_DIR}/.." ) -# Match all headers for dependencies but complain about none. -INCLUDE_REGULAR_EXPRESSION("^.*$") - # source files for zlib SET(ZLIB_SRCS adler32.c compress.c crc32.c deflate.c gzio.c inffast.c diff --git a/Utilities/cmzlib/deflate.c b/Utilities/cmzlib/deflate.c index 29ce1f6..a5e7a35 100644 --- a/Utilities/cmzlib/deflate.c +++ b/Utilities/cmzlib/deflate.c @@ -285,6 +285,13 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH); s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte)); + + // The following memset eliminates the valgrind uninitialized warning + // "swept under the carpet" here: + // http://www.zlib.net/zlib_faq.html#faq36 + // + memset(s->window, 0, s->w_size*2*sizeof(Byte)); + s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos)); s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos)); |