diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CMakeCXXCompiler.cmake.in | 1 | ||||
-rw-r--r-- | Modules/CMakeDetermineCompileFeatures.cmake | 7 | ||||
-rw-r--r-- | Modules/CMakeDetermineCompilerId.cmake | 11 | ||||
-rw-r--r-- | Modules/CMakeSystemSpecificInitialize.cmake | 20 | ||||
-rw-r--r-- | Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 | ||||
-rw-r--r-- | Modules/Compiler/GNU-CXX.cmake | 4 | ||||
-rw-r--r-- | Modules/CompilerId/Xcode-3.pbxproj.in | 2 | ||||
-rw-r--r-- | Modules/ExternalProject.cmake | 2 | ||||
-rw-r--r-- | Modules/FindCUDA.cmake | 89 | ||||
-rw-r--r-- | Modules/Platform/Darwin-Initialize.cmake | 136 | ||||
-rw-r--r-- | Modules/Platform/Darwin.cmake | 137 | ||||
-rw-r--r-- | Modules/UseSWIG.cmake | 4 |
12 files changed, 247 insertions, 167 deletions
diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index fdee336..6e531ca 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -3,6 +3,7 @@ set(CMAKE_CXX_COMPILER_ARG1 "@CMAKE_CXX_COMPILER_ARG1@") set(CMAKE_CXX_COMPILER_ID "@CMAKE_CXX_COMPILER_ID@") set(CMAKE_CXX_COMPILER_VERSION "@CMAKE_CXX_COMPILER_VERSION@") set(CMAKE_CXX_COMPILE_FEATURES "@CMAKE_CXX_COMPILE_FEATURES@") +set(CMAKE_CXX98_COMPILE_FEATURES "@CMAKE_CXX98_COMPILE_FEATURES@") set(CMAKE_CXX11_COMPILE_FEATURES "@CMAKE_CXX11_COMPILE_FEATURES@") set(CMAKE_CXX_PLATFORM_ID "@CMAKE_CXX_PLATFORM_ID@") diff --git a/Modules/CMakeDetermineCompileFeatures.cmake b/Modules/CMakeDetermineCompileFeatures.cmake index 40aa9d6..583ff8d 100644 --- a/Modules/CMakeDetermineCompileFeatures.cmake +++ b/Modules/CMakeDetermineCompileFeatures.cmake @@ -17,6 +17,7 @@ function(cmake_determine_compile_features lang) if(lang STREQUAL CXX AND COMMAND cmake_record_cxx_compile_features) message(STATUS "Detecting ${lang} compile features") + set(CMAKE_CXX98_COMPILE_FEATURES) set(CMAKE_CXX11_COMPILE_FEATURES) include("${CMAKE_ROOT}/Modules/Internal/FeatureTesting.cmake") @@ -28,13 +29,19 @@ function(cmake_determine_compile_features lang) return() endif() + if (CMAKE_CXX98_COMPILE_FEATURES) + list(REMOVE_ITEM CMAKE_CXX11_COMPILE_FEATURES ${CMAKE_CXX98_COMPILE_FEATURES}) + endif() + if(NOT CMAKE_CXX_COMPILE_FEATURES) set(CMAKE_CXX_COMPILE_FEATURES + ${CMAKE_CXX98_COMPILE_FEATURES} ${CMAKE_CXX11_COMPILE_FEATURES} ) endif() set(CMAKE_CXX_COMPILE_FEATURES ${CMAKE_CXX_COMPILE_FEATURES} PARENT_SCOPE) + set(CMAKE_CXX98_COMPILE_FEATURES ${CMAKE_CXX98_COMPILE_FEATURES} PARENT_SCOPE) set(CMAKE_CXX11_COMPILE_FEATURES ${CMAKE_CXX11_COMPILE_FEATURES} PARENT_SCOPE) message(STATUS "Detecting ${lang} compile features - done") diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index f109dc4..17f27b3 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -215,6 +215,17 @@ Id flags: ${testflags} else() set(id_toolset "") endif() + if(CMAKE_OSX_DEPLOYMENT_TARGET) + set(id_deployment_target + "MACOSX_DEPLOYMENT_TARGET = \"${CMAKE_OSX_DEPLOYMENT_TARGET}\";") + else() + set(id_deployment_target "") + endif() + if(CMAKE_OSX_SYSROOT) + set(id_sdkroot "SDKROOT = \"${CMAKE_OSX_SYSROOT}\";") + else() + set(id_sdkroot "") + endif() if(NOT ${XCODE_VERSION} VERSION_LESS 3) set(v 3) set(ext xcodeproj) diff --git a/Modules/CMakeSystemSpecificInitialize.cmake b/Modules/CMakeSystemSpecificInitialize.cmake new file mode 100644 index 0000000..5327ac1 --- /dev/null +++ b/Modules/CMakeSystemSpecificInitialize.cmake @@ -0,0 +1,20 @@ + +#============================================================================= +# Copyright 2002-2014 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 distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# This file is included by cmGlobalGenerator::EnableLanguage. +# It is included before the compiler has been determined. + +include(Platform/${CMAKE_SYSTEM_NAME}-Initialize OPTIONAL) + +set(CMAKE_SYSTEM_SPECIFIC_INITIALIZE_LOADED 1) diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index 3f169d2..fe0ff0b 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -74,4 +74,5 @@ set(_cmake_feature_test_cxx_extern_templates "${_oldestSupported} && __cplusplus # TODO: Should be supported forever? set(_cmake_feature_test_cxx_func_identifier "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_variadic_macros "${_oldestSupported} && __cplusplus >= 201103L") +set(_cmake_feature_test_cxx_template_template_parameters "${_oldestSupported} && __cplusplus >= 199711L") set(_oldestSupported) diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake index 7acad52..6ec3958 100644 --- a/Modules/Compiler/GNU-CXX.cmake +++ b/Modules/Compiler/GNU-CXX.cmake @@ -27,10 +27,14 @@ endif() macro(cmake_record_cxx_compile_features) macro(_get_gcc_features std_version list) record_compiler_features(CXX "-std=${std_version}" ${list}) + if (NOT _result EQUAL 0) + return() + endif() endmacro() if (UNIX AND NOT APPLE AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) _get_gcc_features(c++11 CMAKE_CXX11_COMPILE_FEATURES) + _get_gcc_features(c++98 CMAKE_CXX98_COMPILE_FEATURES) else() set(_result 0) endif() diff --git a/Modules/CompilerId/Xcode-3.pbxproj.in b/Modules/CompilerId/Xcode-3.pbxproj.in index 6f861eb..eabfc6b 100644 --- a/Modules/CompilerId/Xcode-3.pbxproj.in +++ b/Modules/CompilerId/Xcode-3.pbxproj.in @@ -84,6 +84,8 @@ CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)"; SYMROOT = .; @id_toolset@ + @id_deployment_target@ + @id_sdkroot@ }; name = Debug; }; diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index f587985..fc31ce4 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -709,7 +709,7 @@ does not match expected value Retrying download. \") file(REMOVE \"\${file}\") - execute_process(COMMAND ${CMAKE_COMMAND} -P \"${download_script}\") + execute_process(COMMAND \${CMAKE_COMMAND} -P \"${download_script}\") endif() endwhile() diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index c02809d..1f69620 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -31,8 +31,8 @@ # The following variables affect the behavior of the macros in the # script (in alphebetical order). Note that any of these flags can be # changed multiple times in the same directory before calling -# CUDA_ADD_EXECUTABLE, CUDA_ADD_LIBRARY, CUDA_COMPILE, CUDA_COMPILE_PTX -# or CUDA_WRAP_SRCS:: +# CUDA_ADD_EXECUTABLE, CUDA_ADD_LIBRARY, CUDA_COMPILE, CUDA_COMPILE_PTX, +# CUDA_COMPILE_FATBIN, CUDA_COMPILE_CUBIN or CUDA_WRAP_SRCS:: # # CUDA_64_BIT_DEVICE_CODE (Default matches host bit size) # -- Set to ON to compile for 64 bit device code, OFF for 32 bit device code. @@ -152,6 +152,12 @@ # CUDA_COMPILE_PTX( generated_files file0 file1 ... [OPTIONS ...] ) # -- Returns a list of PTX files generated from the input source files. # +# CUDA_COMPILE_FATBIN( generated_files file0 file1 ... [OPTIONS ...] ) +# -- Returns a list of FATBIN files generated from the input source files. +# +# CUDA_COMPILE_CUBIN( generated_files file0 file1 ... [OPTIONS ...] ) +# -- Returns a list of CUBIN files generated from the input source files. +# # CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME( output_file_var # cuda_target # object_files ) @@ -1016,7 +1022,7 @@ endfunction() # a .cpp or .ptx file. # INPUT: # cuda_target - Target name -# format - PTX or OBJ +# format - PTX, CUBIN, FATBIN or OBJ # FILE1 .. FILEN - The remaining arguments are the sources to be wrapped. # OPTIONS - Extra options to NVCC # OUTPUT: @@ -1202,16 +1208,22 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files) set(_cuda_source_format ${format}) endif() - if( ${_cuda_source_format} MATCHES "PTX" ) - set( compile_to_ptx ON ) - elseif( ${_cuda_source_format} MATCHES "OBJ") - set( compile_to_ptx OFF ) + if( ${_cuda_source_format} MATCHES "OBJ") + set( cuda_compile_to_external_module OFF ) else() - message( FATAL_ERROR "Invalid format flag passed to CUDA_WRAP_SRCS for file '${file}': '${_cuda_source_format}'. Use OBJ or PTX.") + set( cuda_compile_to_external_module ON ) + if( ${_cuda_source_format} MATCHES "PTX" ) + set( cuda_compile_to_external_module_type "ptx" ) + elseif( ${_cuda_source_format} MATCHES "CUBIN") + set( cuda_compile_to_external_module_type "cubin" ) + elseif( ${_cuda_source_format} MATCHES "FATBIN") + set( cuda_compile_to_external_module_type "fatbin" ) + else() + message( FATAL_ERROR "Invalid format flag passed to CUDA_WRAP_SRCS for file '${file}': '${_cuda_source_format}'. Use OBJ, PTX, CUBIN or FATBIN.") + endif() endif() - - if(compile_to_ptx) + if(cuda_compile_to_external_module) # Don't use any of the host compilation flags for PTX targets. set(CUDA_HOST_FLAGS) set(CUDA_NVCC_FLAGS_CONFIG) @@ -1226,7 +1238,7 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files) if(CUDA_GENERATED_OUTPUT_DIR) set(cuda_compile_output_dir "${CUDA_GENERATED_OUTPUT_DIR}") else() - if ( compile_to_ptx ) + if ( cuda_compile_to_external_module ) set(cuda_compile_output_dir "${CMAKE_CURRENT_BINARY_DIR}") else() set(cuda_compile_output_dir "${cuda_compile_intermediate_directory}") @@ -1236,10 +1248,10 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files) # Add a custom target to generate a c or ptx file. ###################### get_filename_component( basename ${file} NAME ) - if( compile_to_ptx ) + if( cuda_compile_to_external_module ) set(generated_file_path "${cuda_compile_output_dir}") - set(generated_file_basename "${cuda_target}_generated_${basename}.ptx") - set(format_flag "-ptx") + set(generated_file_basename "${cuda_target}_generated_${basename}.${cuda_compile_to_external_module_type}") + set(format_flag "-${cuda_compile_to_external_module_type}") file(MAKE_DIRECTORY "${cuda_compile_output_dir}") else() set(generated_file_path "${cuda_compile_output_dir}/${CMAKE_CFG_INTDIR}") @@ -1262,7 +1274,7 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files) set(custom_target_script "${cuda_compile_intermediate_directory}/${generated_file_basename}.cmake") # Setup properties for obj files: - if( NOT compile_to_ptx ) + if( NOT cuda_compile_to_external_module ) set_source_files_properties("${generated_file}" PROPERTIES EXTERNAL_OBJECT true # This is an object file not to be compiled, but only be linked. @@ -1277,7 +1289,7 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files) set(source_file "${CMAKE_CURRENT_SOURCE_DIR}/${file}") endif() - if( NOT compile_to_ptx AND CUDA_SEPARABLE_COMPILATION) + if( NOT cuda_compile_to_external_module AND CUDA_SEPARABLE_COMPILATION) list(APPEND ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS "${generated_file}") endif() @@ -1294,7 +1306,7 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files) # Build the NVCC made dependency file ################################### set(build_cubin OFF) if ( NOT CUDA_BUILD_EMULATION AND CUDA_BUILD_CUBIN ) - if ( NOT compile_to_ptx ) + if ( NOT cuda_compile_to_external_module ) set ( build_cubin ON ) endif() endif() @@ -1321,8 +1333,8 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files) # Create up the comment string file(RELATIVE_PATH generated_file_relative_path "${CMAKE_BINARY_DIR}" "${generated_file}") - if(compile_to_ptx) - set(cuda_build_comment_string "Building NVCC ptx file ${generated_file_relative_path}") + if(cuda_compile_to_external_module) + set(cuda_build_comment_string "Building NVCC ${cuda_compile_to_external_module_type} file ${generated_file_relative_path}") else() set(cuda_build_comment_string "Building NVCC (${cuda_build_type}) object ${generated_file_relative_path}") endif() @@ -1552,21 +1564,29 @@ endmacro() ############################################################################### ############################################################################### -# CUDA COMPILE +# (Internal) helper for manually added cuda source files with specific targets ############################################################################### ############################################################################### -macro(CUDA_COMPILE generated_files) +macro(cuda_compile_base cuda_target format generated_files) # Separate the sources from the options CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN}) # Create custom commands and targets for each file. - CUDA_WRAP_SRCS( cuda_compile OBJ _generated_files ${_sources} ${_cmake_options} + CUDA_WRAP_SRCS( ${cuda_target} ${format} _generated_files ${_sources} ${_cmake_options} OPTIONS ${_options} ) set( ${generated_files} ${_generated_files}) endmacro() +############################################################################### +############################################################################### +# CUDA COMPILE +############################################################################### +############################################################################### +macro(CUDA_COMPILE generated_files) + cuda_compile_base(cuda_compile OBJ ${generated_files} ${ARGN}) +endmacro() ############################################################################### ############################################################################### @@ -1574,17 +1594,28 @@ endmacro() ############################################################################### ############################################################################### macro(CUDA_COMPILE_PTX generated_files) + cuda_compile_base(cuda_compile_ptx PTX ${generated_files} ${ARGN}) +endmacro() - # Separate the sources from the options - CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN}) - # Create custom commands and targets for each file. - CUDA_WRAP_SRCS( cuda_compile_ptx PTX _generated_files ${_sources} ${_cmake_options} - OPTIONS ${_options} ) - - set( ${generated_files} ${_generated_files}) +############################################################################### +############################################################################### +# CUDA COMPILE FATBIN +############################################################################### +############################################################################### +macro(CUDA_COMPILE_FATBIN generated_files) + cuda_compile_base(cuda_compile_fatbin FATBIN ${generated_files} ${ARGN}) +endmacro() +############################################################################### +############################################################################### +# CUDA COMPILE CUBIN +############################################################################### +############################################################################### +macro(CUDA_COMPILE_CUBIN generated_files) + cuda_compile_base(cuda_compile_cubin CUBIN ${generated_files} ${ARGN}) endmacro() + ############################################################################### ############################################################################### # CUDA ADD CUFFT TO TARGET diff --git a/Modules/Platform/Darwin-Initialize.cmake b/Modules/Platform/Darwin-Initialize.cmake new file mode 100644 index 0000000..82c6f3d --- /dev/null +++ b/Modules/Platform/Darwin-Initialize.cmake @@ -0,0 +1,136 @@ +# Ask xcode-select where to find /Developer or fall back to ancient location. +execute_process(COMMAND xcode-select -print-path + OUTPUT_VARIABLE _stdout + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE _stderr + RESULT_VARIABLE _failed) +if(NOT _failed AND IS_DIRECTORY ${_stdout}) + set(OSX_DEVELOPER_ROOT ${_stdout}) +elseif(IS_DIRECTORY "/Developer") + set(OSX_DEVELOPER_ROOT "/Developer") +else() + set(OSX_DEVELOPER_ROOT "") +endif() + +execute_process(COMMAND sw_vers -productVersion + OUTPUT_VARIABLE CURRENT_OSX_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE) + +# Save CMAKE_OSX_ARCHITECTURES from the environment. +set(CMAKE_OSX_ARCHITECTURES "$ENV{CMAKE_OSX_ARCHITECTURES}" CACHE STRING + "Build architectures for OSX") + +#---------------------------------------------------------------------------- +# _CURRENT_OSX_VERSION - as a two-component string: 10.5, 10.6, ... +# +string(REGEX REPLACE "^([0-9]+\\.[0-9]+).*$" "\\1" + _CURRENT_OSX_VERSION "${CURRENT_OSX_VERSION}") + +#---------------------------------------------------------------------------- +# CMAKE_OSX_DEPLOYMENT_TARGET + +# Set cache variable - end user may change this during ccmake or cmake-gui configure. +if(_CURRENT_OSX_VERSION VERSION_GREATER 10.3) + set(CMAKE_OSX_DEPLOYMENT_TARGET "$ENV{MACOSX_DEPLOYMENT_TARGET}" CACHE STRING + "Minimum OS X version to target for deployment (at runtime); newer APIs weak linked. Set to empty string for default value.") +endif() + +#---------------------------------------------------------------------------- +# CMAKE_OSX_SYSROOT + +if(CMAKE_OSX_SYSROOT) + # Use the existing value without further computation to choose a default. + set(_CMAKE_OSX_SYSROOT_DEFAULT "${CMAKE_OSX_SYSROOT}") +elseif(NOT "x$ENV{SDKROOT}" STREQUAL "x" AND + (NOT "x$ENV{SDKROOT}" MATCHES "/" OR IS_DIRECTORY "$ENV{SDKROOT}")) + # Use the value of SDKROOT from the environment. + set(_CMAKE_OSX_SYSROOT_DEFAULT "$ENV{SDKROOT}") +elseif("${CMAKE_GENERATOR}" MATCHES Xcode + OR CMAKE_OSX_DEPLOYMENT_TARGET + OR CMAKE_OSX_ARCHITECTURES MATCHES "[^;]" + OR NOT EXISTS "/usr/include/sys/types.h") + # Find installed SDKs in either Xcode-4.3+ or pre-4.3 SDKs directory. + set(_CMAKE_OSX_SDKS_DIR "") + if(OSX_DEVELOPER_ROOT) + foreach(d Platforms/MacOSX.platform/Developer/SDKs SDKs) + file(GLOB _CMAKE_OSX_SDKS ${OSX_DEVELOPER_ROOT}/${d}/*) + if(_CMAKE_OSX_SDKS) + set(_CMAKE_OSX_SDKS_DIR ${OSX_DEVELOPER_ROOT}/${d}) + break() + endif() + endforeach() + endif() + + if(_CMAKE_OSX_SDKS_DIR) + # Select SDK for current OSX version accounting for the known + # specially named SDKs. + set(_CMAKE_OSX_SDKS_VER_SUFFIX_10.4 "u") + set(_CMAKE_OSX_SDKS_VER_SUFFIX_10.3 ".9") + if(CMAKE_OSX_DEPLOYMENT_TARGET) + set(_CMAKE_OSX_SDKS_VER ${CMAKE_OSX_DEPLOYMENT_TARGET}${_CMAKE_OSX_SDKS_VER_SUFFIX_${CMAKE_OSX_DEPLOYMENT_TARGET}}) + set(_CMAKE_OSX_SYSROOT_CHECK "${_CMAKE_OSX_SDKS_DIR}/MacOSX${_CMAKE_OSX_SDKS_VER}.sdk") + if(IS_DIRECTORY "${_CMAKE_OSX_SYSROOT_CHECK}") + set(_CMAKE_OSX_SYSROOT_DEFAULT "${_CMAKE_OSX_SYSROOT_CHECK}") + else() + set(_CMAKE_OSX_SDKS_VER ${_CURRENT_OSX_VERSION}${_CMAKE_OSX_SDKS_VER_SUFFIX_${_CURRENT_OSX_VERSION}}) + set(_CMAKE_OSX_SYSROOT_DEFAULT "${_CMAKE_OSX_SDKS_DIR}/MacOSX${_CMAKE_OSX_SDKS_VER}.sdk") + message(WARNING + "CMAKE_OSX_DEPLOYMENT_TARGET is '${CMAKE_OSX_DEPLOYMENT_TARGET}' " + "but the matching SDK does not exist at:\n \"${_CMAKE_OSX_SYSROOT_CHECK}\"\n" + "Instead using SDK:\n \"${_CMAKE_OSX_SYSROOT_DEFAULT}\"\n" + "matching the host OS X version." + ) + endif() + else() + set(_CMAKE_OSX_SDKS_VER ${_CURRENT_OSX_VERSION}${_CMAKE_OSX_SDKS_VER_SUFFIX_${_CURRENT_OSX_VERSION}}) + set(_CMAKE_OSX_SYSROOT_DEFAULT "${_CMAKE_OSX_SDKS_DIR}/MacOSX${_CMAKE_OSX_SDKS_VER}.sdk") + endif() + else() + # Assume developer files are in root (such as Xcode 4.5 command-line tools). + set(_CMAKE_OSX_SYSROOT_DEFAULT "") + endif() +endif() + +# Set cache variable - end user may change this during ccmake or cmake-gui configure. +# Choose the type based on the current value. +set(_CMAKE_OSX_SYSROOT_TYPE STRING) +foreach(v CMAKE_OSX_SYSROOT _CMAKE_OSX_SYSROOT_DEFAULT) + if("x${${v}}" MATCHES "/") + set(_CMAKE_OSX_SYSROOT_TYPE PATH) + break() + endif() +endforeach() +set(CMAKE_OSX_SYSROOT "${_CMAKE_OSX_SYSROOT_DEFAULT}" CACHE ${_CMAKE_OSX_SYSROOT_TYPE} + "The product will be built against the headers and libraries located inside the indicated SDK.") + +# Transform the cached value to something we can use. +set(_CMAKE_OSX_SYSROOT_ORIG "${CMAKE_OSX_SYSROOT}") +set(_CMAKE_OSX_SYSROOT_PATH "") +if(CMAKE_OSX_SYSROOT) + if("x${CMAKE_OSX_SYSROOT}" MATCHES "/") + # This is a path to the SDK. Make sure it exists. + if(NOT IS_DIRECTORY "${CMAKE_OSX_SYSROOT}") + message(WARNING "Ignoring CMAKE_OSX_SYSROOT value:\n ${CMAKE_OSX_SYSROOT}\n" + "because the directory does not exist.") + set(CMAKE_OSX_SYSROOT "") + set(_CMAKE_OSX_SYSROOT_ORIG "") + endif() + set(_CMAKE_OSX_SYSROOT_PATH "${CMAKE_OSX_SYSROOT}") + else() + # Transform the sdk name into a path. + execute_process( + COMMAND xcodebuild -sdk ${CMAKE_OSX_SYSROOT} -version Path + OUTPUT_VARIABLE _stdout + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE _stderr + RESULT_VARIABLE _failed + ) + if(NOT _failed AND IS_DIRECTORY "${_stdout}") + set(_CMAKE_OSX_SYSROOT_PATH "${_stdout}") + # For non-Xcode generators use the path. + if(NOT "${CMAKE_GENERATOR}" MATCHES "Xcode") + set(CMAKE_OSX_SYSROOT "${_CMAKE_OSX_SYSROOT_PATH}") + endif() + endif() + endif() +endif() diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake index df0756b..e25df1e 100644 --- a/Modules/Platform/Darwin.cmake +++ b/Modules/Platform/Darwin.cmake @@ -64,143 +64,6 @@ if(NOT DEFINED CMAKE_INSTALL_NAME_TOOL) mark_as_advanced(CMAKE_INSTALL_NAME_TOOL) endif() -# Ask xcode-select where to find /Developer or fall back to ancient location. -execute_process(COMMAND xcode-select -print-path - OUTPUT_VARIABLE _stdout - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_VARIABLE _stderr - RESULT_VARIABLE _failed) -if(NOT _failed AND IS_DIRECTORY ${_stdout}) - set(OSX_DEVELOPER_ROOT ${_stdout}) -elseif(IS_DIRECTORY "/Developer") - set(OSX_DEVELOPER_ROOT "/Developer") -else() - set(OSX_DEVELOPER_ROOT "") -endif() - -execute_process(COMMAND sw_vers -productVersion - OUTPUT_VARIABLE CURRENT_OSX_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE) - -# Save CMAKE_OSX_ARCHITECTURES from the environment. -set(CMAKE_OSX_ARCHITECTURES "$ENV{CMAKE_OSX_ARCHITECTURES}" CACHE STRING - "Build architectures for OSX") - -#---------------------------------------------------------------------------- -# _CURRENT_OSX_VERSION - as a two-component string: 10.5, 10.6, ... -# -string(REGEX REPLACE "^([0-9]+\\.[0-9]+).*$" "\\1" - _CURRENT_OSX_VERSION "${CURRENT_OSX_VERSION}") - -#---------------------------------------------------------------------------- -# CMAKE_OSX_DEPLOYMENT_TARGET - -# Set cache variable - end user may change this during ccmake or cmake-gui configure. -if(_CURRENT_OSX_VERSION VERSION_GREATER 10.3) - set(CMAKE_OSX_DEPLOYMENT_TARGET "$ENV{MACOSX_DEPLOYMENT_TARGET}" CACHE STRING - "Minimum OS X version to target for deployment (at runtime); newer APIs weak linked. Set to empty string for default value.") -endif() - -#---------------------------------------------------------------------------- -# CMAKE_OSX_SYSROOT - -if(CMAKE_OSX_SYSROOT) - # Use the existing value without further computation to choose a default. - set(_CMAKE_OSX_SYSROOT_DEFAULT "${CMAKE_OSX_SYSROOT}") -elseif(NOT "x$ENV{SDKROOT}" STREQUAL "x" AND - (NOT "x$ENV{SDKROOT}" MATCHES "/" OR IS_DIRECTORY "$ENV{SDKROOT}")) - # Use the value of SDKROOT from the environment. - set(_CMAKE_OSX_SYSROOT_DEFAULT "$ENV{SDKROOT}") -elseif("${CMAKE_GENERATOR}" MATCHES Xcode - OR CMAKE_OSX_DEPLOYMENT_TARGET - OR CMAKE_OSX_ARCHITECTURES MATCHES "[^;]" - OR NOT EXISTS "/usr/include/sys/types.h") - # Find installed SDKs in either Xcode-4.3+ or pre-4.3 SDKs directory. - set(_CMAKE_OSX_SDKS_DIR "") - if(OSX_DEVELOPER_ROOT) - foreach(d Platforms/MacOSX.platform/Developer/SDKs SDKs) - file(GLOB _CMAKE_OSX_SDKS ${OSX_DEVELOPER_ROOT}/${d}/*) - if(_CMAKE_OSX_SDKS) - set(_CMAKE_OSX_SDKS_DIR ${OSX_DEVELOPER_ROOT}/${d}) - break() - endif() - endforeach() - endif() - - if(_CMAKE_OSX_SDKS_DIR) - # Select SDK for current OSX version accounting for the known - # specially named SDKs. - set(_CMAKE_OSX_SDKS_VER_SUFFIX_10.4 "u") - set(_CMAKE_OSX_SDKS_VER_SUFFIX_10.3 ".9") - if(CMAKE_OSX_DEPLOYMENT_TARGET) - set(_CMAKE_OSX_SDKS_VER ${CMAKE_OSX_DEPLOYMENT_TARGET}${_CMAKE_OSX_SDKS_VER_SUFFIX_${CMAKE_OSX_DEPLOYMENT_TARGET}}) - set(_CMAKE_OSX_SYSROOT_CHECK "${_CMAKE_OSX_SDKS_DIR}/MacOSX${_CMAKE_OSX_SDKS_VER}.sdk") - if(IS_DIRECTORY "${_CMAKE_OSX_SYSROOT_CHECK}") - set(_CMAKE_OSX_SYSROOT_DEFAULT "${_CMAKE_OSX_SYSROOT_CHECK}") - else() - set(_CMAKE_OSX_SDKS_VER ${_CURRENT_OSX_VERSION}${_CMAKE_OSX_SDKS_VER_SUFFIX_${_CURRENT_OSX_VERSION}}) - set(_CMAKE_OSX_SYSROOT_DEFAULT "${_CMAKE_OSX_SDKS_DIR}/MacOSX${_CMAKE_OSX_SDKS_VER}.sdk") - message(WARNING - "CMAKE_OSX_DEPLOYMENT_TARGET is '${CMAKE_OSX_DEPLOYMENT_TARGET}' " - "but the matching SDK does not exist at:\n \"${_CMAKE_OSX_SYSROOT_CHECK}\"\n" - "Instead using SDK:\n \"${_CMAKE_OSX_SYSROOT_DEFAULT}\"\n" - "matching the host OS X version." - ) - endif() - else() - set(_CMAKE_OSX_SDKS_VER ${_CURRENT_OSX_VERSION}${_CMAKE_OSX_SDKS_VER_SUFFIX_${_CURRENT_OSX_VERSION}}) - set(_CMAKE_OSX_SYSROOT_DEFAULT "${_CMAKE_OSX_SDKS_DIR}/MacOSX${_CMAKE_OSX_SDKS_VER}.sdk") - endif() - else() - # Assume developer files are in root (such as Xcode 4.5 command-line tools). - set(_CMAKE_OSX_SYSROOT_DEFAULT "") - endif() -endif() - -# Set cache variable - end user may change this during ccmake or cmake-gui configure. -# Choose the type based on the current value. -set(_CMAKE_OSX_SYSROOT_TYPE STRING) -foreach(v CMAKE_OSX_SYSROOT _CMAKE_OSX_SYSROOT_DEFAULT) - if("x${${v}}" MATCHES "/") - set(_CMAKE_OSX_SYSROOT_TYPE PATH) - break() - endif() -endforeach() -set(CMAKE_OSX_SYSROOT "${_CMAKE_OSX_SYSROOT_DEFAULT}" CACHE ${_CMAKE_OSX_SYSROOT_TYPE} - "The product will be built against the headers and libraries located inside the indicated SDK.") - -# Transform the cached value to something we can use. -set(_CMAKE_OSX_SYSROOT_ORIG "${CMAKE_OSX_SYSROOT}") -set(_CMAKE_OSX_SYSROOT_PATH "") -if(CMAKE_OSX_SYSROOT) - if("x${CMAKE_OSX_SYSROOT}" MATCHES "/") - # This is a path to the SDK. Make sure it exists. - if(NOT IS_DIRECTORY "${CMAKE_OSX_SYSROOT}") - message(WARNING "Ignoring CMAKE_OSX_SYSROOT value:\n ${CMAKE_OSX_SYSROOT}\n" - "because the directory does not exist.") - set(CMAKE_OSX_SYSROOT "") - set(_CMAKE_OSX_SYSROOT_ORIG "") - endif() - set(_CMAKE_OSX_SYSROOT_PATH "${CMAKE_OSX_SYSROOT}") - else() - # Transform the sdk name into a path. - execute_process( - COMMAND xcodebuild -sdk ${CMAKE_OSX_SYSROOT} -version Path - OUTPUT_VARIABLE _stdout - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_VARIABLE _stderr - RESULT_VARIABLE _failed - ) - if(NOT _failed AND IS_DIRECTORY "${_stdout}") - set(_CMAKE_OSX_SYSROOT_PATH "${_stdout}") - # For non-Xcode generators use the path. - if(NOT "${CMAKE_GENERATOR}" MATCHES "Xcode") - set(CMAKE_OSX_SYSROOT "${_CMAKE_OSX_SYSROOT_PATH}") - endif() - endif() - endif() -endif() - # Make sure the combination of SDK and Deployment Target are allowed if(CMAKE_OSX_DEPLOYMENT_TARGET) if("${_CMAKE_OSX_SYSROOT_PATH}" MATCHES "/MacOSX([0-9]+\\.[0-9]+)[^/]*\\.sdk") diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index f4fe1df..918e2ec 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -244,6 +244,8 @@ macro(SWIG_ADD_MODULE name language) if ("${swig_lowercase_language}" STREQUAL "octave") set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "") set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES SUFFIX ".oct") + elseif ("${swig_lowercase_language}" STREQUAL "go") + set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "") elseif ("${swig_lowercase_language}" STREQUAL "java") if (APPLE) # In java you want: @@ -254,6 +256,8 @@ macro(SWIG_ADD_MODULE name language) # Linux : libLIBRARY.so set_target_properties (${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES SUFFIX ".jnilib") endif () + elseif ("${swig_lowercase_language}" STREQUAL "lua") + set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "") elseif ("${swig_lowercase_language}" STREQUAL "python") # this is only needed for the python case where a _modulename.so is generated set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "") |