diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CMakeFindDependencyMacro.cmake | 34 | ||||
-rw-r--r-- | Modules/ExternalProject.cmake | 9 | ||||
-rw-r--r-- | Modules/FindGTest.cmake | 8 | ||||
-rw-r--r-- | Modules/FindHg.cmake | 37 | ||||
-rw-r--r-- | Modules/FindOpenCL.cmake | 134 | ||||
-rw-r--r-- | Modules/Platform/Windows-MSVC.cmake | 2 | ||||
-rw-r--r-- | Modules/UseQt4.cmake | 4 | ||||
-rw-r--r-- | Modules/UseSWIG.cmake | 7 |
8 files changed, 213 insertions, 22 deletions
diff --git a/Modules/CMakeFindDependencyMacro.cmake b/Modules/CMakeFindDependencyMacro.cmake index 0f1f56d..9334ba3 100644 --- a/Modules/CMakeFindDependencyMacro.cmake +++ b/Modules/CMakeFindDependencyMacro.cmake @@ -29,29 +29,34 @@ macro(find_dependency dep) if (NOT ${dep}_FOUND) - if (${ARGV1}) - set(version ${ARGV1}) + set(cmake_fd_version) + if (${ARGC} GREATER 1) + set(cmake_fd_version ${ARGV1}) endif() - set(exact_arg) + set(cmake_fd_exact_arg) if(${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION_EXACT) - set(exact_arg EXACT) + set(cmake_fd_exact_arg EXACT) endif() - set(quiet_arg) + set(cmake_fd_quiet_arg) if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY) - set(quiet_arg QUIET) + set(cmake_fd_quiet_arg QUIET) endif() - set(required_arg) + set(cmake_fd_required_arg) if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED) - set(required_arg REQUIRED) + set(cmake_fd_required_arg REQUIRED) endif() - get_property(alreadyTransitive GLOBAL PROPERTY + get_property(cmake_fd_alreadyTransitive GLOBAL PROPERTY _CMAKE_${dep}_TRANSITIVE_DEPENDENCY ) - find_package(${dep} ${version} ${exact_arg} ${quiet_arg} ${required_arg}) + find_package(${dep} ${cmake_fd_version} + ${cmake_fd_exact_arg} + ${cmake_fd_quiet_arg} + ${cmake_fd_required_arg} + ) - if(NOT DEFINED alreadyTransitive OR alreadyTransitive) + if(NOT DEFINED cmake_fd_alreadyTransitive OR cmake_fd_alreadyTransitive) set_property(GLOBAL PROPERTY _CMAKE_${dep}_TRANSITIVE_DEPENDENCY TRUE) endif() @@ -60,8 +65,9 @@ macro(find_dependency dep) set(${CMAKE_FIND_PACKAGE_NAME}_FOUND False) return() endif() - set(required_arg) - set(quiet_arg) - set(exact_arg) + set(cmake_fd_version) + set(cmake_fd_required_arg) + set(cmake_fd_quiet_arg) + set(cmake_fd_exact_arg) endif() endmacro() diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 0df51a8..1e83163 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -54,6 +54,7 @@ # [BINARY_DIR dir] # Specify build dir location # [BUILD_COMMAND cmd...] # Command to drive the native build # [BUILD_IN_SOURCE 1] # Use source dir for build dir +# [BUILD_ALWAYS 1] # No stamp file, build step always runs # #--Install step--------------- # [INSTALL_DIR dir] # Installation prefix # [INSTALL_COMMAND cmd...] # Command to drive install after build @@ -1716,10 +1717,18 @@ function(_ep_add_build_command name) set(log "") endif() + get_property(build_always TARGET ${name} PROPERTY _EP_BUILD_ALWAYS) + if(build_always) + set(always 1) + else() + set(always 0) + endif() + ExternalProject_Add_Step(${name} build COMMAND ${cmd} WORKING_DIRECTORY ${binary_dir} DEPENDEES configure + ALWAYS ${always} ${log} ) endfunction() diff --git a/Modules/FindGTest.cmake b/Modules/FindGTest.cmake index c00a750..aa3c235 100644 --- a/Modules/FindGTest.cmake +++ b/Modules/FindGTest.cmake @@ -79,7 +79,7 @@ # extra_args = Pass a list of extra arguments to be passed to # executable enclosed in quotes (or "" for none) # ARGN = A list of source files to search for tests & test -# fixtures. +# fixtures. Or AUTO to find them from executable target. # # # @@ -88,7 +88,7 @@ # Example: # set(FooTestArgs --foo 1 --bar 2) # add_executable(FooTest FooUnitTest.cc) -# GTEST_ADD_TESTS(FooTest "${FooTestArgs}" FooUnitTest.cc) +# GTEST_ADD_TESTS(FooTest "${FooTestArgs}" AUTO) #============================================================================= # Copyright 2009 Kitware, Inc. @@ -111,6 +111,10 @@ function(GTEST_ADD_TESTS executable extra_args) if(NOT ARGN) message(FATAL_ERROR "Missing ARGN: Read the documentation for GTEST_ADD_TESTS") endif() + if(ARGN STREQUAL "AUTO") + # obtain sources used for building that executable + get_property(ARGN TARGET ${executable} PROPERTY SOURCES) + endif() foreach(source ${ARGN}) file(READ "${source}" contents) string(REGEX MATCHALL "TEST_?F?\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents}) diff --git a/Modules/FindHg.cmake b/Modules/FindHg.cmake index a1fb33f..c418afd 100644 --- a/Modules/FindHg.cmake +++ b/Modules/FindHg.cmake @@ -2,7 +2,7 @@ # FindHg # ------ # -# +# Extract information from a mercurial working copy. # # The module defines the following variables: # @@ -12,6 +12,20 @@ # HG_FOUND - true if the command line client was found # HG_VERSION_STRING - the version of mercurial found # +# If the command line client executable is found the following macro is defined: +# +# :: +# +# HG_WC_INFO(<dir> <var-prefix>) +# +# Hg_WC_INFO extracts information of a mercurial working copy +# at a given location. This macro defines the following variables: +# +# :: +# +# <var-prefix>_WC_CHANGESET - current changeset +# <var-prefix>_WC_REVISION - current revision +# # Example usage: # # :: @@ -19,11 +33,15 @@ # find_package(Hg) # if(HG_FOUND) # message("hg found: ${HG_EXECUTABLE}") +# HG_WC_INFO(${PROJECT_SOURCE_DIR} Project) +# message("Current revision is ${Project_WC_REVISION}") +# message("Current changeset is ${Project_WC_CHANGESET}") # endif() #============================================================================= # Copyright 2010-2012 Kitware, Inc. # Copyright 2012 Rolf Eike Beer <eike@sf-mail.de> +# Copyright 2014 Matthaeus G. Chajdas # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -37,6 +55,8 @@ find_program(HG_EXECUTABLE NAMES hg + PATHS + [HKEY_LOCAL_MACHINE\\Software\\TortoiseHG] PATH_SUFFIXES Mercurial DOC "hg command line client" ) @@ -51,6 +71,21 @@ if(HG_EXECUTABLE) set(HG_VERSION_STRING "${CMAKE_MATCH_1}") endif() unset(hg_version) + + macro(HG_WC_INFO dir prefix) + execute_process(COMMAND ${HG_EXECUTABLE} id -i -n + WORKING_DIRECTORY ${dir} + RESULT_VARIABLE hg_id_result + ERROR_VARIABLE hg_id_error + OUTPUT_VARIABLE ${prefix}_WC_DATA + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT ${hg_id_result} EQUAL 0) + message(SEND_ERROR "Command \"${HG_EXECUTBALE} id -n\" in directory ${dir} failed with output:\n${hg_id_error}") + endif() + + string(REGEX REPLACE "([0-9a-f]+)\\+? [0-9]+\\+?" "\\1" ${prefix}_WC_CHANGESET ${${prefix}_WC_DATA}) + string(REGEX REPLACE "[0-9a-f]+\\+? ([0-9]+)\\+?" "\\1" ${prefix}_WC_REVISION ${${prefix}_WC_DATA}) + endmacro(HG_WC_INFO) endif() # Handle the QUIETLY and REQUIRED arguments and set HG_FOUND to TRUE if diff --git a/Modules/FindOpenCL.cmake b/Modules/FindOpenCL.cmake new file mode 100644 index 0000000..eee06bf --- /dev/null +++ b/Modules/FindOpenCL.cmake @@ -0,0 +1,134 @@ +#.rst: +# FindOpenCL +# ---------- +# +# Try to find OpenCL +# +# Once done this will define:: +# +# OpenCL_FOUND - True if OpenCL was found +# OpenCL_INCLUDE_DIRS - include directories for OpenCL +# OpenCL_LIBRARIES - link against this library to use OpenCL +# OpenCL_VERSION_STRING - Highest supported OpenCL version (eg. 1.2) +# OpenCL_VERSION_MAJOR - The major version of the OpenCL implementation +# OpenCL_VERSION_MINOR - The minor version of the OpenCL implementation +# +# The module will also define two cache variables:: +# +# OpenCL_INCLUDE_DIR - the OpenCL include directory +# OpenCL_LIBRARY - the path to the OpenCL library +# + +#============================================================================= +# Copyright 2014 Matthaeus G. Chajdas +# +# 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 distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +function(_FIND_OPENCL_VERSION) + include(CheckSymbolExists) + include(CMakePushCheckState) + + CMAKE_PUSH_CHECK_STATE() + foreach(VERSION "2_0" "1_2" "1_1" "1_0") + set(CMAKE_REQUIRED_INCLUDES "${OpenCL_INCLUDE_DIR}") + + if(APPLE) + CHECK_SYMBOL_EXISTS( + CL_VERSION_${VERSION} + "${OpenCL_INCLUDE_DIR}/OpenCL/cl.h" + OPENCL_VERSION_${VERSION}) + else() + CHECK_SYMBOL_EXISTS( + CL_VERSION_${VERSION} + "${OpenCL_INCLUDE_DIR}/CL/cl.h" + OPENCL_VERSION_${VERSION}) + endif() + + if(OPENCL_VERSION_${VERSION}) + string(REPLACE "_" "." VERSION "${VERSION}") + set(OpenCL_VERSION_STRING ${VERSION} PARENT_SCOPE) + string(REGEX MATCHALL "[0-9]+" version_components "${VERSION}") + list(GET version_components 0 major_version) + list(GET version_components 1 minor_version) + set(OpenCL_VERSION_MAJOR ${major_version} PARENT_SCOPE) + set(OpenCL_VERSION_MINOR ${minor_version} PARENT_SCOPE) + break() + endif() + endforeach() + CMAKE_POP_CHECK_STATE() +endfunction() + +find_path(OpenCL_INCLUDE_DIR + NAMES + CL/cl.h OpenCL/cl.h + PATHS ENV + "PROGRAMFILES(X86)" + AMDAPPSDKROOT + INTELOCLSDKROOT + NVSDKCOMPUTE_ROOT + CUDA_PATH + ATISTREAMSDKROOT + PATH_SUFFIXES + OpenCL/common/inc + "AMD APP/include") + +_FIND_OPENCL_VERSION() + +if(WIN32) + if(CMAKE_SIZEOF_VOID_P EQUAL 4) + find_library(OpenCL_LIBRARY + NAMES OpenCL + PATHS ENV + "PROGRAMFILES(X86)" + AMDAPPSDKROOT + INTELOCLSDKROOT + CUDA_PATH + NVSDKCOMPUTE_ROOT + ATISTREAMSDKROOT + PATH_SUFFIXES + "AMD APP/lib/x86" + lib/x86 + lib/Win32 + OpenCL/common/lib/Win32) + elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) + find_library(OpenCL_LIBRARY + NAMES OpenCL + PATHS ENV + "PROGRAMFILES(X86)" + AMDAPPSDKROOT + INTELOCLSDKROOT + CUDA_PATH + NVSDKCOMPUTE_ROOT + ATISTREAMSDKROOT + PATH_SUFFIXES + "AMD APP/lib/x86_64" + lib/x86_64 + lib/x64 + OpenCL/common/lib/x64) + endif() +else() + find_library(OpenCL_LIBRARY + NAMES OpenCL) +endif() + +set(OpenCL_LIBRARIES ${OpenCL_LIBRARY}) +set(OpenCL_INCLUDE_DIRS ${OpenCL_INCLUDE_DIR}) + +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +find_package_handle_standard_args( + OpenCL + FOUND_VAR OpenCL_FOUND + REQUIRED_VARS OpenCL_LIBRARY OpenCL_INCLUDE_DIR + VERSION_VAR OpenCL_VERSION_STRING) + +mark_as_advanced( + OpenCL_INCLUDE_DIR + OpenCL_LIBRARY) diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index e29aaf4..5732170 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -241,7 +241,7 @@ macro(__windows_compiler_msvc lang) set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "<CMAKE_LINKER> /lib ${CMAKE_CL_NOLOGO} <LINK_FLAGS> /out:<TARGET> <OBJECTS> ") set(CMAKE_${lang}_COMPILE_OBJECT - "<CMAKE_${lang}_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO}${_COMPILE_${lang}} <FLAGS> <DEFINES> /Fo<OBJECT> /Fd<OBJECT_DIR>/${_FS_${lang}} -c <SOURCE>${CMAKE_END_TEMP_FILE}") + "<CMAKE_${lang}_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO}${_COMPILE_${lang}} <FLAGS> <DEFINES> /Fo<OBJECT> /Fd<TARGET_COMPILE_PDB>${_FS_${lang}} -c <SOURCE>${CMAKE_END_TEMP_FILE}") set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> > <PREPROCESSED_SOURCE> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO}${_COMPILE_${lang}} <FLAGS> <DEFINES> -E <SOURCE>${CMAKE_END_TEMP_FILE}") set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE diff --git a/Modules/UseQt4.cmake b/Modules/UseQt4.cmake index 7478310..cba22af 100644 --- a/Modules/UseQt4.cmake +++ b/Modules/UseQt4.cmake @@ -98,7 +98,9 @@ foreach(module QT3SUPPORT QTOPENGL QTASSISTANT QTDESIGNER QTMOTIF QTNSPLUGIN include_directories(SYSTEM ${QT_${module}_INCLUDE_DIR}) endif(QT_INCLUDE_DIRS_NO_SYSTEM) endif() - set(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIBRARY}) + if(QT_USE_${module} OR QT_IS_STATIC) + set(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIBRARY}) + endif() set(QT_LIBRARIES_PLUGINS ${QT_LIBRARIES_PLUGINS} ${QT_${module}_PLUGINS}) if(QT_IS_STATIC) set(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIB_DEPENDENCIES}) diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index 11ca205..4ae6f81 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -85,9 +85,6 @@ macro(SWIG_GET_EXTRA_OUTPUT_FILES language outfiles generatedpath infile) set(${outfiles} "") get_source_file_property(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename ${infile} SWIG_MODULE_NAME) - if(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename STREQUAL "NOTFOUND") - get_filename_component(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename "${infile}" NAME_WE) - endif() foreach(it ${SWIG_${language}_EXTRA_FILE_EXTENSION}) set(${outfiles} ${${outfiles}} "${generatedpath}/${SWIG_GET_EXTRA_OUTPUT_FILES_module_basename}.${it}") @@ -103,6 +100,10 @@ macro(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) get_source_file_property(swig_source_file_generated ${infile} GENERATED) get_source_file_property(swig_source_file_cplusplus ${infile} CPLUSPLUS) get_source_file_property(swig_source_file_flags ${infile} SWIG_FLAGS) + get_source_file_property(_SWIG_MODULE_NAME ${infile} SWIG_MODULE_NAME) + if ( NOT _SWIG_MODULE_NAME ) + set_source_files_properties(${infile} PROPERTIES SWIG_MODULE_NAME ${name}) + endif () if("${swig_source_file_flags}" STREQUAL "NOTFOUND") set(swig_source_file_flags "") endif() |