Merge topic 'AutomocUseTargetProperties' into export-sets

Conflicts:
	Source/cmGlobalGenerator.h
This commit is contained in:
Alex Neundorf 2012-09-24 22:06:20 +02:00 committed by Brad King
commit 80112da54e
69 changed files with 2199 additions and 941 deletions

View File

@ -1,7 +1,6 @@
set(AM_SOURCES @_moc_files@ ) set(AM_SOURCES @_moc_files@ )
set(AM_HEADERS @_moc_headers@ ) set(AM_HEADERS @_moc_headers@ )
set(AM_MOC_COMPILE_DEFINITIONS @_moc_compile_defs@) set(AM_MOC_COMPILE_DEFINITIONS @_moc_compile_defs@)
set(AM_MOC_DEFINITIONS @_moc_defs@)
set(AM_MOC_INCLUDES @_moc_incs@) set(AM_MOC_INCLUDES @_moc_incs@)
set(AM_MOC_OPTIONS @_moc_options@) set(AM_MOC_OPTIONS @_moc_options@)
set(AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE "@CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE@") set(AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE "@CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE@")

View File

@ -24,7 +24,10 @@
# [HG_REPOSITORY url] # URL of mercurial repo # [HG_REPOSITORY url] # URL of mercurial repo
# [HG_TAG tag] # Mercurial branch name, commit id or tag # [HG_TAG tag] # Mercurial branch name, commit id or tag
# [URL /.../src.tgz] # Full path or URL of source # [URL /.../src.tgz] # Full path or URL of source
# [URL_MD5 md5] # MD5 checksum of file at URL # [URL_HASH ALGO=value] # Hash of file at URL
# [URL_MD5 md5] # Equivalent to URL_HASH MD5=md5
# [TLS_VERIFY bool] # Should certificate for https be checked
# [TLS_CAINFO file] # Path to a certificate authority file
# [TIMEOUT seconds] # Time allowed for file download operations # [TIMEOUT seconds] # Time allowed for file download operations
# #--Update/Patch step---------- # #--Update/Patch step----------
# [UPDATE_COMMAND cmd...] # Source work-tree update command # [UPDATE_COMMAND cmd...] # Source work-tree update command
@ -184,6 +187,9 @@ if(_ep_func)
set(_ep_keywords_${_ep_func} "${_ep_keywords_${_ep_func}})$") set(_ep_keywords_${_ep_func} "${_ep_keywords_${_ep_func}})$")
endif() endif()
# Save regex matching supported hash algorithm names.
set(_ep_hash_algos "MD5|SHA1|SHA224|SHA256|SHA384|SHA512")
set(_ep_hash_regex "^(${_ep_hash_algos})=([0-9A-Fa-f]+)$")
function(_ep_parse_arguments f name ns args) function(_ep_parse_arguments f name ns args)
# Transfer the arguments to this function into target properties for the # Transfer the arguments to this function into target properties for the
@ -395,7 +401,7 @@ endif()
endfunction() endfunction()
function(_ep_write_downloadfile_script script_filename remote local timeout md5) function(_ep_write_downloadfile_script script_filename remote local timeout hash tls_verify tls_cainfo)
if(timeout) if(timeout)
set(timeout_args TIMEOUT ${timeout}) set(timeout_args TIMEOUT ${timeout})
set(timeout_msg "${timeout} seconds") set(timeout_msg "${timeout} seconds")
@ -404,10 +410,31 @@ function(_ep_write_downloadfile_script script_filename remote local timeout md5)
set(timeout_msg "none") set(timeout_msg "none")
endif() endif()
if(md5) if("${hash}" MATCHES "${_ep_hash_regex}")
set(md5_args EXPECTED_MD5 ${md5}) set(hash_args EXPECTED_HASH ${CMAKE_MATCH_1} ${CMAKE_MATCH_2})
else() else()
set(md5_args "# no EXPECTED_MD5") set(hash_args "# no EXPECTED_HASH")
endif()
# check for curl globals in the project
if(DEFINED CMAKE_TLS_VERIFY)
set(tls_verify "set(CMAKE_TLS_VERIFY ${CMAKE_TLS_VERIFY})")
endif()
if(DEFINED CMAKE_TLS_CAINFO)
set(tls_cainfo "set(CMAKE_TLS_CAINFO \"${CMAKE_TLS_CAINFO}\")")
endif()
# now check for curl locals so that the local values
# will override the globals
# check for tls_verify argument
string(LENGTH "${tls_verify}" tls_verify_len)
if(tls_verify_len GREATER 0)
set(tls_verify "set(CMAKE_TLS_VERIFY ${tls_verify})")
endif()
# check for tls_cainfo argument
string(LENGTH "${tls_cainfo}" tls_cainfo_len)
if(tls_cainfo_len GREATER 0)
set(tls_cainfo "set(CMAKE_TLS_CAINFO \"${tls_cainfo}\")")
endif() endif()
file(WRITE ${script_filename} file(WRITE ${script_filename}
@ -416,11 +443,14 @@ function(_ep_write_downloadfile_script script_filename remote local timeout md5)
dst='${local}' dst='${local}'
timeout='${timeout_msg}'\") timeout='${timeout_msg}'\")
${tls_verify}
${tls_cainfo}
file(DOWNLOAD file(DOWNLOAD
\"${remote}\" \"${remote}\"
\"${local}\" \"${local}\"
SHOW_PROGRESS SHOW_PROGRESS
${md5_args} ${hash_args}
${timeout_args} ${timeout_args}
STATUS status STATUS status
LOG log) LOG log)
@ -443,48 +473,30 @@ message(STATUS \"downloading... done\")
endfunction() endfunction()
function(_ep_write_verifyfile_script script_filename local md5) function(_ep_write_verifyfile_script script_filename local hash)
file(WRITE ${script_filename} if("${hash}" MATCHES "${_ep_hash_regex}")
"message(STATUS \"verifying file... set(algo "${CMAKE_MATCH_1}")
file='${local}'\") string(TOLOWER "${CMAKE_MATCH_2}" expect_value)
set(script_content "set(expect_value \"${expect_value}\")
set(verified 0) file(${algo} \"\${file}\" actual_value)
if(\"\${actual_value}\" STREQUAL \"\${expect_value}\")
# If an expected md5 checksum exists, compare against it:
#
if(NOT \"${md5}\" STREQUAL \"\")
execute_process(COMMAND \${CMAKE_COMMAND} -E md5sum \"${local}\"
OUTPUT_VARIABLE ov
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE rv)
if(NOT rv EQUAL 0)
message(FATAL_ERROR \"error: computing md5sum of '${local}' failed\")
endif()
string(REGEX MATCH \"^([0-9A-Fa-f]+)\" md5_actual \"\${ov}\")
string(TOLOWER \"\${md5_actual}\" md5_actual)
string(TOLOWER \"${md5}\" md5)
if(NOT \"\${md5}\" STREQUAL \"\${md5_actual}\")
message(FATAL_ERROR \"error: md5sum of '${local}' does not match expected value
md5_expected: \${md5}
md5_actual: \${md5_actual}
\")
endif()
set(verified 1)
endif()
if(verified)
message(STATUS \"verifying file... done\") message(STATUS \"verifying file... done\")
else() else()
message(STATUS \"verifying file... warning: did not verify file - no URL_MD5 checksum argument? corrupt file?\") message(FATAL_ERROR \"error: ${algo} hash of
endif() \${file}
" does not match expected value
) expected: \${expect_value}
actual: \${actual_value}
\")
endif()")
else()
set(script_content "message(STATUS \"verifying file... warning: did not verify file - no URL_HASH specified?\")")
endif()
file(WRITE ${script_filename} "set(file \"${local}\")
message(STATUS \"verifying file...
file='\${file}'\")
${script_content}
")
endfunction() endfunction()
@ -1254,10 +1266,22 @@ function(_ep_add_download_command name)
list(APPEND depends ${stamp_dir}/${name}-hginfo.txt) list(APPEND depends ${stamp_dir}/${name}-hginfo.txt)
elseif(url) elseif(url)
get_filename_component(work_dir "${source_dir}" PATH) get_filename_component(work_dir "${source_dir}" PATH)
get_property(hash TARGET ${name} PROPERTY _EP_URL_HASH)
if(hash AND NOT "${hash}" MATCHES "${_ep_hash_regex}")
message(FATAL_ERROR "URL_HASH is set to\n ${hash}\n"
"but must be ALGO=value where ALGO is\n ${_ep_hash_algos}\n"
"and value is a hex string.")
endif()
get_property(md5 TARGET ${name} PROPERTY _EP_URL_MD5) get_property(md5 TARGET ${name} PROPERTY _EP_URL_MD5)
if(md5 AND NOT "MD5=${md5}" MATCHES "${_ep_hash_regex}")
message(FATAL_ERROR "URL_MD5 is set to\n ${md5}\nbut must be a hex string.")
endif()
if(md5 AND NOT hash)
set(hash "MD5=${md5}")
endif()
set(repository "external project URL") set(repository "external project URL")
set(module "${url}") set(module "${url}")
set(tag "${md5}") set(tag "${hash}")
configure_file( configure_file(
"${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in" "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
"${stamp_dir}/${name}-urlinfo.txt" "${stamp_dir}/${name}-urlinfo.txt"
@ -1283,7 +1307,10 @@ function(_ep_add_download_command name)
string(REPLACE ";" "-" fname "${fname}") string(REPLACE ";" "-" fname "${fname}")
set(file ${download_dir}/${fname}) set(file ${download_dir}/${fname})
get_property(timeout TARGET ${name} PROPERTY _EP_TIMEOUT) get_property(timeout TARGET ${name} PROPERTY _EP_TIMEOUT)
_ep_write_downloadfile_script("${stamp_dir}/download-${name}.cmake" "${url}" "${file}" "${timeout}" "${md5}") get_property(tls_verify TARGET ${name} PROPERTY _EP_TLS_VERIFY)
get_property(tls_cainfo TARGET ${name} PROPERTY _EP_TLS_CAINFO)
_ep_write_downloadfile_script("${stamp_dir}/download-${name}.cmake"
"${url}" "${file}" "${timeout}" "${hash}" "${tls_verify}" "${tls_cainfo}")
set(cmd ${CMAKE_COMMAND} -P ${stamp_dir}/download-${name}.cmake set(cmd ${CMAKE_COMMAND} -P ${stamp_dir}/download-${name}.cmake
COMMAND) COMMAND)
set(comment "Performing download step (download, verify and extract) for '${name}'") set(comment "Performing download step (download, verify and extract) for '${name}'")
@ -1291,7 +1318,7 @@ function(_ep_add_download_command name)
set(file "${url}") set(file "${url}")
set(comment "Performing download step (verify and extract) for '${name}'") set(comment "Performing download step (verify and extract) for '${name}'")
endif() endif()
_ep_write_verifyfile_script("${stamp_dir}/verify-${name}.cmake" "${file}" "${md5}") _ep_write_verifyfile_script("${stamp_dir}/verify-${name}.cmake" "${file}" "${hash}")
list(APPEND cmd ${CMAKE_COMMAND} -P ${stamp_dir}/verify-${name}.cmake list(APPEND cmd ${CMAKE_COMMAND} -P ${stamp_dir}/verify-${name}.cmake
COMMAND) COMMAND)
_ep_write_extractfile_script("${stamp_dir}/extract-${name}.cmake" "${name}" "${file}" "${source_dir}") _ep_write_extractfile_script("${stamp_dir}/extract-${name}.cmake" "${name}" "${file}" "${source_dir}")

View File

@ -68,6 +68,13 @@
# CUDA_HOST_COMPILATION_CPP (Default ON) # CUDA_HOST_COMPILATION_CPP (Default ON)
# -- Set to OFF for C compilation of host code. # -- Set to OFF for C compilation of host code.
# #
# CUDA_HOST_COMPILER (Default CMAKE_C_COMPILER, $(VCInstallDir)/bin for VS)
# -- Set the host compiler to be used by nvcc. Ignored if -ccbin or
# --compiler-bindir is already present in the CUDA_NVCC_FLAGS or
# CUDA_NVCC_FLAGS_<CONFIG> variables. For Visual Studio targets
# $(VCInstallDir)/bin is a special value that expands out to the path when
# the command is run from withing VS.
#
# CUDA_NVCC_FLAGS # CUDA_NVCC_FLAGS
# CUDA_NVCC_FLAGS_<CONFIG> # CUDA_NVCC_FLAGS_<CONFIG>
# -- Additional NVCC command line arguments. NOTE: multiple arguments must be # -- Additional NVCC command line arguments. NOTE: multiple arguments must be
@ -390,6 +397,12 @@ option(CUDA_HOST_COMPILATION_CPP "Generated file extension" ON)
# Extra user settable flags # Extra user settable flags
set(CUDA_NVCC_FLAGS "" CACHE STRING "Semi-colon delimit multiple arguments.") set(CUDA_NVCC_FLAGS "" CACHE STRING "Semi-colon delimit multiple arguments.")
if(CMAKE_GENERATOR MATCHES "Visual Studio")
set(CUDA_HOST_COMPILER "$(VCInstallDir)bin" CACHE FILEPATH "Host side compiler used by NVCC")
else()
set(CUDA_HOST_COMPILER "${CMAKE_C_COMPILER}" CACHE FILEPATH "Host side compiler used by NVCC")
endif()
# Propagate the host flags to the host compiler via -Xcompiler # Propagate the host flags to the host compiler via -Xcompiler
option(CUDA_PROPAGATE_HOST_FLAGS "Propage C/CXX_FLAGS and friends to the host compiler via -Xcompile" ON) option(CUDA_PROPAGATE_HOST_FLAGS "Propage C/CXX_FLAGS and friends to the host compiler via -Xcompile" ON)
@ -932,12 +945,11 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files)
endif() endif()
# This needs to be passed in at this stage, because VS needs to fill out the # This needs to be passed in at this stage, because VS needs to fill out the
# value of VCInstallDir from within VS. # value of VCInstallDir from within VS. Note that CCBIN is only used if
# -ccbin or --compiler-bindir isn't used and CUDA_HOST_COMPILER matches
# $(VCInstallDir)/bin.
if(CMAKE_GENERATOR MATCHES "Visual Studio") if(CMAKE_GENERATOR MATCHES "Visual Studio")
if( CMAKE_SIZEOF_VOID_P EQUAL 8 ) set(ccbin_flags -D "\"CCBIN:PATH=$(VCInstallDir)bin\"" )
# Add nvcc flag for 64b Windows
set(ccbin_flags -D "\"CCBIN:PATH=$(VCInstallDir)bin\"" )
endif()
endif() endif()
# Figure out which configure we will use and pass that in as an argument to # Figure out which configure we will use and pass that in as an argument to

View File

@ -62,6 +62,7 @@ set(cmake_dependency_file "@cmake_dependency_file@") # path
set(CUDA_make2cmake "@CUDA_make2cmake@") # path set(CUDA_make2cmake "@CUDA_make2cmake@") # path
set(CUDA_parse_cubin "@CUDA_parse_cubin@") # path set(CUDA_parse_cubin "@CUDA_parse_cubin@") # path
set(build_cubin @build_cubin@) # bool set(build_cubin @build_cubin@) # bool
set(CUDA_HOST_COMPILER "@CUDA_HOST_COMPILER@") # bool
# We won't actually use these variables for now, but we need to set this, in # We won't actually use these variables for now, but we need to set this, in
# order to force this file to be run again if it changes. # order to force this file to be run again if it changes.
set(generated_file_path "@generated_file_path@") # path set(generated_file_path "@generated_file_path@") # path
@ -102,8 +103,15 @@ endif()
# Add the build specific configuration flags # Add the build specific configuration flags
list(APPEND CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS_${build_configuration}}) list(APPEND CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS_${build_configuration}})
if(DEFINED CCBIN) # Any -ccbin existing in CUDA_NVCC_FLAGS gets highest priority
set(CCBIN -ccbin "${CCBIN}") list( FIND CUDA_NVCC_FLAGS "-ccbin" ccbin_found0 )
list( FIND CUDA_NVCC_FLAGS "--compiler-bindir" ccbin_found1 )
if( ccbin_found0 LESS 0 AND ccbin_found1 LESS 0 )
if (CUDA_HOST_COMPILER STREQUAL "$(VCInstallDir)bin" AND DEFINED CCBIN)
set(CCBIN -ccbin "${CCBIN}")
else()
set(CCBIN -ccbin "${CUDA_HOST_COMPILER}")
endif()
endif() endif()
# cuda_execute_process - Executes a command with optional command echo and status message. # cuda_execute_process - Executes a command with optional command echo and status message.

30
Modules/FindGLEW.cmake Normal file
View File

@ -0,0 +1,30 @@
# - Find the OpenGL Extension Wrangler Library (GLEW)
# This module defines the following variables:
# GLEW_INCLUDE_DIRS - include directories for GLEW
# GLEW_LIBRARIES - libraries to link against GLEW
# GLEW_FOUND - true if GLEW has been found and can be used
#=============================================================================
# Copyright 2012 Benjamin Eikel
#
# 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.)
find_path(GLEW_INCLUDE_DIR GL/glew.h)
find_library(GLEW_LIBRARY NAMES GLEW glew32 glew glew32s PATH_SUFFIXES lib64)
set(GLEW_INCLUDE_DIRS ${GLEW_INCLUDE_DIR})
set(GLEW_LIBRARIES ${GLEW_LIBRARY})
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
find_package_handle_standard_args(GLEW
REQUIRED_VARS GLEW_INCLUDE_DIR GLEW_LIBRARY)
mark_as_advanced(GLEW_INCLUDE_DIR GLEW_LIBRARY)

View File

@ -145,23 +145,6 @@ if(OSG_INCLUDE_DIR)
endif() endif()
endif() endif()
#
# Version checking
#
if(OpenSceneGraph_FIND_VERSION AND OPENSCENEGRAPH_VERSION)
if(OpenSceneGraph_FIND_VERSION_EXACT)
if(NOT OPENSCENEGRAPH_VERSION VERSION_EQUAL ${OpenSceneGraph_FIND_VERSION})
set(_osg_version_not_exact TRUE)
endif()
else()
# version is too low
if(NOT OPENSCENEGRAPH_VERSION VERSION_EQUAL ${OpenSceneGraph_FIND_VERSION} AND
NOT OPENSCENEGRAPH_VERSION VERSION_GREATER ${OpenSceneGraph_FIND_VERSION})
set(_osg_version_not_high_enough TRUE)
endif()
endif()
endif()
set(_osg_quiet) set(_osg_quiet)
if(OpenSceneGraph_FIND_QUIETLY) if(OpenSceneGraph_FIND_QUIETLY)
set(_osg_quiet "QUIET") set(_osg_quiet "QUIET")
@ -190,63 +173,22 @@ if(OPENSCENEGRAPH_INCLUDE_DIR)
endif() endif()
# #
# Inform the users with an error message based on # Check each module to see if it's found
# what version they have vs. what version was
# required.
# #
set(_osg_component_founds)
if(OpenSceneGraph_FIND_REQUIRED) if(OpenSceneGraph_FIND_REQUIRED)
set(_osg_version_output_type FATAL_ERROR) foreach(_osg_module ${_osg_modules_to_process})
else() string(TOUPPER ${_osg_module} _osg_module_UC)
set(_osg_version_output_type STATUS) list(APPEND _osg_component_founds ${_osg_module_UC}_FOUND)
endif() endforeach()
if(_osg_version_not_high_enough)
set(_osg_EPIC_FAIL TRUE)
if(NOT OpenSceneGraph_FIND_QUIETLY)
message(${_osg_version_output_type}
"ERROR: Version ${OpenSceneGraph_FIND_VERSION} or higher of the OSG "
"is required. Version ${OPENSCENEGRAPH_VERSION} was found.")
endif()
elseif(_osg_version_not_exact)
set(_osg_EPIC_FAIL TRUE)
if(NOT OpenSceneGraph_FIND_QUIETLY)
message(${_osg_version_output_type}
"ERROR: Version ${OpenSceneGraph_FIND_VERSION} of the OSG is required "
"(exactly), version ${OPENSCENEGRAPH_VERSION} was found.")
endif()
else()
#
# Check each module to see if it's found
#
if(OpenSceneGraph_FIND_REQUIRED)
set(_osg_missing_message)
foreach(_osg_module ${_osg_modules_to_process})
string(TOUPPER ${_osg_module} _osg_module_UC)
if(NOT ${_osg_module_UC}_FOUND)
set(_osg_missing_nodekit_fail true)
set(_osg_missing_message "${_osg_missing_message} ${_osg_module}")
endif()
endforeach()
if(_osg_missing_nodekit_fail)
message(FATAL_ERROR "ERROR: Missing the following osg "
"libraries: ${_osg_missing_message}.\n"
"Consider using CMAKE_PREFIX_PATH or the OSG_DIR "
"environment variable. See the "
"${CMAKE_CURRENT_LIST_FILE} for more details.")
endif()
endif()
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenSceneGraph DEFAULT_MSG OPENSCENEGRAPH_LIBRARIES OPENSCENEGRAPH_INCLUDE_DIR)
endif() endif()
if(_osg_EPIC_FAIL) include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
# Zero out everything, we didn't meet version requirements FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenSceneGraph
set(OPENSCENEGRAPH_FOUND FALSE) REQUIRED_VARS OPENSCENEGRAPH_LIBRARIES OPENSCENEGRAPH_INCLUDE_DIR ${_osg_component_founds}
set(OPENSCENEGRAPH_LIBRARIES) VERSION_VAR OPENSCENEGRAPH_VERSION)
set(OPENSCENEGRAPH_INCLUDE_DIR)
endif() unset(_osg_component_founds)
set(OPENSCENEGRAPH_INCLUDE_DIRS ${OPENSCENEGRAPH_INCLUDE_DIR}) set(OPENSCENEGRAPH_INCLUDE_DIRS ${OPENSCENEGRAPH_INCLUDE_DIR})

View File

@ -133,10 +133,12 @@ endif()
if(SDL_LIBRARY_TEMP) if(SDL_LIBRARY_TEMP)
# For SDLmain # For SDLmain
if(NOT SDL_BUILDING_LIBRARY) if(SDLMAIN_LIBRARY AND NOT SDL_BUILDING_LIBRARY)
if(SDLMAIN_LIBRARY) list(FIND SDL_LIBRARY_TEMP "${SDLMAIN_LIBRARY}" _SDL_MAIN_INDEX)
set(SDL_LIBRARY_TEMP ${SDLMAIN_LIBRARY} ${SDL_LIBRARY_TEMP}) if(_SDL_MAIN_INDEX EQUAL -1)
list(APPEND SDL_LIBRARY_TEMP "${SDLMAIN_LIBRARY}")
endif() endif()
unset(_SDL_MAIN_INDEX)
endif() endif()
# For OS X, SDL uses Cocoa as a backend so it must link to Cocoa. # For OS X, SDL uses Cocoa as a backend so it must link to Cocoa.

View File

@ -187,6 +187,12 @@ set(SRCS
cmFileTimeComparison.cxx cmFileTimeComparison.cxx
cmFileTimeComparison.h cmFileTimeComparison.h
cmGeneratedFileStream.cxx cmGeneratedFileStream.cxx
cmGeneratorExpressionEvaluator.cxx
cmGeneratorExpressionEvaluator.h
cmGeneratorExpressionLexer.cxx
cmGeneratorExpressionLexer.h
cmGeneratorExpressionParser.cxx
cmGeneratorExpressionParser.h
cmGeneratorExpression.cxx cmGeneratorExpression.cxx
cmGeneratorExpression.h cmGeneratorExpression.h
cmGeneratorTarget.cxx cmGeneratorTarget.cxx
@ -553,7 +559,7 @@ endif()
# Qt GUI # Qt GUI
option(BUILD_QtDialog "Build Qt dialog for CMake" FALSE) option(BUILD_QtDialog "Build Qt dialog for CMake" FALSE)
if(BUILD_QtDialog) if(BUILD_QtDialog)
subdirs(QtDialog) add_subdirectory(QtDialog)
endif() endif()
include (${CMake_BINARY_DIR}/Source/LocalUserOptions.cmake OPTIONAL) include (${CMake_BINARY_DIR}/Source/LocalUserOptions.cmake OPTIONAL)

View File

@ -2,5 +2,5 @@
set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MAJOR 2)
set(CMake_VERSION_MINOR 8) set(CMake_VERSION_MINOR 8)
set(CMake_VERSION_PATCH 9) set(CMake_VERSION_PATCH 9)
set(CMake_VERSION_TWEAK 20120915) set(CMake_VERSION_TWEAK 20120919)
#set(CMake_VERSION_RC 1) #set(CMake_VERSION_RC 1)

View File

@ -9,115 +9,129 @@
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information. # See the License for more information.
#============================================================================= #=============================================================================
project(QtDialog)
set(QT_MIN_VERSION "4.4.0")
find_package(Qt4 REQUIRED)
if(NOT QT4_FOUND) project(QtDialog)
message(SEND_ERROR "Failed to find Qt 4.4 or greater.") find_package(Qt5Widgets QUIET)
if (Qt5Widgets_FOUND)
include_directories(${Qt5Widgets_INCLUDE_DIRS})
add_definitions(${Qt5Widgets_DEFINITONS})
macro(qt4_wrap_ui)
qt5_wrap_ui(${ARGN})
endmacro()
macro(qt4_wrap_cpp)
qt5_wrap_cpp(${ARGN})
endmacro()
macro(qt4_add_resources)
qt5_add_resources(${ARGN})
endmacro()
set(QT_LIBRARIES ${Qt5Widgets_LIBRARIES})
else() else()
set(QT_MIN_VERSION "4.4.0")
find_package(Qt4 REQUIRED)
if(NOT QT4_FOUND)
message(SEND_ERROR "Failed to find Qt 4.4 or greater.")
return()
endif()
include(${QT_USE_FILE}) include(${QT_USE_FILE})
set(CMAKE_PACKAGE_QTGUI TRUE)
set(SRCS
AddCacheEntry.cxx
AddCacheEntry.h
CMakeSetup.cxx
CMakeSetupDialog.cxx
CMakeSetupDialog.h
FirstConfigure.cxx
FirstConfigure.h
QCMake.cxx
QCMake.h
QCMakeCacheView.cxx
QCMakeCacheView.h
QCMakeWidgets.cxx
QCMakeWidgets.h
QMacInstallDialog.cxx
QMacInstallDialog.h
)
QT4_WRAP_UI(UI_SRCS
CMakeSetupDialog.ui
Compilers.ui
CrossCompiler.ui
AddCacheEntry.ui
MacInstallDialog.ui
)
QT4_WRAP_CPP(MOC_SRCS
AddCacheEntry.h
Compilers.h
CMakeSetupDialog.h
FirstConfigure.h
QCMake.h
QCMakeCacheView.h
QCMakeWidgets.h
QMacInstallDialog.h
)
QT4_ADD_RESOURCES(RC_SRCS CMakeSetup.qrc)
set(SRCS ${SRCS} ${UI_SRCS} ${MOC_SRCS} ${RC_SRCS})
if(Q_WS_WIN)
set(SRCS ${SRCS} CMakeSetup.rc)
endif()
if(Q_WS_MAC)
set(SRCS ${SRCS} CMakeSetup.icns)
set(MACOSX_BUNDLE_ICON_FILE CMakeSetup.icns)
set_source_files_properties(CMakeSetup.icns PROPERTIES
MACOSX_PACKAGE_LOCATION Resources)
endif()
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_executable(cmake-gui WIN32 MACOSX_BUNDLE ${SRCS})
target_link_libraries(cmake-gui CMakeLib ${QT_QTMAIN_LIBRARY} ${QT_LIBRARIES})
if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.4)
if(APPLE)
set_target_properties(cmake-gui PROPERTIES
OUTPUT_NAME ${CMAKE_BUNDLE_NAME})
endif()
set(CMAKE_INSTALL_DESTINATION_ARGS
BUNDLE DESTINATION "${CMAKE_BUNDLE_LOCATION}")
endif()
install(TARGETS cmake-gui RUNTIME DESTINATION bin ${CMAKE_INSTALL_DESTINATION_ARGS})
if(UNIX)
# install a desktop file so CMake appears in the application start menu
# with an icon
install(FILES CMake.desktop DESTINATION share/applications )
install(FILES CMakeSetup32.png DESTINATION share/pixmaps )
install(FILES cmakecache.xml DESTINATION share/mime/packages )
endif()
if(APPLE)
set(CMAKE_POSTFLIGHT_SCRIPT
"${CMake_BINARY_DIR}/Source/QtDialog/postflight.sh")
set(CMAKE_POSTUPGRADE_SCRIPT
"${CMake_BINARY_DIR}/Source/QtDialog/postupgrade.sh")
configure_file("${CMake_SOURCE_DIR}/Source/QtDialog/postflight.sh.in"
"${CMake_BINARY_DIR}/Source/QtDialog/postflight.sh")
configure_file("${CMake_SOURCE_DIR}/Source/QtDialog/postupgrade.sh.in"
"${CMake_BINARY_DIR}/Source/QtDialog/postupgrade.sh")
install(CODE "execute_process(COMMAND ln -s \"../MacOS/${CMAKE_BUNDLE_NAME}\" cmake-gui
WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin)")
endif()
if(APPLE OR WIN32)
# install rules for including 3rd party libs such as Qt
# if a system Qt is used (e.g. installed in /usr/lib/), it will not be included in the installation
set(fixup_exe "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin/cmake-gui${CMAKE_EXECUTABLE_SUFFIX}")
if(APPLE)
set(fixup_exe "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/MacOS/${CMAKE_BUNDLE_NAME}")
endif()
install(CODE "
include(\"${CMake_SOURCE_DIR}/Modules/BundleUtilities.cmake\")
set(BU_CHMOD_BUNDLE_ITEMS ON)
fixup_bundle(\"${fixup_exe}\" \"\" \"${QT_LIBRARY_DIR};${QT_BINARY_DIR}\")
")
endif()
configure_file("${QtDialog_SOURCE_DIR}/QtDialogCPack.cmake.in"
"${QtDialog_BINARY_DIR}/QtDialogCPack.cmake" @ONLY)
endif() endif()
set(SRCS
AddCacheEntry.cxx
AddCacheEntry.h
CMakeSetup.cxx
CMakeSetupDialog.cxx
CMakeSetupDialog.h
FirstConfigure.cxx
FirstConfigure.h
QCMake.cxx
QCMake.h
QCMakeCacheView.cxx
QCMakeCacheView.h
QCMakeWidgets.cxx
QCMakeWidgets.h
QMacInstallDialog.cxx
QMacInstallDialog.h
)
QT4_WRAP_UI(UI_SRCS
CMakeSetupDialog.ui
Compilers.ui
CrossCompiler.ui
AddCacheEntry.ui
MacInstallDialog.ui
)
QT4_WRAP_CPP(MOC_SRCS
AddCacheEntry.h
Compilers.h
CMakeSetupDialog.h
FirstConfigure.h
QCMake.h
QCMakeCacheView.h
QCMakeWidgets.h
QMacInstallDialog.h
)
QT4_ADD_RESOURCES(RC_SRCS CMakeSetup.qrc)
set(SRCS ${SRCS} ${UI_SRCS} ${MOC_SRCS} ${RC_SRCS})
if(WIN32)
set(SRCS ${SRCS} CMakeSetup.rc)
endif()
if(APPLE)
set(SRCS ${SRCS} CMakeSetup.icns)
set(MACOSX_BUNDLE_ICON_FILE CMakeSetup.icns)
set_source_files_properties(CMakeSetup.icns PROPERTIES
MACOSX_PACKAGE_LOCATION Resources)
endif()
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_executable(cmake-gui WIN32 MACOSX_BUNDLE ${SRCS})
target_link_libraries(cmake-gui CMakeLib ${QT_QTMAIN_LIBRARY} ${QT_LIBRARIES})
if(APPLE)
set_target_properties(cmake-gui PROPERTIES
OUTPUT_NAME ${CMAKE_BUNDLE_NAME})
endif()
set(CMAKE_INSTALL_DESTINATION_ARGS
BUNDLE DESTINATION "${CMAKE_BUNDLE_LOCATION}")
install(TARGETS cmake-gui RUNTIME DESTINATION bin ${CMAKE_INSTALL_DESTINATION_ARGS})
if(UNIX)
# install a desktop file so CMake appears in the application start menu
# with an icon
install(FILES CMake.desktop DESTINATION share/applications )
install(FILES CMakeSetup32.png DESTINATION share/pixmaps )
install(FILES cmakecache.xml DESTINATION share/mime/packages )
endif()
if(APPLE)
set(CMAKE_POSTFLIGHT_SCRIPT
"${CMake_BINARY_DIR}/Source/QtDialog/postflight.sh")
set(CMAKE_POSTUPGRADE_SCRIPT
"${CMake_BINARY_DIR}/Source/QtDialog/postupgrade.sh")
configure_file("${CMake_SOURCE_DIR}/Source/QtDialog/postflight.sh.in"
"${CMake_BINARY_DIR}/Source/QtDialog/postflight.sh")
configure_file("${CMake_SOURCE_DIR}/Source/QtDialog/postupgrade.sh.in"
"${CMake_BINARY_DIR}/Source/QtDialog/postupgrade.sh")
install(CODE "execute_process(COMMAND ln -s \"../MacOS/${CMAKE_BUNDLE_NAME}\" cmake-gui
WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin)")
endif()
if(APPLE OR WIN32)
# install rules for including 3rd party libs such as Qt
# if a system Qt is used (e.g. installed in /usr/lib/), it will not be included in the installation
set(fixup_exe "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin/cmake-gui${CMAKE_EXECUTABLE_SUFFIX}")
if(APPLE)
set(fixup_exe "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/MacOS/${CMAKE_BUNDLE_NAME}")
endif()
install(CODE "
include(\"${CMake_SOURCE_DIR}/Modules/BundleUtilities.cmake\")
set(BU_CHMOD_BUNDLE_ITEMS ON)
fixup_bundle(\"${fixup_exe}\" \"\" \"${QT_LIBRARY_DIR};${QT_BINARY_DIR}\")
")
endif()
set(CMAKE_PACKAGE_QTGUI TRUE)
configure_file("${QtDialog_SOURCE_DIR}/QtDialogCPack.cmake.in"
"${QtDialog_BINARY_DIR}/QtDialogCPack.cmake" @ONLY)

View File

@ -348,7 +348,11 @@ void QCMake::interrupt()
bool QCMake::interruptCallback(void* cd) bool QCMake::interruptCallback(void* cd)
{ {
QCMake* self = reinterpret_cast<QCMake*>(cd); QCMake* self = reinterpret_cast<QCMake*>(cd);
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
return self->InterruptFlag; return self->InterruptFlag;
#else
return self->InterruptFlag.load();
#endif
} }
void QCMake::progressCallback(const char* msg, float percent, void* cd) void QCMake::progressCallback(const char* msg, float percent, void* cd)

View File

@ -21,7 +21,7 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(
cmCustomCommand const& cc, const char* config, cmMakefile* mf): cmCustomCommand const& cc, const char* config, cmMakefile* mf):
CC(cc), Config(config), Makefile(mf), LG(mf->GetLocalGenerator()), CC(cc), Config(config), Makefile(mf), LG(mf->GetLocalGenerator()),
OldStyle(cc.GetEscapeOldStyle()), MakeVars(cc.GetEscapeAllowMakeVars()), OldStyle(cc.GetEscapeOldStyle()), MakeVars(cc.GetEscapeAllowMakeVars()),
GE(new cmGeneratorExpression(mf, config, cc.GetBacktrace())) GE(new cmGeneratorExpression(cc.GetBacktrace()))
{ {
} }
@ -47,7 +47,7 @@ std::string cmCustomCommandGenerator::GetCommand(unsigned int c) const
{ {
return target->GetLocation(this->Config); return target->GetLocation(this->Config);
} }
return this->GE->Process(argv0); return this->GE->Parse(argv0).Evaluate(this->Makefile, this->Config);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -58,7 +58,8 @@ cmCustomCommandGenerator
cmCustomCommandLine const& commandLine = this->CC.GetCommandLines()[c]; cmCustomCommandLine const& commandLine = this->CC.GetCommandLines()[c];
for(unsigned int j=1;j < commandLine.size(); ++j) for(unsigned int j=1;j < commandLine.size(); ++j)
{ {
std::string arg = this->GE->Process(commandLine[j]); std::string arg = this->GE->Parse(commandLine[j]).Evaluate(this->Makefile,
this->Config);
cmd += " "; cmd += " ";
if(this->OldStyle) if(this->OldStyle)
{ {

View File

@ -636,9 +636,11 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
// the include directories for this target // the include directories for this target
std::set<std::string> uniqIncludeDirs; std::set<std::string> uniqIncludeDirs;
cmGeneratorTarget *gtgt = this->GlobalGenerator
->GetGeneratorTarget(target);
std::vector<std::string> includes; std::vector<std::string> includes;
target->GetMakefile()->GetLocalGenerator()-> target->GetMakefile()->GetLocalGenerator()->
GetIncludeDirectories(includes, target); GetIncludeDirectories(includes, gtgt);
for(std::vector<std::string>::const_iterator dirIt=includes.begin(); for(std::vector<std::string>::const_iterator dirIt=includes.begin();
dirIt != includes.end(); dirIt != includes.end();
++dirIt) ++dirIt)

View File

@ -884,11 +884,13 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
it != this->GlobalGenerator->GetLocalGenerators().end(); it != this->GlobalGenerator->GetLocalGenerators().end();
++it) ++it)
{ {
cmTargets & targets = (*it)->GetMakefile()->GetTargets(); cmGeneratorTargetsType targets = (*it)->GetMakefile()
for (cmTargets::iterator l = targets.begin(); l != targets.end(); ++l) ->GetGeneratorTargets();
for (cmGeneratorTargetsType::iterator l = targets.begin();
l != targets.end(); ++l)
{ {
std::vector<std::string> includeDirs; std::vector<std::string> includeDirs;
(*it)->GetIncludeDirectories(includeDirs, &l->second); (*it)->GetIncludeDirectories(includeDirs, l->second);
this->AppendIncludeDirectories(fout, includeDirs, emmited); this->AppendIncludeDirectories(fout, includeDirs, emmited);
} }
} }

View File

@ -2667,9 +2667,8 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
long inactivity_timeout = 0; long inactivity_timeout = 0;
std::string verboseLog; std::string verboseLog;
std::string statusVar; std::string statusVar;
std::string caFile; bool tls_verify = this->Makefile->IsOn("CMAKE_TLS_VERIFY");
bool checkSSL = false; const char* cainfo = this->Makefile->GetDefinition("CMAKE_TLS_CAINFO");
bool verifySSL = false;
std::string expectedHash; std::string expectedHash;
std::string hashMatchMSG; std::string hashMatchMSG;
cmsys::auto_ptr<cmCryptoHash> hash; cmsys::auto_ptr<cmCryptoHash> hash;
@ -2723,30 +2722,29 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
} }
statusVar = *i; statusVar = *i;
} }
else if(*i == "SSL_VERIFY") else if(*i == "TLS_VERIFY")
{ {
++i; ++i;
if(i != args.end()) if(i != args.end())
{ {
verifySSL = cmSystemTools::IsOn(i->c_str()); tls_verify = cmSystemTools::IsOn(i->c_str());
checkSSL = true;
} }
else else
{ {
this->SetError("SSL_VERIFY missing bool value."); this->SetError("TLS_VERIFY missing bool value.");
return false; return false;
} }
} }
else if(*i == "SSL_CAINFO_FILE") else if(*i == "TLS_CAINFO")
{ {
++i; ++i;
if(i != args.end()) if(i != args.end())
{ {
caFile = *i; cainfo = i->c_str();
} }
else else
{ {
this->SetError("SSL_CAFILE missing file value."); this->SetError("TLS_CAFILE missing file value.");
return false; return false;
} }
} }
@ -2865,41 +2863,23 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
cmFileCommandCurlDebugCallback); cmFileCommandCurlDebugCallback);
check_curl_result(res, "DOWNLOAD cannot set debug function: "); check_curl_result(res, "DOWNLOAD cannot set debug function: ");
// check to see if SSL verification is requested // check to see if TLS verification is requested
const char* verifyValue = if(tls_verify)
this->Makefile->GetDefinition("CMAKE_CURLOPT_SSL_VERIFYPEER");
// if there is a cmake variable or if the command has SSL_VERIFY requested
if(verifyValue || checkSSL)
{ {
// the args to the command come first res = ::curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1);
bool verify = verifySSL; check_curl_result(res, "Unable to set TLS/SSL Verify on: ");
if(!verify && verifyValue) }
{ else
verify = cmSystemTools::IsOn(verifyValue); {
} res = ::curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
if(verify) check_curl_result(res, "Unable to set TLS/SSL Verify off: ");
{
res = ::curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1);
check_curl_result(res, "Unable to set SSL Verify on: ");
}
else
{
res = ::curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
check_curl_result(res, "Unable to set SSL Verify off: ");
}
} }
// check to see if a CAINFO file has been specified // check to see if a CAINFO file has been specified
const char* cainfo =
this->Makefile->GetDefinition("CMAKE_CURLOPT_CAINFO_FILE");
// command arg comes first // command arg comes first
if(caFile.size()) if(cainfo && *cainfo)
{
cainfo = caFile.c_str();
}
if(cainfo)
{ {
res = ::curl_easy_setopt(curl, CURLOPT_CAINFO, cainfo); res = ::curl_easy_setopt(curl, CURLOPT_CAINFO, cainfo);
check_curl_result(res, "Unable to set SSL Verify CAINFO: "); check_curl_result(res, "Unable to set TLS/SSL Verify CAINFO: ");
} }
cmFileCommandVectorOfChar chunkDebug; cmFileCommandVectorOfChar chunkDebug;

View File

@ -85,7 +85,7 @@ public:
" [TIMEOUT timeout] [STATUS status] [LOG log] [SHOW_PROGRESS]\n" " [TIMEOUT timeout] [STATUS status] [LOG log] [SHOW_PROGRESS]\n"
" [EXPECTED_HASH MD5|SHA1|SHA224|SHA256|SHA384|SHA512 hash]\n" " [EXPECTED_HASH MD5|SHA1|SHA224|SHA256|SHA384|SHA512 hash]\n"
" [EXPECTED_MD5 sum]\n" " [EXPECTED_MD5 sum]\n"
" [SSL_VERIFY on|off] [SSL_CAINFO_FILE file])\n" " [TLS_VERIFY on|off] [TLS_CAINFO file])\n"
" file(UPLOAD filename url [INACTIVITY_TIMEOUT timeout]\n" " file(UPLOAD filename url [INACTIVITY_TIMEOUT timeout]\n"
" [TIMEOUT timeout] [STATUS status] [LOG log] [SHOW_PROGRESS])\n" " [TIMEOUT timeout] [STATUS status] [LOG log] [SHOW_PROGRESS])\n"
"WRITE will write a message into a file called 'filename'. It " "WRITE will write a message into a file called 'filename'. It "
@ -177,12 +177,12 @@ public:
"If SHOW_PROGRESS is specified, progress information will be printed " "If SHOW_PROGRESS is specified, progress information will be printed "
"as status messages until the operation is complete. " "as status messages until the operation is complete. "
"For https URLs CMake must be built with OpenSSL. " "For https URLs CMake must be built with OpenSSL. "
"SSL certificates are not checked by default. " "TLS/SSL certificates are not checked by default. "
"Set SSL_VERIFY to ON to check certificates and/or use " "Set TLS_VERIFY to ON to check certificates and/or use "
"EXPECTED_HASH to verify downloaded content. " "EXPECTED_HASH to verify downloaded content. "
"Set SSL_CAINFO_FILE to specify a custom Certificate Authority file. " "Set TLS_CAINFO to specify a custom Certificate Authority file. "
"If either SSL option is not given CMake will check variables " "If either TLS option is not given CMake will check variables "
"CMAKE_CURLOPT_SSL_VERIFYPEER and CMAKE_CURLOPT_CAINFO_FILE, " "CMAKE_TLS_VERIFY and CMAKE_TLS_CAINFO, "
"respectively." "respectively."
"\n" "\n"
"UPLOAD will upload the given file to the given URL. " "UPLOAD will upload the given file to the given URL. "

View File

@ -16,233 +16,112 @@
#include <cmsys/String.h> #include <cmsys/String.h>
#include "cmGeneratorExpressionEvaluator.h"
#include "cmGeneratorExpressionLexer.h"
#include "cmGeneratorExpressionParser.h"
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmGeneratorExpression::cmGeneratorExpression( cmGeneratorExpression::cmGeneratorExpression(
cmMakefile* mf, const char* config, cmListFileBacktrace const& backtrace):
cmListFileBacktrace const& backtrace, bool quiet): Backtrace(backtrace), CompiledExpression(0)
Makefile(mf), Config(config), Backtrace(backtrace), Quiet(quiet)
{ {
this->TargetInfo.compile("^\\$<TARGET"
"(|_SONAME|_LINKER)" // File with what purpose?
"_FILE(|_NAME|_DIR):" // Filename component.
"([A-Za-z0-9_.-]+)" // Target name.
">$");
this->TestConfig.compile("^\\$<CONFIG:([A-Za-z0-9_]*)>$");
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
const char* cmGeneratorExpression::Process(std::string const& input) const cmCompiledGeneratorExpression &
cmGeneratorExpression::Parse(std::string const& input)
{ {
return this->Process(input.c_str()); return this->Parse(input.c_str());
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
const char* cmGeneratorExpression::Process(const char* input) const cmCompiledGeneratorExpression &
cmGeneratorExpression::Parse(const char* input)
{ {
this->Data.clear(); cmGeneratorExpressionLexer l;
std::vector<cmGeneratorExpressionToken> tokens = l.Tokenize(input);
bool needsParsing = l.GetSawGeneratorExpression();
std::vector<cmGeneratorExpressionEvaluator*> evaluators;
// We construct and evaluate expressions directly in the output if (needsParsing)
// buffer. Each expression is replaced by its own output value
// after evaluation. A stack of barriers records the starting
// indices of open (pending) expressions.
for(const char* c = input; *c; ++c)
{ {
if(c[0] == '$' && c[1] == '<') cmGeneratorExpressionParser p(tokens);
{ p.Parse(evaluators);
this->Barriers.push(this->Data.size());
this->Data.push_back('$');
this->Data.push_back('<');
c += 1;
}
else if(c[0] == '>' && !this->Barriers.empty())
{
this->Data.push_back('>');
if(!this->Evaluate()) { break; }
this->Barriers.pop();
}
else
{
this->Data.push_back(c[0]);
}
} }
// Return a null-terminated output value. delete this->CompiledExpression;
this->Data.push_back('\0'); this->CompiledExpression = new cmCompiledGeneratorExpression(
return &*this->Data.begin(); this->Backtrace,
evaluators,
input,
needsParsing);
return *this->CompiledExpression;
}
cmGeneratorExpression::~cmGeneratorExpression()
{
delete this->CompiledExpression;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmGeneratorExpression::Evaluate() const char *cmCompiledGeneratorExpression::Evaluate(
cmMakefile* mf, const char* config, bool quiet) const
{ {
// The top-most barrier points at the beginning of the expression. if (!this->NeedsParsing)
size_t barrier = this->Barriers.top();
// Construct a null-terminated representation of the expression.
this->Data.push_back('\0');
const char* expr = &*(this->Data.begin()+barrier);
// Evaluate the expression.
std::string result;
if(this->Evaluate(expr, result))
{ {
// Success. Replace the expression with its evaluation result. return this->Input;
this->Data.erase(this->Data.begin()+barrier, this->Data.end());
this->Data.insert(this->Data.end(), result.begin(), result.end());
return true;
} }
else if(!this->Quiet)
this->Output = "";
std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it
= this->Evaluators.begin();
const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end
= this->Evaluators.end();
cmGeneratorExpressionContext context;
context.Makefile = mf;
context.Config = config;
context.Quiet = quiet;
context.HadError = false;
context.Backtrace = this->Backtrace;
for ( ; it != end; ++it)
{ {
// Failure. Report the error message. this->Output += (*it)->Evaluate(&context);
cmOStringStream e; if (context.HadError)
e << "Error evaluating generator expression:\n" {
<< " " << expr << "\n" this->Output = "";
<< result; break;
this->Makefile->GetCMakeInstance() }
->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(),
this->Backtrace);
return false;
} }
return true;
this->Targets = context.Targets;
// TODO: Return a std::string from here instead?
return this->Output.c_str();
} }
cmCompiledGeneratorExpression::cmCompiledGeneratorExpression(
cmListFileBacktrace const& backtrace,
const std::vector<cmGeneratorExpressionEvaluator*> &evaluators,
const char *input, bool needsParsing)
: Backtrace(backtrace), Evaluators(evaluators), Input(input),
NeedsParsing(needsParsing)
{
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
static bool cmGeneratorExpressionBool(const char* c, std::string& result, cmCompiledGeneratorExpression::~cmCompiledGeneratorExpression()
const char* name,
const char* a, const char* b)
{ {
result = a; std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it
while((c[0] == '0' || c[0] == '1') && (c[1] == ',' || c[1] == '>')) = this->Evaluators.begin();
const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end
= this->Evaluators.end();
for ( ; it != end; ++it)
{ {
if(c[0] == b[0]) { result = b; } delete *it;
c += 2;
} }
if(c[0])
{
result = name;
result += " requires one or more comma-separated '0' or '1' values.";
return false;
}
return true;
}
//----------------------------------------------------------------------------
bool cmGeneratorExpression::Evaluate(const char* expr, std::string& result)
{
if(this->TargetInfo.find(expr))
{
if(!this->EvaluateTargetInfo(result))
{
return false;
}
}
else if(strcmp(expr, "$<CONFIGURATION>") == 0)
{
result = this->Config? this->Config : "";
}
else if(strncmp(expr, "$<0:",4) == 0)
{
result = "";
}
else if(strncmp(expr, "$<1:",4) == 0)
{
result = std::string(expr+4, strlen(expr)-5);
}
else if(strncmp(expr, "$<NOT:",6) == 0)
{
const char* c = expr+6;
if((c[0] != '0' && c[0] != '1') || c[1] != '>' || c[2])
{
result = "NOT requires exactly one '0' or '1' value.";
return false;
}
result = c[0] == '1'? "0" : "1";
}
else if(strncmp(expr, "$<AND:",6) == 0)
{
return cmGeneratorExpressionBool(expr+6, result, "AND", "1", "0");
}
else if(strncmp(expr, "$<OR:",5) == 0)
{
return cmGeneratorExpressionBool(expr+5, result, "OR", "0", "1");
}
else if(this->TestConfig.find(expr))
{
result = cmsysString_strcasecmp(this->TestConfig.match(1).c_str(),
this->Config? this->Config:"") == 0
? "1":"0";
}
else
{
result = "Expression syntax not recognized.";
return false;
}
return true;
}
//----------------------------------------------------------------------------
bool cmGeneratorExpression::EvaluateTargetInfo(std::string& result)
{
// Lookup the referenced target.
std::string name = this->TargetInfo.match(3);
cmTarget* target = this->Makefile->FindTargetToUse(name.c_str());
if(!target)
{
result = "No target \"" + name + "\"";
return false;
}
if(target->GetType() >= cmTarget::UTILITY &&
target->GetType() != cmTarget::UNKNOWN_LIBRARY)
{
result = "Target \"" + name + "\" is not an executable or library.";
return false;
}
this->Targets.insert(target);
// Lookup the target file with the given purpose.
std::string purpose = this->TargetInfo.match(1);
if(purpose == "")
{
// The target implementation file (.so.1.2, .dll, .exe, .a).
result = target->GetFullPath(this->Config, false, true);
}
else if(purpose == "_LINKER")
{
// The file used to link to the target (.so, .lib, .a).
if(!target->IsLinkable())
{
result = ("TARGET_LINKER_FILE is allowed only for libraries and "
"executables with ENABLE_EXPORTS.");
return false;
}
result = target->GetFullPath(this->Config, target->HasImportLibrary());
}
else if(purpose == "_SONAME")
{
// The target soname file (.so.1).
if(target->IsDLLPlatform())
{
result = "TARGET_SONAME_FILE is not allowed for DLL target platforms.";
return false;
}
if(target->GetType() != cmTarget::SHARED_LIBRARY)
{
result = "TARGET_SONAME_FILE is allowed only for SHARED libraries.";
return false;
}
result = target->GetDirectory(this->Config);
result += "/";
result += target->GetSOName(this->Config);
}
// Extract the requested portion of the full path.
std::string part = this->TargetInfo.match(2);
if(part == "_NAME")
{
result = cmSystemTools::GetFilenameName(result);
}
else if(part == "_DIR")
{
result = cmSystemTools::GetFilenamePath(result);
}
return true;
} }

View File

@ -19,6 +19,10 @@ class cmTarget;
class cmMakefile; class cmMakefile;
class cmListFileBacktrace; class cmListFileBacktrace;
struct cmGeneratorExpressionEvaluator;
class cmCompiledGeneratorExpression;
/** \class cmGeneratorExpression /** \class cmGeneratorExpression
* \brief Evaluate generate-time query expression syntax. * \brief Evaluate generate-time query expression syntax.
* *
@ -31,29 +35,48 @@ class cmListFileBacktrace;
class cmGeneratorExpression class cmGeneratorExpression
{ {
public: public:
/** Construct with an evaluation context and configuration. */ /** Construct. */
cmGeneratorExpression(cmMakefile* mf, const char* config, cmGeneratorExpression(cmListFileBacktrace const& backtrace);
cmListFileBacktrace const& backtrace, ~cmGeneratorExpression();
bool quiet = false);
/** Evaluate generator expressions in a string. */ const cmCompiledGeneratorExpression& Parse(std::string const& input);
const char* Process(std::string const& input); const cmCompiledGeneratorExpression& Parse(const char* input);
const char* Process(const char* input);
private:
cmGeneratorExpression(const cmGeneratorExpression &);
void operator=(const cmGeneratorExpression &);
cmListFileBacktrace const& Backtrace;
cmCompiledGeneratorExpression *CompiledExpression;
};
class cmCompiledGeneratorExpression
{
public:
const char* Evaluate(cmMakefile* mf, const char* config,
bool quiet = false) const;
/** Get set of targets found during evaluations. */ /** Get set of targets found during evaluations. */
std::set<cmTarget*> const& GetTargets() const std::set<cmTarget*> const& GetTargets() const
{ return this->Targets; } { return this->Targets; }
~cmCompiledGeneratorExpression();
private: private:
cmMakefile* Makefile; cmCompiledGeneratorExpression(cmListFileBacktrace const& backtrace,
const char* Config; const std::vector<cmGeneratorExpressionEvaluator*> &evaluators,
const char *input, bool needsParsing);
friend class cmGeneratorExpression;
cmCompiledGeneratorExpression(const cmCompiledGeneratorExpression &);
void operator=(const cmCompiledGeneratorExpression &);
cmListFileBacktrace const& Backtrace; cmListFileBacktrace const& Backtrace;
bool Quiet; const std::vector<cmGeneratorExpressionEvaluator*> Evaluators;
std::vector<char> Data; const char* const Input;
std::stack<size_t> Barriers; const bool NeedsParsing;
cmsys::RegularExpression TargetInfo;
cmsys::RegularExpression TestConfig; mutable std::set<cmTarget*> Targets;
std::set<cmTarget*> Targets; mutable std::string Output;
bool Evaluate();
bool Evaluate(const char* expr, std::string& result);
bool EvaluateTargetInfo(std::string& result);
}; };

View File

@ -0,0 +1,568 @@
/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2012 Stephen Kelly <steveire@gmail.com>
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 "cmMakefile.h"
#include "cmGeneratorExpressionEvaluator.h"
#include "cmGeneratorExpressionParser.h"
//----------------------------------------------------------------------------
static void reportError(cmGeneratorExpressionContext *context,
const std::string &expr, const std::string &result)
{
context->HadError = true;
if (context->Quiet)
{
return;
}
cmOStringStream e;
e << "Error evaluating generator expression:\n"
<< " " << expr << "\n"
<< result;
context->Makefile->GetCMakeInstance()
->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(),
context->Backtrace);
}
//----------------------------------------------------------------------------
struct cmGeneratorExpressionNode
{
virtual ~cmGeneratorExpressionNode() {}
virtual bool GeneratesContent() const { return true; }
virtual bool AcceptsSingleArbitraryContentParameter() const
{ return false; }
virtual int NumExpectedParameters() const { return 1; }
virtual std::string Evaluate(const std::vector<std::string> &parameters,
cmGeneratorExpressionContext *context,
const GeneratorExpressionContent *content
) const = 0;
};
//----------------------------------------------------------------------------
static const struct ZeroNode : public cmGeneratorExpressionNode
{
ZeroNode() {}
virtual bool GeneratesContent() const { return false; }
std::string Evaluate(const std::vector<std::string> &,
cmGeneratorExpressionContext *,
const GeneratorExpressionContent *) const
{
// Unreachable
return std::string();
}
} zeroNode;
//----------------------------------------------------------------------------
static const struct OneNode : public cmGeneratorExpressionNode
{
OneNode() {}
virtual bool AcceptsSingleArbitraryContentParameter() const { return true; }
std::string Evaluate(const std::vector<std::string> &,
cmGeneratorExpressionContext *,
const GeneratorExpressionContent *) const
{
// Unreachable
return std::string();
}
} oneNode;
//----------------------------------------------------------------------------
#define BOOLEAN_OP_NODE(OPNAME, OP, SUCCESS_VALUE, FAILURE_VALUE) \
static const struct OP ## Node : public cmGeneratorExpressionNode \
{ \
OP ## Node () {} \
/* We let -1 carry the meaning 'at least one' */ \
virtual int NumExpectedParameters() const { return -1; } \
\
std::string Evaluate(const std::vector<std::string> &parameters, \
cmGeneratorExpressionContext *context, \
const GeneratorExpressionContent *content) const \
{ \
std::vector<std::string>::const_iterator it = parameters.begin(); \
const std::vector<std::string>::const_iterator end = parameters.end(); \
for ( ; it != end; ++it) \
{ \
if (*it == #FAILURE_VALUE) \
{ \
return #FAILURE_VALUE; \
} \
else if (*it != #SUCCESS_VALUE) \
{ \
reportError(context, content->GetOriginalExpression(), \
"Parameters to $<" #OP "> must resolve to either '0' or '1'."); \
return std::string(); \
} \
} \
return #SUCCESS_VALUE; \
} \
} OPNAME;
BOOLEAN_OP_NODE(andNode, AND, 1, 0)
BOOLEAN_OP_NODE(orNode, OR, 0, 1)
#undef BOOLEAN_OP_NODE
//----------------------------------------------------------------------------
static const struct NotNode : public cmGeneratorExpressionNode
{
NotNode() {}
std::string Evaluate(const std::vector<std::string> &parameters,
cmGeneratorExpressionContext *context,
const GeneratorExpressionContent *content) const
{
if (*parameters.begin() != "0" && *parameters.begin() != "1")
{
reportError(context, content->GetOriginalExpression(),
"$<NOT> parameter must resolve to exactly one '0' or '1' value.");
return std::string();
}
return *parameters.begin() == "0" ? "1" : "0";
}
} notNode;
//----------------------------------------------------------------------------
static const struct ConfigurationNode : public cmGeneratorExpressionNode
{
ConfigurationNode() {}
virtual int NumExpectedParameters() const { return 0; }
std::string Evaluate(const std::vector<std::string> &,
cmGeneratorExpressionContext *context,
const GeneratorExpressionContent *) const
{
return context->Config ? context->Config : "";
}
} configurationNode;
//----------------------------------------------------------------------------
static const struct ConfigurationTestNode : public cmGeneratorExpressionNode
{
ConfigurationTestNode() {}
virtual int NumExpectedParameters() const { return 1; }
std::string Evaluate(const std::vector<std::string> &parameters,
cmGeneratorExpressionContext *context,
const GeneratorExpressionContent *content) const
{
if (!context->Config)
{
return std::string();
}
cmsys::RegularExpression configValidator;
configValidator.compile("^[A-Za-z0-9_]*$");
if (!configValidator.find(parameters.begin()->c_str()))
{
reportError(context, content->GetOriginalExpression(),
"Expression syntax not recognized.");
return std::string();
}
return *parameters.begin() == context->Config ? "1" : "0";
}
} configurationTestNode;
//----------------------------------------------------------------------------
template<bool linker, bool soname>
struct TargetFilesystemArtifactResultCreator
{
static std::string Create(cmTarget* target,
cmGeneratorExpressionContext *context,
const GeneratorExpressionContent *content);
};
//----------------------------------------------------------------------------
template<>
struct TargetFilesystemArtifactResultCreator<false, true>
{
static std::string Create(cmTarget* target,
cmGeneratorExpressionContext *context,
const GeneratorExpressionContent *content)
{
// The target soname file (.so.1).
if(target->IsDLLPlatform())
{
::reportError(context, content->GetOriginalExpression(),
"TARGET_SONAME_FILE is not allowed "
"for DLL target platforms.");
return std::string();
}
if(target->GetType() != cmTarget::SHARED_LIBRARY)
{
::reportError(context, content->GetOriginalExpression(),
"TARGET_SONAME_FILE is allowed only for "
"SHARED libraries.");
return std::string();
}
std::string result = target->GetDirectory(context->Config);
result += "/";
result += target->GetSOName(context->Config);
return result;
}
};
//----------------------------------------------------------------------------
template<>
struct TargetFilesystemArtifactResultCreator<true, false>
{
static std::string Create(cmTarget* target,
cmGeneratorExpressionContext *context,
const GeneratorExpressionContent *content)
{
// The file used to link to the target (.so, .lib, .a).
if(!target->IsLinkable())
{
::reportError(context, content->GetOriginalExpression(),
"TARGET_LINKER_FILE is allowed only for libraries and "
"executables with ENABLE_EXPORTS.");
return std::string();
}
return target->GetFullPath(context->Config,
target->HasImportLibrary());
}
};
//----------------------------------------------------------------------------
template<>
struct TargetFilesystemArtifactResultCreator<false, false>
{
static std::string Create(cmTarget* target,
cmGeneratorExpressionContext *context,
const GeneratorExpressionContent *)
{
return target->GetFullPath(context->Config, false, true);
}
};
//----------------------------------------------------------------------------
template<bool dirQual, bool nameQual>
struct TargetFilesystemArtifactResultGetter
{
static std::string Get(const std::string &result);
};
//----------------------------------------------------------------------------
template<>
struct TargetFilesystemArtifactResultGetter<false, true>
{
static std::string Get(const std::string &result)
{ return cmSystemTools::GetFilenameName(result); }
};
//----------------------------------------------------------------------------
template<>
struct TargetFilesystemArtifactResultGetter<true, false>
{
static std::string Get(const std::string &result)
{ return cmSystemTools::GetFilenamePath(result); }
};
//----------------------------------------------------------------------------
template<>
struct TargetFilesystemArtifactResultGetter<false, false>
{
static std::string Get(const std::string &result)
{ return result; }
};
//----------------------------------------------------------------------------
template<bool linker, bool soname, bool dirQual, bool nameQual>
struct TargetFilesystemArtifact : public cmGeneratorExpressionNode
{
TargetFilesystemArtifact() {}
virtual int NumExpectedParameters() const { return 1; }
std::string Evaluate(const std::vector<std::string> &parameters,
cmGeneratorExpressionContext *context,
const GeneratorExpressionContent *content) const
{
// Lookup the referenced target.
std::string name = *parameters.begin();
cmsys::RegularExpression targetValidator;
targetValidator.compile("^[A-Za-z0-9_]+$");
if (!targetValidator.find(name.c_str()))
{
::reportError(context, content->GetOriginalExpression(),
"Expression syntax not recognized.");
return std::string();
}
cmTarget* target = context->Makefile->FindTargetToUse(name.c_str());
if(!target)
{
::reportError(context, content->GetOriginalExpression(),
"No target \"" + name + "\"");
return std::string();
}
if(target->GetType() >= cmTarget::UTILITY &&
target->GetType() != cmTarget::UNKNOWN_LIBRARY)
{
::reportError(context, content->GetOriginalExpression(),
"Target \"" + name + "\" is not an executable or library.");
return std::string();
}
context->Targets.insert(target);
std::string result =
TargetFilesystemArtifactResultCreator<linker, soname>::Create(
target,
context,
content);
if (context->HadError)
{
return std::string();
}
return
TargetFilesystemArtifactResultGetter<dirQual, nameQual>::Get(result);
}
};
//----------------------------------------------------------------------------
static const
TargetFilesystemArtifact<false, false, false, false> targetFileNode;
static const
TargetFilesystemArtifact<true, false, false, false> targetLinkerFileNode;
static const
TargetFilesystemArtifact<false, true, false, false> targetSoNameFileNode;
static const
TargetFilesystemArtifact<false, false, false, true> targetFileNameNode;
static const
TargetFilesystemArtifact<true, false, false, true> targetLinkerFileNameNode;
static const
TargetFilesystemArtifact<false, true, false, true> targetSoNameFileNameNode;
static const
TargetFilesystemArtifact<false, false, true, false> targetFileDirNode;
static const
TargetFilesystemArtifact<true, false, true, false> targetLinkerFileDirNode;
static const
TargetFilesystemArtifact<false, true, true, false> targetSoNameFileDirNode;
//----------------------------------------------------------------------------
static const
cmGeneratorExpressionNode* GetNode(const std::string &identifier)
{
if (identifier == "0")
return &zeroNode;
if (identifier == "1")
return &oneNode;
if (identifier == "AND")
return &andNode;
if (identifier == "OR")
return &orNode;
if (identifier == "NOT")
return &notNode;
else if (identifier == "CONFIGURATION")
return &configurationNode;
else if (identifier == "CONFIG")
return &configurationTestNode;
else if (identifier == "TARGET_FILE")
return &targetFileNode;
else if (identifier == "TARGET_LINKER_FILE")
return &targetLinkerFileNode;
else if (identifier == "TARGET_SONAME_FILE")
return &targetSoNameFileNode;
else if (identifier == "TARGET_FILE_NAME")
return &targetFileNameNode;
else if (identifier == "TARGET_LINKER_FILE_NAME")
return &targetLinkerFileNameNode;
else if (identifier == "TARGET_SONAME_FILE_NAME")
return &targetSoNameFileNameNode;
else if (identifier == "TARGET_FILE_DIR")
return &targetFileDirNode;
else if (identifier == "TARGET_LINKER_FILE_DIR")
return &targetLinkerFileDirNode;
else if (identifier == "TARGET_SONAME_FILE_DIR")
return &targetSoNameFileDirNode;
return 0;
}
//----------------------------------------------------------------------------
GeneratorExpressionContent::GeneratorExpressionContent(
const char *startContent,
unsigned int length)
: StartContent(startContent), ContentLength(length)
{
}
//----------------------------------------------------------------------------
std::string GeneratorExpressionContent::GetOriginalExpression() const
{
return std::string(this->StartContent, this->ContentLength);
}
//----------------------------------------------------------------------------
std::string GeneratorExpressionContent::Evaluate(
cmGeneratorExpressionContext *context) const
{
std::string identifier;
{
std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it
= this->IdentifierChildren.begin();
const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end
= this->IdentifierChildren.end();
for ( ; it != end; ++it)
{
identifier += (*it)->Evaluate(context);
if (context->HadError)
{
return std::string();
}
}
}
const cmGeneratorExpressionNode *node = GetNode(identifier);
if (!node)
{
reportError(context, this->GetOriginalExpression(),
"Expression did not evaluate to a known generator expression");
return std::string();
}
if (!node->GeneratesContent())
{
return std::string();
}
if (node->AcceptsSingleArbitraryContentParameter())
{
std::string result;
std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator
pit = this->ParamChildren.begin();
const
std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator
pend = this->ParamChildren.end();
for ( ; pit != pend; ++pit)
{
if (!result.empty())
{
result += ",";
}
std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it
= pit->begin();
const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end
= pit->end();
for ( ; it != end; ++it)
{
result += (*it)->Evaluate(context);
if (context->HadError)
{
return std::string();
}
}
}
return result;
}
std::vector<std::string> parameters;
{
std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator
pit = this->ParamChildren.begin();
const
std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator
pend = this->ParamChildren.end();
for ( ; pit != pend; ++pit)
{
std::string parameter;
std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it =
pit->begin();
const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end =
pit->end();
for ( ; it != end; ++it)
{
parameter += (*it)->Evaluate(context);
if (context->HadError)
{
return std::string();
}
}
parameters.push_back(parameter);
}
}
int numExpected = node->NumExpectedParameters();
if ((numExpected != -1 && (unsigned int)numExpected != parameters.size()))
{
if (numExpected == 0)
{
reportError(context, this->GetOriginalExpression(),
"$<" + identifier + "> expression requires no parameters.");
}
else if (numExpected == 1)
{
reportError(context, this->GetOriginalExpression(),
"$<" + identifier + "> expression requires "
"exactly one parameter.");
}
else
{
cmOStringStream e;
e << "$<" + identifier + "> expression requires "
<< numExpected
<< " comma separated parameters, but got "
<< parameters.size() << " instead.";
reportError(context, this->GetOriginalExpression(), e.str());
}
return std::string();
}
if (numExpected == -1 && parameters.empty())
{
reportError(context, this->GetOriginalExpression(), "$<" + identifier
+ "> expression requires at least one parameter.");
return std::string();
}
return node->Evaluate(parameters, context, this);
}
//----------------------------------------------------------------------------
static void deleteAll(const std::vector<cmGeneratorExpressionEvaluator*> &c)
{
std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it
= c.begin();
const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end
= c.end();
for ( ; it != end; ++it)
{
delete *it;
}
}
//----------------------------------------------------------------------------
GeneratorExpressionContent::~GeneratorExpressionContent()
{
deleteAll(this->IdentifierChildren);
typedef std::vector<cmGeneratorExpressionEvaluator*> EvaluatorVector;
typedef std::vector<cmGeneratorExpressionToken> TokenVector;
std::vector<EvaluatorVector>::const_iterator pit =
this->ParamChildren.begin();
const std::vector<EvaluatorVector>::const_iterator pend =
this->ParamChildren.end();
for ( ; pit != pend; ++pit)
{
deleteAll(*pit);
}
}

View File

@ -0,0 +1,118 @@
/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2012 Stephen Kelly <steveire@gmail.com>
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 cmGeneratorExpressionEvaluator_h
#define cmGeneratorExpressionEvaluator_h
#include <vector>
#include <string>
//----------------------------------------------------------------------------
struct cmGeneratorExpressionContext
{
cmListFileBacktrace Backtrace;
std::set<cmTarget*> Targets;
cmMakefile *Makefile;
const char *Config;
cmTarget *Target;
bool Quiet;
bool HadError;
};
//----------------------------------------------------------------------------
struct cmGeneratorExpressionEvaluator
{
cmGeneratorExpressionEvaluator() {}
virtual ~cmGeneratorExpressionEvaluator() {}
enum Type
{
Text,
Generator
};
virtual Type GetType() const = 0;
virtual std::string Evaluate(cmGeneratorExpressionContext *context
) const = 0;
private:
cmGeneratorExpressionEvaluator(const cmGeneratorExpressionEvaluator &);
void operator=(const cmGeneratorExpressionEvaluator &);
};
struct TextContent : public cmGeneratorExpressionEvaluator
{
TextContent(const char *start, unsigned int length)
: Content(start), Length(length)
{
}
std::string Evaluate(cmGeneratorExpressionContext *) const
{
return std::string(this->Content, this->Length);
}
Type GetType() const
{
return cmGeneratorExpressionEvaluator::Text;
}
void Extend(unsigned int length)
{
this->Length += length;
}
unsigned int GetLength()
{
return this->Length;
}
private:
const char *Content;
unsigned int Length;
};
//----------------------------------------------------------------------------
struct GeneratorExpressionContent : public cmGeneratorExpressionEvaluator
{
GeneratorExpressionContent(const char *startContent, unsigned int length);
void SetIdentifier(std::vector<cmGeneratorExpressionEvaluator*> identifier)
{
this->IdentifierChildren = identifier;
}
void SetParameters(
std::vector<std::vector<cmGeneratorExpressionEvaluator*> > parameters)
{
this->ParamChildren = parameters;
}
Type GetType() const
{
return cmGeneratorExpressionEvaluator::Generator;
}
std::string Evaluate(cmGeneratorExpressionContext *context) const;
std::string GetOriginalExpression() const;
~GeneratorExpressionContent();
private:
std::vector<cmGeneratorExpressionEvaluator*> IdentifierChildren;
std::vector<std::vector<cmGeneratorExpressionEvaluator*> > ParamChildren;
const char *StartContent;
unsigned int ContentLength;
};
#endif

View File

@ -0,0 +1,85 @@
/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2012 Stephen Kelly <steveire@gmail.com>
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 "cmGeneratorExpressionLexer.h"
//----------------------------------------------------------------------------
cmGeneratorExpressionLexer::cmGeneratorExpressionLexer()
: SawBeginExpression(false), SawGeneratorExpression(false)
{
}
//----------------------------------------------------------------------------
static void InsertText(const char *upto, const char *c,
std::vector<cmGeneratorExpressionToken> &result)
{
if (upto != c)
{
result.push_back(cmGeneratorExpressionToken(
cmGeneratorExpressionToken::Text, upto, c - upto));
}
}
//----------------------------------------------------------------------------
std::vector<cmGeneratorExpressionToken>
cmGeneratorExpressionLexer::Tokenize(const char *input)
{
std::vector<cmGeneratorExpressionToken> result;
if (!input)
return result;
const char *c = input;
const char *upto = c;
for ( ; *c; ++c)
{
if(c[0] == '$' && c[1] == '<')
{
InsertText(upto, c, result);
upto = c;
result.push_back(cmGeneratorExpressionToken(
cmGeneratorExpressionToken::BeginExpression, upto, 2));
upto = c + 2;
++c;
SawBeginExpression = true;
}
else if(c[0] == '>')
{
InsertText(upto, c, result);
upto = c;
result.push_back(cmGeneratorExpressionToken(
cmGeneratorExpressionToken::EndExpression, upto, 1));
upto = c + 1;
SawGeneratorExpression = SawBeginExpression;
}
else if(c[0] == ':')
{
InsertText(upto, c, result);
upto = c;
result.push_back(cmGeneratorExpressionToken(
cmGeneratorExpressionToken::ColonSeparator, upto, 1));
upto = c + 1;
}
else if(c[0] == ',')
{
InsertText(upto, c, result);
upto = c;
result.push_back(cmGeneratorExpressionToken(
cmGeneratorExpressionToken::CommaSeparator, upto, 1));
upto = c + 1;
}
}
InsertText(upto, c, result);
return result;
}

View File

@ -0,0 +1,58 @@
/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2012 Stephen Kelly <steveire@gmail.com>
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 cmGeneratorExpressionLexer_h
#define cmGeneratorExpressionLexer_h
#include "cmStandardIncludes.h"
#include <vector>
//----------------------------------------------------------------------------
struct cmGeneratorExpressionToken
{
cmGeneratorExpressionToken(unsigned type, const char *c, unsigned l)
: TokenType(type), Content(c), Length(l)
{
}
enum {
Text,
BeginExpression,
EndExpression,
ColonSeparator,
CommaSeparator
};
unsigned TokenType;
const char *Content;
unsigned Length;
};
/** \class cmGeneratorExpressionLexer
*
*/
class cmGeneratorExpressionLexer
{
public:
cmGeneratorExpressionLexer();
std::vector<cmGeneratorExpressionToken> Tokenize(const char *input);
bool GetSawGeneratorExpression() const
{
return this->SawGeneratorExpression;
}
private:
bool SawBeginExpression;
bool SawGeneratorExpression;
};
#endif

View File

@ -0,0 +1,235 @@
/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2012 Stephen Kelly <steveire@gmail.com>
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 "cmGeneratorExpressionParser.h"
#include "cmGeneratorExpressionEvaluator.h"
//----------------------------------------------------------------------------
cmGeneratorExpressionParser::cmGeneratorExpressionParser(
const std::vector<cmGeneratorExpressionToken> &tokens)
: Tokens(tokens), NestingLevel(0)
{
}
//----------------------------------------------------------------------------
void cmGeneratorExpressionParser::Parse(
std::vector<cmGeneratorExpressionEvaluator*> &result)
{
it = this->Tokens.begin();
while (this->it != this->Tokens.end())
{
this->ParseContent(result);
}
}
//----------------------------------------------------------------------------
static void extendText(std::vector<cmGeneratorExpressionEvaluator*> &result,
std::vector<cmGeneratorExpressionToken>::const_iterator it)
{
if (result.size() > 0
&& (*(result.end() - 1))->GetType()
== cmGeneratorExpressionEvaluator::Text)
{
TextContent *textContent = static_cast<TextContent*>(*(result.end() - 1));
textContent->Extend(it->Length);
}
else
{
TextContent *textContent = new TextContent(it->Content, it->Length);
result.push_back(textContent);
}
}
//----------------------------------------------------------------------------
static void extendResult(std::vector<cmGeneratorExpressionEvaluator*> &result,
const std::vector<cmGeneratorExpressionEvaluator*> &contents)
{
if (result.size() > 0
&& (*(result.end() - 1))->GetType()
== cmGeneratorExpressionEvaluator::Text
&& (*contents.begin())->GetType()
== cmGeneratorExpressionEvaluator::Text)
{
TextContent *textContent = static_cast<TextContent*>(*(result.end() - 1));
textContent->Extend(
static_cast<TextContent*>(*contents.begin())->GetLength());
delete *contents.begin();
result.insert(result.end(), contents.begin() + 1, contents.end());
} else {
result.insert(result.end(), contents.begin(), contents.end());
}
}
//----------------------------------------------------------------------------
void cmGeneratorExpressionParser::ParseGeneratorExpression(
std::vector<cmGeneratorExpressionEvaluator*> &result)
{
unsigned int nestedLevel = this->NestingLevel;
++this->NestingLevel;
std::vector<cmGeneratorExpressionToken>::const_iterator startToken
= this->it - 1;
std::vector<cmGeneratorExpressionEvaluator*> identifier;
while(this->it->TokenType != cmGeneratorExpressionToken::EndExpression
&& this->it->TokenType != cmGeneratorExpressionToken::ColonSeparator)
{
this->ParseContent(identifier);
if (this->it == this->Tokens.end())
{
break;
}
}
if (identifier.empty())
{
// ERROR
}
if (this->it->TokenType == cmGeneratorExpressionToken::EndExpression)
{
GeneratorExpressionContent *content = new GeneratorExpressionContent(
startToken->Content, this->it->Content
- startToken->Content
+ this->it->Length);
++this->it;
--this->NestingLevel;
content->SetIdentifier(identifier);
result.push_back(content);
return;
}
std::vector<std::vector<cmGeneratorExpressionEvaluator*> > parameters;
std::vector<std::vector<cmGeneratorExpressionToken>::const_iterator>
commaTokens;
std::vector<cmGeneratorExpressionToken>::const_iterator colonToken;
if (this->it->TokenType == cmGeneratorExpressionToken::ColonSeparator)
{
colonToken = this->it;
parameters.resize(parameters.size() + 1);
++this->it;
while(this->it->TokenType != cmGeneratorExpressionToken::EndExpression)
{
this->ParseContent(*(parameters.end() - 1));
if (this->it->TokenType == cmGeneratorExpressionToken::CommaSeparator)
{
commaTokens.push_back(this->it);
parameters.resize(parameters.size() + 1);
++this->it;
}
if (this->it == this->Tokens.end())
{
break;
}
}
if(this->it->TokenType == cmGeneratorExpressionToken::EndExpression)
{
--this->NestingLevel;
++this->it;
}
if (parameters.empty())
{
// ERROR
}
}
if (nestedLevel != this->NestingLevel)
{
// There was a '$<' in the text, but no corresponding '>'. Rebuild to
// treat the '$<' as having been plain text, along with the
// corresponding : and , tokens that might have been found.
extendText(result, startToken);
extendResult(result, identifier);
if (!parameters.empty())
{
extendText(result, colonToken);
typedef std::vector<cmGeneratorExpressionEvaluator*> EvaluatorVector;
typedef std::vector<cmGeneratorExpressionToken> TokenVector;
std::vector<EvaluatorVector>::const_iterator pit = parameters.begin();
const std::vector<EvaluatorVector>::const_iterator pend =
parameters.end();
std::vector<TokenVector::const_iterator>::const_iterator commaIt =
commaTokens.begin();
for ( ; pit != pend; ++pit, ++commaIt)
{
extendResult(result, *pit);
if (commaIt != commaTokens.end())
{
extendText(result, *commaIt);
}
}
}
return;
}
int contentLength = ((this->it - 1)->Content
- startToken->Content)
+ (this->it - 1)->Length;
GeneratorExpressionContent *content = new GeneratorExpressionContent(
startToken->Content, contentLength);
content->SetIdentifier(identifier);
content->SetParameters(parameters);
result.push_back(content);
}
//----------------------------------------------------------------------------
void cmGeneratorExpressionParser::ParseContent(
std::vector<cmGeneratorExpressionEvaluator*> &result)
{
switch(this->it->TokenType)
{
case cmGeneratorExpressionToken::Text:
{
if (this->NestingLevel == 0)
{
if (result.size() > 0
&& (*(result.end() - 1))->GetType()
== cmGeneratorExpressionEvaluator::Text)
{
// A comma in 'plain text' could have split text that should
// otherwise be continuous. Extend the last text content instead of
// creating a new one.
TextContent *textContent =
static_cast<TextContent*>(*(result.end() - 1));
textContent->Extend(this->it->Length);
++this->it;
return;
}
}
cmGeneratorExpressionEvaluator* n = new TextContent(this->it->Content,
this->it->Length);
result.push_back(n);
++this->it;
return ;
}
case cmGeneratorExpressionToken::BeginExpression:
++this->it;
this->ParseGeneratorExpression(result);
return;
case cmGeneratorExpressionToken::EndExpression:
case cmGeneratorExpressionToken::ColonSeparator:
case cmGeneratorExpressionToken::CommaSeparator:
if (this->NestingLevel == 0)
{
extendText(result, this->it);
}
else
{
// TODO: Unreachable. Assert?
}
++this->it;
return;
}
// Unreachable. Assert?
}

View File

@ -0,0 +1,45 @@
/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2012 Stephen Kelly <steveire@gmail.com>
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 cmGeneratorExpressionParser_h
#define cmGeneratorExpressionParser_h
#include "cmGeneratorExpressionLexer.h"
#include <set>
#include <vector>
#include "cmListFileCache.h"
class cmMakefile;
class cmTarget;
struct cmGeneratorExpressionEvaluator;
//----------------------------------------------------------------------------
struct cmGeneratorExpressionParser
{
cmGeneratorExpressionParser(
const std::vector<cmGeneratorExpressionToken> &tokens);
void Parse(std::vector<cmGeneratorExpressionEvaluator*> &result);
private:
void ParseContent(std::vector<cmGeneratorExpressionEvaluator*> &);
void ParseGeneratorExpression(
std::vector<cmGeneratorExpressionEvaluator*> &);
private:
std::vector<cmGeneratorExpressionToken>::const_iterator it;
const std::vector<cmGeneratorExpressionToken> Tokens;
unsigned int NestingLevel;
};
#endif

View File

@ -14,9 +14,12 @@
#include "cmTarget.h" #include "cmTarget.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmLocalGenerator.h" #include "cmLocalGenerator.h"
#include "cmComputeLinkInformation.h"
#include "cmGlobalGenerator.h" #include "cmGlobalGenerator.h"
#include "cmSourceFile.h" #include "cmSourceFile.h"
#include <assert.h>
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmGeneratorTarget::cmGeneratorTarget(cmTarget* t): Target(t) cmGeneratorTarget::cmGeneratorTarget(cmTarget* t): Target(t)
{ {
@ -27,6 +30,45 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t): Target(t)
this->LookupObjectLibraries(); this->LookupObjectLibraries();
} }
cmGeneratorTarget::~cmGeneratorTarget()
{
for(std::map<cmStdString, cmComputeLinkInformation*>::iterator i
= LinkInformation.begin(); i != LinkInformation.end(); ++i)
{
delete i->second;
}
}
//----------------------------------------------------------------------------
int cmGeneratorTarget::GetType() const
{
return this->Target->GetType();
}
//----------------------------------------------------------------------------
const char *cmGeneratorTarget::GetName() const
{
return this->Target->GetName();
}
//----------------------------------------------------------------------------
const char *cmGeneratorTarget::GetProperty(const char *prop)
{
return this->Target->GetProperty(prop);
}
//----------------------------------------------------------------------------
bool cmGeneratorTarget::GetPropertyAsBool(const char *prop)
{
return this->Target->GetPropertyAsBool(prop);
}
//----------------------------------------------------------------------------
std::vector<cmSourceFile*> const& cmGeneratorTarget::GetSourceFiles()
{
return this->Target->GetSourceFiles();
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGeneratorTarget::ClassifySources() void cmGeneratorTarget::ClassifySources()
{ {
@ -175,3 +217,179 @@ void cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs)
} }
} }
} }
//----------------------------------------------------------------------------
void cmGeneratorTarget::GenerateTargetManifest(const char* config)
{
cmMakefile* mf = this->Target->GetMakefile();
cmLocalGenerator* lg = mf->GetLocalGenerator();
cmGlobalGenerator* gg = lg->GetGlobalGenerator();
// Get the names.
std::string name;
std::string soName;
std::string realName;
std::string impName;
std::string pdbName;
if(this->GetType() == cmTarget::EXECUTABLE)
{
this->Target->GetExecutableNames(name, realName, impName, pdbName,
config);
}
else if(this->GetType() == cmTarget::STATIC_LIBRARY ||
this->GetType() == cmTarget::SHARED_LIBRARY ||
this->GetType() == cmTarget::MODULE_LIBRARY)
{
this->Target->GetLibraryNames(name, soName, realName, impName, pdbName,
config);
}
else
{
return;
}
// Get the directory.
std::string dir = this->Target->GetDirectory(config, false);
// Add each name.
std::string f;
if(!name.empty())
{
f = dir;
f += "/";
f += name;
gg->AddToManifest(config? config:"", f);
}
if(!soName.empty())
{
f = dir;
f += "/";
f += soName;
gg->AddToManifest(config? config:"", f);
}
if(!realName.empty())
{
f = dir;
f += "/";
f += realName;
gg->AddToManifest(config? config:"", f);
}
if(!pdbName.empty())
{
f = dir;
f += "/";
f += pdbName;
gg->AddToManifest(config? config:"", f);
}
if(!impName.empty())
{
f = this->Target->GetDirectory(config, true);
f += "/";
f += impName;
gg->AddToManifest(config? config:"", f);
}
}
//----------------------------------------------------------------------------
cmComputeLinkInformation*
cmGeneratorTarget::GetLinkInformation(const char* config)
{
// Lookup any existing information for this configuration.
std::map<cmStdString, cmComputeLinkInformation*>::iterator
i = this->LinkInformation.find(config?config:"");
if(i == this->LinkInformation.end())
{
// Compute information for this configuration.
cmComputeLinkInformation* info =
new cmComputeLinkInformation(this->Target, config);
if(!info || !info->Compute())
{
delete info;
info = 0;
}
// Store the information for this configuration.
std::map<cmStdString, cmComputeLinkInformation*>::value_type
entry(config?config:"", info);
i = this->LinkInformation.insert(entry).first;
}
return i->second;
}
//----------------------------------------------------------------------------
void cmGeneratorTarget::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->Target->GetProperty(defVarName.c_str());
}
if(!archs)
{
archs = this->Target->GetProperty("OSX_ARCHITECTURES");
}
if(archs)
{
cmSystemTools::ExpandListArgument(std::string(archs), archVec);
}
}
//----------------------------------------------------------------------------
const char* cmGeneratorTarget::GetCreateRuleVariable()
{
switch(this->GetType())
{
case cmTarget::STATIC_LIBRARY:
return "_CREATE_STATIC_LIBRARY";
case cmTarget::SHARED_LIBRARY:
return "_CREATE_SHARED_LIBRARY";
case cmTarget::MODULE_LIBRARY:
return "_CREATE_SHARED_MODULE";
case cmTarget::EXECUTABLE:
return "_LINK_EXECUTABLE";
default:
break;
}
return "";
}
//----------------------------------------------------------------------------
std::vector<std::string> cmGeneratorTarget::GetIncludeDirectories()
{
std::vector<std::string> includes;
const char *prop = this->Target->GetProperty("INCLUDE_DIRECTORIES");
if(prop)
{
cmSystemTools::ExpandListArgument(prop, includes);
}
std::set<std::string> uniqueIncludes;
std::vector<std::string> orderedAndUniqueIncludes;
for(std::vector<std::string>::const_iterator
li = includes.begin(); li != includes.end(); ++li)
{
if(uniqueIncludes.insert(*li).second)
{
orderedAndUniqueIncludes.push_back(*li);
}
}
return orderedAndUniqueIncludes;
}
//----------------------------------------------------------------------------
const char *cmGeneratorTarget::GetCompileDefinitions(const char *config)
{
if (!config)
{
return this->Target->GetProperty("COMPILE_DEFINITIONS");
}
std::string defPropName = "COMPILE_DEFINITIONS_";
defPropName +=
cmSystemTools::UpperCase(config);
return this->Target->GetProperty(defPropName.c_str());
}

View File

@ -14,6 +14,7 @@
#include "cmStandardIncludes.h" #include "cmStandardIncludes.h"
class cmComputeLinkInformation;
class cmCustomCommand; class cmCustomCommand;
class cmGlobalGenerator; class cmGlobalGenerator;
class cmLocalGenerator; class cmLocalGenerator;
@ -25,6 +26,13 @@ class cmGeneratorTarget
{ {
public: public:
cmGeneratorTarget(cmTarget*); cmGeneratorTarget(cmTarget*);
~cmGeneratorTarget();
int GetType() const;
const char *GetName() const;
const char *GetProperty(const char *prop);
bool GetPropertyAsBool(const char *prop);
std::vector<cmSourceFile*> const& GetSourceFiles();
cmTarget* Target; cmTarget* Target;
cmMakefile* Makefile; cmMakefile* Makefile;
@ -52,6 +60,25 @@ public:
void UseObjectLibraries(std::vector<std::string>& objs); void UseObjectLibraries(std::vector<std::string>& objs);
/** Add the target output files to the global generator manifest. */
void GenerateTargetManifest(const char* config);
std::map<cmStdString, cmComputeLinkInformation*> LinkInformation;
cmComputeLinkInformation* GetLinkInformation(const char* config);
void GetAppleArchs(const char* config,
std::vector<std::string>& archVec);
///! Return the rule variable used to create this type of target,
// need to add CMAKE_(LANG) for full name.
const char* GetCreateRuleVariable();
/** Get the include directories for this target. */
std::vector<std::string> GetIncludeDirectories();
const char *GetCompileDefinitions(const char *config = 0);
private: private:
void ClassifySources(); void ClassifySources();
void LookupObjectLibraries(); void LookupObjectLibraries();
@ -60,4 +87,6 @@ private:
void operator=(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&);
}; };
typedef std::map<cmTarget*, cmGeneratorTarget*> cmGeneratorTargetsType;
#endif #endif

View File

@ -1075,23 +1075,46 @@ void cmGlobalGenerator::CreateGeneratorTargets()
// Construct per-target generator information. // Construct per-target generator information.
for(unsigned int i=0; i < this->LocalGenerators.size(); ++i) for(unsigned int i=0; i < this->LocalGenerators.size(); ++i)
{ {
cmTargets& targets = cmGeneratorTargetsType generatorTargets;
this->LocalGenerators[i]->GetMakefile()->GetTargets();
cmMakefile *mf = this->LocalGenerators[i]->GetMakefile();
const char *noconfig_compile_definitions =
mf->GetProperty("COMPILE_DEFINITIONS");
std::vector<std::string> configs;
mf->GetConfigurations(configs);
cmTargets& targets = mf->GetTargets();
for(cmTargets::iterator ti = targets.begin(); for(cmTargets::iterator ti = targets.begin();
ti != targets.end(); ++ti) ti != targets.end(); ++ti)
{ {
cmTarget* t = &ti->second; cmTarget* t = &ti->second;
{
t->AppendProperty("COMPILE_DEFINITIONS", noconfig_compile_definitions);
for(std::vector<std::string>::const_iterator ci = configs.begin();
ci != configs.end(); ++ci)
{
std::string defPropName = "COMPILE_DEFINITIONS_";
defPropName += cmSystemTools::UpperCase(*ci);
t->AppendProperty(defPropName.c_str(),
mf->GetProperty(defPropName.c_str()));
}
}
cmGeneratorTarget* gt = new cmGeneratorTarget(t); cmGeneratorTarget* gt = new cmGeneratorTarget(t);
this->GeneratorTargets[t] = gt; this->GeneratorTargets[t] = gt;
this->ComputeTargetObjects(gt); this->ComputeTargetObjects(gt);
generatorTargets[t] = gt;
} }
mf->SetGeneratorTargets(generatorTargets);
} }
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalGenerator::ClearGeneratorTargets() void cmGlobalGenerator::ClearGeneratorTargets()
{ {
for(GeneratorTargetsType::iterator i = this->GeneratorTargets.begin(); for(cmGeneratorTargetsType::iterator i = this->GeneratorTargets.begin();
i != this->GeneratorTargets.end(); ++i) i != this->GeneratorTargets.end(); ++i)
{ {
delete i->second; delete i->second;
@ -1102,7 +1125,7 @@ void cmGlobalGenerator::ClearGeneratorTargets()
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmGeneratorTarget* cmGlobalGenerator::GetGeneratorTarget(cmTarget* t) const cmGeneratorTarget* cmGlobalGenerator::GetGeneratorTarget(cmTarget* t) const
{ {
GeneratorTargetsType::const_iterator ti = this->GeneratorTargets.find(t); cmGeneratorTargetsType::const_iterator ti = this->GeneratorTargets.find(t);
if(ti == this->GeneratorTargets.end()) if(ti == this->GeneratorTargets.end())
{ {
this->CMakeInstance->IssueMessage( this->CMakeInstance->IssueMessage(
@ -1129,13 +1152,13 @@ void cmGlobalGenerator::CheckLocalGenerators()
{ {
manager = this->LocalGenerators[i]->GetMakefile()->GetCacheManager(); manager = this->LocalGenerators[i]->GetMakefile()->GetCacheManager();
this->LocalGenerators[i]->ConfigureFinalPass(); this->LocalGenerators[i]->ConfigureFinalPass();
cmTargets & targets = cmGeneratorTargetsType targets =
this->LocalGenerators[i]->GetMakefile()->GetTargets(); this->LocalGenerators[i]->GetMakefile()->GetGeneratorTargets();
for (cmTargets::iterator l = targets.begin(); for (cmGeneratorTargetsType::iterator l = targets.begin();
l != targets.end(); l++) l != targets.end(); l++)
{ {
const cmTarget::LinkLibraryVectorType& libs = const cmTarget::LinkLibraryVectorType& libs =
l->second.GetOriginalLinkLibraries(); l->second->Target->GetOriginalLinkLibraries();
for(cmTarget::LinkLibraryVectorType::const_iterator lib = libs.begin(); for(cmTarget::LinkLibraryVectorType::const_iterator lib = libs.begin();
lib != libs.end(); ++lib) lib != libs.end(); ++lib)
{ {
@ -1151,14 +1174,14 @@ void cmGlobalGenerator::CheckLocalGenerators()
} }
std::string text = notFoundMap[varName]; std::string text = notFoundMap[varName];
text += "\n linked by target \""; text += "\n linked by target \"";
text += l->second.GetName(); text += l->second->GetName();
text += "\" in directory "; text += "\" in directory ";
text+=this->LocalGenerators[i]->GetMakefile()->GetCurrentDirectory(); text+=this->LocalGenerators[i]->GetMakefile()->GetCurrentDirectory();
notFoundMap[varName] = text; notFoundMap[varName] = text;
} }
} }
std::vector<std::string> incs; std::vector<std::string> incs;
this->LocalGenerators[i]->GetIncludeDirectories(incs, &l->second); this->LocalGenerators[i]->GetIncludeDirectories(incs, l->second);
for( std::vector<std::string>::const_iterator incDir = incs.begin(); for( std::vector<std::string>::const_iterator incDir = incs.begin();
incDir != incs.end(); ++incDir) incDir != incs.end(); ++incDir)

View File

@ -19,6 +19,8 @@
#include "cmTargetDepend.h" // For cmTargetDependSet #include "cmTargetDepend.h" // For cmTargetDependSet
#include "cmSystemTools.h" // for cmSystemTools::OutputOption #include "cmSystemTools.h" // for cmSystemTools::OutputOption
#include "cmExportSetMap.h" // For cmExportSetMap #include "cmExportSetMap.h" // For cmExportSetMap
#include "cmGeneratorTarget.h"
class cmake; class cmake;
class cmGeneratorTarget; class cmGeneratorTarget;
class cmMakefile; class cmMakefile;
@ -372,8 +374,7 @@ private:
TargetDependMap TargetDependencies; TargetDependMap TargetDependencies;
// Per-target generator information. // Per-target generator information.
typedef std::map<cmTarget*, cmGeneratorTarget*> GeneratorTargetsType; cmGeneratorTargetsType GeneratorTargets;
GeneratorTargetsType GeneratorTargets;
void CreateGeneratorTargets(); void CreateGeneratorTargets();
void ClearGeneratorTargets(); void ClearGeneratorTargets();
virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const; virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const;

View File

@ -22,17 +22,6 @@ cmGlobalVisualStudio8Win64Generator::cmGlobalVisualStudio8Win64Generator()
this->ArchitectureId = "x64"; this->ArchitectureId = "x64";
} }
///! Create a local generator appropriate to this Global Generator
cmLocalGenerator *cmGlobalVisualStudio8Win64Generator::CreateLocalGenerator()
{
cmLocalVisualStudio7Generator *lg
= new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS8);
lg->SetPlatformName(this->GetPlatformName());
lg->SetExtraFlagTable(this->GetExtraFlagTableVS8());
lg->SetGlobalGenerator(this);
return lg;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalVisualStudio8Win64Generator void cmGlobalVisualStudio8Win64Generator
::GetDocumentation(cmDocumentationEntry& entry) const ::GetDocumentation(cmDocumentationEntry& entry) const

View File

@ -38,9 +38,6 @@ public:
/** Get the documentation entry for this generator. */ /** Get the documentation entry for this generator. */
virtual void GetDocumentation(cmDocumentationEntry& entry) const; virtual void GetDocumentation(cmDocumentationEntry& entry) const;
///! create the correct local generator
virtual cmLocalGenerator *CreateLocalGenerator();
/** /**
* Try to determine system infomation such as shared library * Try to determine system infomation such as shared library
* extension, pthreads, byte order etc. * extension, pthreads, byte order etc.

View File

@ -19,17 +19,6 @@ cmGlobalVisualStudio9IA64Generator::cmGlobalVisualStudio9IA64Generator()
this->ArchitectureId = "Itanium"; this->ArchitectureId = "Itanium";
} }
///! Create a local generator appropriate to this Global Generator
cmLocalGenerator *cmGlobalVisualStudio9IA64Generator::CreateLocalGenerator()
{
cmLocalVisualStudio7Generator *lg =
new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS9);
lg->SetPlatformName(this->GetPlatformName());
lg->SetExtraFlagTable(this->GetExtraFlagTableVS8());
lg->SetGlobalGenerator(this);
return lg;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalVisualStudio9IA64Generator void cmGlobalVisualStudio9IA64Generator
::GetDocumentation(cmDocumentationEntry& entry) const ::GetDocumentation(cmDocumentationEntry& entry) const

View File

@ -38,9 +38,6 @@ public:
/** Get the documentation entry for this generator. */ /** Get the documentation entry for this generator. */
virtual void GetDocumentation(cmDocumentationEntry& entry) const; virtual void GetDocumentation(cmDocumentationEntry& entry) const;
///! create the correct local generator
virtual cmLocalGenerator *CreateLocalGenerator();
/** /**
* Try to determine system infomation such as shared library * Try to determine system infomation such as shared library
* extension, pthreads, byte order etc. * extension, pthreads, byte order etc.

View File

@ -19,17 +19,6 @@ cmGlobalVisualStudio9Win64Generator::cmGlobalVisualStudio9Win64Generator()
this->ArchitectureId = "x64"; this->ArchitectureId = "x64";
} }
///! Create a local generator appropriate to this Global Generator
cmLocalGenerator *cmGlobalVisualStudio9Win64Generator::CreateLocalGenerator()
{
cmLocalVisualStudio7Generator *lg =
new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS9);
lg->SetPlatformName(this->GetPlatformName());
lg->SetExtraFlagTable(this->GetExtraFlagTableVS8());
lg->SetGlobalGenerator(this);
return lg;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalVisualStudio9Win64Generator void cmGlobalVisualStudio9Win64Generator
::GetDocumentation(cmDocumentationEntry& entry) const ::GetDocumentation(cmDocumentationEntry& entry) const

View File

@ -38,9 +38,6 @@ public:
/** Get the documentation entry for this generator. */ /** Get the documentation entry for this generator. */
virtual void GetDocumentation(cmDocumentationEntry& entry) const; virtual void GetDocumentation(cmDocumentationEntry& entry) const;
///! create the correct local generator
virtual cmLocalGenerator *CreateLocalGenerator();
/** /**
* Try to determine system infomation such as shared library * Try to determine system infomation such as shared library
* extension, pthreads, byte order etc. * extension, pthreads, byte order etc.

View File

@ -1713,7 +1713,10 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
// Set target-specific architectures. // Set target-specific architectures.
std::vector<std::string> archs; std::vector<std::string> archs;
target.GetAppleArchs(configName, archs); {
cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target);
gtgt->GetAppleArchs(configName, archs);
}
if(!archs.empty()) if(!archs.empty())
{ {
// Enable ARCHS attribute. // Enable ARCHS attribute.
@ -1950,7 +1953,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
BuildObjectListOrString dirs(this, this->XcodeVersion >= 30); BuildObjectListOrString dirs(this, this->XcodeVersion >= 30);
BuildObjectListOrString fdirs(this, this->XcodeVersion >= 30); BuildObjectListOrString fdirs(this, this->XcodeVersion >= 30);
std::vector<std::string> includes; std::vector<std::string> includes;
this->CurrentLocalGenerator->GetIncludeDirectories(includes, &target); cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target);
this->CurrentLocalGenerator->GetIncludeDirectories(includes, gtgt);
std::set<cmStdString> emitted; std::set<cmStdString> emitted;
emitted.insert("/System/Library/Frameworks"); emitted.insert("/System/Library/Frameworks");
for(std::vector<std::string>::iterator i = includes.begin(); for(std::vector<std::string>::iterator i = includes.begin();
@ -2625,7 +2629,8 @@ void cmGlobalXCodeGenerator
} }
// Compute the link library and directory information. // Compute the link library and directory information.
cmComputeLinkInformation* pcli = cmtarget->GetLinkInformation(configName); cmGeneratorTarget* gtgt = this->GetGeneratorTarget(cmtarget);
cmComputeLinkInformation* pcli = gtgt->GetLinkInformation(configName);
if(!pcli) if(!pcli)
{ {
continue; continue;

View File

@ -409,14 +409,18 @@ namespace
enum Op { OpLess, OpEqual, OpGreater }; enum Op { OpLess, OpEqual, OpGreater };
bool HandleVersionCompare(Op op, const char* lhs_str, const char* rhs_str) bool HandleVersionCompare(Op op, const char* lhs_str, const char* rhs_str)
{ {
// Parse out up to 4 components. // Parse out up to 8 components.
unsigned int lhs[4] = {0,0,0,0}; unsigned int lhs[8] = {0,0,0,0,0,0,0,0};
unsigned int rhs[4] = {0,0,0,0}; unsigned int rhs[8] = {0,0,0,0,0,0,0,0};
sscanf(lhs_str, "%u.%u.%u.%u", &lhs[0], &lhs[1], &lhs[2], &lhs[3]); sscanf(lhs_str, "%u.%u.%u.%u.%u.%u.%u.%u",
sscanf(rhs_str, "%u.%u.%u.%u", &rhs[0], &rhs[1], &rhs[2], &rhs[3]); &lhs[0], &lhs[1], &lhs[2], &lhs[3],
&lhs[4], &lhs[5], &lhs[6], &lhs[7]);
sscanf(rhs_str, "%u.%u.%u.%u.%u.%u.%u.%u",
&rhs[0], &rhs[1], &rhs[2], &rhs[3],
&rhs[4], &rhs[5], &rhs[6], &rhs[7]);
// Do component-wise comparison. // Do component-wise comparison.
for(unsigned int i=0; i < 4; ++i) for(unsigned int i=0; i < 8; ++i)
{ {
if(lhs[i] < rhs[i]) if(lhs[i] < rhs[i])
{ {

View File

@ -16,6 +16,7 @@
#include "cmLocalGenerator.h" #include "cmLocalGenerator.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmake.h" #include "cmake.h"
#include "cmGeneratorTarget.h"
#include <assert.h> #include <assert.h>
@ -26,7 +27,8 @@ cmInstallTargetGenerator
std::vector<std::string> const& configurations, std::vector<std::string> const& configurations,
const char* component, bool optional): const char* component, bool optional):
cmInstallGenerator(dest, configurations, component), Target(&t), cmInstallGenerator(dest, configurations, component), Target(&t),
ImportLibrary(implib), FilePermissions(file_permissions), Optional(optional) ImportLibrary(implib), FilePermissions(file_permissions),
Optional(optional), GeneratorTarget(0)
{ {
this->ActionsPerConfig = true; this->ActionsPerConfig = true;
this->NamelinkMode = NamelinkModeNone; this->NamelinkMode = NamelinkModeNone;
@ -484,6 +486,17 @@ void cmInstallTargetGenerator::PostReplacementTweaks(std::ostream& os,
this->AddStripRule(os, indent, file); this->AddStripRule(os, indent, file);
} }
void cmInstallTargetGenerator::CreateGeneratorTarget()
{
if (!this->GeneratorTarget)
{
this->GeneratorTarget = this->Target->GetMakefile()
->GetLocalGenerator()
->GetGlobalGenerator()
->GetGeneratorTarget(this->Target);
}
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void void
cmInstallTargetGenerator cmInstallTargetGenerator
@ -507,10 +520,13 @@ cmInstallTargetGenerator
return; return;
} }
this->CreateGeneratorTarget();
// Build a map of build-tree install_name to install-tree install_name for // Build a map of build-tree install_name to install-tree install_name for
// shared libraries linked to this target. // shared libraries linked to this target.
std::map<cmStdString, cmStdString> install_name_remap; std::map<cmStdString, cmStdString> install_name_remap;
if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config)) if(cmComputeLinkInformation* cli =
this->GeneratorTarget->GetLinkInformation(config))
{ {
std::set<cmTarget*> const& sharedLibs = cli->GetSharedLibrariesLinked(); std::set<cmTarget*> const& sharedLibs = cli->GetSharedLibrariesLinked();
for(std::set<cmTarget*>::const_iterator j = sharedLibs.begin(); for(std::set<cmTarget*>::const_iterator j = sharedLibs.begin();
@ -608,9 +624,12 @@ cmInstallTargetGenerator
return; return;
} }
this->CreateGeneratorTarget();
// Get the link information for this target. // Get the link information for this target.
// It can provide the RPATH. // It can provide the RPATH.
cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config); cmComputeLinkInformation* cli =
this->GeneratorTarget->GetLinkInformation(config);
if(!cli) if(!cli)
{ {
return; return;
@ -639,9 +658,12 @@ cmInstallTargetGenerator
return; return;
} }
this->CreateGeneratorTarget();
// Get the link information for this target. // Get the link information for this target.
// It can provide the RPATH. // It can provide the RPATH.
cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config); cmComputeLinkInformation* cli =
this->GeneratorTarget->GetLinkInformation(config);
if(!cli) if(!cli)
{ {
return; return;

View File

@ -15,6 +15,8 @@
#include "cmInstallGenerator.h" #include "cmInstallGenerator.h"
#include "cmTarget.h" #include "cmTarget.h"
class cmGeneratorTarget;
/** \class cmInstallTargetGenerator /** \class cmInstallTargetGenerator
* \brief Generate target installation rules. * \brief Generate target installation rules.
*/ */
@ -92,11 +94,14 @@ protected:
void AddRanlibRule(std::ostream& os, Indent const& indent, void AddRanlibRule(std::ostream& os, Indent const& indent,
const std::string& toDestDirPath); const std::string& toDestDirPath);
void CreateGeneratorTarget();
cmTarget* Target; cmTarget* Target;
bool ImportLibrary; bool ImportLibrary;
std::string FilePermissions; std::string FilePermissions;
bool Optional; bool Optional;
NamelinkModeType NamelinkMode; NamelinkModeType NamelinkMode;
cmGeneratorTarget* GeneratorTarget;
}; };
#endif #endif

View File

@ -533,10 +533,11 @@ void cmLocalGenerator::GenerateTargetManifest()
this->Makefile->GetConfigurations(configNames); this->Makefile->GetConfigurations(configNames);
// Add our targets to the manifest for each configuration. // Add our targets to the manifest for each configuration.
cmTargets& targets = this->Makefile->GetTargets(); cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets();
for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) for(cmGeneratorTargetsType::iterator t = targets.begin();
t != targets.end(); ++t)
{ {
cmTarget& target = t->second; cmGeneratorTarget& target = *t->second;
if(configNames.empty()) if(configNames.empty())
{ {
target.GenerateTargetManifest(0); target.GenerateTargetManifest(0);
@ -554,9 +555,9 @@ void cmLocalGenerator::GenerateTargetManifest()
} }
void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
const char* lang, const char* lang,
cmSourceFile& source, cmSourceFile& source,
cmTarget& target) cmGeneratorTarget& target)
{ {
std::string objectDir = cmSystemTools::GetFilenamePath(std::string(ofname)); std::string objectDir = cmSystemTools::GetFilenamePath(std::string(ofname));
objectDir = this->Convert(objectDir.c_str(),START_OUTPUT,SHELL); objectDir = this->Convert(objectDir.c_str(),START_OUTPUT,SHELL);
@ -635,7 +636,8 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
); );
} }
void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target) void cmLocalGenerator::AddBuildTargetRule(const char* llang,
cmGeneratorTarget& target)
{ {
cmStdString objs; cmStdString objs;
std::vector<std::string> objVector; std::vector<std::string> objVector;
@ -669,7 +671,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target)
std::string createRule = "CMAKE_"; std::string createRule = "CMAKE_";
createRule += llang; createRule += llang;
createRule += target.GetCreateRuleVariable(); createRule += target.GetCreateRuleVariable();
std::string targetName = target.GetFullName(); std::string targetName = target.Target->GetFullName();
// Executable : // Executable :
// Shared Library: // Shared Library:
// Static Library: // Static Library:
@ -677,7 +679,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target)
std::string linkLibs; // should be set std::string linkLibs; // should be set
std::string flags; // should be set std::string flags; // should be set
std::string linkFlags; // should be set std::string linkFlags; // should be set
this->GetTargetFlags(linkLibs, flags, linkFlags, target); this->GetTargetFlags(linkLibs, flags, linkFlags, &target);
cmLocalGenerator::RuleVariables vars; cmLocalGenerator::RuleVariables vars;
vars.Language = llang; vars.Language = llang;
vars.Objects = objs.c_str(); vars.Objects = objs.c_str();
@ -714,7 +716,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target)
// Store this command line. // Store this command line.
commandLines.push_back(commandLine); commandLines.push_back(commandLine);
} }
std::string targetFullPath = target.GetFullPath(); std::string targetFullPath = target.Target->GetFullPath();
// Generate a meaningful comment for the command. // Generate a meaningful comment for the command.
std::string comment = "Linking "; std::string comment = "Linking ";
comment += llang; comment += llang;
@ -728,7 +730,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target)
comment.c_str(), comment.c_str(),
this->Makefile->GetStartOutputDirectory() this->Makefile->GetStartOutputDirectory()
); );
target.AddSourceFile target.Target->AddSourceFile
(this->Makefile->GetSource(targetFullPath.c_str())); (this->Makefile->GetSource(targetFullPath.c_str()));
} }
@ -736,11 +738,11 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target)
void cmLocalGenerator void cmLocalGenerator
::CreateCustomTargetsAndCommands(std::set<cmStdString> const& lang) ::CreateCustomTargetsAndCommands(std::set<cmStdString> const& lang)
{ {
cmTargets &tgts = this->Makefile->GetTargets(); cmGeneratorTargetsType tgts = this->Makefile->GetGeneratorTargets();
for(cmTargets::iterator l = tgts.begin(); for(cmGeneratorTargetsType::iterator l = tgts.begin();
l != tgts.end(); l++) l != tgts.end(); l++)
{ {
cmTarget& target = l->second; cmGeneratorTarget& target = *l->second;
switch(target.GetType()) switch(target.GetType())
{ {
case cmTarget::STATIC_LIBRARY: case cmTarget::STATIC_LIBRARY:
@ -748,12 +750,12 @@ void cmLocalGenerator
case cmTarget::MODULE_LIBRARY: case cmTarget::MODULE_LIBRARY:
case cmTarget::EXECUTABLE: case cmTarget::EXECUTABLE:
{ {
const char* llang = target.GetLinkerLanguage(); const char* llang = target.Target->GetLinkerLanguage();
if(!llang) if(!llang)
{ {
cmSystemTools::Error cmSystemTools::Error
("CMake can not determine linker language for target:", ("CMake can not determine linker language for target:",
target.GetName()); target.Target->GetName());
return; return;
} }
// if the language is not in the set lang then create custom // if the language is not in the set lang then create custom
@ -1318,7 +1320,7 @@ std::string cmLocalGenerator::GetIncludeFlags(
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
cmTarget* target, cmGeneratorTarget* target,
const char* lang) const char* lang)
{ {
// Need to decide whether to automatically include the source and // Need to decide whether to automatically include the source and
@ -1449,7 +1451,7 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
std::string& flags, std::string& flags,
std::string& linkFlags, std::string& linkFlags,
cmTarget& target) cmGeneratorTarget* target)
{ {
std::string buildType = std::string buildType =
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
@ -1457,12 +1459,12 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
const char* libraryLinkVariable = const char* libraryLinkVariable =
"CMAKE_SHARED_LINKER_FLAGS"; // default to shared library "CMAKE_SHARED_LINKER_FLAGS"; // default to shared library
switch(target.GetType()) switch(target->GetType())
{ {
case cmTarget::STATIC_LIBRARY: case cmTarget::STATIC_LIBRARY:
{ {
const char* targetLinkFlags = const char* targetLinkFlags =
target.GetProperty("STATIC_LIBRARY_FLAGS"); target->GetProperty("STATIC_LIBRARY_FLAGS");
if(targetLinkFlags) if(targetLinkFlags)
{ {
linkFlags += targetLinkFlags; linkFlags += targetLinkFlags;
@ -1472,7 +1474,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
{ {
std::string build = "STATIC_LIBRARY_FLAGS_"; std::string build = "STATIC_LIBRARY_FLAGS_";
build += buildType; build += buildType;
targetLinkFlags = target.GetProperty(build.c_str()); targetLinkFlags = target->GetProperty(build.c_str());
if(targetLinkFlags) if(targetLinkFlags)
{ {
linkFlags += targetLinkFlags; linkFlags += targetLinkFlags;
@ -1498,7 +1500,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
if(this->Makefile->IsOn("WIN32") && if(this->Makefile->IsOn("WIN32") &&
!(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW"))) !(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW")))
{ {
const std::vector<cmSourceFile*>& sources = target.GetSourceFiles(); const std::vector<cmSourceFile*>& sources = target->GetSourceFiles();
for(std::vector<cmSourceFile*>::const_iterator i = sources.begin(); for(std::vector<cmSourceFile*>::const_iterator i = sources.begin();
i != sources.end(); ++i) i != sources.end(); ++i)
{ {
@ -1513,7 +1515,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
} }
} }
} }
const char* targetLinkFlags = target.GetProperty("LINK_FLAGS"); const char* targetLinkFlags = target->GetProperty("LINK_FLAGS");
if(targetLinkFlags) if(targetLinkFlags)
{ {
linkFlags += targetLinkFlags; linkFlags += targetLinkFlags;
@ -1523,7 +1525,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
{ {
std::string configLinkFlags = "LINK_FLAGS_"; std::string configLinkFlags = "LINK_FLAGS_";
configLinkFlags += buildType; configLinkFlags += buildType;
targetLinkFlags = target.GetProperty(configLinkFlags.c_str()); targetLinkFlags = target->GetProperty(configLinkFlags.c_str());
if(targetLinkFlags) if(targetLinkFlags)
{ {
linkFlags += targetLinkFlags; linkFlags += targetLinkFlags;
@ -1531,7 +1533,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
} }
} }
cmOStringStream linklibsStr; cmOStringStream linklibsStr;
this->OutputLinkLibraries(linklibsStr, target, false); this->OutputLinkLibraries(linklibsStr, *target, false);
linkLibs = linklibsStr.str(); linkLibs = linklibsStr.str();
} }
break; break;
@ -1547,17 +1549,17 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
linkFlags += this->Makefile->GetSafeDefinition(build.c_str()); linkFlags += this->Makefile->GetSafeDefinition(build.c_str());
linkFlags += " "; linkFlags += " ";
} }
const char* linkLanguage = target.GetLinkerLanguage(); const char* linkLanguage = target->Target->GetLinkerLanguage();
if(!linkLanguage) if(!linkLanguage)
{ {
cmSystemTools::Error cmSystemTools::Error
("CMake can not determine linker language for target:", ("CMake can not determine linker language for target:",
target.GetName()); target->Target->GetName());
return; return;
} }
this->AddLanguageFlags(flags, linkLanguage, buildType.c_str()); this->AddLanguageFlags(flags, linkLanguage, buildType.c_str());
cmOStringStream linklibs; cmOStringStream linklibs;
this->OutputLinkLibraries(linklibs, target, false); this->OutputLinkLibraries(linklibs, *target, false);
linkLibs = linklibs.str(); linkLibs = linklibs.str();
if(cmSystemTools::IsOn if(cmSystemTools::IsOn
(this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) (this->Makefile->GetDefinition("BUILD_SHARED_LIBS")))
@ -1567,7 +1569,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
linkFlags += this->Makefile->GetSafeDefinition(sFlagVar.c_str()); linkFlags += this->Makefile->GetSafeDefinition(sFlagVar.c_str());
linkFlags += " "; linkFlags += " ";
} }
if ( target.GetPropertyAsBool("WIN32_EXECUTABLE") ) if ( target->GetPropertyAsBool("WIN32_EXECUTABLE") )
{ {
linkFlags += linkFlags +=
this->Makefile->GetSafeDefinition("CMAKE_CREATE_WIN32_EXE"); this->Makefile->GetSafeDefinition("CMAKE_CREATE_WIN32_EXE");
@ -1579,7 +1581,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
this->Makefile->GetSafeDefinition("CMAKE_CREATE_CONSOLE_EXE"); this->Makefile->GetSafeDefinition("CMAKE_CREATE_CONSOLE_EXE");
linkFlags += " "; linkFlags += " ";
} }
if (target.IsExecutableWithExports()) if (target->Target->IsExecutableWithExports())
{ {
std::string exportFlagVar = "CMAKE_EXE_EXPORTS_"; std::string exportFlagVar = "CMAKE_EXE_EXPORTS_";
exportFlagVar += linkLanguage; exportFlagVar += linkLanguage;
@ -1589,7 +1591,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
this->Makefile->GetSafeDefinition(exportFlagVar.c_str()); this->Makefile->GetSafeDefinition(exportFlagVar.c_str());
linkFlags += " "; linkFlags += " ";
} }
const char* targetLinkFlags = target.GetProperty("LINK_FLAGS"); const char* targetLinkFlags = target->GetProperty("LINK_FLAGS");
if(targetLinkFlags) if(targetLinkFlags)
{ {
linkFlags += targetLinkFlags; linkFlags += targetLinkFlags;
@ -1599,7 +1601,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
{ {
std::string configLinkFlags = "LINK_FLAGS_"; std::string configLinkFlags = "LINK_FLAGS_";
configLinkFlags += buildType; configLinkFlags += buildType;
targetLinkFlags = target.GetProperty(configLinkFlags.c_str()); targetLinkFlags = target->GetProperty(configLinkFlags.c_str());
if(targetLinkFlags) if(targetLinkFlags)
{ {
linkFlags += targetLinkFlags; linkFlags += targetLinkFlags;
@ -1651,7 +1653,7 @@ std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib)
* to the name of the library. This will not link a library against itself. * to the name of the library. This will not link a library against itself.
*/ */
void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout, void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout,
cmTarget& tgt, cmGeneratorTarget& tgt,
bool relink) bool relink)
{ {
const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
@ -1778,7 +1780,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmLocalGenerator::AddArchitectureFlags(std::string& flags, void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
cmTarget* target, cmGeneratorTarget* target,
const char *lang, const char *lang,
const char* config) const char* config)
{ {

View File

@ -16,6 +16,7 @@
class cmMakefile; class cmMakefile;
class cmGlobalGenerator; class cmGlobalGenerator;
class cmGeneratorTarget;
class cmTarget; class cmTarget;
class cmTargetManifest; class cmTargetManifest;
class cmSourceFile; class cmSourceFile;
@ -135,7 +136,7 @@ public:
std::vector<cmLocalGenerator*>& GetChildren() { return this->Children; }; std::vector<cmLocalGenerator*>& GetChildren() { return this->Children; };
void AddArchitectureFlags(std::string& flags, cmTarget* target, void AddArchitectureFlags(std::string& flags, cmGeneratorTarget* target,
const char *lang, const char* config); const char *lang, const char* config);
void AddLanguageFlags(std::string& flags, const char* lang, void AddLanguageFlags(std::string& flags, const char* lang,
@ -205,7 +206,7 @@ public:
/** Get the include flags for the current makefile and language. */ /** Get the include flags for the current makefile and language. */
void GetIncludeDirectories(std::vector<std::string>& dirs, void GetIncludeDirectories(std::vector<std::string>& dirs,
cmTarget* target, cmGeneratorTarget* target,
const char* lang = "C"); const char* lang = "C");
/** Compute the language used to compile the given source file. */ /** Compute the language used to compile the given source file. */
@ -334,11 +335,12 @@ public:
void GetTargetFlags(std::string& linkLibs, void GetTargetFlags(std::string& linkLibs,
std::string& flags, std::string& flags,
std::string& linkFlags, std::string& linkFlags,
cmTarget&target); cmGeneratorTarget* target);
protected: protected:
///! put all the libraries for a target on into the given stream ///! put all the libraries for a target on into the given stream
virtual void OutputLinkLibraries(std::ostream&, cmTarget&, bool relink); virtual void OutputLinkLibraries(std::ostream&, cmGeneratorTarget&,
bool relink);
// Expand rule variables in CMake of the type found in language rules // Expand rule variables in CMake of the type found in language rules
void ExpandRuleVariables(std::string& string, void ExpandRuleVariables(std::string& string,
@ -354,12 +356,12 @@ protected:
/** Convert a target to a utility target for unsupported /** Convert a target to a utility target for unsupported
* languages of a generator */ * languages of a generator */
void AddBuildTargetRule(const char* llang, cmTarget& target); void AddBuildTargetRule(const char* llang, cmGeneratorTarget& target);
///! add a custom command to build a .o file that is part of a target ///! add a custom command to build a .o file that is part of a target
void AddCustomCommandToCreateObject(const char* ofname, void AddCustomCommandToCreateObject(const char* ofname,
const char* lang, const char* lang,
cmSourceFile& source, cmSourceFile& source,
cmTarget& target); cmGeneratorTarget& target);
// Create Custom Targets and commands for unsupported languages // Create Custom Targets and commands for unsupported languages
// The set passed in should contain the languages supported by the // The set passed in should contain the languages supported by the
// generator directly. Any targets containing files that are not // generator directly. Any targets containing files that are not

View File

@ -862,10 +862,13 @@ cmLocalVisualStudio6Generator::GetTargetIncludeOptions(cmTarget &target)
// the length threatens this problem. // the length threatens this problem.
unsigned int maxIncludeLength = 3000; unsigned int maxIncludeLength = 3000;
bool useShortPath = false; bool useShortPath = false;
cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(&target);
for(int j=0; j < 2; ++j) for(int j=0; j < 2; ++j)
{ {
std::vector<std::string> includes; std::vector<std::string> includes;
this->GetIncludeDirectories(includes, &target); this->GetIncludeDirectories(includes, gt);
std::vector<std::string>::iterator i; std::vector<std::string>::iterator i;
for(i = includes.begin(); i != includes.end(); ++i) for(i = includes.begin(); i != includes.end(); ++i)
@ -1676,37 +1679,25 @@ void cmLocalVisualStudio6Generator
std::set<std::string> minsizeDefinesSet; std::set<std::string> minsizeDefinesSet;
std::set<std::string> debugrelDefinesSet; std::set<std::string> debugrelDefinesSet;
this->AppendDefines(
definesSet, cmGeneratorTarget* gt =
this->Makefile->GetProperty("COMPILE_DEFINITIONS")); this->GlobalGenerator->GetGeneratorTarget(&target);
this->AppendDefines(
debugDefinesSet,
this->Makefile->GetProperty("COMPILE_DEFINITIONS_DEBUG"));
this->AppendDefines(
releaseDefinesSet,
this->Makefile->GetProperty("COMPILE_DEFINITIONS_RELEASE"));
this->AppendDefines(
minsizeDefinesSet,
this->Makefile->GetProperty("COMPILE_DEFINITIONS_MINSIZEREL"));
this->AppendDefines(
debugrelDefinesSet,
this->Makefile->GetProperty("COMPILE_DEFINITIONS_RELWITHDEBINFO"));
this->AppendDefines( this->AppendDefines(
definesSet, definesSet,
target.GetProperty("COMPILE_DEFINITIONS")); gt->GetCompileDefinitions());
this->AppendDefines( this->AppendDefines(
debugDefinesSet, debugDefinesSet,
target.GetProperty("COMPILE_DEFINITIONS_DEBUG")); gt->GetCompileDefinitions("DEBUG"));
this->AppendDefines( this->AppendDefines(
releaseDefinesSet, releaseDefinesSet,
target.GetProperty("COMPILE_DEFINITIONS_RELEASE")); gt->GetCompileDefinitions("RELEASE"));
this->AppendDefines( this->AppendDefines(
minsizeDefinesSet, minsizeDefinesSet,
target.GetProperty("COMPILE_DEFINITIONS_MINSIZEREL")); gt->GetCompileDefinitions("MINSIZEREL"));
this->AppendDefines( this->AppendDefines(
debugrelDefinesSet, debugrelDefinesSet,
target.GetProperty("COMPILE_DEFINITIONS_RELWITHDEBINFO")); gt->GetCompileDefinitions("RELWITHDEBINFO"));
std::string defines = " "; std::string defines = " ";
std::string debugDefines = " "; std::string debugDefines = " ";
@ -1776,8 +1767,10 @@ void cmLocalVisualStudio6Generator
const std::string extraOptions, const std::string extraOptions,
std::string& options) std::string& options)
{ {
cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(&target);
// Compute the link information for this configuration. // Compute the link information for this configuration.
cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName);
if(!pcli) if(!pcli)
{ {
return; return;

View File

@ -819,7 +819,9 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
targetOptions.OutputAdditionalOptions(fout, "\t\t\t\t", "\n"); targetOptions.OutputAdditionalOptions(fout, "\t\t\t\t", "\n");
fout << "\t\t\t\tAdditionalIncludeDirectories=\""; fout << "\t\t\t\tAdditionalIncludeDirectories=\"";
std::vector<std::string> includes; std::vector<std::string> includes;
this->GetIncludeDirectories(includes, &target); cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(&target);
this->GetIncludeDirectories(includes, gt);
std::vector<std::string>::iterator i = includes.begin(); std::vector<std::string>::iterator i = includes.begin();
for(;i != includes.end(); ++i) for(;i != includes.end(); ++i)
{ {
@ -1079,7 +1081,9 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
targetNameImport, targetNamePDB, configName); targetNameImport, targetNamePDB, configName);
// Compute the link library and directory information. // Compute the link library and directory information.
cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(&target);
cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName);
if(!pcli) if(!pcli)
{ {
return; return;
@ -1164,7 +1168,9 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
targetNameImport, targetNamePDB, configName); targetNameImport, targetNamePDB, configName);
// Compute the link library and directory information. // Compute the link library and directory information.
cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(&target);
cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName);
if(!pcli) if(!pcli)
{ {
return; return;

View File

@ -58,11 +58,12 @@ void cmMakeDepend::SetMakefile(cmMakefile* makefile)
// Now extract any include paths from the targets // Now extract any include paths from the targets
std::set<std::string> uniqueIncludes; std::set<std::string> uniqueIncludes;
std::vector<std::string> orderedAndUniqueIncludes; std::vector<std::string> orderedAndUniqueIncludes;
cmTargets & targets = this->Makefile->GetTargets(); cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets();
for (cmTargets::iterator l = targets.begin(); l != targets.end(); ++l) for (cmGeneratorTargetsType::iterator l = targets.begin();
l != targets.end(); ++l)
{ {
const std::vector<std::string>& includes = const std::vector<std::string>& includes =
l->second.GetIncludeDirectories(); l->second->GetIncludeDirectories();
for(std::vector<std::string>::const_iterator j = includes.begin(); for(std::vector<std::string>::const_iterator j = includes.begin();
j != includes.end(); ++j) j != includes.end(); ++j)
{ {

View File

@ -3984,6 +3984,12 @@ cmTarget* cmMakefile::FindTargetToUse(const char* name)
return this->LocalGenerator->GetGlobalGenerator()->FindTarget(0, name); return this->LocalGenerator->GetGlobalGenerator()->FindTarget(0, name);
} }
cmGeneratorTarget* cmMakefile::FindGeneratorTargetToUse(const char* name)
{
cmTarget *t = this->FindTargetToUse(name);
return this->LocalGenerator->GetGlobalGenerator()->GetGeneratorTarget(t);
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg, bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
bool isCustom) bool isCustom)

View File

@ -20,6 +20,7 @@
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmTarget.h" #include "cmTarget.h"
#include "cmNewLineStyle.h" #include "cmNewLineStyle.h"
#include "cmGeneratorTarget.h"
#include "cmake.h" #include "cmake.h"
#if defined(CMAKE_BUILD_WITH_CMAKE) #if defined(CMAKE_BUILD_WITH_CMAKE)
@ -519,11 +520,22 @@ public:
*/ */
const cmTargets &GetTargets() const { return this->Targets; } const cmTargets &GetTargets() const { return this->Targets; }
const cmGeneratorTargetsType &GetGeneratorTargets() const
{
return this->GeneratorTargets;
}
void SetGeneratorTargets(const cmGeneratorTargetsType &targets)
{
this->GeneratorTargets = targets;
}
cmTarget* FindTarget(const char* name); cmTarget* FindTarget(const char* name);
/** Find a target to use in place of the given name. The target /** Find a target to use in place of the given name. The target
returned may be imported or built within the project. */ returned may be imported or built within the project. */
cmTarget* FindTargetToUse(const char* name); cmTarget* FindTargetToUse(const char* name);
cmGeneratorTarget* FindGeneratorTargetToUse(const char* name);
/** /**
* Mark include directories as system directories. * Mark include directories as system directories.
@ -865,6 +877,7 @@ protected:
// libraries, classes, and executables // libraries, classes, and executables
cmTargets Targets; cmTargets Targets;
cmGeneratorTargetsType GeneratorTargets;
std::vector<cmSourceFile*> SourceFiles; std::vector<cmSourceFile*> SourceFiles;
// Tests // Tests

View File

@ -210,7 +210,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
// Add language feature flags. // Add language feature flags.
this->AddFeatureFlags(flags, linkLanguage); this->AddFeatureFlags(flags, linkLanguage);
this->LocalGenerator->AddArchitectureFlags(flags, this->Target, this->LocalGenerator->AddArchitectureFlags(flags, this->GeneratorTarget,
linkLanguage, this->ConfigName); linkLanguage, this->ConfigName);
// Add target-specific linker flags. // Add target-specific linker flags.
@ -319,7 +319,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
// Collect up flags to link in needed libraries. // Collect up flags to link in needed libraries.
cmOStringStream linklibs; cmOStringStream linklibs;
this->LocalGenerator->OutputLinkLibraries(linklibs, *this->Target, relink); this->LocalGenerator->OutputLinkLibraries(linklibs, *this->GeneratorTarget,
relink);
// Construct object file lists that may be needed to expand the // Construct object file lists that may be needed to expand the
// rule. // rule.

View File

@ -546,7 +546,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
if(this->Target->GetType() != cmTarget::STATIC_LIBRARY) if(this->Target->GetType() != cmTarget::STATIC_LIBRARY)
{ {
this->LocalGenerator this->LocalGenerator
->OutputLinkLibraries(linklibs, *this->Target, relink); ->OutputLinkLibraries(linklibs, *this->GeneratorTarget, relink);
} }
// Construct object file lists that may be needed to expand the // Construct object file lists that may be needed to expand the
@ -625,7 +625,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
std::string langFlags; std::string langFlags;
this->AddFeatureFlags(langFlags, linkLanguage); this->AddFeatureFlags(langFlags, linkLanguage);
this->LocalGenerator->AddArchitectureFlags(langFlags, this->Target, this->LocalGenerator->AddArchitectureFlags(langFlags, this->GeneratorTarget,
linkLanguage, this->ConfigName); linkLanguage, this->ConfigName);
// remove any language flags that might not work with the // remove any language flags that might not work with the

View File

@ -259,7 +259,7 @@ std::string cmMakefileTargetGenerator::GetFlags(const std::string &l)
// Add language feature flags. // Add language feature flags.
this->AddFeatureFlags(flags, lang); this->AddFeatureFlags(flags, lang);
this->LocalGenerator->AddArchitectureFlags(flags, this->Target, this->LocalGenerator->AddArchitectureFlags(flags, this->GeneratorTarget,
lang, this->ConfigName); lang, this->ConfigName);
// Fortran-specific flags computed for this target. // Fortran-specific flags computed for this target.
@ -302,16 +302,11 @@ std::string cmMakefileTargetGenerator::GetDefines(const std::string &l)
// Add preprocessor definitions for this target and configuration. // Add preprocessor definitions for this target and configuration.
this->LocalGenerator->AppendDefines this->LocalGenerator->AppendDefines
(defines, this->Makefile->GetProperty("COMPILE_DEFINITIONS")); (defines, this->GeneratorTarget->GetCompileDefinitions());
this->LocalGenerator->AppendDefines this->LocalGenerator->AppendDefines
(defines, this->Target->GetProperty("COMPILE_DEFINITIONS")); (defines, this->GeneratorTarget->GetCompileDefinitions(
std::string defPropName = "COMPILE_DEFINITIONS_"; this->LocalGenerator->ConfigurationName.c_str()));
defPropName +=
cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName);
this->LocalGenerator->AppendDefines
(defines, this->Makefile->GetProperty(defPropName.c_str()));
this->LocalGenerator->AppendDefines
(defines, this->Target->GetProperty(defPropName.c_str()));
std::string definesString; std::string definesString;
this->LocalGenerator->JoinDefines(defines, definesString, lang); this->LocalGenerator->JoinDefines(defines, definesString, lang);
@ -1022,7 +1017,8 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
<< "SET(CMAKE_TARGET_LINKED_INFO_FILES\n"; << "SET(CMAKE_TARGET_LINKED_INFO_FILES\n";
std::set<cmTarget const*> emitted; std::set<cmTarget const*> emitted;
const char* cfg = this->LocalGenerator->ConfigurationName.c_str(); const char* cfg = this->LocalGenerator->ConfigurationName.c_str();
if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg)) if(cmComputeLinkInformation* cli =
this->GeneratorTarget->GetLinkInformation(cfg))
{ {
cmComputeLinkInformation::ItemVector const& items = cli->GetItems(); cmComputeLinkInformation::ItemVector const& items = cli->GetItems();
for(cmComputeLinkInformation::ItemVector::const_iterator for(cmComputeLinkInformation::ItemVector::const_iterator
@ -1061,7 +1057,8 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
*this->InfoFileStream *this->InfoFileStream
<< "SET(CMAKE_C_TARGET_INCLUDE_PATH\n"; << "SET(CMAKE_C_TARGET_INCLUDE_PATH\n";
std::vector<std::string> includes; std::vector<std::string> includes;
this->LocalGenerator->GetIncludeDirectories(includes, this->Target); this->LocalGenerator->GetIncludeDirectories(includes,
this->GeneratorTarget);
for(std::vector<std::string>::iterator i = includes.begin(); for(std::vector<std::string>::iterator i = includes.begin();
i != includes.end(); ++i) i != includes.end(); ++i)
{ {
@ -1546,7 +1543,8 @@ std::string cmMakefileTargetGenerator::GetFrameworkFlags()
emitted.insert("/System/Library/Frameworks"); emitted.insert("/System/Library/Frameworks");
#endif #endif
std::vector<std::string> includes; std::vector<std::string> includes;
this->LocalGenerator->GetIncludeDirectories(includes, this->Target); this->LocalGenerator->GetIncludeDirectories(includes,
this->GeneratorTarget);
std::vector<std::string>::iterator i; std::vector<std::string>::iterator i;
// check all include directories for frameworks as this // check all include directories for frameworks as this
// will already have added a -F for the framework // will already have added a -F for the framework
@ -1590,7 +1588,8 @@ void cmMakefileTargetGenerator
// Loop over all library dependencies. // Loop over all library dependencies.
const char* cfg = this->LocalGenerator->ConfigurationName.c_str(); const char* cfg = this->LocalGenerator->ConfigurationName.c_str();
if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg)) if(cmComputeLinkInformation* cli =
this->GeneratorTarget->GetLinkInformation(cfg))
{ {
std::vector<std::string> const& libDeps = cli->GetDepends(); std::vector<std::string> const& libDeps = cli->GetDepends();
for(std::vector<std::string>::const_iterator j = libDeps.begin(); for(std::vector<std::string>::const_iterator j = libDeps.begin();
@ -1850,7 +1849,8 @@ void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags,
std::vector<std::string> includes; std::vector<std::string> includes;
this->LocalGenerator->GetIncludeDirectories(includes, this->Target, lang); this->LocalGenerator->GetIncludeDirectories(includes,
this->GeneratorTarget, lang);
std::string includeFlags = std::string includeFlags =
this->LocalGenerator->GetIncludeFlags(includes, lang, useResponseFile); this->LocalGenerator->GetIncludeFlags(includes, lang, useResponseFile);
@ -1953,7 +1953,8 @@ void cmMakefileTargetGenerator::AddFortranFlags(std::string& flags)
this->Makefile->GetDefinition("CMAKE_Fortran_MODPATH_FLAG")) this->Makefile->GetDefinition("CMAKE_Fortran_MODPATH_FLAG"))
{ {
std::vector<std::string> includes; std::vector<std::string> includes;
this->LocalGenerator->GetIncludeDirectories(includes, this->Target); this->LocalGenerator->GetIncludeDirectories(includes,
this->GeneratorTarget);
for(std::vector<std::string>::const_iterator idi = includes.begin(); for(std::vector<std::string>::const_iterator idi = includes.begin();
idi != includes.end(); ++idi) idi != includes.end(); ++idi)
{ {

View File

@ -423,7 +423,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
this->GetLocalGenerator()->GetTargetFlags(vars["LINK_LIBRARIES"], this->GetLocalGenerator()->GetTargetFlags(vars["LINK_LIBRARIES"],
vars["FLAGS"], vars["FLAGS"],
vars["LINK_FLAGS"], vars["LINK_FLAGS"],
*this->GetTarget()); this->GetGeneratorTarget());
this->AddModuleDefinitionFlag(vars["LINK_FLAGS"]); this->AddModuleDefinitionFlag(vars["LINK_FLAGS"]);
@ -434,7 +434,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
? vars["FLAGS"] ? vars["FLAGS"]
: vars["ARCH_FLAGS"]); : vars["ARCH_FLAGS"]);
this->GetLocalGenerator()->AddArchitectureFlags(flags, this->GetLocalGenerator()->AddArchitectureFlags(flags,
this->GetTarget(), this->GetGeneratorTarget(),
this->TargetLinkLanguage, this->TargetLinkLanguage,
this->GetConfigName()); this->GetConfigName());
if (targetType == cmTarget::EXECUTABLE) { if (targetType == cmTarget::EXECUTABLE) {

View File

@ -134,7 +134,7 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source,
this->AddFeatureFlags(flags, language.c_str()); this->AddFeatureFlags(flags, language.c_str());
this->GetLocalGenerator()->AddArchitectureFlags(flags, this->GetLocalGenerator()->AddArchitectureFlags(flags,
this->GetTarget(), this->GeneratorTarget,
language.c_str(), language.c_str(),
this->GetConfigName()); this->GetConfigName());
@ -152,7 +152,7 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source,
// Add include directory flags. // Add include directory flags.
{ {
std::vector<std::string> includes; std::vector<std::string> includes;
this->LocalGenerator->GetIncludeDirectories(includes, this->Target, this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget,
language.c_str()); language.c_str());
std::string includeFlags = std::string includeFlags =
this->LocalGenerator->GetIncludeFlags(includes, language.c_str(), this->LocalGenerator->GetIncludeFlags(includes, language.c_str(),
@ -195,10 +195,7 @@ ComputeDefines(cmSourceFile *source, const std::string& language)
// Add preprocessor definitions for this target and configuration. // Add preprocessor definitions for this target and configuration.
this->LocalGenerator->AppendDefines this->LocalGenerator->AppendDefines
(defines, (defines,
this->Makefile->GetProperty("COMPILE_DEFINITIONS")); this->GeneratorTarget->GetCompileDefinitions());
this->LocalGenerator->AppendDefines
(defines,
this->Target->GetProperty("COMPILE_DEFINITIONS"));
this->LocalGenerator->AppendDefines this->LocalGenerator->AppendDefines
(defines, (defines,
source->GetProperty("COMPILE_DEFINITIONS")); source->GetProperty("COMPILE_DEFINITIONS"));
@ -207,10 +204,7 @@ ComputeDefines(cmSourceFile *source, const std::string& language)
defPropName += cmSystemTools::UpperCase(this->GetConfigName()); defPropName += cmSystemTools::UpperCase(this->GetConfigName());
this->LocalGenerator->AppendDefines this->LocalGenerator->AppendDefines
(defines, (defines,
this->Makefile->GetProperty(defPropName.c_str())); this->GeneratorTarget->GetCompileDefinitions(this->GetConfigName()));
this->LocalGenerator->AppendDefines
(defines,
this->Target->GetProperty(defPropName.c_str()));
this->LocalGenerator->AppendDefines this->LocalGenerator->AppendDefines
(defines, (defines,
source->GetProperty(defPropName.c_str())); source->GetProperty(defPropName.c_str()));
@ -231,7 +225,7 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const
return cmNinjaDeps(); return cmNinjaDeps();
cmComputeLinkInformation* cli = cmComputeLinkInformation* cli =
this->Target->GetLinkInformation(this->GetConfigName()); this->GeneratorTarget->GetLinkInformation(this->GetConfigName());
if(!cli) if(!cli)
return cmNinjaDeps(); return cmNinjaDeps();

View File

@ -52,6 +52,9 @@ protected:
cmTarget* GetTarget() const cmTarget* GetTarget() const
{ return this->Target; } { return this->Target; }
cmGeneratorTarget* GetGeneratorTarget() const
{ return this->GeneratorTarget; }
cmLocalNinjaGenerator* GetLocalGenerator() const cmLocalNinjaGenerator* GetLocalGenerator() const
{ return this->LocalGenerator; } { return this->LocalGenerator; }

View File

@ -111,6 +111,7 @@ cmQtAutomoc::cmQtAutomoc()
void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) void cmQtAutomoc::SetupAutomocTarget(cmTarget* target)
{ {
cmMakefile* makefile = target->GetMakefile(); cmMakefile* makefile = target->GetMakefile();
cmLocalGenerator* localGen = makefile->GetLocalGenerator();
const char* targetName = target->GetName(); const char* targetName = target->GetName();
// don't do anything if there is no Qt4 or Qt5Core (which contains moc): // don't do anything if there is no Qt4 or Qt5Core (which contains moc):
std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR"); std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR");
@ -193,12 +194,28 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target)
} }
} }
const char* tmp = makefile->GetProperty("INCLUDE_DIRECTORIES"); std::vector<std::string> includeDirs;
std::string _moc_incs = (tmp!=0 ? tmp : ""); cmGeneratorTarget gtgt(target);
tmp = makefile->GetProperty("DEFINITIONS"); localGen->GetIncludeDirectories(includeDirs, &gtgt, "CXX");
std::string _moc_defs = (tmp!=0 ? tmp : ""); std::string _moc_incs = "";
tmp = makefile->GetProperty("COMPILE_DEFINITIONS"); const char* sep = "";
for(std::vector<std::string>::const_iterator incDirIt = includeDirs.begin();
incDirIt != includeDirs.end();
++incDirIt)
{
_moc_incs += sep;
sep = ";";
_moc_incs += *incDirIt;
}
const char* tmp = target->GetProperty("COMPILE_DEFINITIONS");
std::string _moc_compile_defs = (tmp!=0 ? tmp : ""); std::string _moc_compile_defs = (tmp!=0 ? tmp : "");
tmp = makefile->GetProperty("COMPILE_DEFINITIONS");
if (tmp)
{
_moc_compile_defs += ";";
_moc_compile_defs += tmp;
}
tmp = target->GetProperty("AUTOMOC_MOC_OPTIONS"); tmp = target->GetProperty("AUTOMOC_MOC_OPTIONS");
std::string _moc_options = (tmp!=0 ? tmp : ""); std::string _moc_options = (tmp!=0 ? tmp : "");
@ -210,8 +227,6 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target)
cmLocalGenerator::EscapeForCMake(automocTargetName.c_str()).c_str()); cmLocalGenerator::EscapeForCMake(automocTargetName.c_str()).c_str());
makefile->AddDefinition("_moc_incs", makefile->AddDefinition("_moc_incs",
cmLocalGenerator::EscapeForCMake(_moc_incs.c_str()).c_str()); cmLocalGenerator::EscapeForCMake(_moc_incs.c_str()).c_str());
makefile->AddDefinition("_moc_defs",
cmLocalGenerator::EscapeForCMake(_moc_defs.c_str()).c_str());
makefile->AddDefinition("_moc_compile_defs", makefile->AddDefinition("_moc_compile_defs",
cmLocalGenerator::EscapeForCMake(_moc_compile_defs.c_str()).c_str()); cmLocalGenerator::EscapeForCMake(_moc_compile_defs.c_str()).c_str());
makefile->AddDefinition("_moc_options", makefile->AddDefinition("_moc_options",
@ -314,7 +329,6 @@ bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile,
this->MocExecutable = makefile->GetSafeDefinition("AM_QT_MOC_EXECUTABLE"); this->MocExecutable = makefile->GetSafeDefinition("AM_QT_MOC_EXECUTABLE");
this->MocCompileDefinitionsStr = makefile->GetSafeDefinition( this->MocCompileDefinitionsStr = makefile->GetSafeDefinition(
"AM_MOC_COMPILE_DEFINITIONS"); "AM_MOC_COMPILE_DEFINITIONS");
this->MocDefinitionsStr = makefile->GetSafeDefinition("AM_MOC_DEFINITIONS");
this->MocIncludesStr = makefile->GetSafeDefinition("AM_MOC_INCLUDES"); this->MocIncludesStr = makefile->GetSafeDefinition("AM_MOC_INCLUDES");
this->MocOptionsStr = makefile->GetSafeDefinition("AM_MOC_OPTIONS"); this->MocOptionsStr = makefile->GetSafeDefinition("AM_MOC_OPTIONS");
this->ProjectBinaryDir = makefile->GetSafeDefinition("AM_CMAKE_BINARY_DIR"); this->ProjectBinaryDir = makefile->GetSafeDefinition("AM_CMAKE_BINARY_DIR");
@ -332,7 +346,7 @@ bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile,
std::string cmQtAutomoc::MakeCompileSettingsString(cmMakefile* makefile) std::string cmQtAutomoc::MakeCompileSettingsString(cmMakefile* makefile)
{ {
std::string s; std::string s;
s += makefile->GetSafeDefinition("AM_MOC_DEFINITIONS"); s += makefile->GetSafeDefinition("AM_MOC_COMPILE_DEFINITIONS");
s += " ~~~ "; s += " ~~~ ";
s += makefile->GetSafeDefinition("AM_MOC_INCLUDES"); s += makefile->GetSafeDefinition("AM_MOC_INCLUDES");
s += " ~~~ "; s += " ~~~ ";
@ -387,32 +401,11 @@ void cmQtAutomoc::Init()
std::vector<std::string> cdefList; std::vector<std::string> cdefList;
cmSystemTools::ExpandListArgument(this->MocCompileDefinitionsStr, cdefList); cmSystemTools::ExpandListArgument(this->MocCompileDefinitionsStr, cdefList);
if (!cdefList.empty()) for(std::vector<std::string>::const_iterator it = cdefList.begin();
it != cdefList.end();
++it)
{ {
for(std::vector<std::string>::const_iterator it = cdefList.begin(); this->MocDefinitions.push_back("-D" + (*it));
it != cdefList.end();
++it)
{
this->MocDefinitions.push_back("-D" + (*it));
}
}
else
{
std::string tmpMocDefs = this->MocDefinitionsStr;
cmSystemTools::ReplaceString(tmpMocDefs, " ", ";");
std::vector<std::string> defList;
cmSystemTools::ExpandListArgument(tmpMocDefs, defList);
for(std::vector<std::string>::const_iterator it = defList.begin();
it != defList.end();
++it)
{
if (this->StartsWith(*it, "-D"))
{
this->MocDefinitions.push_back(*it);
}
}
} }
cmSystemTools::ExpandListArgument(this->MocOptionsStr, this->MocOptions); cmSystemTools::ExpandListArgument(this->MocOptionsStr, this->MocOptions);

View File

@ -69,7 +69,6 @@ private:
std::string Builddir; std::string Builddir;
std::string MocExecutable; std::string MocExecutable;
std::string MocCompileDefinitionsStr; std::string MocCompileDefinitionsStr;
std::string MocDefinitionsStr;
std::string MocIncludesStr; std::string MocIncludesStr;
std::string MocOptionsStr; std::string MocOptionsStr;
std::string ProjectBinaryDir; std::string ProjectBinaryDir;

View File

@ -15,7 +15,6 @@
#include "cmSourceFile.h" #include "cmSourceFile.h"
#include "cmLocalGenerator.h" #include "cmLocalGenerator.h"
#include "cmGlobalGenerator.h" #include "cmGlobalGenerator.h"
#include "cmComputeLinkInformation.h"
#include "cmDocumentCompileDefinitions.h" #include "cmDocumentCompileDefinitions.h"
#include "cmDocumentLocationUndefined.h" #include "cmDocumentLocationUndefined.h"
#include "cmListFileCache.h" #include "cmListFileCache.h"
@ -1623,7 +1622,11 @@ cmTargetTraceDependencies
{ {
// Transform command names that reference targets built in this // Transform command names that reference targets built in this
// project to corresponding target-level dependencies. // project to corresponding target-level dependencies.
cmGeneratorExpression ge(this->Makefile, 0, cc.GetBacktrace(), true); cmGeneratorExpression ge(cc.GetBacktrace());
// Add target-level dependencies referenced by generator expressions.
std::set<cmTarget*> targets;
for(cmCustomCommandLines::const_iterator cit = cc.GetCommandLines().begin(); for(cmCustomCommandLines::const_iterator cit = cc.GetCommandLines().begin();
cit != cc.GetCommandLines().end(); ++cit) cit != cc.GetCommandLines().end(); ++cit)
{ {
@ -1645,12 +1648,17 @@ cmTargetTraceDependencies
for(cmCustomCommandLine::const_iterator cli = cit->begin(); for(cmCustomCommandLine::const_iterator cli = cit->begin();
cli != cit->end(); ++cli) cli != cit->end(); ++cli)
{ {
ge.Process(*cli); const cmCompiledGeneratorExpression &cge = ge.Parse(*cli);
cge.Evaluate(this->Makefile, 0, true);
std::set<cmTarget*> geTargets = cge.GetTargets();
for(std::set<cmTarget*>::const_iterator it = geTargets.begin();
it != geTargets.end(); ++it)
{
targets.insert(*it);
}
} }
} }
// Add target-level dependencies referenced by generator expressions.
std::set<cmTarget*> targets = ge.GetTargets();
for(std::set<cmTarget*>::iterator ti = targets.begin(); for(std::set<cmTarget*>::iterator ti = targets.begin();
ti != targets.end(); ++ti) ti != targets.end(); ++ti)
{ {
@ -2944,25 +2952,6 @@ void cmTarget::ComputeLinkClosure(const char* config, LinkClosure& lc)
} }
} }
//----------------------------------------------------------------------------
const char* cmTarget::GetCreateRuleVariable()
{
switch(this->GetType())
{
case cmTarget::STATIC_LIBRARY:
return "_CREATE_STATIC_LIBRARY";
case cmTarget::SHARED_LIBRARY:
return "_CREATE_SHARED_LIBRARY";
case cmTarget::MODULE_LIBRARY:
return "_CREATE_SHARED_MODULE";
case cmTarget::EXECUTABLE:
return "_LINK_EXECUTABLE";
default:
break;
}
return "";
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
const char* cmTarget::GetSuffixVariableInternal(bool implib) const char* cmTarget::GetSuffixVariableInternal(bool implib)
{ {
@ -3505,76 +3494,6 @@ bool cmTarget::GetImplibGNUtoMS(std::string const& gnuName,
return false; return false;
} }
//----------------------------------------------------------------------------
void cmTarget::GenerateTargetManifest(const char* config)
{
cmMakefile* mf = this->Makefile;
cmLocalGenerator* lg = mf->GetLocalGenerator();
cmGlobalGenerator* gg = lg->GetGlobalGenerator();
// Get the names.
std::string name;
std::string soName;
std::string realName;
std::string impName;
std::string pdbName;
if(this->GetType() == cmTarget::EXECUTABLE)
{
this->GetExecutableNames(name, realName, impName, pdbName, config);
}
else if(this->GetType() == cmTarget::STATIC_LIBRARY ||
this->GetType() == cmTarget::SHARED_LIBRARY ||
this->GetType() == cmTarget::MODULE_LIBRARY)
{
this->GetLibraryNames(name, soName, realName, impName, pdbName, config);
}
else
{
return;
}
// Get the directory.
std::string dir = this->GetDirectory(config, false);
// Add each name.
std::string f;
if(!name.empty())
{
f = dir;
f += "/";
f += name;
gg->AddToManifest(config? config:"", f);
}
if(!soName.empty())
{
f = dir;
f += "/";
f += soName;
gg->AddToManifest(config? config:"", f);
}
if(!realName.empty())
{
f = dir;
f += "/";
f += realName;
gg->AddToManifest(config? config:"", f);
}
if(!pdbName.empty())
{
f = dir;
f += "/";
f += pdbName;
gg->AddToManifest(config? config:"", f);
}
if(!impName.empty())
{
f = this->GetDirectory(config, true);
f += "/";
f += impName;
gg->AddToManifest(config? config:"", f);
}
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmTarget::SetPropertyDefault(const char* property, void cmTarget::SetPropertyDefault(const char* property,
const char* default_value) const char* default_value)
@ -3970,27 +3889,6 @@ 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) bool cmTarget::IsChrpathUsed(const char* config)
{ {
@ -4661,56 +4559,6 @@ std::string cmTarget::CheckCMP0004(std::string const& item)
return lib; return lib;
} }
//----------------------------------------------------------------------------
cmComputeLinkInformation*
cmTarget::GetLinkInformation(const char* config)
{
// Lookup any existing information for this configuration.
std::map<cmStdString, cmComputeLinkInformation*>::iterator
i = this->LinkInformation.find(config?config:"");
if(i == this->LinkInformation.end())
{
// Compute information for this configuration.
cmComputeLinkInformation* info =
new cmComputeLinkInformation(this, config);
if(!info || !info->Compute())
{
delete info;
info = 0;
}
// Store the information for this configuration.
std::map<cmStdString, cmComputeLinkInformation*>::value_type
entry(config?config:"", info);
i = this->LinkInformation.insert(entry).first;
}
return i->second;
}
//----------------------------------------------------------------------------
std::vector<std::string> cmTarget::GetIncludeDirectories()
{
std::vector<std::string> includes;
const char *prop = this->GetProperty("INCLUDE_DIRECTORIES");
if(prop)
{
cmSystemTools::ExpandListArgument(prop, includes);
}
std::set<std::string> uniqueIncludes;
std::vector<std::string> orderedAndUniqueIncludes;
for(std::vector<std::string>::const_iterator
li = includes.begin(); li != includes.end(); ++li)
{
if(uniqueIncludes.insert(*li).second)
{
orderedAndUniqueIncludes.push_back(*li);
}
}
return orderedAndUniqueIncludes;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string cmTarget::GetFrameworkDirectory(const char* config) std::string cmTarget::GetFrameworkDirectory(const char* config)
{ {
@ -4768,29 +4616,6 @@ std::string cmTarget::GetMacContentDirectory(const char* config,
return fpath; return fpath;
} }
//----------------------------------------------------------------------------
cmTargetLinkInformationMap
::cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r): derived()
{
// Ideally cmTarget instances should never be copied. However until
// we can make a sweep to remove that, this copy constructor avoids
// allowing the resources (LinkInformation) from getting copied. In
// the worst case this will lead to extra cmComputeLinkInformation
// instances. We also enforce in debug mode that the map be emptied
// when copied.
static_cast<void>(r);
assert(r.empty());
}
//----------------------------------------------------------------------------
cmTargetLinkInformationMap::~cmTargetLinkInformationMap()
{
for(derived::iterator i = this->begin(); i != this->end(); ++i)
{
delete i->second;
}
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmTargetInternalPointer::cmTargetInternalPointer() cmTargetInternalPointer::cmTargetInternalPointer()
{ {

View File

@ -22,18 +22,8 @@ class cmake;
class cmMakefile; class cmMakefile;
class cmSourceFile; class cmSourceFile;
class cmGlobalGenerator; class cmGlobalGenerator;
class cmComputeLinkInformation;
class cmListFileBacktrace; class cmListFileBacktrace;
struct cmTargetLinkInformationMap:
public std::map<cmStdString, cmComputeLinkInformation*>
{
typedef std::map<cmStdString, cmComputeLinkInformation*> derived;
cmTargetLinkInformationMap() {}
cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r);
~cmTargetLinkInformationMap();
};
class cmTargetInternals; class cmTargetInternals;
class cmTargetInternalPointer class cmTargetInternalPointer
{ {
@ -330,10 +320,6 @@ public:
///! Return the preferred linker language for this target ///! Return the preferred linker language for this target
const char* GetLinkerLanguage(const char* config = 0); const char* GetLinkerLanguage(const char* config = 0);
///! Return the rule variable used to create this type of target,
// need to add CMAKE_(LANG) for full name.
const char* GetCreateRuleVariable();
/** Get the full name of the target according to the settings in its /** Get the full name of the target according to the settings in its
makefile. */ makefile. */
std::string GetFullName(const char* config=0, bool implib = false); std::string GetFullName(const char* config=0, bool implib = false);
@ -381,9 +367,6 @@ public:
bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out, bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out,
const char* newExt = 0); const char* newExt = 0);
/** Add the target output files to the global generator manifest. */
void GenerateTargetManifest(const char* config);
/** /**
* Compute whether this target must be relinked before installing. * Compute whether this target must be relinked before installing.
*/ */
@ -400,8 +383,6 @@ public:
std::string GetInstallNameDirForInstallTree(const char* config, std::string GetInstallNameDirForInstallTree(const char* config,
bool for_xcode = false); bool for_xcode = false);
cmComputeLinkInformation* GetLinkInformation(const char* config);
// Get the properties // Get the properties
cmPropertyMap &GetProperties() { return this->Properties; }; cmPropertyMap &GetProperties() { return this->Properties; };
@ -419,9 +400,6 @@ public:
// until we have per-target object file properties. // until we have per-target object file properties.
void GetLanguages(std::set<cmStdString>& languages) const; 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 /** Return whether this target is an executable with symbol exports
enabled. */ enabled. */
bool IsExecutableWithExports(); bool IsExecutableWithExports();
@ -459,9 +437,6 @@ public:
directory. */ directory. */
bool UsesDefaultOutputDir(const char* config, bool implib); bool UsesDefaultOutputDir(const char* config, bool implib);
/** Get the include directories for this target. */
std::vector<std::string> GetIncludeDirectories();
/** Append to @a base the mac content directory and return it. */ /** Append to @a base the mac content directory and return it. */
std::string BuildMacContentDirectory(const std::string& base, std::string BuildMacContentDirectory(const std::string& base,
const char* config = 0, const char* config = 0,
@ -599,8 +574,6 @@ private:
ImportInfo const* GetImportInfo(const char* config); ImportInfo const* GetImportInfo(const char* config);
void ComputeImportInfo(std::string const& desired_config, ImportInfo& info); void ComputeImportInfo(std::string const& desired_config, ImportInfo& info);
cmTargetLinkInformationMap LinkInformation;
bool ComputeLinkInterface(const char* config, LinkInterface& iface); bool ComputeLinkInterface(const char* config, LinkInterface& iface);
void ComputeLinkImplementation(const char* config, void ComputeLinkImplementation(const char* config,

View File

@ -91,8 +91,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
this->TestGenerated = true; this->TestGenerated = true;
// Set up generator expression evaluation context. // Set up generator expression evaluation context.
cmMakefile* mf = this->Test->GetMakefile(); cmGeneratorExpression ge(this->Test->GetBacktrace());
cmGeneratorExpression ge(mf, config, this->Test->GetBacktrace());
// Start the test command. // Start the test command.
os << indent << "ADD_TEST(" << this->Test->GetName() << " "; os << indent << "ADD_TEST(" << this->Test->GetName() << " ";
@ -103,6 +102,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
// Check whether the command executable is a target whose name is to // Check whether the command executable is a target whose name is to
// be translated. // be translated.
std::string exe = command[0]; std::string exe = command[0];
cmMakefile* mf = this->Test->GetMakefile();
cmTarget* target = mf->FindTargetToUse(exe.c_str()); cmTarget* target = mf->FindTargetToUse(exe.c_str());
if(target && target->GetType() == cmTarget::EXECUTABLE) if(target && target->GetType() == cmTarget::EXECUTABLE)
{ {
@ -112,7 +112,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
else else
{ {
// Use the command name given. // Use the command name given.
exe = ge.Process(exe.c_str()); exe = ge.Parse(exe.c_str()).Evaluate(mf, config);
cmSystemTools::ConvertToUnixSlashes(exe); cmSystemTools::ConvertToUnixSlashes(exe);
} }
@ -122,7 +122,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
for(std::vector<std::string>::const_iterator ci = command.begin()+1; for(std::vector<std::string>::const_iterator ci = command.begin()+1;
ci != command.end(); ++ci) ci != command.end(); ++ci)
{ {
os << " " << lg->EscapeForCMake(ge.Process(*ci)); os << " " << lg->EscapeForCMake(ge.Parse(*ci).Evaluate(mf, config));
} }
// Finish the test command. // Finish the test command.

View File

@ -1452,7 +1452,7 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const&
// Replace spaces in libs with ; // Replace spaces in libs with ;
cmSystemTools::ReplaceString(libs, " ", ";"); cmSystemTools::ReplaceString(libs, " ", ";");
cmComputeLinkInformation* pcli = cmComputeLinkInformation* pcli =
this->Target->GetLinkInformation(config.c_str()); this->GeneratorTarget->GetLinkInformation(config.c_str());
if(!pcli) if(!pcli)
{ {
cmSystemTools::Error cmSystemTools::Error
@ -1594,7 +1594,8 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups()
static_cast<cmGlobalVisualStudio7Generator *> static_cast<cmGlobalVisualStudio7Generator *>
(this->GlobalGenerator)->GetConfigurations(); (this->GlobalGenerator)->GetConfigurations();
std::vector<std::string> includes; std::vector<std::string> includes;
this->LocalGenerator->GetIncludeDirectories(includes, this->Target); this->LocalGenerator->GetIncludeDirectories(includes,
this->GeneratorTarget);
for(std::vector<std::string>::iterator i = configs->begin(); for(std::vector<std::string>::iterator i = configs->begin();
i != configs->end(); ++i) i != configs->end(); ++i)
{ {

View File

@ -630,7 +630,8 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
std::string linkLibs; std::string linkLibs;
std::string flags; std::string flags;
std::string linkFlags; std::string linkFlags;
lg->GetTargetFlags(linkLibs, flags, linkFlags, *tgt); cmGeneratorTarget gtgt(tgt);
lg->GetTargetFlags(linkLibs, flags, linkFlags, &gtgt);
printf("%s\n", linkLibs.c_str() ); printf("%s\n", linkLibs.c_str() );

View File

@ -7,3 +7,10 @@ if("${CMAKE_VERSION}" VERSION_LESS "${min_ver}")
else() else()
message("CMAKE_VERSION=[${CMAKE_VERSION}] is not less than [${min_ver}]") message("CMAKE_VERSION=[${CMAKE_VERSION}] is not less than [${min_ver}]")
endif() endif()
set(v 1.2.3.4.5.6.7)
if("${v}.8" VERSION_LESS "${v}.9")
message(STATUS "${v}.8 is less than ${v}.9")
else()
message(FATAL_ERROR "${v}.8 is not less than ${v}.9?")
endif()

View File

@ -189,7 +189,7 @@ set_property(TARGET ${proj} PROPERTY FOLDER "Local/TGZ")
set(proj TutorialStep1-LocalNoDirTGZ) set(proj TutorialStep1-LocalNoDirTGZ)
ExternalProject_Add(${proj} ExternalProject_Add(${proj}
URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1NoDir.tgz" URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1NoDir.tgz"
URL_MD5 0b8182edcecdf40bf1c9d71d7d259f78 URL_HASH SHA256=496229e2a5ed620a37c385ad9406004a18026beab8b55dd2c4565d4b7f1d5383
CMAKE_GENERATOR "${CMAKE_GENERATOR}" CMAKE_GENERATOR "${CMAKE_GENERATOR}"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
INSTALL_COMMAND "" INSTALL_COMMAND ""

View File

@ -1,9 +1,18 @@
CMake Error at BadAND.cmake:1 \(add_custom_target\):
Error evaluating generator expression:
\$<AND>
\$<AND> expression requires at least one parameter.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
+
CMake Error at BadAND.cmake:1 \(add_custom_target\): CMake Error at BadAND.cmake:1 \(add_custom_target\):
Error evaluating generator expression: Error evaluating generator expression:
\$<AND:> \$<AND:>
AND requires one or more comma-separated '0' or '1' values. Parameters to \$<AND> must resolve to either '0' or '1'.
Call Stack \(most recent call first\): Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\) CMakeLists.txt:3 \(include\)
+ +
@ -12,6 +21,24 @@ CMake Error at BadAND.cmake:1 \(add_custom_target\):
\$<AND:,> \$<AND:,>
AND requires one or more comma-separated '0' or '1' values. Parameters to \$<AND> must resolve to either '0' or '1'.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
+
CMake Error at BadAND.cmake:1 \(add_custom_target\):
Error evaluating generator expression:
\$<AND:01>
Parameters to \$<AND> must resolve to either '0' or '1'.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
+
CMake Error at BadAND.cmake:1 \(add_custom_target\):
Error evaluating generator expression:
\$<AND:nothing>
Parameters to \$<AND> must resolve to either '0' or '1'.
Call Stack \(most recent call first\): Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)$ CMakeLists.txt:3 \(include\)$

View File

@ -1,4 +1,7 @@
add_custom_target(check ALL COMMAND check add_custom_target(check ALL COMMAND check
$<AND>
$<AND:> $<AND:>
$<AND:,> $<AND:,>
$<AND:01>
$<AND:nothing>
VERBATIM) VERBATIM)

View File

@ -1,8 +1,44 @@
CMake Error at BadCONFIG.cmake:1 \(add_custom_target\):
Error evaluating generator expression:
\$<CONFIG>
\$<CONFIG> expression requires exactly one parameter.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
+
CMake Error at BadCONFIG.cmake:1 \(add_custom_target\): CMake Error at BadCONFIG.cmake:1 \(add_custom_target\):
Error evaluating generator expression: Error evaluating generator expression:
\$<CONFIG:.> \$<CONFIG:.>
Expression syntax not recognized.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
+
CMake Error at BadCONFIG.cmake:1 \(add_custom_target\):
Error evaluating generator expression:
\$<CONFIG:Foo,Bar>
\$<CONFIG> expression requires exactly one parameter.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
+
CMake Error at BadCONFIG.cmake:1 \(add_custom_target\):
Error evaluating generator expression:
\$<CONFIG:Foo-Bar>
Expression syntax not recognized.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
+
CMake Error at BadCONFIG.cmake:1 \(add_custom_target\):
Error evaluating generator expression:
\$<CONFIG:Foo-Nested>
Expression syntax not recognized. Expression syntax not recognized.
Call Stack \(most recent call first\): Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)$ CMakeLists.txt:3 \(include\)$

View File

@ -1,3 +1,7 @@
add_custom_target(check ALL COMMAND check add_custom_target(check ALL COMMAND check
$<CONFIG>
$<CONFIG:.> $<CONFIG:.>
$<CONFIG:Foo,Bar>
$<CONFIG:Foo-Bar>
$<$<CONFIG:Foo-Nested>:foo>
VERBATIM) VERBATIM)

View File

@ -1,9 +1,17 @@
CMake Error at BadNOT.cmake:1 \(add_custom_target\): CMake Error at BadNOT.cmake:1 \(add_custom_target\):
Error evaluating generator expression:
\$<NOT>
\$<NOT> expression requires exactly one parameter.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
+CMake Error at BadNOT.cmake:1 \(add_custom_target\):
Error evaluating generator expression: Error evaluating generator expression:
\$<NOT:> \$<NOT:>
NOT requires exactly one '0' or '1' value. \$<NOT> parameter must resolve to exactly one '0' or '1' value.
Call Stack \(most recent call first\): Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\) CMakeLists.txt:3 \(include\)
+ +
@ -12,7 +20,7 @@ CMake Error at BadNOT.cmake:1 \(add_custom_target\):
\$<NOT:,> \$<NOT:,>
NOT requires exactly one '0' or '1' value. \$<NOT> parameter must resolve to exactly one '0' or '1' value.
Call Stack \(most recent call first\): Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\) CMakeLists.txt:3 \(include\)
+ +
@ -21,6 +29,24 @@ CMake Error at BadNOT.cmake:1 \(add_custom_target\):
\$<NOT:0,1> \$<NOT:0,1>
NOT requires exactly one '0' or '1' value. \$<NOT> expression requires exactly one parameter.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
+
CMake Error at BadNOT.cmake:1 \(add_custom_target\):
Error evaluating generator expression:
\$<NOT:01>
\$<NOT> parameter must resolve to exactly one '0' or '1' value.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
+
CMake Error at BadNOT.cmake:1 \(add_custom_target\):
Error evaluating generator expression:
\$<NOT:nothing>
\$<NOT> parameter must resolve to exactly one '0' or '1' value.
Call Stack \(most recent call first\): Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)$ CMakeLists.txt:3 \(include\)$

View File

@ -1,5 +1,8 @@
add_custom_target(check ALL COMMAND check add_custom_target(check ALL COMMAND check
$<NOT>
$<NOT:> $<NOT:>
$<NOT:,> $<NOT:,>
$<NOT:0,1> $<NOT:0,1>
$<NOT:01>
$<NOT:nothing>
VERBATIM) VERBATIM)

View File

@ -1,9 +1,18 @@
CMake Error at BadOR.cmake:1 \(add_custom_target\):
Error evaluating generator expression:
\$<OR>
\$<OR> expression requires at least one parameter.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
+
CMake Error at BadOR.cmake:1 \(add_custom_target\): CMake Error at BadOR.cmake:1 \(add_custom_target\):
Error evaluating generator expression: Error evaluating generator expression:
\$<OR:> \$<OR:>
OR requires one or more comma-separated '0' or '1' values. Parameters to \$<OR> must resolve to either '0' or '1'.
Call Stack \(most recent call first\): Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\) CMakeLists.txt:3 \(include\)
+ +
@ -12,6 +21,24 @@ CMake Error at BadOR.cmake:1 \(add_custom_target\):
\$<OR:,> \$<OR:,>
OR requires one or more comma-separated '0' or '1' values. Parameters to \$<OR> must resolve to either '0' or '1'.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
+
CMake Error at BadOR.cmake:1 \(add_custom_target\):
Error evaluating generator expression:
\$<OR:01>
Parameters to \$<OR> must resolve to either '0' or '1'.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
+
CMake Error at BadOR.cmake:1 \(add_custom_target\):
Error evaluating generator expression:
\$<OR:nothing>
Parameters to \$<OR> must resolve to either '0' or '1'.
Call Stack \(most recent call first\): Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)$ CMakeLists.txt:3 \(include\)$

View File

@ -1,4 +1,7 @@
add_custom_target(check ALL COMMAND check add_custom_target(check ALL COMMAND check
$<OR>
$<OR:> $<OR:>
$<OR:,> $<OR:,>
$<OR:01>
$<OR:nothing>
VERBATIM) VERBATIM)

View File

@ -204,6 +204,9 @@ CMAKE_CXX_SOURCES="\
cmInstallDirectoryGenerator \ cmInstallDirectoryGenerator \
cmGeneratedFileStream \ cmGeneratedFileStream \
cmGeneratorTarget \ cmGeneratorTarget \
cmGeneratorExpressionEvaluator \
cmGeneratorExpressionLexer \
cmGeneratorExpressionParser \
cmGeneratorExpression \ cmGeneratorExpression \
cmGlobalGenerator \ cmGlobalGenerator \
cmLocalGenerator \ cmLocalGenerator \